datastreamplot.h
1 /********************************************************************************
2  * FARSA DataStreamPlot UI *
3  * Copyright (C) 2012-2013 *
4  * Gianluca Massera <emmegian@yahoo.it> *
5  * *
6  * This program is free software; you can redistribute it and/or modify *
7  * it under the terms of the GNU General Public License as published by *
8  * the Free Software Foundation; either version 2 of the License, or *
9  * (at your option) any later version. *
10  * *
11  * This program is distributed in the hope that it will be useful, *
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14  * GNU General Public License for more details. *
15  * *
16  * You should have received a copy of the GNU General Public License *
17  * along with this program; if not, write to the Free Software *
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
19  ********************************************************************************/
20 
21 #ifndef DATASTREAMPLOT_H
22 #define DATASTREAMPLOT_H
23 
24 #include "qwt/qwt_plot.h"
25 #include "utilitiesconfig.h"
26 #include <QColor>
27 #include <QList>
28 #include <QMutex>
29 
30 class QwtPlotCurve;
31 class QwtPlotDirectPainter;
32 
33 namespace farsa {
34 
39 class FARSA_UTIL_API DataStreamPlot : public QwtPlot {
40  Q_OBJECT
41 public:
43  DataStreamPlot( QWidget* parent = 0 );
45  virtual ~DataStreamPlot();
51  int addDataStream( QString name );
56  void setDataStreamColor( int streamID, QColor color );
62  void appendData( int streamID, float value );
63 public slots:
65  void updatePlot();
66 private slots:
67  // react on the check/uncheck of an item on the legend
68  void legendChecked( const QVariant& item, bool on );
69 private:
70  // show/hide the curve (this is called by legendChecked)
71  void showCurve( QwtPlotItem* curve, bool on );
72 
73  // the data streams to plot
74  QList<QwtPlotCurve*> streams;
75  // direct painter for incremental drawing of points
76  QwtPlotDirectPainter* directPainter;
77  // the min y value added so far
78  float minY;
79  // the max y value added so far
80  float maxY;
81  // the max value on the x scale (corresponding to the number of value added from start)
82  float maxX;
83  // dimension of the window of data to show
84  float windowSize;
85 };
86 
87 } // end namespace farsa
88 
89 #endif
This file contains the common type defitions used on the whole framework.
A macro to deprecate functions.
The DataStreamPlot display a series of data streams into the plot storing all the history of the data...