move IntervalPlotData into .cpp and fix mem leak

This commit is contained in:
Sean Rhea
2009-12-13 15:16:57 -05:00
parent 333fe46196
commit 74742965dd
2 changed files with 16 additions and 20 deletions

View File

@@ -35,6 +35,21 @@
#include <qwt_data.h>
#include <QMultiMap>
class IntervalPlotData : public QwtData
{
public:
IntervalPlotData(AllPlot *allPlot, MainWindow *mainWindow) :
allPlot(allPlot), mainWindow(mainWindow) {}
double x(size_t i) const ;
double y(size_t i) const ;
size_t size() const ;
virtual QwtData *copy() const ;
void init() ;
IntervalItem *intervalNum(int n) const;
int intervalCount() const;
AllPlot *allPlot;
MainWindow *mainWindow;
};
// define a background class to handle shading of power zones
// draws power zone bands IF zones are defined and the option
@@ -188,8 +203,6 @@ AllPlot::AllPlot(QWidget *parent, MainWindow *mainWindow):
bg = new AllPlotBackground(this);
bg->attach(this);
intervalPlotData = new IntervalPlotData(this, mainWindow);
insertLegend(new QwtLegend(), QwtPlot::BottomLegend);
setCanvasBackground(Qt::white);
@@ -236,7 +249,7 @@ AllPlot::AllPlot(QWidget *parent, MainWindow *mainWindow):
QColor ihlbrush = QColor(Qt::blue);
ihlbrush.setAlpha(64);
intervalHighlighterCurve->setBrush(ihlbrush); // fill below the line
intervalHighlighterCurve->setData(*intervalPlotData);
intervalHighlighterCurve->setData(IntervalPlotData(this, mainWindow));
intervalHighlighterCurve->attach(this);
this->legend()->remove(intervalHighlighterCurve); // don't show in legend

View File

@@ -34,22 +34,6 @@ class AllPlot;
class IntervalItem;
class MainWindow;
class IntervalPlotData : public QwtData
{
public:
IntervalPlotData(AllPlot *allPlot, MainWindow *mainWindow) :
allPlot(allPlot), mainWindow(mainWindow) {}
double x(size_t i) const ;
double y(size_t i) const ;
size_t size() const ;
virtual QwtData *copy() const ;
void init() ;
IntervalItem *intervalNum(int n) const;
int intervalCount() const;
AllPlot *allPlot;
MainWindow *mainWindow;
};
class AllPlot : public QwtPlot
{
Q_OBJECT
@@ -104,7 +88,6 @@ class AllPlot : public QwtPlot
QwtPlotGrid *grid;
IntervalPlotData *intervalPlotData;
QVector<double> hrArray;
QVector<double> wattsArray;
QVector<double> speedArray;