Commit 677db865c0f1815c4a644dac933d2339a8ae7400
1 parent
7f62f27f
Exists in
master
and in
90 other branches
Draw intervals on a time plot
Showing
7 changed files
with
80 additions
and
51 deletions
Show diff stats
config/xsd/info/paramInfo.xsd
@@ -67,10 +67,12 @@ | @@ -67,10 +67,12 @@ | ||
67 | </xs:complexType> | 67 | </xs:complexType> |
68 | </xs:element> | 68 | </xs:element> |
69 | 69 | ||
70 | - <xs:attributeGroup name="StatusGroup"> | 70 | + |
71 | + <xs:attributeGroup name="StatusGroup"> | ||
71 | <xs:attribute name="minVal" type="xs:double" /> | 72 | <xs:attribute name="minVal" type="xs:double" /> |
72 | <xs:attribute name="maxVal" type="xs:double" /> | 73 | <xs:attribute name="maxVal" type="xs:double" /> |
73 | <xs:attribute name="name" type="xs:string" /> | 74 | <xs:attribute name="name" type="xs:string" /> |
75 | + <xs:attribute name="color" type="xs:string" /> | ||
74 | </xs:attributeGroup> | 76 | </xs:attributeGroup> |
75 | 77 | ||
76 | <xs:complexType name="paramInfoType"> | 78 | <xs:complexType name="paramInfoType"> |
src/ParamOutputImpl/Plot/IntervalsNode.hh
@@ -58,13 +58,6 @@ public: | @@ -58,13 +58,6 @@ public: | ||
58 | xmlFree(value); | 58 | xmlFree(value); |
59 | } | 59 | } |
60 | 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 | 61 | // add intervals definition to parameter |
69 | plotOutput->getParameter((const char*)name).addIntervalsProperties(intervalsPropsPtr); | 62 | plotOutput->getParameter((const char*)name).addIntervalsProperties(intervalsPropsPtr); |
70 | } | 63 | } |
src/ParamOutputImpl/Plot/IntervalsProperties.hh
@@ -31,24 +31,23 @@ public: | @@ -31,24 +31,23 @@ public: | ||
31 | void dump(std::ostream& out_, std::string& prefix_); | 31 | void dump(std::ostream& out_, std::string& prefix_); |
32 | 32 | ||
33 | IntervalsProperties() : | 33 | IntervalsProperties() : |
34 | - DrawingProperties(), _paramId(""), _indexDef(""), _colorMapIndex(0) { | 34 | + DrawingProperties(), _paramId(""), _indexDef("") { |
35 | } | 35 | } |
36 | 36 | ||
37 | IntervalsProperties(const DrawingProperties& ref_) : | 37 | IntervalsProperties(const DrawingProperties& ref_) : |
38 | - DrawingProperties(ref_), _paramId(""), _indexDef(""), _colorMapIndex(0) { | 38 | + DrawingProperties(ref_), _paramId(""), _indexDef("") { |
39 | 39 | ||
40 | } | 40 | } |
41 | 41 | ||
42 | IntervalsProperties(const IntervalsProperties& pParamDrawingProperties_) : | 42 | IntervalsProperties(const IntervalsProperties& pParamDrawingProperties_) : |
43 | DrawingProperties(pParamDrawingProperties_), _paramId(""), | 43 | DrawingProperties(pParamDrawingProperties_), _paramId(""), |
44 | - _indexDef(pParamDrawingProperties_._indexDef), _colorMapIndex(pParamDrawingProperties_._colorMapIndex) { | 44 | + _indexDef(pParamDrawingProperties_._indexDef) { |
45 | } | 45 | } |
46 | 46 | ||
47 | IntervalsProperties& operator=(const IntervalsProperties& ref_) { | 47 | IntervalsProperties& operator=(const IntervalsProperties& ref_) { |
48 | DrawingProperties::operator=(ref_); | 48 | DrawingProperties::operator=(ref_); |
49 | _paramId = ref_._paramId; | 49 | _paramId = ref_._paramId; |
50 | _indexDef = ref_._indexDef; | 50 | _indexDef = ref_._indexDef; |
51 | - _colorMapIndex = ref_._colorMapIndex; | ||
52 | return *this; | 51 | return *this; |
53 | } | 52 | } |
54 | 53 | ||
@@ -81,14 +80,6 @@ public: | @@ -81,14 +80,6 @@ public: | ||
81 | _indexList = indexList; | 80 | _indexList = indexList; |
82 | } | 81 | } |
83 | 82 | ||
84 | - void setColorMapIndex( int colorMapIndex){ | ||
85 | - _colorMapIndex = colorMapIndex; | ||
86 | - } | ||
87 | - | ||
88 | - int getColorMapIndex() const{ | ||
89 | - return _colorMapIndex; | ||
90 | - } | ||
91 | - | ||
92 | private: | 83 | private: |
93 | /** | 84 | /** |
94 | * @brief Calculated paramId (from resolution). | 85 | * @brief Calculated paramId (from resolution). |
@@ -104,11 +95,6 @@ private: | @@ -104,11 +95,6 @@ private: | ||
104 | * @brief List of components used by the spectro | 95 | * @brief List of components used by the spectro |
105 | */ | 96 | */ |
106 | AMDA::Common::ParameterIndexComponentList _indexList; | 97 | AMDA::Common::ParameterIndexComponentList _indexList; |
107 | - | ||
108 | - /** | ||
109 | - * @brief Color Map index to use | ||
110 | - */ | ||
111 | - int _colorMapIndex; | ||
112 | }; | 98 | }; |
113 | 99 | ||
114 | } /* namespace plot */ | 100 | } /* namespace plot */ |
src/ParamOutputImpl/Plot/PanelPlotOutput.cc
@@ -1358,16 +1358,20 @@ void PanelPlotOutput::drawLines(LineType pType, LineStyle pStyle, int pWidth, Co | @@ -1358,16 +1358,20 @@ void PanelPlotOutput::drawLines(LineType pType, LineStyle pStyle, int pWidth, Co | ||
1358 | /** | 1358 | /** |
1359 | * Draw a rectangle | 1359 | * Draw a rectangle |
1360 | */ | 1360 | */ |
1361 | -void PanelPlotOutput::drawRectangle(double xmin, double xmax, double ymin, double ymax, int colorIndex, int colorMapIndex, double alpha) | 1361 | +void PanelPlotOutput::drawRectangle(double xmin, double xmax, double ymin, double ymax, Color& color, double alpha) |
1362 | { | 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 | - | 1363 | + if (!color.isSet()) { |
1364 | + return; | ||
1365 | + } | ||
1366 | + | ||
1367 | + Color lInitialColor; | ||
1368 | + | ||
1369 | + // Set color. | ||
1370 | + lInitialColor = changeColor(_pls, color, _panel->_page->_mode); | ||
1371 | + | ||
1372 | + // Draw rectangle | ||
1370 | PLFLT x[4], y[4]; | 1373 | PLFLT x[4], y[4]; |
1374 | + | ||
1371 | x[0] = xmin; | 1375 | x[0] = xmin; |
1372 | x[1] = xmin; | 1376 | x[1] = xmin; |
1373 | x[2] = xmax; | 1377 | x[2] = xmax; |
@@ -1376,8 +1380,9 @@ void PanelPlotOutput::drawRectangle(double xmin, double xmax, double ymin, doubl | @@ -1376,8 +1380,9 @@ void PanelPlotOutput::drawRectangle(double xmin, double xmax, double ymin, doubl | ||
1376 | y[1] = ymax; | 1380 | y[1] = ymax; |
1377 | y[2] = ymax; | 1381 | y[2] = ymax; |
1378 | y[3] = ymin; | 1382 | y[3] = ymin; |
1379 | - | ||
1380 | - PLINT icol = (PLINT)colorIndex; | 1383 | + |
1384 | + // Fill rectangle | ||
1385 | + PLINT icol = 0; | ||
1381 | PLINT r, g, b = 0; | 1386 | PLINT r, g, b = 0; |
1382 | PLFLT a = 0; | 1387 | PLFLT a = 0; |
1383 | _pls->gcol0a( icol, r, g, b, a); | 1388 | _pls->gcol0a( icol, r, g, b, a); |
@@ -1386,12 +1391,6 @@ void PanelPlotOutput::drawRectangle(double xmin, double xmax, double ymin, doubl | @@ -1386,12 +1391,6 @@ void PanelPlotOutput::drawRectangle(double xmin, double xmax, double ymin, doubl | ||
1386 | _pls->col0( icol ); | 1391 | _pls->col0( icol ); |
1387 | 1392 | ||
1388 | _pls->fill(4, x, y); | 1393 | _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 | 1394 | ||
1396 | // Restore color. | 1395 | // Restore color. |
1397 | restoreColor(_pls, lInitialColor, _panel->_page->_mode); | 1396 | restoreColor(_pls, lInitialColor, _panel->_page->_mode); |
src/ParamOutputImpl/Plot/PanelPlotOutput.hh
@@ -328,7 +328,7 @@ protected: | @@ -328,7 +328,7 @@ protected: | ||
328 | /** | 328 | /** |
329 | * Draw a rectangle | 329 | * Draw a rectangle |
330 | */ | 330 | */ |
331 | - void drawRectangle(double xmin, double xmax, double ymin, double ymax, int colorIndex, int colorMapIndex, double alpha = 1.); | 331 | + void drawRectangle(double xmin, double xmax, double ymin, double ymax, Color& pColor, double alpha = 1.); |
332 | 332 | ||
333 | /** | 333 | /** |
334 | * Draw errors segments | 334 | * Draw errors segments |
src/ParamOutputImpl/Plot/Time/TimePlot.cc
@@ -1016,6 +1016,47 @@ void TimePlot::drawSpectro(double startDate, double stopDate, std::string pParam | @@ -1016,6 +1016,47 @@ void TimePlot::drawSpectro(double startDate, double stopDate, std::string pParam | ||
1016 | minValColor, maxValColor, lZAxis->_color._colorMapIndex, FALSE, pSpectro.getUseLog0AsMin()); | 1016 | minValColor, maxValColor, lZAxis->_color._colorMapIndex, FALSE, pSpectro.getUseLog0AsMin()); |
1017 | } | 1017 | } |
1018 | 1018 | ||
1019 | +Color TimePlot::getStatusColor(AMDA::Info::ParamInfoSPtr& paramInfo, double value) { | ||
1020 | + Color color; | ||
1021 | + | ||
1022 | + if ((paramInfo != nullptr) && !paramInfo->getStatusDef().empty()) { | ||
1023 | + for (int s = 0 ; s < (int)paramInfo->getStatusDef().size(); ++s) { | ||
1024 | + if (value >= paramInfo->getStatusDef()[s].getMinValue() && value <= paramInfo->getStatusDef()[s].getMaxValue()) { | ||
1025 | + if (!paramInfo->getStatusDef()[s].getColor().empty()) { | ||
1026 | + std::string colorStr = paramInfo->getStatusDef()[s].getColor(); | ||
1027 | + createColor(color, colorStr); | ||
1028 | + return color; | ||
1029 | + } | ||
1030 | + } | ||
1031 | + } | ||
1032 | + } | ||
1033 | + | ||
1034 | + return color; | ||
1035 | +} | ||
1036 | + | ||
1037 | +void TimePlot::drawOneInterval(double tmin, double tmax, Color color) { | ||
1038 | + if (!color.isSet()) { | ||
1039 | + return; | ||
1040 | + } | ||
1041 | + | ||
1042 | + //Fill interval | ||
1043 | + PanelPlotOutput::drawRectangle(tmin, tmax, 0., 1., color, 0.25); | ||
1044 | + | ||
1045 | + //Draw borders | ||
1046 | + PLFLT x[2], y[2]; | ||
1047 | + x[0] = tmin; | ||
1048 | + y[0] = 0.; | ||
1049 | + x[1] = tmin; | ||
1050 | + y[1] = 1.; | ||
1051 | + PanelPlotOutput::drawLines(LineType::LINE, LineStyle::PLAIN, 2, color, 2, x, y); | ||
1052 | + | ||
1053 | + x[0] = tmax; | ||
1054 | + y[0] = 0.; | ||
1055 | + x[1] = tmax; | ||
1056 | + y[1] = 1.; | ||
1057 | + PanelPlotOutput::drawLines(LineType::LINE, LineStyle::PLAIN, 2, color, 2, x, y); | ||
1058 | +} | ||
1059 | + | ||
1019 | void TimePlot::drawIntervals(double startDate, double stopDate, std::string pParamId, | 1060 | void TimePlot::drawIntervals(double startDate, double stopDate, std::string pParamId, |
1020 | IntervalsProperties& pIntervals) { | 1061 | IntervalsProperties& pIntervals) { |
1021 | LOG4CXX_DEBUG(gLogger, "TimePlot::drawIntervals Drawing intervals for parameter "<<pParamId); | 1062 | LOG4CXX_DEBUG(gLogger, "TimePlot::drawIntervals Drawing intervals for parameter "<<pParamId); |
@@ -1028,14 +1069,15 @@ void TimePlot::drawIntervals(double startDate, double stopDate, std::string pPar | @@ -1028,14 +1069,15 @@ void TimePlot::drawIntervals(double startDate, double stopDate, std::string pPar | ||
1028 | std::get<2>(lPlWindow), std::get<3>(lPlWindow)); | 1069 | std::get<2>(lPlWindow), std::get<3>(lPlWindow)); |
1029 | 1070 | ||
1030 | ParameterData& data = (*_pParameterValues)[pIntervals.getParamId()]; | 1071 | 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()); | 1072 | + |
1073 | + ParameterSPtr p = _parameterManager.getParameter(pIntervals.getParamId()); | ||
1074 | + AMDA::Info::ParamInfoSPtr paramInfo = AMDA::Info::ParamMgr::getInstance()->getParamInfoFromId(p->getInfoId()); | ||
1035 | 1075 | ||
1036 | //get computed values | 1076 | //get computed values |
1037 | int startIndex, nbData; | 1077 | int startIndex, nbData; |
1038 | data.getIntervalBounds(startDate, stopDate, startIndex, nbData); | 1078 | data.getIntervalBounds(startDate, stopDate, startIndex, nbData); |
1079 | + | ||
1080 | + Color crtColor; | ||
1039 | 1081 | ||
1040 | // Draw intervals | 1082 | // Draw intervals |
1041 | double crtVal = NAN; | 1083 | double crtVal = NAN; |
@@ -1055,10 +1097,11 @@ void TimePlot::drawIntervals(double startDate, double stopDate, std::string pPar | @@ -1055,10 +1097,11 @@ void TimePlot::drawIntervals(double startDate, double stopDate, std::string pPar | ||
1055 | tmax = t2; | 1097 | tmax = t2; |
1056 | continue; | 1098 | continue; |
1057 | } | 1099 | } |
1058 | - | ||
1059 | - //Draw interval between tmin and tmax | ||
1060 | - PanelPlotOutput::drawRectangle(tmin, tmax, 0., 1., (int)crtVal, pIntervals.getColorMapIndex(), 0.25); | ||
1061 | - | 1100 | + |
1101 | + crtColor = getStatusColor(paramInfo, crtVal); | ||
1102 | + | ||
1103 | + drawOneInterval(tmin, tmax, crtColor); | ||
1104 | + | ||
1062 | tmin = t1; | 1105 | tmin = t1; |
1063 | tmax = t2; | 1106 | tmax = t2; |
1064 | crtVal = v; | 1107 | crtVal = v; |
@@ -1066,7 +1109,7 @@ void TimePlot::drawIntervals(double startDate, double stopDate, std::string pPar | @@ -1066,7 +1109,7 @@ void TimePlot::drawIntervals(double startDate, double stopDate, std::string pPar | ||
1066 | 1109 | ||
1067 | //Draw last interval if need | 1110 | //Draw last interval if need |
1068 | if (!isNAN(crtVal)) { | 1111 | if (!isNAN(crtVal)) { |
1069 | - PanelPlotOutput::drawRectangle(tmin, tmax, 0., 1., (int)crtVal, pIntervals.getColorMapIndex(), 0.25); | 1112 | + drawOneInterval(tmin, tmax, crtColor); |
1070 | } | 1113 | } |
1071 | } | 1114 | } |
1072 | 1115 |
src/ParamOutputImpl/Plot/Time/TimePlot.hh
@@ -22,6 +22,8 @@ | @@ -22,6 +22,8 @@ | ||
22 | 22 | ||
23 | #include "TimePlotNode.hh" | 23 | #include "TimePlotNode.hh" |
24 | 24 | ||
25 | +#include "ParamInfo.hh" | ||
26 | + | ||
25 | extern "C" { | 27 | extern "C" { |
26 | #include <plplot/qsastime.h> | 28 | #include <plplot/qsastime.h> |
27 | } | 29 | } |
@@ -202,6 +204,10 @@ private: | @@ -202,6 +204,10 @@ private: | ||
202 | bool colorLessSpecified, Color& colorLess, | 204 | bool colorLessSpecified, Color& colorLess, |
203 | SeriesProperties &rSeriesProperties); | 205 | SeriesProperties &rSeriesProperties); |
204 | 206 | ||
207 | + Color getStatusColor(AMDA::Info::ParamInfoSPtr& paramInfo, double value); | ||
208 | + | ||
209 | + void drawOneInterval(double tmin, double tmax, Color color); | ||
210 | + | ||
205 | std::shared_ptr<TimeAxisDecorator> _xdecoratorPtr; | 211 | std::shared_ptr<TimeAxisDecorator> _xdecoratorPtr; |
206 | 212 | ||
207 | bool _startDateDrawn; | 213 | bool _startDateDrawn; |