Skip to content

Commit 5754cd4

Browse files
committed
- Added some preprocessor ifs to OMPlot and OMEdit to make them compile with QWT 6.
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@10287 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
1 parent 19d85e5 commit 5754cd4

File tree

5 files changed

+29
-7
lines changed

5 files changed

+29
-7
lines changed

OMPlot/OMPlotGUI/PlotCurve.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,19 @@ bool PlotCurve::hasCustomColor()
123123
return mCustomColor;
124124
}
125125

126+
void PlotCurve::setData(const double* xData, const double* yData, int size)
127+
{
128+
#if QWT_VERSION >= 0x060000
129+
setRawSamples(xData, yData, size);
130+
#else
131+
setRawData(xData, yData, size);
132+
#endif
133+
}
134+
126135
void PlotCurve::updateLegend(QwtLegend *legend) const
127136
{
128137
QwtPlotCurve::updateLegend(legend);
138+
#if QWT_VERSION < 0x060000
129139
QwtLegendItem *lgdItem = dynamic_cast<QwtLegendItem*>(legend->find(this));
130140
if (lgdItem)
131141
{
@@ -134,4 +144,5 @@ void PlotCurve::updateLegend(QwtLegend *legend) const
134144
}
135145

136146
QwtPlotItem::updateLegend(legend);
147+
#endif
137148
}

OMPlot/OMPlotGUI/PlotCurve.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ class PlotCurve : public QwtPlotCurve
6868
QString getYVariable();
6969
void setCustomColor(bool value);
7070
bool hasCustomColor();
71+
void setData(const double* xData, const double* yData, int size);
7172
virtual void updateLegend(QwtLegend *legend) const;
7273
};
7374
}

