Skip to content

Commit

Permalink
- Added a new LegendPosition option to plot command.
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@17270 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
adeas31 committed Sep 16, 2013
1 parent 509176f commit 52d01ca
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 19 deletions.
9 changes: 6 additions & 3 deletions Compiler/FrontEnd/ModelicaBuiltin.mo
Original file line number Diff line number Diff line change
Expand Up @@ -2185,8 +2185,9 @@ function plot "Launches a plot window using OMPlot."
input Real yRange[2] := {0.0,0.0} "Determines the vertical interval that is visible in the diagram. {0,0} will select a suitable range.";
input Real curveWidth := 1.0 "Sets the width of the curve.";
input Integer curveStyle := 1 "Sets the style of the curve. SolidLine=1, DashLine=2, DotLine=3, DashDotLine=4, DashDotDotLine=5, Sticks=6, Steps=7.";
input String legendPosition := "right" "Sets the POSITION of the legend i.e left, right, top, bottom.";
output Boolean success "Returns true on success";
output String[:] result "Returns list i.e {\"_omc_PlotResult\",\"<fileName>\",\"<title>\",\"<legend>\",\"<grid>\",\"<PlotType>\",\"<logX>\",\"<logY>\",\"<xLabel>\",\"<yLabel>\",\"<xRange>\",\"<yRange>\",\"<PlotVariables>\"}";
output String[:] result "Returns list i.e {\"_omc_PlotResult\",\"<fileName>\",\"<title>\",\"<legend>\",\"<grid>\",\"<PlotType>\",\"<logX>\",\"<logY>\",\"<xLabel>\",\"<yLabel>\",\"<xRange>\",\"<yRange>\",\"<curveWidth>\",\"<curveStyle>\",\"<legendPosition>\",\"<PlotVariables>\"}";
external "builtin";
annotation(preferredView="text",Documentation(info="<html>
<p>Launches a plot window using OMPlot. Returns true on success.</p>
Expand Down Expand Up @@ -2221,8 +2222,9 @@ function plotAll "Works in the same way as plot(), but does not accept any
input Real yRange[2] := {0.0,0.0} "Determines the vertical interval that is visible in the diagram. {0,0} will select a suitable range.";
input Real curveWidth := 1.0 "Sets the width of the curve.";
input Integer curveStyle := 1 "Sets the style of the curve. SolidLine=1, DashLine=2, DotLine=3, DashDotLine=4, DashDotDotLine=5, Sticks=6, Steps=7.";
input String legendPosition := "right" "Sets the POSITION of the legend i.e left, right, top, bottom.";
output Boolean success "Returns true on success";
output String[:] result "Returns list i.e {\"_omc_PlotResult\",\"<fileName>\",\"<title>\",\"<legend>\",\"<grid>\",\"<PlotType>\",\"<logX>\",\"<logY>\",\"<xLabel>\",\"<yLabel>\",\"<xRange>\",\"<yRange>\",\"<PlotVariables>\"}";
output String[:] result "Returns list i.e {\"_omc_PlotResult\",\"<fileName>\",\"<title>\",\"<legend>\",\"<grid>\",\"<PlotType>\",\"<logX>\",\"<logY>\",\"<xLabel>\",\"<yLabel>\",\"<xRange>\",\"<yRange>\",\"<curveWidth>\",\"<curveStyle>\",\"<legendPosition>\",\"<PlotVariables>\"}";
external "builtin";
annotation(preferredView="text");
end plotAll;
Expand Down Expand Up @@ -2264,8 +2266,9 @@ function plotParametric "Launches a plotParametric window using OMPlot. Returns
input Real yRange[2] := {0.0,0.0} "Determines the vertical interval that is visible in the diagram. {0,0} will select a suitable range.";
input Real curveWidth := 1.0 "Sets the width of the curve.";
input Integer curveStyle := 1 "Sets the style of the curve. SolidLine=1, DashLine=2, DotLine=3, DashDotLine=4, DashDotDotLine=5, Sticks=6, Steps=7.";
input String legendPosition := "right" "Sets the POSITION of the legend i.e left, right, top, bottom.";
output Boolean success "Returns true on success";
output String[:] result "Returns list i.e {\"_omc_PlotResult\",\"<fileName>\",\"<title>\",\"<legend>\",\"<grid>\",\"<PlotType>\",\"<logX>\",\"<logY>\",\"<xLabel>\",\"<yLabel>\",\"<xRange>\",\"<yRange>\",\"<PlotVariables>\"}";
output String[:] result "Returns list i.e {\"_omc_PlotResult\",\"<fileName>\",\"<title>\",\"<legend>\",\"<grid>\",\"<PlotType>\",\"<logX>\",\"<logY>\",\"<xLabel>\",\"<yLabel>\",\"<xRange>\",\"<yRange>\",\"<curveWidth>\",\"<curveStyle>\",\"<legendPosition>\",\"<PlotVariables>\"}";
external "builtin";
annotation(preferredView="text");
end plotParametric;
Expand Down
35 changes: 19 additions & 16 deletions Compiler/Script/CevalScript.mo
Original file line number Diff line number Diff line change
Expand Up @@ -823,7 +823,7 @@ algorithm
call,str_1,mp,pathstr,name,cname,errMsg,errorStr,
title,xLabel,yLabel,filename2,varNameStr,xml_filename,xml_contents,visvar_str,pwd,omhome,omlib,omcpath,os,
platform,usercflags,senddata,res,workdir,gcc,confcmd,touch_file,uname,filenameprefix,compileDir,libDir,exeDir,configDir,from,to,
legendStr, gridStr, logXStr, logYStr, x1Str, x2Str, y1Str, y2Str, curveWidthStr, curveStyleStr,scriptFile,logFile, simflags2, outputFile,
legendStr, gridStr, logXStr, logYStr, x1Str, x2Str, y1Str, y2Str, curveWidthStr, curveStyleStr, legendPosition,scriptFile,logFile, simflags2, outputFile,
systemPath, gccVersion, gd, strlinearizeTime, direction, suffix;
list<Values.Value> vals;
Absyn.Path path,classpath,className,baseClassPath;
Expand Down Expand Up @@ -2449,7 +2449,8 @@ algorithm
Values.ARRAY(valueLst={Values.REAL(x1),Values.REAL(x2)}),
Values.ARRAY(valueLst={Values.REAL(y1),Values.REAL(y2)}),
Values.REAL(curveWidth),
Values.INTEGER(curveStyle)
Values.INTEGER(curveStyle),
Values.STRING(legendPosition)
},
st,
_)
Expand All @@ -2468,9 +2469,8 @@ algorithm
// create the path till OMPlot
str2 = stringAppendList({omhome,pd,"bin",pd,"OMPlot",s1});
// create the list of arguments for OMPlot
str3 = "--filename=\"" +& filename +& "\" --title=\"" +& title +& "\" --legend=" +& boolString(legend) +& " --grid=" +& boolString(grid) +& " --plotAll --logx=" +& boolString(logX) +& " --logy=" +& boolString(logY) +& " --xlabel=\"" +& xLabel +& "\" --ylabel=\"" +& yLabel +& "\" --xrange=" +& realString(x1) +& ":" +& realString(x2) +& " --yrange=" +& realString(y1) +& ":" +& realString(y2) +& " --new-window=" +& boolString(externalWindow) +& " --curve-width=" +& realString(curveWidth) +& " --curve-style=" +& intString(curveStyle);
str3 = "--filename=\"" +& filename +& "\" --title=\"" +& title +& "\" --legend=" +& boolString(legend) +& " --grid=" +& boolString(grid) +& " --plotAll --logx=" +& boolString(logX) +& " --logy=" +& boolString(logY) +& " --xlabel=\"" +& xLabel +& "\" --ylabel=\"" +& yLabel +& "\" --xrange=" +& realString(x1) +& ":" +& realString(x2) +& " --yrange=" +& realString(y1) +& ":" +& realString(y2) +& " --new-window=" +& boolString(externalWindow) +& " --curve-width=" +& realString(curveWidth) +& " --curve-style=" +& intString(curveStyle) +& " --legend-position=\"" +& legendPosition +& "\"";
call = stringAppendList({"\"",str2,"\""," ",str3});

