@@ -53,23 +53,31 @@ PlotWindow::PlotWindow(QStringList arguments, QWidget *parent)
5353 setLegend (true );
5454 else if (QString (arguments[3 ]) == " false" )
5555 setLegend (false );
56+ else
57+ throw PlotException (" Invalid input" );
5658 // read the grid
5759 if (QString (arguments[4 ]) == " true" )
5860 setGrid (true );
5961 else if (QString (arguments[4 ]) == " false" )
6062 setGrid (false );
63+ else
64+ throw PlotException (" Invalid input" );
6165 // read the plot type
6266 QString plotType = arguments[5 ];
6367 // read the logx
6468 if (QString (arguments[6 ]) == " true" )
6569 setLogX (true );
6670 else if (QString (arguments[6 ]) == " false" )
6771 setLogX (false );
72+ else
73+ throw PlotException (" Invalid input" );
6874 // read the logy
6975 if (QString (arguments[7 ]) == " true" )
7076 setLogY (true );
7177 else if (QString (arguments[7 ]) == " false" )
7278 setLogY (false );
79+ else
80+ throw PlotException (" Invalid input" );
7381 // read the x label value
7482 setXLabel (QString (arguments[8 ]));
7583 // read the y label value
@@ -344,8 +352,9 @@ void PlotWindow::plot(QStringList variables)
344352
345353 // Read in timevector
346354 QVector<double > timeVector;
347- var = omc_matlab4_find_var (&reader, " Time" );
348- double *vals = omc_matlab4_read_vals (&reader,var->index );
355+ if (reader.nvar < 1 )
356+ throw NoVariableException (" Variable doesnt exist: time" );
357+ double *vals = omc_matlab4_read_vals (&reader,0 );
349358 for (int j = 0 ; j<reader.nrows ; j++)
350359 timeVector.push_back (vals[j]);
351360
@@ -360,8 +369,6 @@ void PlotWindow::plot(QStringList variables)
360369 for (int i = 0 ; i < variables.length (); i++)
361370 {
362371 QString currentPlotVariable = variables[i];
363- if (currentPlotVariable == " time" )
364- currentPlotVariable = " Time" ;
365372
366373 PlotCurve *pPlotCurve = new PlotCurve (mpPlot);
367374 pPlotCurve->setXAxisVector (timeVector);
@@ -370,9 +377,17 @@ void PlotWindow::plot(QStringList variables)
370377 var = omc_matlab4_find_var (&reader, currentPlotVariable.toStdString ().c_str ());
371378 if (!var)
372379 throw NoVariableException (QString (" Variable doesnt exist : " ).append (currentPlotVariable).toStdString ().c_str ());
373- vals = omc_matlab4_read_vals (&reader, var->index );
374- for (int j = 0 ; j < reader.nrows ; j++)
375- pPlotCurve->addYAxisValue (vals[j]);
380+ if (!var->isParam ) {
381+ vals = omc_matlab4_read_vals (&reader, var->index );
382+ for (int j = 0 ; j < reader.nrows ; j++)
383+ pPlotCurve->addYAxisValue (vals[j]);
384+ } else {
385+ double val;
386+ if (omc_matlab4_val (&val,&reader,var,0.0 ))
387+ throw NoVariableException (QString (" Parameter doesn't have a value : " ).append (currentPlotVariable).toStdString ().c_str ());
388+ for (int j = 0 ; j < reader.nrows ; j++)
389+ pPlotCurve->addYAxisValue (val);
390+ }
376391
377392 // Set curvename and push back to list
378393 pPlotCurve->setTitle (variables[i]);
@@ -518,11 +533,6 @@ void PlotWindow::plotParametric(QString xVariable, QString yVariable)
518533 if (0 != (msg = omc_new_matlab4_reader (mpFile->fileName ().toStdString ().c_str (), &reader)))
519534 return ;
520535
521- if (xVariable == " time" )
522- xVariable = " Time" ;
523- if (yVariable == " time" )
524- yVariable = " Time" ;
525-
526536 PlotCurve *pPlotCurve = new PlotCurve (mpPlot);
527537
528538 // Fill variable x with data
0 commit comments