Skip to content

Commit

Permalink
- Handle the new plot grid options in plotting APIs & OMNotebook.
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@20538 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
adeas31 committed May 9, 2014
1 parent 967ab98 commit 88f0c6a
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 10 deletions.
31 changes: 25 additions & 6 deletions OMPlot/OMPlotGUI/PlotWindow.cpp
Expand Up @@ -90,12 +90,7 @@ void PlotWindow::initializePlot(QStringList arguments)
initializeFile(QString(arguments[1]));
//Set up arguments
setTitle(QString(arguments[2]));
if(QString(arguments[3]) == "true")
setDetailedGrid(true);
else if(QString(arguments[3]) == "false")
setNoGrid(true);
else
throw PlotException("Invalid input" + arguments[4]);
setGrid(QString(arguments[3]));
QString plotType = arguments[4];
if(QString(arguments[5]) == "true")
setLogX(true);
Expand Down Expand Up @@ -647,6 +642,27 @@ void PlotWindow::setTitle(QString title)
mpPlot->setTitle(title);
}

void PlotWindow::setGrid(QString grid)
{
if (grid.toLower().compare("simple") == 0)
{
setGrid(true);
}
else if (grid.toLower().compare("none") == 0)
{
setNoGrid(true);
}
else
{
setDetailedGrid(true);
}
}

QString PlotWindow::getGrid()
{
return mGridType;
}

QCheckBox* PlotWindow::getLogXCheckBox()
{
return mpLogXCheckBox;
Expand Down Expand Up @@ -939,6 +955,7 @@ void PlotWindow::setGrid(bool on)
{
if (on)
{
mGridType = "simple";
mpPlot->getPlotGrid()->setGrid();
mpPlot->getPlotGrid()->attach(mpPlot);
mpGridButton->setChecked(true);
Expand All @@ -950,6 +967,7 @@ void PlotWindow::setDetailedGrid(bool on)
{
if (on)
{
mGridType = "detailed";
mpPlot->getPlotGrid()->setDetailedGrid();
mpPlot->getPlotGrid()->attach(mpPlot);
mpDetailedGridButton->setChecked(true);
Expand All @@ -961,6 +979,7 @@ void PlotWindow::setNoGrid(bool on)
{
if (on)
{
mGridType = "none";
mpPlot->getPlotGrid()->detach();
mpNoGridButton->setChecked(true);
}
Expand Down
3 changes: 3 additions & 0 deletions OMPlot/OMPlotGUI/PlotWindow.h
Expand Up @@ -68,6 +68,7 @@ class PlotWindow : public QMainWindow
QFile mFile;
QStringList mVariablesList;
PlotType mPlotType;
QString mGridType;
QString mXRangeMin;
QString mXRangeMax;
QString mYRangeMin;
Expand All @@ -88,6 +89,8 @@ class PlotWindow : public QMainWindow
void plot();
void plotParametric();
void setTitle(QString title);
void setGrid(QString grid);
QString getGrid();
QCheckBox* getLogXCheckBox();
QCheckBox* getLogYCheckBox();
void setXLabel(QString label);
Expand Down
8 changes: 4 additions & 4 deletions OMPlot/OMPlotGUI/main.cpp
Expand Up @@ -49,7 +49,7 @@ void printUsage()
printf("OPTIONS\n");
printf(" --title=TITLE Sets the TITLE of the plot window\n");
printf(" --filename=NAME Sets the NAME of the file to plot\n");
printf(" --grid=[true|false] Enable a grid in the window\n");
printf(" --grid=GRID Sets the GRID of the plot i.e simple, detailed, none\n");
printf(" --logx=[true|false] Use log scale for the x-axis\n");
printf(" --logy=[true|false] Use log scale for the y-axis\n");
printf(" --xlabel=LABEL Use LABEL as the label of the x-axis\n");
Expand All @@ -72,7 +72,7 @@ int main(int argc, char *argv[])
QStringList arguments;
bool newApplication = false;
QString title("");
bool grid = true;
QString grid = "detailed";
QString plottype("plot");
bool logx = false;
bool logy = false;
Expand All @@ -98,7 +98,7 @@ int main(int argc, char *argv[])
} else if (strncmp(argv[i], "--title=", 8) == 0) {
title = argv[i]+8;
} else if (strncmp(argv[i], "--grid=",7) == 0) {
CONSUME_BOOL_ARG(i,7,grid);
grid = argv[i]+7;
} else if (strncmp(argv[i], "--logx=",7) == 0) {
CONSUME_BOOL_ARG(i,7,logx);
} else if (strncmp(argv[i], "--logy=",7) == 0) {
Expand Down Expand Up @@ -155,7 +155,7 @@ int main(int argc, char *argv[])
arguments.append(argv[0]);
arguments.append(filename);
arguments.append(title);
arguments.append(grid ? "true" : "false");
arguments.append(grid);
arguments.append(plottype);
arguments.append(logx ? "true" : "false");
arguments.append(logy ? "true" : "false");
Expand Down

0 comments on commit 88f0c6a

Please sign in to comment.