
lxGP.newExpr=function(id,expr,symbol)
{var ed=this.editorWin,gBOI=ed.gBOI,gOM=ed.gOM,obj,t;gBOI.setXY(-1,-1);gBOI.OT3=symbol==""?"Calculation":"Function";gBOI.es[1]=symbol;try{ed.Expr.parseSrc(expr,gBOI);}catch(err)
{this.errMsg="Exprssion error!";return false;}
obj=gOM.make("Expr");gOM.addToDAGAndCanvas(obj);gOM.setIdx(obj);obj.id=id;ed.ids[id]=obj;if(symbol!=""||obj.isType("Parameter"))
{t=(symbol!="")?"Function":"Parameter";obj.setLabel(ed.ParentInfo.arr[t].genLabel());obj.labelSet=true;}
gOM.unSelectAnything();gOM.switchSel(obj);return id;};lxGP.newFun=function(id,expr)
{var ed=this.editorWin,obj;obj=ed.ids[id];if(expr=="")
{this.errMsg="Expression is empty";return false;}
if(obj)
{this.errMsg="An object with the same id "+id+" already exists";return false;}
return this.newExpr(id,expr,"x");};lxG.APIs['newFun']={"desc0":"new function","desc":"create a new function","args":[{"type":"id","notNull":false,"newObj":true,"desc":"the id you want to give to the function"},{"type":"expr","notNull":true,"desc":"the function expression"}]};lxGP.updFun=function(id,expr)
{var ed=this.editorWin,obj;obj=ed.ids[id];if(expr=="")
{this.errMsg="Expression is empty";return false;}
if(obj)
{if(!obj.isType("Function"))
{this.errMsg="Not a function object";return false;}
return this.set(id,expr);}
else
{this.errMsg="Could not find object with the id "+id;return false;}};lxGP.newCal=function(id,expr)
{var ed=this.editorWin,obj;obj=ed.ids[id];if(expr=="")
{this.errMsg="Expression is empty";return false;}
if(obj)
{this.errMsg="An object with the same id "+id+" already exists";return false;}
return this.newExpr(id,expr,"");};lxGP.updCal=function(id,expr)
{var ed=this.editorWin,obj;obj=ed.ids[id];if(expr=="")
{this.errMsg="Expression is empty";return false;}
if(obj)
{if(obj.OT3!="Calculation")
{this.errMsg="Not an expression object";return false;}
return this.set(id,expr);}
else
{this.errMsg="Could not find object with the id "+id;return false;}};lxGP.newPlot=function(graphId,funId)
{var ed=this.editorWin,fun=ed.ids[funId],graph=ed.ids[graphId],gOM=ed.gOM;if(!fun||fun.OT3!="Function")
{this.errMsg="Could not find a function with id "+funId;return false;}
if(graph)
{this.errMsg="Object with id "+graphId+" already exists";return false;}
gOM.unSelectAnything();gOM.switchSel(fun);ed._CO('PlotFunction');return true;};lxG.APIs['newPlot']={"desc0":"new function plot","desc":"create a function graph for an existing function","args":[{"type":"id","notNull":false,"newObj":true,"desc":"the id you want to give to the plot"},{"type":"id","notNull":true,"desc":"the id of the function"}]};lxGP.setColor=function(id,c)
{var ed=this.editorWin,obj=ed.ids[id],gEP=ed.gEP;try{gEP.setExpr(c);gEP.findTokens();gEP.infixToPostfix();gEP.evaluate();}
catch(e)
{this.errMsg='Color expression error!';return false;}
if(gEP.result.constructor!=ed.RColor)
{this.errMsg='Not an expression for color';return false;}
if(typeof obj.color=="object")
obj.color.rmAff(obj.color.affc,obj);obj.setColor(gEP.result.toString1());obj.updStyle();return true;};lxG.APIs['setColor']={"desc0":"set color","desc":"set the color of an object","args":[{"type":"id","notNull":true,"desc":"the id of the function"},{"type":"color","notNull":true,"desc":"the color"}]};