dRonin  adbada4
dRonin GCS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Groups Pages
plotdata.h
Go to the documentation of this file.
1 
13 /*
14  * This program is free software; you can redistribute it and/or modify
15  * it under the terms of the GNU General Public License as published by
16  * the Free Software Foundation; either version 3 of the License, or
17  * (at your option) any later version.
18  *
19  * This program is distributed in the hope that it will be useful, but
20  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
21  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  * for more details.
23  *
24  * You should have received a copy of the GNU General Public License along
25  * with this program; if not, see <http://www.gnu.org/licenses/>
26  */
27 
28 #ifndef PLOTDATA_H
29 #define PLOTDATA_H
30 
31 class ScopeGadgetWidget;
32 class ScopeConfig;
33 
34 #include "uavobjects/uavobject.h"
35 
36 #include "qwt/src/qwt_color_map.h"
37 #include "qwt/src/qwt_scale_widget.h"
38 
39 #include <QTimer>
40 #include <QTime>
41 #include <QVector>
42 
43 class PlotData : public QObject
44 {
45  Q_OBJECT
46 public:
47  double valueAsDouble(UAVObject *obj, UAVObjectField *field, bool haveSubField,
48  QString uavSubFieldName);
49 
50  // Setter functions
51  void setXMinimum(double val) { xMinimum = val; }
52  virtual void setXMaximum(double val) { xMaximum = val; }
53  void setYMinimum(double val) { yMinimum = val; }
54  void setYMaximum(double val) { yMaximum = val; }
55  void setXWindowSize(double val) { m_xWindowSize = val; }
56  void setScalePower(int val) { scalePower = val; }
57  void setMeanSamples(int val) { meanSamples = val; }
58  void setMathFunction(QString val) { mathFunction = val; }
59 
60  // Getter functions
61  double getXMinimum() { return xMinimum; }
62  double getXMaximum() { return xMaximum; }
63  double getYMinimum() { return yMinimum; }
64  double getYMaximum() { return yMaximum; }
65  double getXWindowSize() { return m_xWindowSize; }
66 
67  QString getUavoName() { return uavObjectName; }
68  QString getUavoFieldName() { return uavFieldName; }
69  QString getUavoSubFieldName() { return uavSubFieldName; }
70  bool getHaveSubFieldFlag() { return haveSubField; }
71 
72  int getScalePower() { return scalePower; }
73  int getMeanSamples() { return meanSamples; }
74  QString getMathFunction() { return mathFunction; }
75 
76  QVector<double> *getXData() { return xData; }
77  QVector<double> *getYData() { return yData; }
78 
79  virtual bool append(UAVObject *obj) = 0;
80  virtual void removeStaleData() = 0;
81  virtual void setUpdatedFlagToTrue() = 0;
82  virtual bool readAndResetUpdatedFlag() = 0;
83  virtual void plotNewData(PlotData *, ScopeConfig *, ScopeGadgetWidget *) = 0;
84  virtual void deletePlots(PlotData *) = 0;
85  virtual void clearPlots() = 0;
86 
87  QwtScaleWidget *rightAxis;
88 
89 protected:
90  QVector<double> *xData; // Data vector for plots
91  QVector<double> *yData; // Used vector for plots
92 
93  double m_xWindowSize;
94  double xMinimum;
95  double xMaximum;
96  double yMinimum;
97  double yMaximum;
98 
99  QString uavObjectName;
100  QString uavFieldName;
103 
104  int scalePower; // This is the power to which each value must be raised
105  unsigned int meanSamples;
106  QString mathFunction;
107  double meanSum;
108 
111 
112 private:
113 };
114 
118 class ColorMap : public QwtLinearColorMap
119 {
120 public:
125 
127  : QwtLinearColorMap()
128  {
129  switch (colorMapType) {
130  case JET:
131  createJet();
132  break;
133  case STANDARD:
134  default:
135  createStandard();
136  break;
137  }
138  }
139 
140  void createJet()
141  {
142  // The color interval must be created separately.
143  setColorInterval(QColor(0, 0, 30), QColor(0.5 * 255, 0, 0));
144 
145  // Greyscale input values given normalized to 1.
146  addColorStop(0.1, QColor(0.00000 * 255, 0.00000 * 255, 0.50000 * 255));
147  addColorStop(0.2, QColor(0.00000 * 255, 0.00000 * 255, 0.94444 * 255));
148  addColorStop(0.3, QColor(0.00000 * 255, 0.38889 * 255, 1.00000 * 255));
149  addColorStop(0.4, QColor(0.00000 * 255, 0.83333 * 255, 1.00000 * 255));
150  addColorStop(0.5, QColor(0.27778 * 255, 1.00000 * 255, 0.72222 * 255));
151  addColorStop(0.6, QColor(0.72222 * 255, 1.00000 * 255, 0.27778 * 255));
152  addColorStop(0.7, QColor(1.00000 * 255, 0.83333 * 255, 0.00000 * 255));
153  addColorStop(0.8, QColor(1.00000 * 255, 0.38889 * 255, 0.00000 * 255));
154  addColorStop(0.9, QColor(0.94444 * 255, 0.00000 * 255, 0.00000 * 255));
155  }
156 
158  {
159  // The color interval must be created separately.
160  setColorInterval(Qt::darkCyan, Qt::red);
161 
162  // Greyscale input values given normalized to 1.
163  addColorStop(0.1, Qt::cyan);
164  addColorStop(0.6, Qt::green);
165  addColorStop(0.95, Qt::yellow);
166  }
167 };
168 
169 #endif // PLOTDATA_H
unsigned int meanSamples
Definition: plotdata.h:105
virtual bool append(UAVObject *obj)=0
virtual void setXMaximum(double val)
Definition: plotdata.h:52
QVector< double > * xData
Definition: plotdata.h:90
The ColorMap class Defines a program-wide colormap.
Definition: plotdata.h:118
ColorMap(ColorMapType colorMapType=STANDARD)
Definition: plotdata.h:126
virtual void removeStaleData()=0
void setXWindowSize(double val)
Definition: plotdata.h:55
virtual void plotNewData(PlotData *, ScopeConfig *, ScopeGadgetWidget *)=0
void setMathFunction(QString val)
Definition: plotdata.h:58
double correctionSum
Definition: plotdata.h:109
QString uavFieldName
Definition: plotdata.h:100
void setScalePower(int val)
Definition: plotdata.h:56
QString getUavoName()
Definition: plotdata.h:67
QString getUavoFieldName()
Definition: plotdata.h:68
void setYMaximum(double val)
Definition: plotdata.h:54
double meanSum
Definition: plotdata.h:107
QVector< double > * getYData()
Definition: plotdata.h:77
ColorMapType
The ColorMapType enum Defines the different type of color maps.
Definition: plotdata.h:124
QString getUavoSubFieldName()
Definition: plotdata.h:69
void setMeanSamples(int val)
Definition: plotdata.h:57
QwtScaleWidget * rightAxis
Definition: plotdata.h:87
int correctionCount
Definition: plotdata.h:110
virtual bool readAndResetUpdatedFlag()=0
void setYMinimum(double val)
Definition: plotdata.h:53
QVector< double > * yData
Definition: plotdata.h:91
double getXMinimum()
Definition: plotdata.h:61
QVector< double > * getXData()
Definition: plotdata.h:76
double yMinimum
Definition: plotdata.h:96
double xMinimum
Definition: plotdata.h:94
virtual void setUpdatedFlagToTrue()=0
void setXMinimum(double val)
Definition: plotdata.h:51
QString getMathFunction()
Definition: plotdata.h:74
double getXWindowSize()
Definition: plotdata.h:65
The ScopeConfig class The parent class for scope configuration classes data sources.
Definition: scopesconfig.h:56
double yMaximum
Definition: plotdata.h:97
int getMeanSamples()
Definition: plotdata.h:73
QString uavSubFieldName
Definition: plotdata.h:101
int scalePower
Definition: plotdata.h:104
int getScalePower()
Definition: plotdata.h:72
double getYMaximum()
Definition: plotdata.h:64
double xMaximum
Definition: plotdata.h:95
void createStandard()
Definition: plotdata.h:157
virtual void clearPlots()=0
void createJet()
Definition: plotdata.h:140
bool haveSubField
Definition: plotdata.h:102
bool getHaveSubFieldFlag()
Definition: plotdata.h:70
double getXMaximum()
Definition: plotdata.h:62
QString mathFunction
Definition: plotdata.h:106
double valueAsDouble(UAVObject *obj, UAVObjectField *field, bool haveSubField, QString uavSubFieldName)
valueAsDouble Fetch the value from the UAVO and return it as a double
Definition: plotdata.cpp:148
QString uavObjectName
Definition: plotdata.h:99
double getYMinimum()
Definition: plotdata.h:63
double m_xWindowSize
Definition: plotdata.h:93
virtual void deletePlots(PlotData *)=0