Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
- Allow preserving the zoom level. Don't always auto rescale for new variables in plot.

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@25480 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
adeas31 committed Apr 9, 2015
1 parent 1e8e072 commit 7d9a87e
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 17 deletions.
9 changes: 6 additions & 3 deletions Compiler/FrontEnd/ModelicaBuiltin.mo
Expand Up @@ -2511,8 +2511,9 @@ function plot "Launches a plot window using OMPlot."
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 = "top" "Sets the POSITION of the legend i.e left, right, top, bottom, none.";
input String footer = "" "This text will be used as the diagram footer.";
input Boolean autoScale = true "Use auto scale while plotting.";
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>\",\"<curveWidth>\",\"<curveStyle>\",\"<legendPosition>\",\"<PlotVariables>\"}";
output String[:] result "Returns list i.e {\"_omc_PlotResult\",\"<fileName>\",\"<title>\",\"<legend>\",\"<grid>\",\"<PlotType>\",\"<logX>\",\"<logY>\",\"<xLabel>\",\"<yLabel>\",\"<xRange>\",\"<yRange>\",\"<curveWidth>\",\"<curveStyle>\",\"<legendPosition>\",\"<footer>\",\"<autoScale>\",\"<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 @@ -2548,8 +2549,9 @@ function plotAll "Works in the same way as plot(), but does not accept any
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 = "top" "Sets the POSITION of the legend i.e left, right, top, bottom, none.";
input String footer = "" "This text will be used as the diagram footer.";
input Boolean autoScale = true "Use auto scale while plotting.";
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>\",\"<curveWidth>\",\"<curveStyle>\",\"<legendPosition>\",\"<PlotVariables>\"}";
output String[:] result "Returns list i.e {\"_omc_PlotResult\",\"<fileName>\",\"<title>\",\"<legend>\",\"<grid>\",\"<PlotType>\",\"<logX>\",\"<logY>\",\"<xLabel>\",\"<yLabel>\",\"<xRange>\",\"<yRange>\",\"<curveWidth>\",\"<curveStyle>\",\"<legendPosition>\",\"<footer>\",\"<autoScale>\",\"<PlotVariables>\"}";
external "builtin";
annotation(preferredView="text");
end plotAll;
Expand Down Expand Up @@ -2592,8 +2594,9 @@ function plotParametric "Launches a plotParametric window using OMPlot. Returns
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 = "top" "Sets the POSITION of the legend i.e left, right, top, bottom, none.";
input String footer = "" "This text will be used as the diagram footer.";
input Boolean autoScale = true "Use auto scale while plotting.";
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>\",\"<curveWidth>\",\"<curveStyle>\",\"<legendPosition>\",\"<PlotVariables>\"}";
output String[:] result "Returns list i.e {\"_omc_PlotResult\",\"<fileName>\",\"<title>\",\"<legend>\",\"<grid>\",\"<PlotType>\",\"<logX>\",\"<logY>\",\"<xLabel>\",\"<yLabel>\",\"<xRange>\",\"<yRange>\",\"<curveWidth>\",\"<curveStyle>\",\"<legendPosition>\",\"<footer>\",\"<autoScale>\",\"<PlotVariables>\"}";
external "builtin";
annotation(preferredView="text");
end plotParametric;
Expand Down
37 changes: 23 additions & 14 deletions Compiler/Script/CevalScript.mo
Expand Up @@ -886,7 +886,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,
gridStr, logXStr, logYStr, x1Str, x2Str, y1Str, y2Str, curveWidthStr, curveStyleStr, legendPosition, footer,scriptFile,logFile, simflags2, outputFile,
gridStr, logXStr, logYStr, x1Str, x2Str, y1Str, y2Str, curveWidthStr, curveStyleStr, legendPosition, footer, autoScaleStr,scriptFile,logFile, simflags2, outputFile,
systemPath, gccVersion, gd, strlinearizeTime, direction, suffix;
list<DAE.Exp> simOptions;
list<Values.Value> vals;
Expand Down Expand Up @@ -928,7 +928,7 @@ algorithm
Real timeTotal,timeSimulation,timeStamp,val,x1,x2,y1,y2,r,r1,r2,linearizeTime,curveWidth,offset,offset1,offset2,scaleFactor,scaleFactor1,scaleFactor2;
GlobalScript.Statements istmts;
list<GlobalScript.Statements> istmtss;
Boolean have_corba, bval, anyCode, b, b1, b2, externalWindow, logX, logY, gcc_res, omcfound, rm_res, touch_res, uname_res, ifcpp, ifmsvc,sort, builtin, showProtected, inputConnectors, outputConnectors;
Boolean have_corba, bval, anyCode, b, b1, b2, externalWindow, logX, logY, autoScale, gcc_res, omcfound, rm_res, touch_res, uname_res, ifcpp, ifmsvc,sort, builtin, showProtected, inputConnectors, outputConnectors;
FCore.Cache cache;
list<GlobalScript.LoadedFile> lf;
Absyn.ComponentRef crefCName;
Expand Down Expand Up @@ -2975,7 +2975,8 @@ algorithm
Values.REAL(curveWidth),
Values.INTEGER(curveStyle),
Values.STRING(legendPosition),
Values.STRING(footer)
Values.STRING(footer),
Values.BOOL(autoScale)
},
st,
_)
Expand All @@ -2994,7 +2995,7 @@ 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 + "\" --grid=" + gridStr + " --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 + "\" --footer=\"" + footer + "\"";
str3 = "--filename=\"" + filename + "\" --title=\"" + title + "\" --grid=" + gridStr + " --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 + "\" --footer=\"" + footer + "\" --auto-scale=" + boolString(autoScale);
call = stringAppendList({"\"",str2,"\""," ",str3});
0 = System.spawnCall(str2, call);
then
Expand All @@ -3016,7 +3017,8 @@ algorithm
Values.REAL(curveWidth),
Values.INTEGER(curveStyle),
Values.STRING(legendPosition),
Values.STRING(footer)
Values.STRING(footer),
Values.BOOL(autoScale)
},
st,
_)
Expand All @@ -3037,7 +3039,8 @@ algorithm
y2Str = realString(y2);
curveWidthStr = realString(curveWidth);
curveStyleStr = intString(curveStyle);
args = {"_omc_PlotResult",filename,title,gridStr,"plotAll",logXStr,logYStr,xLabel,yLabel,x1Str,x2Str,y1Str,y2Str,curveWidthStr,curveStyleStr,legendPosition,footer};
autoScaleStr = boolString(autoScale);
args = {"_omc_PlotResult",filename,title,gridStr,"plotAll",logXStr,logYStr,xLabel,yLabel,x1Str,x2Str,y1Str,y2Str,curveWidthStr,curveStyleStr,legendPosition,footer,autoScaleStr};
vals = List.map(args, ValuesUtil.makeString);
v = ValuesUtil.makeArray(vals);
then
Expand All @@ -3063,7 +3066,8 @@ algorithm
Values.REAL(curveWidth),
Values.INTEGER(curveStyle),
Values.STRING(legendPosition),
Values.STRING(footer)
Values.STRING(footer),
Values.BOOL(autoScale)
},
st,_)
equation
Expand All @@ -3085,7 +3089,7 @@ 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 + "\" --grid=" + gridStr + " --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 + "\" --footer=\"" + footer + "\" \"" + str + "\"";
str3 = "--filename=\"" + filename + "\" --title=\"" + title + "\" --grid=" + gridStr + " --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 + "\" --footer=\"" + footer + "\" --auto-scale=" + boolString(autoScale) + " \"" + str + "\"";
call = stringAppendList({"\"",str2,"\""," ",str3});
0 = System.spawnCall(str2, call);
then
Expand All @@ -3108,7 +3112,8 @@ algorithm
Values.REAL(curveWidth),
Values.INTEGER(curveStyle),
Values.STRING(legendPosition),
Values.STRING(footer)
Values.STRING(footer),
Values.BOOL(autoScale)
},
st,_)
equation
Expand All @@ -3132,7 +3137,8 @@ algorithm
y2Str = realString(y2);
curveWidthStr = realString(curveWidth);
curveStyleStr = intString(curveStyle);
args = {"_omc_PlotResult",filename,title,gridStr,"plot",logXStr,logYStr,xLabel,yLabel,x1Str,x2Str,y1Str,y2Str,curveWidthStr,curveStyleStr,legendPosition,footer};
autoScaleStr = boolString(autoScale);
args = {"_omc_PlotResult",filename,title,gridStr,"plot",logXStr,logYStr,xLabel,yLabel,x1Str,x2Str,y1Str,y2Str,curveWidthStr,curveStyleStr,legendPosition,footer,autoScaleStr};
args = listAppend(args, vars_1);
vals = List.map(args, ValuesUtil.makeString);
v = ValuesUtil.makeArray(vals);
Expand Down Expand Up @@ -3418,7 +3424,8 @@ algorithm
Values.REAL(curveWidth),
Values.INTEGER(curveStyle),
Values.STRING(legendPosition),
Values.STRING(footer)
Values.STRING(footer),
Values.BOOL(autoScale)
},
st,_)
equation
Expand All @@ -3438,7 +3445,7 @@ 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 + "\" --grid=" + gridStr + " --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 + "\" --footer=\"" + footer + "\" \"" + str + "\"";
str3 = "--filename=\"" + filename + "\" --title=\"" + title + "\" --grid=" + gridStr + " --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 + "\" --footer=\"" + footer + "\" --auto-scale=" + boolString(autoScale) + " \"" + str + "\"";
call = stringAppendList({"\"",str2,"\""," ",str3});
0 = System.spawnCall(str2, call);
then
Expand All @@ -3462,7 +3469,8 @@ algorithm
Values.REAL(curveWidth),
Values.INTEGER(curveStyle),
Values.STRING(legendPosition),
Values.STRING(footer)
Values.STRING(footer),
Values.BOOL(autoScale)
},
st,_)
equation
Expand All @@ -3485,7 +3493,8 @@ algorithm
y2Str = realString(y2);
curveWidthStr = realString(curveWidth);
curveStyleStr = intString(curveStyle);
args = {"_omc_PlotResult",filename,title,gridStr,"plotParametric",logXStr,logYStr,xLabel,yLabel,x1Str,x2Str,y1Str,y2Str,curveWidthStr,curveStyleStr,legendPosition,footer,str,str3};
autoScaleStr = boolString(autoScale);
args = {"_omc_PlotResult",filename,title,gridStr,"plotParametric",logXStr,logYStr,xLabel,yLabel,x1Str,x2Str,y1Str,y2Str,curveWidthStr,curveStyleStr,legendPosition,footer,autoScaleStr,str,str3};
vals = List.map(args, ValuesUtil.makeString);
v = ValuesUtil.makeArray(vals);
then
Expand Down

0 comments on commit 7d9a87e

Please sign in to comment.