Commit e257cfb975dce11c9b92c70f844d49665b149b91
1 parent
40f1fe40
Exists in
master
and in
91 other branches
First implementation to draw TT and catalog in a time series plot (#5973)
Showing
13 changed files
with
530 additions
and
8 deletions
Show diff stats
config/app/plotConfig.xml
... | ... | @@ -49,6 +49,7 @@ |
49 | 49 | <file index="0">cmap0_default.pal</file> |
50 | 50 | <file index="1">cmap1_default.pal</file> |
51 | 51 | <file index="2">cmap0_test.pal</file> |
52 | + <file index="3">cmap0_intervals.pal</file> | |
52 | 53 | </color> |
53 | 54 | <coloraxis default="0"> |
54 | 55 | <file index="0">cmap1_default.pal</file> | ... | ... |
config/xsd/request/plot.xsd
... | ... | @@ -218,7 +218,15 @@ |
218 | 218 | </xs:documentation> |
219 | 219 | </xs:annotation> |
220 | 220 | </xs:element> |
221 | - | |
221 | + | |
222 | + <xs:element name="intervals" type="ParameterIntervalsPropertiesType" substitutionGroup="ParameterDrawElement"> | |
223 | + <xs:annotation> | |
224 | + <xs:documentation> | |
225 | + define drawing properties for a | |
226 | + intervals serie. | |
227 | + </xs:documentation> | |
228 | + </xs:annotation> | |
229 | + </xs:element> | |
222 | 230 | |
223 | 231 | <!-- Define additional plot objects --> |
224 | 232 | <xs:complexType name="AdditionalObjetctsType"> |
... | ... | @@ -853,6 +861,11 @@ Note : This attribute may be unecessary since kind of line may be deduce from Pl |
853 | 861 | <xs:attribute name="colorSerieId" type="xs:integer"></xs:attribute> |
854 | 862 | </xs:complexType> |
855 | 863 | |
864 | + <xs:complexType name="ParameterIntervalsPropertiesType"> | |
865 | + <xs:attribute name="index" type="xs:string" use="optional"></xs:attribute> | |
866 | + <xs:attribute name="colorMapIndex" type="xs:integer" use="optional"></xs:attribute> | |
867 | + </xs:complexType> | |
868 | + | |
856 | 869 | <xs:complexType name="ParameterSpectroPropertiesType"> |
857 | 870 | <xs:attribute name="yAxis" type="xs:string" /> |
858 | 871 | <xs:attribute name="index" type="xs:string" use="optional"></xs:attribute> | ... | ... |
... | ... | @@ -0,0 +1,76 @@ |
1 | +/* | |
2 | + * IntervalsNode.hh | |
3 | + * | |
4 | + * Created on: Feb 4, 2019 | |
5 | + * Author: AKKA | |
6 | + */ | |
7 | + | |
8 | +#ifndef INTERVALSNODE_HH_ | |
9 | +#define INTERVALSNODE_HH_ | |
10 | + | |
11 | +#include <libxml/globals.h> | |
12 | +#include <libxml/tree.h> | |
13 | +#include <libxml/xmlstring.h> | |
14 | +#include <iosfwd> | |
15 | + | |
16 | +#include "FileConfigurator.hh" | |
17 | +#include "DrawingPropertiesNode.hh" | |
18 | +#include "PlotLogger.hh" | |
19 | +#include "IntervalsProperties.hh" | |
20 | + | |
21 | +namespace plot { | |
22 | +/** | |
23 | + * Class that handle a <intervals> xml node. | |
24 | + * Template class that should be instanciated for each subclass of PanelOutputPanel. | |
25 | + */ | |
26 | + | |
27 | +template<class PlotType> | |
28 | +class IntervalsNode: public plot::DrawingPropertiesNode<PlotType> { | |
29 | +public: | |
30 | + IntervalsNode(): | |
31 | + DrawingPropertiesNode<PlotType>() { | |
32 | + } | |
33 | + virtual ~IntervalsNode() { | |
34 | + } | |
35 | + | |
36 | + void proceed(xmlNodePtr pNode_,const AMDA::Parameters::CfgContext& pContext_) { | |
37 | + LOG4CXX_DEBUG(gLogger, "IntervalsNode::proceed"); | |
38 | + PlotType* plotOutput = pContext_.get<PlotType*>(); | |
39 | + xmlChar* name = pContext_.get<xmlChar*>(); | |
40 | + | |
41 | + // initialize intervals with default properties | |
42 | + DrawingProperties defaultProps = plotOutput->getParameter( | |
43 | + (const char*) name).getDefaultProperties(); | |
44 | + | |
45 | + // read parent attributes | |
46 | + DrawingPropertiesNode<PlotType>::parseAttributes(pNode_, defaultProps); | |
47 | + | |
48 | + // intervals properties | |
49 | + std::shared_ptr<IntervalsProperties> intervalsPropsPtr = | |
50 | + std::shared_ptr<IntervalsProperties>(new IntervalsProperties(defaultProps)); | |
51 | + | |
52 | + // read index definition | |
53 | + xmlChar * value = NULL; | |
54 | + | |
55 | + value = xmlGetProp(pNode_, (const xmlChar*) "index"); | |
56 | + if (value) { | |
57 | + intervalsPropsPtr->setIndexDef((const char*) value); | |
58 | + xmlFree(value); | |
59 | + } | |
60 | + | |
61 | + // colorMapIndex attribute | |
62 | + value = xmlGetProp(pNode_, (const xmlChar *) "colorMapIndex"); | |
63 | + if (value != nullptr) { | |
64 | + intervalsPropsPtr->setColorMapIndex(atoi((const char*) value)); | |
65 | + xmlFree(value); | |
66 | + } | |
67 | + | |
68 | + // add intervals definition to parameter | |
69 | + plotOutput->getParameter((const char*)name).addIntervalsProperties(intervalsPropsPtr); | |
70 | + } | |
71 | +}; | |
72 | + | |
73 | +} | |
74 | +/* namespace plot */ | |
75 | + | |
76 | +#endif /* INTERVALSNODE_HH_ */ | ... | ... |
... | ... | @@ -0,0 +1,35 @@ |
1 | +/* | |
2 | + * IntervalsProperties.cc | |
3 | + * | |
4 | + * Created on: Feb 4, 2019 | |
5 | + * Author: AKKA | |
6 | + */ | |
7 | +#include "IntervalsProperties.hh" | |
8 | +#include "DrawingProperties.hh" | |
9 | +#include <sstream> | |
10 | + | |
11 | +namespace plot { | |
12 | + | |
13 | +/* | |
14 | + * Dumps properties for test. | |
15 | + */ | |
16 | +void IntervalsProperties::dump(std::ostream& out_, std::string& prefix_) { | |
17 | + out_ << "[INTERVALS PROPERTIES]" << std::endl; | |
18 | + out_ << prefix_ << "xAxisId=" << getXAxisId() << std::endl; | |
19 | + out_ << prefix_ << "paramId=" << getParamId() << std::endl; | |
20 | + out_ << prefix_ << "index=" << getIndexDef() << std::endl; | |
21 | + getColor().dump(out_, prefix_); | |
22 | +} | |
23 | + | |
24 | +std::ostream& operator<<(std::ostream& out_, const IntervalsProperties& prop_) { | |
25 | + out_ << "[INTERVALS PROPERTIES]" << std::endl; | |
26 | + out_ << "{" << std::endl; | |
27 | + out_ << " xAxis Id = " << prop_.getXAxisId() << std::endl; | |
28 | + out_ << " index = " << prop_.getIndexDef() << std::endl; | |
29 | + | |
30 | + out_ << "}" << std::endl; | |
31 | + return out_; | |
32 | +} | |
33 | + | |
34 | +} // namespace plot | |
35 | + | ... | ... |
... | ... | @@ -0,0 +1,116 @@ |
1 | +/* | |
2 | + * IntervalsProperties.hh | |
3 | + * | |
4 | + * Created on: Feb 4, 2019 | |
5 | + * Author: AKKA | |
6 | + */ | |
7 | + | |
8 | +#ifndef INTERVALSPROPERTIES_HH_ | |
9 | +#define INTERVALSPROPERTIES_HH_ | |
10 | + | |
11 | +#include <iostream> | |
12 | +#include <cmath> | |
13 | +#include <string> | |
14 | + | |
15 | +#include "DrawingProperties.hh" | |
16 | + | |
17 | +namespace plot { | |
18 | + | |
19 | +/** | |
20 | + * Drawing properties for a parameter intervals. | |
21 | + */ | |
22 | +class IntervalsProperties: public DrawingProperties { | |
23 | +public: | |
24 | + | |
25 | + friend std::ostream& operator<<(std::ostream& out_, | |
26 | + const IntervalsProperties& lprop_); | |
27 | + | |
28 | + /* | |
29 | + * @brief Dumps properties for test. | |
30 | + */ | |
31 | + void dump(std::ostream& out_, std::string& prefix_); | |
32 | + | |
33 | + IntervalsProperties() : | |
34 | + DrawingProperties(), _paramId(""), _indexDef(""), _colorMapIndex(0) { | |
35 | + } | |
36 | + | |
37 | + IntervalsProperties(const DrawingProperties& ref_) : | |
38 | + DrawingProperties(ref_), _paramId(""), _indexDef(""), _colorMapIndex(0) { | |
39 | + | |
40 | + } | |
41 | + | |
42 | + IntervalsProperties(const IntervalsProperties& pParamDrawingProperties_) : | |
43 | + DrawingProperties(pParamDrawingProperties_), _paramId(""), | |
44 | + _indexDef(pParamDrawingProperties_._indexDef), _colorMapIndex(pParamDrawingProperties_._colorMapIndex) { | |
45 | + } | |
46 | + | |
47 | + IntervalsProperties& operator=(const IntervalsProperties& ref_) { | |
48 | + DrawingProperties::operator=(ref_); | |
49 | + _paramId = ref_._paramId; | |
50 | + _indexDef = ref_._indexDef; | |
51 | + _colorMapIndex = ref_._colorMapIndex; | |
52 | + return *this; | |
53 | + } | |
54 | + | |
55 | + virtual ~IntervalsProperties() { | |
56 | + } | |
57 | + | |
58 | + std::string getParamId(){ | |
59 | + return _paramId; | |
60 | + } | |
61 | + | |
62 | + void setParamId(std::string paramId_) { | |
63 | + _paramId = paramId_; | |
64 | + } | |
65 | + | |
66 | + std::string getIndexDef() const { | |
67 | + return _indexDef; | |
68 | + } | |
69 | + | |
70 | + void setIndexDef(std::string indexDef) { | |
71 | + _indexDef = indexDef; | |
72 | + } | |
73 | + | |
74 | + AMDA::Common::ParameterIndexComponentList& getIndexes() | |
75 | + { | |
76 | + return _indexList; | |
77 | + } | |
78 | + | |
79 | + void setIndexes(AMDA::Common::ParameterIndexComponentList indexList) | |
80 | + { | |
81 | + _indexList = indexList; | |
82 | + } | |
83 | + | |
84 | + void setColorMapIndex( int colorMapIndex){ | |
85 | + _colorMapIndex = colorMapIndex; | |
86 | + } | |
87 | + | |
88 | + int getColorMapIndex() const{ | |
89 | + return _colorMapIndex; | |
90 | + } | |
91 | + | |
92 | +private: | |
93 | + /** | |
94 | + * @brief Calculated paramId (from resolution). | |
95 | + */ | |
96 | + std::string _paramId; | |
97 | + | |
98 | + /** | |
99 | + * @brief Index definition (give by the request) | |
100 | + */ | |
101 | + std::string _indexDef; | |
102 | + | |
103 | + /* | |
104 | + * @brief List of components used by the spectro | |
105 | + */ | |
106 | + AMDA::Common::ParameterIndexComponentList _indexList; | |
107 | + | |
108 | + /** | |
109 | + * @brief Color Map index to use | |
110 | + */ | |
111 | + int _colorMapIndex; | |
112 | +}; | |
113 | + | |
114 | +} /* namespace plot */ | |
115 | + | |
116 | +#endif /* INTERVALSPROPERTIES_HH_ */ | ... | ... |
src/ParamOutputImpl/Plot/PanelPlotOutput.cc
... | ... | @@ -1266,7 +1266,7 @@ bool PanelPlotOutput::getColoredValue(double value, double filterMin, double fil |
1266 | 1266 | // Restore color. |
1267 | 1267 | restoreColor(_pls, lInitialColor, _panel->_page->_mode); |
1268 | 1268 | } |
1269 | - | |
1269 | + | |
1270 | 1270 | /** |
1271 | 1271 | * Draw list of lines |
1272 | 1272 | */ |
... | ... | @@ -1355,6 +1355,48 @@ void PanelPlotOutput::drawLines(LineType pType, LineStyle pStyle, int pWidth, Co |
1355 | 1355 | restoreColor(_pls, lInitialColor, _panel->_page->_mode); |
1356 | 1356 | } |
1357 | 1357 | |
1358 | +/** | |
1359 | + * Draw a rectangle | |
1360 | + */ | |
1361 | +void PanelPlotOutput::drawRectangle(double xmin, double xmax, double ymin, double ymax, int colorIndex, int colorMapIndex, double alpha) | |
1362 | +{ | |
1363 | + //set color map | |
1364 | + std::string lFilePath = ColormapManager::getInstance().get(_panel->_page->_mode, colorMapIndex); | |
1365 | + _pls->spal0(lFilePath.c_str()); | |
1366 | + | |
1367 | + Color lInitialColor; | |
1368 | + _pls->gcol0(0, lInitialColor._red, lInitialColor._green, lInitialColor._blue); | |
1369 | + | |
1370 | + PLFLT x[4], y[4]; | |
1371 | + x[0] = xmin; | |
1372 | + x[1] = xmin; | |
1373 | + x[2] = xmax; | |
1374 | + x[3] = xmax; | |
1375 | + y[0] = ymin; | |
1376 | + y[1] = ymax; | |
1377 | + y[2] = ymax; | |
1378 | + y[3] = ymin; | |
1379 | + | |
1380 | + PLINT icol = (PLINT)colorIndex; | |
1381 | + PLINT r, g, b = 0; | |
1382 | + PLFLT a = 0; | |
1383 | + _pls->gcol0a( icol, r, g, b, a); | |
1384 | + a = alpha; | |
1385 | + _pls->scol0a( icol, r, g, b, a ); | |
1386 | + _pls->col0( icol ); | |
1387 | + | |
1388 | + _pls->fill(4, x, y); | |
1389 | + | |
1390 | + //restore to initial color context | |
1391 | + lFilePath = ColormapManager::getInstance().get(_panel->_page->_mode, 0); | |
1392 | + _pls->spal0(lFilePath.c_str()); | |
1393 | + | |
1394 | + _pls->scol0(0, lInitialColor._red, lInitialColor._green, lInitialColor._blue); | |
1395 | + | |
1396 | + // Restore color. | |
1397 | + restoreColor(_pls, lInitialColor, _panel->_page->_mode); | |
1398 | +} | |
1399 | + | |
1358 | 1400 | /* |
1359 | 1401 | * @brief Draw a matrix |
1360 | 1402 | */ |
... | ... | @@ -2189,10 +2231,37 @@ bool PanelPlotOutput::draw(double startTime, double stopTime, int intervalIndex, |
2189 | 2231 | |
2190 | 2232 | ParameterData &data = (*_pParameterValues)[parameter.getSpectroProperties()->getParamId()]; |
2191 | 2233 | |
2192 | - for (auto index : parameter.getSpectroProperties()->getIndexes()) { | |
2193 | - if (noData) | |
2194 | - noData = data.noData(index); | |
2195 | - } | |
2234 | + if (parameter.getSpectroProperties()->getIndexes().empty()) { | |
2235 | + noData = data.noData(); | |
2236 | + } | |
2237 | + else { | |
2238 | + for (auto index : parameter.getSpectroProperties()->getIndexes()) { | |
2239 | + if (noData) | |
2240 | + noData = data.noData(index); | |
2241 | + } | |
2242 | + } | |
2243 | + } | |
2244 | + } | |
2245 | + | |
2246 | + //Draw intervals | |
2247 | + for (auto parameter : _parameterAxesList) { | |
2248 | + if (parameter.getIntervalsProperties() != nullptr) { | |
2249 | + //draw intervals | |
2250 | + LOG4CXX_DEBUG(gLogger, "Draw intervals for parameter " << parameter._originalParamId); | |
2251 | + // Draw (configure) window for this series. | |
2252 | + drawIntervals(startTime, stopTime, parameter._originalParamId, *(parameter.getIntervalsProperties())); | |
2253 | + | |
2254 | + ParameterData &data = (*_pParameterValues)[parameter.getIntervalsProperties()->getParamId()]; | |
2255 | + | |
2256 | + if (parameter.getIntervalsProperties()->getIndexes().empty()) { | |
2257 | + noData = data.noData(); | |
2258 | + } | |
2259 | + else { | |
2260 | + for (auto index : parameter.getIntervalsProperties()->getIndexes()) { | |
2261 | + if (noData) | |
2262 | + noData = data.noData(index); | |
2263 | + } | |
2264 | + } | |
2196 | 2265 | } |
2197 | 2266 | } |
2198 | 2267 | |
... | ... | @@ -2340,6 +2409,55 @@ void PanelPlotOutput::drawSpectro(double /*startDate*/, double /*stopDate*/, std |
2340 | 2409 | } |
2341 | 2410 | } |
2342 | 2411 | |
2412 | +void PanelPlotOutput::drawIntervals(double /*startDate*/, double /*stopDate*/, std::string /*pParamId*/, | |
2413 | + IntervalsProperties& pIntervals) { | |
2414 | + | |
2415 | + boost::shared_ptr<Axis> lXAxis(_panel->getAxis(pIntervals.getXAxisId())); | |
2416 | + | |
2417 | + PlWindow lPlWindow; | |
2418 | + Range lXRange, lYRange; | |
2419 | + if (lXAxis.get() == nullptr) { | |
2420 | + std::stringstream lError; | |
2421 | + lError << "PanelPlotOutput::drawIntervals" << ": X axis with id '" | |
2422 | + << pIntervals.getXAxisId() << "' not found."; | |
2423 | + BOOST_THROW_EXCEPTION( | |
2424 | + PanelPlotOutputException() << AMDA::ex_msg(lError.str())); | |
2425 | + } | |
2426 | + | |
2427 | + lXRange = lXAxis->getRange(); | |
2428 | + | |
2429 | + lYRange = Range(0,1); | |
2430 | + | |
2431 | + lPlWindow = PlWindow(lXRange.getMin(), lXRange.getMax(), lYRange.getMin(), lYRange.getMax()); | |
2432 | + | |
2433 | + // Calculate X and Y tick | |
2434 | + TickConf lTickConf; | |
2435 | + double lXMajorTickSpace = nan(""); | |
2436 | + int lXMinorTickNumber = 0; | |
2437 | + double lYMajorTickSpace = nan(""); | |
2438 | + int lYMinorTickNumber = 0; | |
2439 | + | |
2440 | + lXMajorTickSpace = getMajorTickSpace(lXAxis.get(), | |
2441 | + std::get<0>(lPlWindow), std::get<1>(lPlWindow)); | |
2442 | + lXMinorTickNumber = getMinorTickNumber(lXAxis.get(), | |
2443 | + std::get<0>(lPlWindow), std::get<1>(lPlWindow), lXMajorTickSpace); | |
2444 | + | |
2445 | + lTickConf = TickConf(lXMajorTickSpace, lXMinorTickNumber, lYMajorTickSpace, lYMinorTickNumber); | |
2446 | + | |
2447 | + // Draw X axis and legend | |
2448 | + if (!lXAxis->_drawn) { | |
2449 | + | |
2450 | + drawXAxis(lXAxis, lPlWindow, _plotAreaBounds, lTickConf); | |
2451 | + | |
2452 | + // Draw legend. | |
2453 | + drawLegends(lXAxis, lPlWindow, _plotAreaBounds); | |
2454 | + } | |
2455 | + | |
2456 | + | |
2457 | + _pls->vpor( _plotAreaBounds._x, _plotAreaBounds._x + _plotAreaBounds._width, | |
2458 | + _plotAreaBounds._y, _plotAreaBounds._y + _plotAreaBounds._height); | |
2459 | +} | |
2460 | + | |
2343 | 2461 | void PanelPlotOutput::drawFills(double /*startDate*/, double /*stopDate*/) { |
2344 | 2462 | // Nothing done here except setting the viewport, see subclasses for specific implementation |
2345 | 2463 | _pls->vpor( _plotAreaBounds._x, _plotAreaBounds._x + _plotAreaBounds._width, |
... | ... | @@ -2804,6 +2922,31 @@ void PanelPlotOutput::createParameters(std::list<std::string>& usedParametersId_ |
2804 | 2922 | usedParametersId_.push_back(tableParamId); |
2805 | 2923 | } |
2806 | 2924 | } |
2925 | + | |
2926 | + //For intervals if defined | |
2927 | + std::shared_ptr<IntervalsProperties> pIntProp = it->getIntervalsProperties(); | |
2928 | + if (pIntProp != nullptr) { | |
2929 | + //get corrected sampling value in relation with max resolution | |
2930 | + double correctedSamplingValue = getCorrectedSamplingValue(pIntProp->getMaxResolution(), samplingValue); | |
2931 | + AMDA::Parameters::ParameterSPtr usedParam; | |
2932 | + | |
2933 | + if (abs(samplingValue - correctedSamplingValue) > 1.) | |
2934 | + { | |
2935 | + //more than one second between samplingValue and correctedSamplingValue | |
2936 | + //=> use resampling parameter | |
2937 | + usedParam = createSampledParameter(originalParam, correctedSamplingValue); | |
2938 | + } | |
2939 | + else | |
2940 | + { | |
2941 | + //use original parameter | |
2942 | + usedParam = originalParam; | |
2943 | + } | |
2944 | + | |
2945 | + //Add used parameter to parameters list | |
2946 | + if (std::find (usedParametersId_.begin(),usedParametersId_.end(),usedParam->getId()) == usedParametersId_.end()) | |
2947 | + usedParametersId_.push_back(usedParam->getId()); | |
2948 | + pIntProp->setParamId(usedParam->getId()); | |
2949 | + } | |
2807 | 2950 | } |
2808 | 2951 | } |
2809 | 2952 | |
... | ... | @@ -2882,6 +3025,30 @@ std::vector<AMDA::Common::ParameterIndexComponent> PanelPlotOutput::getParamUsed |
2882 | 3025 | } |
2883 | 3026 | } |
2884 | 3027 | |
3028 | + //get indexes for intervals | |
3029 | + std::shared_ptr<IntervalsProperties> pIntProp = paramAxeIt->getIntervalsProperties(); | |
3030 | + if (pIntProp != nullptr) | |
3031 | + { | |
3032 | + if (pIntProp->getParamId() == paramId) | |
3033 | + { | |
3034 | + if (pIntProp->getIndexes().empty()) | |
3035 | + { | |
3036 | + //get used indexes by the intervals thanks to the index definition in the request | |
3037 | + AMDA::Common::ParameterIndexComponentList indexList; | |
3038 | + AMDA::Common::ParameterIndexesTool::parse(pIntProp->getIndexDef(), | |
3039 | + dim1Size, dim2Size, indexList); | |
3040 | + pIntProp->setIndexes(indexList); | |
3041 | + } | |
3042 | + | |
3043 | + for (auto index : pIntProp->getIndexes()) | |
3044 | + { | |
3045 | + if (std::find(indexes.begin(),indexes.end(),index) != indexes.end()) | |
3046 | + continue; | |
3047 | + indexes.push_back(index); | |
3048 | + } | |
3049 | + } | |
3050 | + } | |
3051 | + | |
2885 | 3052 | //get indexes for series of this ParameterAxe |
2886 | 3053 | std::vector<AMDA::Common::ParameterIndexComponent> seriesIndexes = paramAxeIt->getParamUsedIndexes(paramId); |
2887 | 3054 | ... | ... |
src/ParamOutputImpl/Plot/PanelPlotOutput.hh
... | ... | @@ -325,8 +325,11 @@ protected: |
325 | 325 | int pNbData, double* pXData, double* pYData, |
326 | 326 | double* pZData = NULL, double filterZMin = -DBL_MAX, double filterZMax = DBL_MAX); |
327 | 327 | |
328 | - | |
329 | - | |
328 | + /** | |
329 | + * Draw a rectangle | |
330 | + */ | |
331 | + void drawRectangle(double xmin, double xmax, double ymin, double ymax, int colorIndex, int colorMapIndex, double alpha = 1.); | |
332 | + | |
330 | 333 | /** |
331 | 334 | * Draw errors segments |
332 | 335 | */ |
... | ... | @@ -345,6 +348,9 @@ protected: |
345 | 348 | virtual void drawSpectro(double startDate, double stopDate, std::string pParamId, |
346 | 349 | SpectroProperties& pSpectro); |
347 | 350 | |
351 | + virtual void drawIntervals(double startDate, double stopDate, std::string pParamId, | |
352 | + IntervalsProperties& pIntervals); | |
353 | + | |
348 | 354 | /* |
349 | 355 | * @brief Draw interval |
350 | 356 | */ | ... | ... |
src/ParamOutputImpl/Plot/ParameterAxes.cc
... | ... | @@ -47,6 +47,10 @@ void ParameterAxes::addSpectroProperties(std::shared_ptr<SpectroProperties> pSPe |
47 | 47 | _spectroPropertiesPtr = pSPectroProperties; |
48 | 48 | } |
49 | 49 | |
50 | +void ParameterAxes::addIntervalsProperties(std::shared_ptr<IntervalsProperties> pIntervalsProperties){ | |
51 | + _intervalsPropertiesPtr = pIntervalsProperties; | |
52 | +} | |
53 | + | |
50 | 54 | void ParameterAxes::addColorSerieProperties(const ColorSeriesProperties& s_) { |
51 | 55 | _colorSeriesProperties.push_back(s_); |
52 | 56 | } |
... | ... | @@ -67,6 +71,15 @@ std::vector<AMDA::Common::ParameterIndexComponent> ParameterAxes::getParamUsedIn |
67 | 71 | |
68 | 72 | } |
69 | 73 | |
74 | + if (_intervalsPropertiesPtr != nullptr) | |
75 | + { | |
76 | + if (_intervalsPropertiesPtr->getParamId() == paramId_) | |
77 | + { | |
78 | + keyset.push_back(AMDA::Common::ParameterIndexComponent(-1,-1)); | |
79 | + return keyset; | |
80 | + } | |
81 | + } | |
82 | + | |
70 | 83 | for (std::vector<SeriesProperties>::iterator it = |
71 | 84 | _ySeriesProperties.begin(); it != _ySeriesProperties.end(); ++it) { |
72 | 85 | // add index only if serie has same paramId to not store |
... | ... | @@ -158,6 +171,14 @@ void ParameterAxes::dump(std::ostream& out_, std::string& prefix_) { |
158 | 171 | _spectroPropertiesPtr->dump(out_, subPrefix); |
159 | 172 | } |
160 | 173 | |
174 | + if (_intervalsPropertiesPtr != nullptr) | |
175 | + { | |
176 | + os.str(""); | |
177 | + os << prefix_ << "intervals" << "."; | |
178 | + subPrefix = os.str(); | |
179 | + _intervalsPropertiesPtr->dump(out_, subPrefix); | |
180 | + } | |
181 | + | |
161 | 182 | std::vector<ColorSeriesProperties>::iterator colorit; |
162 | 183 | for (colorit = _colorSeriesProperties.begin(); colorit != _colorSeriesProperties.end(); |
163 | 184 | ++colorit) { | ... | ... |
src/ParamOutputImpl/Plot/ParameterAxes.hh
... | ... | @@ -17,6 +17,7 @@ |
17 | 17 | #include "XSeriesProperties.hh" |
18 | 18 | #include "DrawingProperties.hh" |
19 | 19 | #include "SpectroProperties.hh" |
20 | +#include "IntervalsProperties.hh" | |
20 | 21 | #include "ColorSeriesProperties.hh" |
21 | 22 | #include "Parameter.hh" |
22 | 23 | #include "ParameterData.hh" |
... | ... | @@ -42,6 +43,7 @@ public: |
42 | 43 | _defaultProperties(), |
43 | 44 | _ySeriesProperties(), |
44 | 45 | _spectroPropertiesPtr(nullptr), |
46 | + _intervalsPropertiesPtr(nullptr), | |
45 | 47 | _colorSeriesProperties() |
46 | 48 | { |
47 | 49 | |
... | ... | @@ -52,6 +54,7 @@ public: |
52 | 54 | _defaultProperties(), |
53 | 55 | _ySeriesProperties(), |
54 | 56 | _spectroPropertiesPtr(nullptr), |
57 | + _intervalsPropertiesPtr(nullptr), | |
55 | 58 | _colorSeriesProperties() |
56 | 59 | { |
57 | 60 | |
... | ... | @@ -63,6 +66,7 @@ public: |
63 | 66 | _ySeriesProperties(pParamAxes._ySeriesProperties), |
64 | 67 | _xSeriesProperties(pParamAxes._xSeriesProperties), |
65 | 68 | _spectroPropertiesPtr(pParamAxes._spectroPropertiesPtr), |
69 | + _intervalsPropertiesPtr(pParamAxes._intervalsPropertiesPtr), | |
66 | 70 | _colorSeriesProperties(pParamAxes._colorSeriesProperties) { |
67 | 71 | |
68 | 72 | } |
... | ... | @@ -73,6 +77,7 @@ public: |
73 | 77 | _ySeriesProperties = pParamAxes_._ySeriesProperties; |
74 | 78 | _xSeriesProperties = pParamAxes_._xSeriesProperties; |
75 | 79 | _spectroPropertiesPtr = pParamAxes_._spectroPropertiesPtr; |
80 | + _intervalsPropertiesPtr = pParamAxes_._intervalsPropertiesPtr; | |
76 | 81 | _colorSeriesProperties = pParamAxes_._colorSeriesProperties; |
77 | 82 | return *this; |
78 | 83 | } |
... | ... | @@ -104,6 +109,11 @@ public: |
104 | 109 | void addSpectroProperties(std::shared_ptr<SpectroProperties> pSPectroProperties); |
105 | 110 | |
106 | 111 | /** |
112 | + * add a new intervals | |
113 | + */ | |
114 | + void addIntervalsProperties(std::shared_ptr<IntervalsProperties> pIntervalsProperties); | |
115 | + | |
116 | + /** | |
107 | 117 | * add a new color serie |
108 | 118 | */ |
109 | 119 | void addColorSerieProperties(const ColorSeriesProperties&); |
... | ... | @@ -125,6 +135,10 @@ public: |
125 | 135 | return _spectroPropertiesPtr; |
126 | 136 | } |
127 | 137 | |
138 | + std::shared_ptr<IntervalsProperties> getIntervalsProperties() { | |
139 | + return _intervalsPropertiesPtr; | |
140 | + } | |
141 | + | |
128 | 142 | std::vector<ColorSeriesProperties>& getColorSeriePropertiesList() { |
129 | 143 | return _colorSeriesProperties; |
130 | 144 | } |
... | ... | @@ -175,6 +189,11 @@ private: |
175 | 189 | std::shared_ptr<SpectroProperties> _spectroPropertiesPtr; |
176 | 190 | |
177 | 191 | /** |
192 | + * Intervals | |
193 | + */ | |
194 | + std::shared_ptr<IntervalsProperties> _intervalsPropertiesPtr; | |
195 | + | |
196 | + /** | |
178 | 197 | * Color Series |
179 | 198 | */ |
180 | 199 | std::vector<ColorSeriesProperties> _colorSeriesProperties; | ... | ... |
src/ParamOutputImpl/Plot/ParamsNode.hh
... | ... | @@ -16,6 +16,7 @@ |
16 | 16 | #include "DrawingPropertiesNode.hh" |
17 | 17 | #include "SeriesNode.hh" |
18 | 18 | #include "SpectroNode.hh" |
19 | +#include "IntervalsNode.hh" | |
19 | 20 | |
20 | 21 | namespace plot { |
21 | 22 | |
... | ... | @@ -30,6 +31,8 @@ public: |
30 | 31 | new SeriesNode<PlotType>()); |
31 | 32 | getChildList()["spectro"] = AMDA::XMLConfigurator::NodeCfgSPtr( |
32 | 33 | new SpectroNode<PlotType>()); |
34 | + getChildList()["intervals"] = AMDA::XMLConfigurator::NodeCfgSPtr( | |
35 | + new IntervalsNode<PlotType>()); | |
33 | 36 | getChildList()["colorserie"] = AMDA::XMLConfigurator::NodeCfgSPtr( |
34 | 37 | new ColorSeriesNode<PlotType>()); |
35 | 38 | } | ... | ... |
src/ParamOutputImpl/Plot/Time/TimePlot.cc
... | ... | @@ -1016,6 +1016,60 @@ void TimePlot::drawSpectro(double startDate, double stopDate, std::string pParam |
1016 | 1016 | minValColor, maxValColor, lZAxis->_color._colorMapIndex, FALSE, pSpectro.getUseLog0AsMin()); |
1017 | 1017 | } |
1018 | 1018 | |
1019 | +void TimePlot::drawIntervals(double startDate, double stopDate, std::string pParamId, | |
1020 | + IntervalsProperties& pIntervals) { | |
1021 | + LOG4CXX_DEBUG(gLogger, "TimePlot::drawIntervals Drawing intervals for parameter "<<pParamId); | |
1022 | + // This will configure window, draw axes (if needed) and legend of axes. | |
1023 | + PanelPlotOutput::drawIntervals(startDate, stopDate, pParamId, pIntervals); | |
1024 | + | |
1025 | + PlWindow lPlWindow = PlWindow(getTimeAxis()->getRange().getMin(), getTimeAxis()->getRange().getMax(), 0, 1); | |
1026 | + | |
1027 | + _pls->wind(std::get<0>(lPlWindow), std::get<1>(lPlWindow), | |
1028 | + std::get<2>(lPlWindow), std::get<3>(lPlWindow)); | |
1029 | + | |
1030 | + ParameterData& data = (*_pParameterValues)[pIntervals.getParamId()]; | |
1031 | + | |
1032 | + std::string lFilePath = ColormapManager::getInstance().get(_panel->_page->_mode, | |
1033 | + pIntervals.getColorMapIndex()); | |
1034 | + _pls->spal0(lFilePath.c_str()); | |
1035 | + | |
1036 | + //get computed values | |
1037 | + int startIndex, nbData; | |
1038 | + data.getIntervalBounds(startDate, stopDate, startIndex, nbData); | |
1039 | + | |
1040 | + // Draw intervals | |
1041 | + double crtVal = NAN; | |
1042 | + double tmin, tmax = 0; | |
1043 | + for (int i = 0; i < nbData - 1; ++i) { | |
1044 | + double t1 = data.getTimes()[startIndex+i]; | |
1045 | + double t2 = data.getTimes()[startIndex+i+1]; | |
1046 | + double v = *data.getValues(AMDA::Common::ParameterIndexComponent(-1,-1), startIndex+i); | |
1047 | + | |
1048 | + if (isNAN(crtVal)) { | |
1049 | + tmin = t1; | |
1050 | + tmax = t2; | |
1051 | + crtVal = v; | |
1052 | + continue; | |
1053 | + } | |
1054 | + else if (crtVal == v) { | |
1055 | + tmax = t2; | |
1056 | + continue; | |
1057 | + } | |
1058 | + | |
1059 | + //Draw interval between tmin and tmax | |
1060 | + PanelPlotOutput::drawRectangle(tmin, tmax, 0., 1., (int)crtVal, pIntervals.getColorMapIndex(), 0.25); | |
1061 | + | |
1062 | + tmin = t1; | |
1063 | + tmax = t2; | |
1064 | + crtVal = v; | |
1065 | + } | |
1066 | + | |
1067 | + //Draw last interval if need | |
1068 | + if (!isNAN(crtVal)) { | |
1069 | + PanelPlotOutput::drawRectangle(tmin, tmax, 0., 1., (int)crtVal, pIntervals.getColorMapIndex(), 0.25); | |
1070 | + } | |
1071 | +} | |
1072 | + | |
1019 | 1073 | /** |
1020 | 1074 | * @brief Draw further information (for instance start date). |
1021 | 1075 | */ | ... | ... |
src/ParamOutputImpl/Plot/Time/TimePlot.hh
... | ... | @@ -102,6 +102,13 @@ protected: |
102 | 102 | SpectroProperties& pSpectro); |
103 | 103 | |
104 | 104 | |
105 | + /** | |
106 | + * @overload PanelPlotOutput::drawIntervals(double startDate, double stopDate, std::string pParamId, IntervalsProperties& pIntervals) | |
107 | + * @brief Draw intervals defined by a parameter | |
108 | + */ | |
109 | + virtual void drawIntervals(double startDate, double stopDate, std::string pParamId, | |
110 | + IntervalsProperties& pIntervals); | |
111 | + | |
105 | 112 | void drawXAxis(boost::shared_ptr<Axis> pXAxis, PlWindow& pPlWindow, Bounds& pPlotAreaSize, TickConf& pTickConf); |
106 | 113 | |
107 | 114 | /** | ... | ... |