0 = System.spawnCall(str2, call);
then
(cache,Values.BOOL(true),st);
Expand All @@ -2490,7 +2490,8 @@ algorithm
Values.ARRAY(valueLst={Values.REAL(x1),Values.REAL(x2)}),
Values.ARRAY(valueLst={Values.REAL(y1),Values.REAL(y2)}),
Values.REAL(curveWidth),
Values.INTEGER(curveStyle)
Values.INTEGER(curveStyle),
Values.STRING(legendPosition)
},
st,
_)
Expand All @@ -2513,7 +2514,7 @@ algorithm
y2Str = realString(y2);
curveWidthStr = realString(curveWidth);
curveStyleStr = intString(curveStyle);
args = {"_omc_PlotResult",filename,title,legendStr,gridStr,"plotAll",logXStr,logYStr,xLabel,yLabel,x1Str,x2Str,y1Str,y2Str,curveWidthStr,curveStyleStr};
args = {"_omc_PlotResult",filename,title,legendStr,gridStr,"plotAll",logXStr,logYStr,xLabel,yLabel,x1Str,x2Str,y1Str,y2Str,curveWidthStr,curveStyleStr,legendPosition};
vals = List.map(args, ValuesUtil.makeString);
v = ValuesUtil.makeArray(vals);
then
Expand All @@ -2538,7 +2539,8 @@ algorithm
Values.ARRAY(valueLst={Values.REAL(x1),Values.REAL(x2)}),
Values.ARRAY(valueLst={Values.REAL(y1),Values.REAL(y2)}),
Values.REAL(curveWidth),
Values.INTEGER(curveStyle)
Values.INTEGER(curveStyle),
Values.STRING(legendPosition)
},
st,_)
equation
Expand All @@ -2560,9 +2562,8 @@ algorithm
// create the path till OMPlot
str2 = stringAppendList({omhome,pd,"bin",pd,"OMPlot",s1});
// create the list of arguments for OMPlot
str3 = "--filename=\"" +& filename +& "\" --title=\"" +& title +& "\" --legend=" +& boolString(legend) +& " --grid=" +& boolString(grid) +& " --plot --logx=" +& boolString(logX) +& " --logy=" +& boolString(logY) +& " --xlabel=\"" +& xLabel +& "\" --ylabel=\"" +& yLabel +& "\" --xrange=" +& realString(x1) +& ":" +& realString(x2) +& " --yrange=" +& realString(y1) +& ":" +& realString(y2) +& " --new-window=" +& boolString(externalWindow) +& " --curve-width=" +& realString(curveWidth) +& " --curve-style=" +& intString(curveStyle) +& " \"" +& str +& "\"";
str3 = "--filename=\"" +& filename +& "\" --title=\"" +& title +& "\" --legend=" +& boolString(legend) +& " --grid=" +& boolString(grid) +& " --plot --logx=" +& boolString(logX) +& " --logy=" +& boolString(logY) +& " --xlabel=\"" +& xLabel +& "\" --ylabel=\"" +& yLabel +& "\" --xrange=" +& realString(x1) +& ":" +& realString(x2) +& " --yrange=" +& realString(y1) +& ":" +& realString(y2) +& " --new-window=" +& boolString(externalWindow) +& " --curve-width=" +& realString(curveWidth) +& " --curve-style=" +& intString(curveStyle) +& " --legend-position=\"" +& legendPosition +& "\" \"" +& str +& "\"";
call = stringAppendList({"\"",str2,"\""," ",str3});

