00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00024
00025 #ifndef QVPLOT_H
00026 #define QVPLOT_H
00027
00028 #include <QTimer>
00029 #include <QVWorker>
00030
00031 #include <qwt_plot.h>
00032 #include <qwt_plot_curve.h>
00033
00034
00035 #ifndef DOXYGEN_IGNORE_THIS
00036 #define MAX_HISTORY 60 // seconds
00037
00046
00047 class QVPlot: public QwtPlot, public QVPropertyContainer
00048 {
00049 Q_OBJECT
00050 public:
00061 QVPlot(const QString name = QString(), bool decorations = true, bool havePie = false, bool brush = false, bool _autoShow = false, bool time = true,
00062 int step = 10, QWidget *parent = 0);
00063
00064 ~QVPlot();
00065
00074 virtual bool linkProperty(QVWorker &worker, const QString propertyName);
00075
00076 virtual bool unlink(QVWorker *worker, const QString propertyName);
00077
00081 bool isAutoShow() const { return autoShow; }
00082
00086 bool isInitied() const { return initied; }
00087
00088 public slots:
00091 virtual void init();
00092
00095 virtual void stop();
00096
00101 void update(uint id, int iteration);
00102
00107 void workerChange(QVWorker::TWorkerStatus status);
00108
00113 void legendItemCheked(bool check);
00114
00115 protected:
00120 virtual QStringList getPropertyCurvNames(QString property) const = 0;
00121
00126 virtual QList<double> getPropertyCurvValues(QString property) const = 0;
00127
00133 virtual QList<int> getPropertyCurvOrders(QString property) const = 0;
00134
00135 class Curve
00136 {
00137 public:
00138 Curve(QString n, QwtPlotCurve *qwtpc, int tempSize): name(n), plot(qwtpc)
00139 {
00140 for (int i = 0; i < MAX_HISTORY; i++) history[i] = 0;
00141 if (tempSize > 0)
00142 {
00143 temp = new double[tempSize];
00144 for (int i = 0; i < tempSize; i++) temp[i] = 0;
00145 }
00146 }
00147 QString name;
00148 QwtPlotCurve * plot;
00149 double history[MAX_HISTORY];
00150 double brushHistory[MAX_HISTORY];
00151 double * temp;
00152 };
00153
00154 class Property
00155 {
00156 public:
00157 Property(QString n): name(n) {}
00158 QString name;
00159 QList<Curve> curves;
00160 };
00161
00162 class LinkedContainer
00163 {
00164 public:
00165 LinkedContainer(int ident): id(ident), iter(0), meanItems(0) {}
00166 uint id;
00167 int iter;
00168 QList<Property> properties;
00169 int meanItems;
00170 };
00171
00172 QList<LinkedContainer> linkCont;
00173 const bool byTime;
00174 int iterationIndex;
00175
00176 QColor nextColor();
00177 virtual void advancePlot();
00178 void timerEvent(QTimerEvent *e);
00179 virtual void insertNewFlags(int cont, int prop);
00180 void updateLegendItems();
00181 void hideStat(const QString labelText);
00182 void showStat(const QString labelText);
00183
00184 static QColor colors[];
00185 const bool decorations, hPie, doBrush;
00186 const int nStep;
00187
00188 friend class PieMarker;
00189 class PieMarker: public QwtPlotItem
00190 {
00191 public:
00192 PieMarker(QVPlot *plot);
00193 virtual int rtti() const;
00194 virtual void draw(QPainter *p, const QwtScaleMap &, const QwtScaleMap &, const QRect &rect) const;
00195
00196 private:
00197 QVPlot *qvplot;
00198 };
00199
00200 bool initied, autoShow;
00201 int timer;
00202 PieMarker *pie;
00203 bool haveCurves;
00204 int activeWorkers;
00205 QList<QVPropertyContainer *> pcl_Workers;
00206 double timeData[MAX_HISTORY];
00207 int dataCount;
00208 int usedColors;
00209 };
00210
00211 #endif
00212 #endif