TimePlot.hh
5.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
/*
* TimePlot.hh
*
* Created on: 22 nov. 2013
* Author: CS
*/
#ifndef TIMEPLOT_HH_
#define TIMEPLOT_HH_
#include "PanelPlotOutput.hh"
#include "NodeCfg.hh"
#include <algorithm>
#include <map>
#include <memory>
#include "DefaultTimeAxisDecorator.hh"
#include "TimeAxisDecorator.hh"
#include "TimePlotNode.hh"
extern "C" {
#include <plplot/qsastime.h>
}
namespace plot {
class TimeAxis;
/**
* Plot that draws f(t)
*/
class TimePlot: public PanelPlotOutput {
public:
TimePlot(AMDA::Parameters::ParameterManager& manager,
boost::shared_ptr<Panel> panel, TimeAxisDecorator* timeAxisDecorator = new DefaultTimeAxisDecorator());
virtual ~TimePlot();
/**
* @overload plot::PanelPlotOutput
*/
virtual const std::string typeName(){
return TIMEPLOT_NODENAME;
}
/**
* @brief overloads ParamOutput::preparePlotArea
*/
virtual void preparePlotArea (double startTime, double stopTime, int intervalIndex);
/**
* @brief overloads ParamOutput::draw()
*/
virtual bool draw(double startTime, double stopTime, int intervalIndex,
bool isFirstInterval, bool isLastInterval);
TimeAxis* getTimeAxis();
void setTimeAxisDecorator(std::shared_ptr<TimeAxisDecorator> pDecorator_){
_xdecoratorPtr = pDecorator_;
}
std::shared_ptr<TimeAxisDecorator> getTimeAxisDecorator(){
return _xdecoratorPtr;
}
/**
* @brief QSAS time configuration for time formatting
*/
static QSASConfig* qsasconfig;
protected:
/**
* @overload PanelPlotOutput::calculatePlotArea(Bounds const& pPanelBounds, bool pKeepRatio)
* @brief Calculate and draw plot area.
*/
virtual void calculatePlotArea(Bounds& bounds_);
/**
* @overload PanelPlotOutput::drawFills(double startDate, double stopDate)
* @brief Draw fill area between parameter and constant or between parameters
*/
virtual void drawFills(double startDate, double stopDate);
/**
* @overload PanelPlotOutput::drawSeries(double startDate, double stopDate, std::string pParamId, SeriesProperties const& pSerie)
* @brief Draw series of parameter on plot.
*/
virtual void drawSeries(double startDate, double stopDate, int intervalIndex, std::string pParamId,
SeriesProperties& pSeries,
AMDA::Common::ParameterIndexComponent pParamIndex,
ParameterAxes& param, bool moreThanOneSerieForAxis);
/**
* @overload PanelPlotOutput::drawSpectro(double startDate, double stopDate, std::string pParamId, SpectroProperties& pSpectro)
* @brief Draw spectro of parameter on plot.
*/
virtual void drawSpectro(double startDate, double stopDate, std::string pParamId,
SpectroProperties& pSpectro);
void drawXAxis(boost::shared_ptr<Axis> pXAxis, PlWindow& pPlWindow, Bounds& pPlotAreaSize, TickConf& pTickConf);
/**
// * @overload convertXAxisValue(const std::string &value)
// * @brief Convert an X axis string value to a double X value
* Subclasses may override it to take into account specific value meaning.
* @param value string value to convert.
*/
virtual double convertXAxisValue(const std::string &value);
/**
* @brief Identify if other side of the plot area need to be drawn or not.
* @note A plot area side need to be drawn when there is no axis associated to it.
*/
std::string drawOppositeSide(boost::shared_ptr<Axis> pAxis);
/**
* @overload PanelPlotOutput::reset - reset plot
*/
virtual void reset() {
_startDateDrawn = false;
PanelPlotOutput::reset();
}
/*
*
*/
private:
void drawStartDate(TimeAxis* pXAxis, double startTime, double stopTime);
const std::string getXAxisId() const;
/**
* @brief Configure series color (symbols and line) and range of axis (depending of parameters series to draw).
*/
void configureSeriesAxis();
/**
* @brief Configure axis legend with paramInfo.
*/
void configureAxisLegend();
/**
* @brief Configure spectro.
*/
void configureSpectroAxis();
/**
* @brief Retrieve ConstantLine informations for a given serieId and constantId.
*/
ConstantLine * getConstantLineFromId (int serieId, int constantId);
/**
* @brief Retrieve serie properties by serie Id.
*/
bool getSeriePropertiesById(int serieId, SeriesProperties &rSerieProperties);
/**
* @brief Merge, sort and remove duplicate from 2 arrays in a vector
*/
void mergeAndSortTime ( double *values1Time, int values1Nb,
double *values2Time, int values2Nb,
std::vector<double> &values);
/**
* @brief Return or compute an interpolated value
*/
double getInterpolatedValue (double *values, double *valuesTime, int valuesNb, double atTime);
/**
* @brief Compute if two ligne segments intersects
*/
bool intersect (double xi, double y1i, double y2i,
double xj, double y1j, double y2j,
double *xInter);
/**
* @brief Compute and add intersections time to the vector if intersections exist
*/
void addIntersectionTime ( double *values1, double *values1Time, int values1Nb,
double *values2, double *values2Time, int values2Nb,
std::vector<double> &valuesTime);
/**
* @brief Draw Fill Area for the given arrays and the valueTime timeline
*/
void drawFillArea ( double *values1, double *values1Time, int values1Nb,
double *values2, double *values2Time, int values2Nb,
std::vector<double> &valuesTime,
bool colorGreaterSpecified, Color& colorGreater,
bool colorLessSpecified, Color& colorLess,
SeriesProperties &rSeriesProperties);
std::shared_ptr<TimeAxisDecorator> _xdecoratorPtr;
bool _startDateDrawn;
};
/**
* @brief Custom generator for time label, just not display min time.
*/
void generateTimeLabel(PLINT axis, PLFLT value, char *label, PLINT length,
PLPointer data);
} /* namespace plot */
#endif /* TIMEPLOT_HH_ */