/* ----------------------------------------------------------------------------- This source file is part of OpenSpace3D For the latest info, see http://www.openspace3d.com Copyright (c) 2012 I-maginer This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA, or go to http://www.gnu.org/copyleft/lesser.txt ----------------------------------------------------------------------------- */ fun deleteOb(inst)= 0;; fun cbAdd(inst, from, action, param, reply, p)= let p -> [value order] in let strextr param -> lp in let nil -> np in ( while lp != nil do ( let hd lp -> line in let nil -> nline in ( while line != nil do ( let hd line -> elem in let atof elem -> pval in let if pval == nil then elem else (ftoa (pval +. value)) -> nelem in set nline = lcat nline nelem::nil; set line = tl line; ); set np = lcat np (strcatnSep nline " ")::nil; ); set lp = tl lp; ); SendPluginEvent inst "Out" (strcatnSep np "\n") nil; ); 0;; fun cbSubtract(inst, from, action, param, reply, p)= let p -> [value order] in let strextr param -> lp in let nil -> np in ( while lp != nil do ( let hd lp -> line in let nil -> nline in ( while line != nil do ( let hd line -> elem in let atof elem -> pval in let if pval == nil then elem else if order then (ftoa (value -. pval)) else (ftoa (pval -. value)) -> nelem in set nline = lcat nline nelem::nil; set line = tl line; ); set np = lcat np (strcatnSep nline " ")::nil; ); set lp = tl lp; ); SendPluginEvent inst "Out" (strcatnSep np "\n") nil; ); 0;; fun cbMultiply(inst, from, action, param, reply, p)= let p -> [value order] in let strextr param -> lp in let nil -> np in ( while lp != nil do ( let hd lp -> line in let nil -> nline in ( while line != nil do ( let hd line -> elem in let atof elem -> pval in let if pval == nil then elem else (ftoa (pval *. value)) -> nelem in set nline = lcat nline nelem::nil; set line = tl line; ); set np = lcat np (strcatnSep nline " ")::nil; ); set lp = tl lp; ); SendPluginEvent inst "Out" (strcatnSep np "\n") nil; ); 0;; fun cbDivide(inst, from, action, param, reply, p)= let p -> [value order] in if value == 0.0 then nil else let strextr param -> lp in let nil -> np in ( while lp != nil do ( let hd lp -> line in let nil -> nline in ( while line != nil do ( let hd line -> elem in let atof elem -> pval in let if pval == nil || pval == 0.0 then elem else if order then (ftoa (value /. pval)) else (ftoa (pval /. value)) -> nelem in set nline = lcat nline nelem::nil; set line = tl line; ); set np = lcat np (strcatnSep nline " ")::nil; ); set lp = tl lp; ); SendPluginEvent inst "Out" (strcatnSep np "\n") nil; ); 0;; fun cbAbsolute(inst, from, action, param, reply, p)= let p -> [value order] in let strextr param -> lp in let nil -> np in ( while lp != nil do ( let hd lp -> line in let nil -> nline in ( while line != nil do ( let hd line -> elem in let atof elem -> pval in let if pval == nil then elem else ftoa (absf pval) -> nelem in set nline = lcat nline nelem::nil; set line = tl line; ); set np = lcat np (strcatnSep nline " ")::nil; ); set lp = tl lp; ); SendPluginEvent inst "Out" (strcatnSep np "\n") nil; ); 0;; fun cbPower(inst, from, action, param, reply, p)= let p -> [value order] in let strextr param -> lp in let nil -> np in ( while lp != nil do ( let hd lp -> line in let nil -> nline in ( while line != nil do ( let hd line -> elem in let atof elem -> pval in let if pval == nil then elem else if order then (ftoa (pow value pval)) else (ftoa (pow pval value)) -> nelem in set nline = lcat nline nelem::nil; set line = tl line; ); set np = lcat np (strcatnSep nline " ")::nil; ); set lp = tl lp; ); SendPluginEvent inst "Out" (strcatnSep np "\n") nil; ); 0;; fun cbSinus(inst, from, action, param, reply, p)= let p -> [value order] in let strextr param -> lp in let nil -> np in ( while lp != nil do ( let hd lp -> line in let nil -> nline in ( while line != nil do ( let hd line -> elem in let atof elem -> pval in let if pval == nil then elem else (ftoa (sin pval)) -> nelem in set nline = lcat nline nelem::nil; set line = tl line; ); set np = lcat np (strcatnSep nline " ")::nil; ); set lp = tl lp; ); SendPluginEvent inst "Out" (strcatnSep np "\n") nil; ); 0;; fun cbCosinus(inst, from, action, param, reply, p)= let p -> [value order] in let strextr param -> lp in let nil -> np in ( while lp != nil do ( let hd lp -> line in let nil -> nline in ( while line != nil do ( let hd line -> elem in let atof elem -> pval in let if pval == nil then elem else (ftoa (cos pval)) -> nelem in set nline = lcat nline nelem::nil; set line = tl line; ); set np = lcat np (strcatnSep nline " ")::nil; ); set lp = tl lp; ); SendPluginEvent inst "Out" (strcatnSep np "\n") nil; ); 0;; fun cbArcCosinus(inst, from, action, param, reply, p)= let p -> [value order] in let strextr param -> lp in let nil -> np in ( while lp != nil do ( let hd lp -> line in let nil -> nline in ( while line != nil do ( let hd line -> elem in let atof elem -> pval in let if pval == nil then elem else (ftoa (acos pval)) -> nelem in set nline = lcat nline nelem::nil; set line = tl line; ); set np = lcat np (strcatnSep nline " ")::nil; ); set lp = tl lp; ); SendPluginEvent inst "Out" (strcatnSep np "\n") nil; ); 0;; fun cbAtan2(inst, from, action, param, reply, p)= let p -> [value order] in let 0.0 -> np in let hd strextr param -> lp in let atof hd lp -> x in let atof hd tl lp -> y in let if x == nil then 0.0 else x -> x in let if y == nil then 0.0 else y -> y in ( SendPluginEvent inst "Out" ftoa SO3MathsRadianToDegree (atan2 x y) nil; ); 0;; fun cbTangente(inst, from, action, param, reply, p)= let p -> [value order] in let strextr param -> lp in let nil -> np in ( while lp != nil do ( let hd lp -> line in let nil -> nline in ( while line != nil do ( let hd line -> elem in let atof elem -> pval in let if pval == nil then elem else (ftoa (tan pval)) -> nelem in set nline = lcat nline nelem::nil; set line = tl line; ); set np = lcat np (strcatnSep nline " ")::nil; ); set lp = tl lp; ); SendPluginEvent inst "Out" (strcatnSep np "\n") nil; ); 0;; fun cbArcTangente(inst, from, action, param, reply, p)= let p -> [value order] in let strextr param -> lp in let nil -> np in ( while lp != nil do ( let hd lp -> line in let nil -> nline in ( while line != nil do ( let hd line -> elem in let atof elem -> pval in let if pval == nil then elem else (ftoa (atan pval)) -> nelem in set nline = lcat nline nelem::nil; set line = tl line; ); set np = lcat np (strcatnSep nline " ")::nil; ); set lp = tl lp; ); SendPluginEvent inst "Out" (strcatnSep np "\n") nil; ); 0;; fun cbModulo(inst, from, action, param, reply, p)= let p -> [value order] in let ftoi value -> ivalue in let strextr param -> lp in let nil -> np in ( while lp != nil do ( let hd lp -> line in let nil -> nline in ( while line != nil do ( let hd line -> elem in let atoi elem -> pval in let if pval == nil then elem else if order then (itoa (mod ivalue pval)) else (itoa (mod pval ivalue)) -> nelem in set nline = lcat nline nelem::nil; set line = tl line; ); set np = lcat np (strcatnSep nline " ")::nil; ); set lp = tl lp; ); SendPluginEvent inst "Out" (strcatnSep np "\n") nil; ); 0;; fun cbSetValue(inst, from, action, param, reply, p)= mutate p <- [(atof param) _]; 0;; fun newOb(inst)= let atof (getPluginInstanceParam inst "value") -> value in let atoi (getPluginInstanceParam inst "order") -> order in let if order == nil then 0 else order -> order in let [value order] -> p in ( PluginRegisterAction inst "Add" mkfun6 @cbAdd p; PluginRegisterAction inst "Subtract" mkfun6 @cbSubtract p; PluginRegisterAction inst "Multiply" mkfun6 @cbMultiply p; PluginRegisterAction inst "Divide" mkfun6 @cbDivide p; PluginRegisterAction inst "Power" mkfun6 @cbPower p; PluginRegisterAction inst "Absolute" mkfun6 @cbAbsolute p; PluginRegisterAction inst "Sinus" mkfun6 @cbSinus p; PluginRegisterAction inst "Cosinus" mkfun6 @cbCosinus p; PluginRegisterAction inst "Arc Cosinus" mkfun6 @cbArcCosinus p; PluginRegisterAction inst "Modulo" mkfun6 @cbModulo p; PluginRegisterAction inst "Atan2" mkfun6 @cbAtan2 p; PluginRegisterAction inst "Tangente" mkfun6 @cbTangente p; PluginRegisterAction inst "Arc Tangente" mkfun6 @cbArcTangente p; PluginRegisterAction inst "Set value" mkfun6 @cbSetValue p; ); setPluginInstanceCbDel inst @deleteOb; 0;; fun IniPlug(file)= PlugRegister @newOb nil; setPluginEditor @dynamicedit; 0;;