0 = System.spawnCall(str2, call);
then
(cache,Values.BOOL(true),st);
Expand All @@ -2583,7 +2584,8 @@ algorithm
Values.ARRAY(valueLst={Values.REAL(x1),Values.REAL(x2)}),
Values.ARRAY(valueLst={Values.REAL(y1),Values.REAL(y2)}),
Values.REAL(curveWidth),
Values.INTEGER(curveStyle)
Values.INTEGER(curveStyle),
Values.STRING(legendPosition)
},
st,_)
equation
Expand All @@ -2609,7 +2611,7 @@ algorithm
y2Str = realString(y2);
curveWidthStr = realString(curveWidth);
curveStyleStr = intString(curveStyle);
args = {"_omc_PlotResult",filename,title,legendStr,gridStr,"plot",logXStr,logYStr,xLabel,yLabel,x1Str,x2Str,y1Str,y2Str,curveWidthStr,curveStyleStr};
args = {"_omc_PlotResult",filename,title,legendStr,gridStr,"plot",logXStr,logYStr,xLabel,yLabel,x1Str,x2Str,y1Str,y2Str,curveWidthStr,curveStyleStr,legendPosition};
args = listAppend(args, vars_1);
vals = List.map(args, ValuesUtil.makeString);
v = ValuesUtil.makeArray(vals);
Expand Down Expand Up @@ -2866,7 +2868,8 @@ algorithm
Values.ARRAY(valueLst={Values.REAL(x1),Values.REAL(x2)}),
Values.ARRAY(valueLst={Values.REAL(y1),Values.REAL(y2)}),
Values.REAL(curveWidth),
Values.INTEGER(curveStyle)
Values.INTEGER(curveStyle),
Values.STRING(legendPosition)
},
st,_)
equation
Expand All @@ -2886,9 +2889,8 @@ algorithm
// create the path till OMPlot
str2 = stringAppendList({omhome,pd,"bin",pd,"OMPlot",s1});
// create the list of arguments for OMPlot
str3 = "--filename=\"" +& filename +& "\" --title=\"" +& title +& "\" --legend=" +& boolString(legend) +& " --grid=" +& boolString(grid) +& " --plotParametric --logx=" +& boolString(logX) +& " --logy=" +& boolString(logY) +& " --xlabel=\"" +& xLabel +& "\" --ylabel=\"" +& yLabel +& "\" --xrange=" +& realString(x1) +& ":" +& realString(x2) +& " --yrange=" +& realString(y1) +& ":" +& realString(y2) +& " --new-window=" +& boolString(externalWindow) +& " --curve-width=" +& realString(curveWidth) +& " --curve-style=" +& intString(curveStyle) +& " \"" +& str +& "\"";
str3 = "--filename=\"" +& filename +& "\" --title=\"" +& title +& "\" --legend=" +& boolString(legend) +& " --grid=" +& boolString(grid) +& " --plotParametric --logx=" +& boolString(logX) +& " --logy=" +& boolString(logY) +& " --xlabel=\"" +& xLabel +& "\" --ylabel=\"" +& yLabel +& "\" --xrange=" +& realString(x1) +& ":" +& realString(x2) +& " --yrange=" +& realString(y1) +& ":" +& realString(y2) +& " --new-window=" +& boolString(externalWindow) +& " --curve-width=" +& realString(curveWidth) +& " --curve-style=" +& intString(curveStyle) +& " --legend-position=\"" +& legendPosition +& "\" \"" +& str +& "\"";
call = stringAppendList({"\"",str2,"\""," ",str3});