OMPlot/OMPlotGUI/PlotWindow.cpp

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ void PlotWindow::plot()
274274
currentLine = mpTextStream->readLine();
275275
}
276276
pPlotCurve->setTitle(currentVariable);
277-
pPlotCurve->setRawData(pPlotCurve->getXAxisVector(), pPlotCurve->getYAxisVector(),
277+
pPlotCurve->setData(pPlotCurve->getXAxisVector(), pPlotCurve->getYAxisVector(),
278278
pPlotCurve->getSize());
279279
pPlotCurve->attach(mpPlot);
280280
mpPlot->replot();
@@ -337,7 +337,7 @@ void PlotWindow::plot()
337337
// plot the curves
338338
for(int i = 0; i < variablesToPlotIndex.size(); i++)
339339
{
340-
pPlotCurve[i]->setRawData(pPlotCurve[i]->getXAxisVector(), pPlotCurve[i]->getYAxisVector(),
340+
pPlotCurve[i]->setData(pPlotCurve[i]->getXAxisVector(), pPlotCurve[i]->getYAxisVector(),
341341
pPlotCurve[i]->getSize());
342342
pPlotCurve[i]->attach(mpPlot);
343343
mpPlot->replot();
@@ -386,7 +386,7 @@ void PlotWindow::plot()
386386
{
387387
double *vals = omc_matlab4_read_vals(&reader, var->index);
388388
// set plot curve data and attach it to plot
389-
pPlotCurve->setRawData(timeVals, vals, reader.nrows);
389+
pPlotCurve->setData(timeVals, vals, reader.nrows);
390390
pPlotCurve->attach(mpPlot);
391391
mpPlot->replot();
392392
}
@@ -401,7 +401,7 @@ void PlotWindow::plot()
401401
pPlotCurve->addYAxisValue(val);
402402
pPlotCurve->addXAxisValue(stopTime);
403403
pPlotCurve->addYAxisValue(val);
404-
pPlotCurve->setRawData(pPlotCurve->getXAxisVector(), pPlotCurve->getYAxisVector(),
404+
pPlotCurve->setData(pPlotCurve->getXAxisVector(), pPlotCurve->getYAxisVector(),
405405
pPlotCurve->getSize());
406406
pPlotCurve->attach(mpPlot);
407407
mpPlot->replot();
@@ -480,7 +480,7 @@ void PlotWindow::plotParametric()
480480
if (variablesPlotted.size() == 2)
481481
{
482482
pPlotCurve->setTitle(yVariable + "(" + xVariable + ")");
483-
pPlotCurve->setRawData(pPlotCurve->getXAxisVector(), pPlotCurve->getYAxisVector(),
483+
pPlotCurve->setData(pPlotCurve->getXAxisVector(), pPlotCurve->getYAxisVector(),
484484
pPlotCurve->getSize());
485485
pPlotCurve->attach(mpPlot);
486486
mpPlot->replot();
@@ -539,7 +539,7 @@ void PlotWindow::plotParametric()
539539
pPlotCurve->addYAxisValue(QString(values[yVariableIndex]).toDouble());
540540
}
541541

542-
pPlotCurve->setRawData(pPlotCurve->getXAxisVector(), pPlotCurve->getYAxisVector(),
542+
pPlotCurve->setData(pPlotCurve->getXAxisVector(), pPlotCurve->getYAxisVector(),
543543
pPlotCurve->getSize());
544544
pPlotCurve->attach(mpPlot);
545545
mpPlot->replot();
@@ -573,7 +573,7 @@ void PlotWindow::plotParametric()
573573
if(!var)
574574
throw NoVariableException(QString("Variable doesn't exist : ").append(yVariable).toStdString().c_str());
575575
double *yVals = omc_matlab4_read_vals(&reader,var->index);
576-
pPlotCurve->setRawData(xVals, yVals, reader.nrows);
576+
pPlotCurve->setData(xVals, yVals, reader.nrows);
577577
pPlotCurve->setTitle(yVariable + "(" + xVariable + ")");
578578
pPlotCurve->attach(mpPlot);
579579
mpPlot->replot();
@@ -686,7 +686,10 @@ void PlotWindow::exportDocument()
686686
generator.setDescription(tr("Generated by OpenModelica Plot Tool"));
687687
generator.setFileName(fileName);
688688
generator.setSize(getPlot()->rect().size());
689+
#if QWT_VERSION < 0x060000
689690
getPlot()->print(generator);
691+
#endif
692+
690693
}
691694
// export png, bmp, jpg
692695
else
@@ -702,6 +705,7 @@ void PlotWindow::exportDocument()
702705

703706
void PlotWindow::printPlot()
704707
{
708+
#if QWT_VERSION < 0x060000
705709
#if 1
706710
QPrinter printer;
707711
#else
@@ -726,6 +730,7 @@ void PlotWindow::printPlot()
726730
}
727731
mpPlot->print(printer, filter);
728732
}
733+
#endif
729734
}
730735

731736
void PlotWindow::setGrid(bool on)

OMPlot/OMPlotGUI/PlotWindow.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@
3636
#include <qwt_plot_zoomer.h>
3737
#include <qwt_plot_panner.h>
3838
#include <qwt_scale_engine.h>
39+
#if QWT_VERSION >= 0x060000
40+
#include <qwt_compat.h>
41+
#endif
3942
#include <stdexcept>
4043
#include "../../c_runtime/read_matlab4.h"
4144
#include "Plot.h"

OMPlot/OMPlotGUI/PlotZoomer.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ using namespace OMPlot;
3838
PlotZoomer::PlotZoomer(int xAxis, int yAxis, QwtPlotCanvas *pParent)
3939
: QwtPlotZoomer(xAxis, yAxis, pParent)
4040
{
41+
#if QWT_VERSION < 0x060000
4142
setSelectionFlags(QwtPicker::DragSelection | QwtPicker::CornerToCorner);
43+
#endif
4244
setTrackerMode(QwtPicker::AlwaysOff);
4345
setRubberBand(QwtPicker::RectRubberBand);
4446
setRubberBandPen(QPen(Qt::black, 1.0, Qt::DashLine));

0 commit comments

Comments
 (0)