src/qvgui/qvplot.h

Go to the documentation of this file.
00001 /*
00002  *      Copyright (C) 2007. PARP Research Group.
00003  *      <http://perception.inf.um.es>
00004  *      University of Murcia, Spain.
00005  *
00006  *      This file is part of the QVision library.
00007  *
00008  *      QVision is free software: you can redistribute it and/or modify
00009  *      it under the terms of the GNU Lesser General Public License as
00010  *      published by the Free Software Foundation, version 3 of the License.
00011  *
00012  *      QVision is distributed in the hope that it will be useful,
00013  *      but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  *      GNU Lesser General Public License for more details.
00016  *
00017  *      You should have received a copy of the GNU Lesser General Public
00018  *      License along with QVision. If not, see <http://www.gnu.org/licenses/>.
00019  */
00020 
00024 
00025 #ifndef QVPLOT_H
00026 #define QVPLOT_H
00027 
00028 #include <QTimer>
00029 #include <qwt_plot.h>
00030 #include <qwt_plot_curve.h>
00031 #include <qvcore/qvworker.h>
00032 
00033 #ifndef DOXYGEN_IGNORE_THIS
00034 #define MAX_HISTORY 60 // seconds
00035 
00044 
00045 class QVPlot: public QwtPlot, public QVPropertyContainer
00046         {
00047         Q_OBJECT
00048         public:
00059                 QVPlot(const QString name = QString(), bool decorations = true, bool havePie = false, bool brush = false, bool autoShow = true, bool time = true,
00060                        int step = 10, QWidget *parent = 0);
00061 
00070                 virtual void linkProperty(QVWorker &worker, const QString propertyName);
00071 
00072         public slots:
00076                 virtual void init();
00077 
00082                 void update(uint id, int iteration);
00083 
00088                 void workerChange(QVWorker::TWorkerStatus status);
00089  
00090         protected:
00095                 virtual QStringList getPropertyCurvNames(QString property) const = 0;
00096 
00101                 virtual QList<double> getPropertyCurvValues(QString property) const = 0;
00102 
00108                 virtual QList<int> getPropertyCurvOrders(QString property) const = 0;
00109 
00110                         class Curve
00111                                 {
00112                                 public:
00113                                         Curve(QString n, QwtPlotCurve *qwtpc, int tempSize): name(n), plot(qwtpc)
00114                                                 {
00115                                                 for (int i = 0; i < MAX_HISTORY; i++) history[i] = 0;
00116                                                 if (tempSize > 0)
00117                                                         {
00118                                                         temp = new double[tempSize];
00119                                                         for (int i = 0; i < tempSize; i++) temp[i] = 0;
00120                                                         }
00121                                                 }
00122                                         QString name;
00123                                         QwtPlotCurve * plot;
00124                                         double history[MAX_HISTORY];
00125                                         double * temp;
00126                                 };
00127         
00128                         class Property
00129                                 {
00130                                 public:
00131                                         Property(QString n): name(n) {}
00132                                         QString name;
00133                                         QList<Curve> curves;
00134                                 };
00135         
00136                         class LinkedContainer
00137                                 {
00138                                 public:
00139                                         LinkedContainer(int ident): id(ident), iter(0), meanItems(0) {}
00140                                         uint id;
00141                                         int iter;
00142                                         QList<Property> properties;
00143                                         int meanItems;
00144                                 };
00145 
00146                 QList<LinkedContainer> linkCont;
00147                 const bool byTime;
00148                 int iterationIndex;
00149 
00150                 QColor nextColor();
00151                 virtual void advancePlot();
00152                 void timerEvent(QTimerEvent *e);
00153                 virtual void insertNewFlags(int cont, int prop);
00154                 void updateValue(const int cont, const int prop, const int curv);
00155                 double getValue(const int cont, const int prop, const int curv) const;
00156 
00157                 static QColor colors[];
00158                 const bool decorations, hPie, doBrush;
00159                 const int nStep;
00160 
00161                         friend class PieMarker;
00162                         class PieMarker: public QwtPlotItem
00163                                 {
00164                                 public:
00165                                         PieMarker(QVPlot *plot);
00166                                         virtual int rtti() const;
00167                                         virtual void draw(QPainter *p, const QwtScaleMap &, const QwtScaleMap &, const QRect &rect) const;
00168                         
00169                                 private:
00170                                         QVPlot *qvplot;
00171                                 };
00172 
00173                 bool initied;
00174                 QTimer timer;
00175                 PieMarker *pie;
00176                 bool haveCurves;
00177                 int activeWorkers;
00178                 QList<QVPropertyContainer> pcl_Workers;
00179                 double timeData[MAX_HISTORY];
00180                 int dataCount;
00181                 int usedColors;
00182         };
00183 
00184 #endif
00185 #endif

Generated on Thu Jul 17 17:23:28 2008 for QVision by  doxygen 1.5.3