0 = System.spawnCall(str2, call);
then
(cache,Values.BOOL(true),st);
Expand All @@ -2910,7 +2912,8 @@ algorithm
Values.ARRAY(valueLst={Values.REAL(x1),Values.REAL(x2)}),
Values.ARRAY(valueLst={Values.REAL(y1),Values.REAL(y2)}),
Values.REAL(curveWidth),
Values.INTEGER(curveStyle)
Values.INTEGER(curveStyle),
Values.STRING(legendPosition)
},
st,_)
equation
Expand All @@ -2935,7 +2938,7 @@ algorithm
y2Str = realString(y2);
curveWidthStr = realString(curveWidth);
curveStyleStr = intString(curveStyle);
args = {"_omc_PlotResult",filename,title,legendStr,gridStr,"plotParametric",logXStr,logYStr,xLabel,yLabel,x1Str,x2Str,y1Str,y2Str,curveWidthStr,curveStyleStr,str,str3};
args = {"_omc_PlotResult",filename,title,legendStr,gridStr,"plotParametric",logXStr,logYStr,xLabel,yLabel,x1Str,x2Str,y1Str,y2Str,curveWidthStr,curveStyleStr,legendPosition,str,str3};
vals = List.map(args, ValuesUtil.makeString);
v = ValuesUtil.makeArray(vals);
then
Expand Down

0 comments on commit 52d01ca

Please sign in to comment.