RTXI  2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
incrementalplot.h
Go to the documentation of this file.
1 /*
2  * IncrementalPlot, derived from QwtPlot, contains a container class for
3  * growing data and allows you to plot data asynchronously of any size from a
4  * single (x,y) point to a series of points. It will also draw lines, e.g. data
5  * fits, holding line data in a separate structure.
6  */
7 
8 #ifndef _INCREMENTALPLOT_H_
9 #define _INCREMENTALPLOT_H_ 1
10 
11 #include "basicplot.h"
12 //#include <qwt_array.h>
13 #include <qwt_plot.h>
14 #include <qwt_symbol.h>
15 
16 class QwtPlotCurve;
17 
18 class CurveData
19 {
20  // A container class for growing data
21 public:
22  CurveData();
23 
24  void append(double* x, double* y, int count);
25 
26  int count() const;
27  int size() const;
28  const double* x() const;
29  const double* y() const;
30 
31 private:
32  int d_count;
33  QwtArray<double> d_x;
34  QwtArray<double> d_y;
35 };
36 
37 class IncrementalPlot : public BasicPlot
38 {
39  Q_OBJECT
40 
41 public:
42  IncrementalPlot(QWidget* parent = NULL);
43  virtual ~IncrementalPlot();
44 
45  void appendData(double x,
46  double y); // draws data point with default symbol style
47  void appendData(
48  double x, double y,
49  QwtSymbol::Style s); // draws data point with specified symbol style
50  void appendData(double* x, double* y, int size); // draws multiple data points
51  void appendData(double* x, double* y, int size, QwtSymbol::Style s);
52 
53  void removeData(); // clears all data and lines
54  const double* xData(); // returns data points (not points defining lines)
55  const double* yData();
56  const uint dataSize(); // returns number of data points
57  bool dataExists(); // returns whether plot contains data
58  void nextSymbol(); // sets symbol to the next QwtSymbol style
59 
60 public slots:
61  void appendLine(double* x, double* y,
62  int size); // draws a line through given points
63 
64 private:
65  CurveData* d_data; // holds data points
66  QwtPlotCurve* d_curve;
67  CurveData* l_data; // holds points defining lines
68  QwtPlotCurve* l_curve;
69 };
70 
71 #endif // _INCREMENTALPLOT_H_
int count() const
void appendLine(double *x, double *y, int size)
QwtPlotCurve * d_curve
CurveData * d_data
IncrementalPlot(QWidget *parent=NULL)
void appendData(double x, double y)
virtual ~IncrementalPlot()
const uint dataSize()
QwtPlotCurve * l_curve
QwtArray< double > d_x
const double * yData()
const double * y() const
void append(double *x, double *y, int count)
const double * x() const
CurveData * l_data
const double * xData()
QwtArray< double > d_y
int size() const