TimePlot.hh
7.14 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
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
/*
* TimePlot.hh
*
* Created on: 22 nov. 2013
* Author: CS
*/
#ifndef TIMEPLOT_HH_
#define TIMEPLOT_HH_
#include "NodeCfg.hh"
#include "PanelPlotOutput.hh"
#include <algorithm>
#include <map>
#include <memory>
#include "DefaultTimeAxisDecorator.hh"
#include "TimeAxisDecorator.hh"
#include "ParamData.hh"
#include "TimePlotNode.hh"
#include "ParamInfo.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(), bool isStandalone = true);
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;
}
void normalize(MatrixGrid &matrixGrid, std::string normalizationType);
/**
* @brief Apply a background subtraction for the given spectro
*
* @param matrixGrid matrix for each index of the sepctro
* @param pSpectro spectro's properties
* @param data data of the parameter associated with the spectro
*/
void applyBackgroundSubtraction(MatrixGrid &matrixGrid, SpectroProperties &pSpectro, ParameterData &data);
/**
* @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(const Bounds &panelBounds_, 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 ¶m, 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);
virtual void drawSauvaud(double startDate, double stopDate, std::string pParamId,
SauvaudProperties &pSauvaud,int subInde, int subsNumber, std::string opositeLegend);
/**
* @overload PanelPlotOutput::drawIntervals(double startDate, double stopDate, std::string pParamId, IntervalsProperties& pIntervals)
* @brief Draw intervals defined by a parameter
*/
virtual void drawIntervals(double startDate, double stopDate, std::string pParamId,
IntervalsProperties &pIntervals);
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::resetPlot - reset plot
*/
virtual void resetPlot()
{
_startDateDrawn = false;
PanelPlotOutput::resetPlot();
}
/*
*
*/
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 Configure spectro.
*/
void configureSauvaudAxis();
/**
* @brief configure the TT/Catalogue intervals legend
*
*/
void configureIntervalsLegend();
/**
* @brief Retrieve ConstantLine informations for a given serieId and constantId.
*/
ConstantLine *getConstantLineFromId(int serieId, int constantId, boost::shared_ptr<Axis> &yAxis);
/**
* @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);
Color getStatusColor(AMDA::Info::ParamInfoSPtr ¶mInfo, double value, Color defaultColor);
void drawOneInterval(double tmin, double tmax, Color color);
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_ */