1 /**********************************************************************************************
2     Copyright (C) 2014 Oliver Eichler <oliver.eichler@gmx.de>
3 
4     This program is free software: you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation, either version 3 of the License, or
7     (at your option) any later version.
8 
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13 
14     You should have received a copy of the GNU General Public License
15     along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 
17 **********************************************************************************************/
18 
19 #ifndef CPLOTDATA_H
20 #define CPLOTDATA_H
21 
22 
23 #include <QColor>
24 #include <QObject>
25 #include <QPixmap>
26 #include <QPolygonF>
27 
28 class CPlotAxis;
29 
30 class CPlotData : public QObject
31 {
32 public:
33     enum axistype_e {eAxisLinear, eAxisTime};
34 
35     CPlotData(axistype_e type, QObject* parent);
36     virtual ~CPlotData();
37 
38     ///get a reference to the x axis
x()39     CPlotAxis& x() const
40     {
41         return *xaxis;
42     }
43     ///get a reference to the y axis
y()44     CPlotAxis& y() const
45     {
46         return *yaxis;
47     }
48 
49     /// create a new x axis
50     void setXAxisType(axistype_e type);
51 
52     /// setup all internal data to fit the dynamic range of all data points
53     void setLimits();
54 
55     struct line_t
56     {
57         QString label;
58         QColor color;
59         QPolygonF points;
60     };
61 
62     /// text shown below the x axis
63     QString xlabel;
64     /// text shown left of the y axis
65     QString ylabel;
66     /// set true for grid
67     bool grid = true;
68 
69     /// list of plot lines
70     QList<line_t> lines;
71 
72     struct point_t
73     {
74         QColor color;
75         QPointF point;
76         QPixmap icon;
77         QString label;
78     };
79 
80     QList<QPointF> focus;
81 
82     /// vector of plot tags such as waypoints
83     QVector<point_t> tags;
84 
85     bool badData = true;
86 
87     axistype_e axisType = eAxisLinear;
88 
89     qreal xmin = 0;
90     qreal xmax = 0;
91     qreal ymin = 0;
92     qreal ymax = 0;
93 
94 protected:
95     CPlotAxis* xaxis = nullptr;
96     CPlotAxis* yaxis = nullptr;
97 };
98 
99 #endif //CPLOTDATA_H
100 
101