PARP Research Group University of Murcia, Spain


src/qvgui/qvplot.h

Go to the documentation of this file.
00001 /*
00002  *      Copyright (C) 2007, 2008. 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 <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                 bool linkProperty(QString sourcePropertyName, QVPropertyContainer *destinyContainer, QString destinyPropertyName, LinkType linkType = AsynchronousLink);
00075                 bool linkProperty(QString sourcePropertyName, QVPropertyContainer &destinyContainer, QString destinyPropertyName, LinkType linkType = AsynchronousLink);
00076                 bool linkProperty(QVPropertyContainer *destinyContainer, QString destinyPropertyName, LinkType linkType = AsynchronousLink);
00077                 bool linkProperty(QVPropertyContainer &destinyContainer, QString destinyPropertyName, LinkType linkType = AsynchronousLink);
00078                 bool linkProperty(QString sourcePropertyName, QVPropertyContainer *destinyContainer, LinkType linkType = AsynchronousLink);
00079                 bool linkProperty(QString sourcePropertyName, QVPropertyContainer &destinyContainer, LinkType linkType = AsynchronousLink);
00080                 void linkProperty(QVPropertyContainer *container, LinkType linkType = AsynchronousLink);
00081                 void linkProperty(QVPropertyContainer &container, LinkType linkType = AsynchronousLink);
00082                 bool unlinkProperty(QString origName, QVPropertyContainer *destCont, QString destName);
00083                 bool unlinkProperty(QString origName, QVPropertyContainer &destCont, QString destName);
00084                 void unlink();
00085 
00086 
00090                 bool isAutoShow() const { return autoShow; }
00091 
00095                 bool isInitied() const { return initied; }
00096 
00097         public slots:
00100                 virtual void init();
00101 
00104                 virtual void stop();
00105 
00110                 void update(uint id, int iteration);
00111 
00116                 void workerChange(QVWorker::TWorkerStatus status);
00117 
00122                 void legendItemCheked(bool check);
00123 
00124         protected:
00125                 virtual bool linkUnspecifiedInputProperty(QVPropertyContainer *sourceContainer, QString sourcePropName, LinkType linkType = AsynchronousLink);
00126                 bool treatUnlinkInputProperty(QString destPropName, QVPropertyContainer *sourceCont, QString sourcePropName);
00127 
00132                 virtual QStringList getPropertyCurvNames(QString property) const = 0;
00133 
00138                 virtual QList<double> getPropertyCurvValues(QString property) const = 0;
00139 
00145                 virtual QList<int> getPropertyCurvOrders(QString property) const = 0;
00146 
00147                         class Curve
00148                                 {
00149                                 public:
00150                                         Curve(QString n, QwtPlotCurve *qwtpc, int tempSize): name(n), plot(qwtpc)
00151                                                 {
00152                                                 for (int i = 0; i < MAX_HISTORY; i++) history[i] = 0;
00153                                                 if (tempSize > 0)
00154                                                         {
00155                                                         temp = new double[tempSize];
00156                                                         for (int i = 0; i < tempSize; i++) temp[i] = 0;
00157                                                         }
00158                                                 }
00159                                         QString name;
00160                                         QwtPlotCurve * plot;
00161                                         double history[MAX_HISTORY];
00162                                         double brushHistory[MAX_HISTORY];
00163                                         double * temp;
00164                                 };
00165         
00166                         class Property
00167                                 {
00168                                 public:
00169                                         Property(QString n): name(n) {}
00170                                         QString name;
00171                                         QList<Curve> curves;
00172                                 };
00173         
00174                         class LinkedContainer
00175                                 {
00176                                 public:
00177                                         LinkedContainer(int ident): id(ident), iter(0), meanItems(0) {}
00178                                         uint id;
00179                                         int iter;
00180                                         QList<Property> properties;
00181                                         int meanItems;
00182                                 };
00183 
00184                 QList<LinkedContainer> linkCont;
00185                 const bool byTime;
00186                 int iterationIndex;
00187 
00188                 QColor nextColor();
00189                 virtual void advancePlot();
00190                 void timerEvent(QTimerEvent *e);
00191                 virtual void insertNewFlags(int cont, int prop);
00192                 void updateLegendItems();
00193                 void hideStat(const QString labelText);
00194                 void showStat(const QString labelText);
00195 
00196                 const bool decorations, hPie, doBrush;
00197                 const int nStep;
00198 
00199                         friend class PieMarker;
00200                         class PieMarker: public QwtPlotItem
00201                                 {
00202                                 public:
00203                                         PieMarker(QVPlot *plot);
00204                                         virtual int rtti() const;
00205                                         virtual void draw(QPainter *p, const QwtScaleMap &, const QwtScaleMap &, const QRect &rect) const;
00206                         
00207                                 private:
00208                                         QVPlot *qvplot;
00209                                 };
00210 
00211                 bool initied, autoShow;
00212                 int timer;
00213                 PieMarker *pie;
00214                 bool haveCurves;
00215                 int activeWorkers;
00216                 QList<QVPropertyContainer *> pcl_Workers;
00217                 double timeData[MAX_HISTORY];
00218                 int usedColors;
00219         };
00220 
00221 #endif
00222 #endif



QVision framework. PARP research group, copyright 2007, 2008.