diff --git a/config/xsd/info/paramInfo.xsd b/config/xsd/info/paramInfo.xsd index 7d61682..fafa582 100644 --- a/config/xsd/info/paramInfo.xsd +++ b/config/xsd/info/paramInfo.xsd @@ -67,10 +67,12 @@ - + + + diff --git a/src/ParamOutputImpl/Plot/IntervalsNode.hh b/src/ParamOutputImpl/Plot/IntervalsNode.hh index db05c84..308a620 100644 --- a/src/ParamOutputImpl/Plot/IntervalsNode.hh +++ b/src/ParamOutputImpl/Plot/IntervalsNode.hh @@ -58,13 +58,6 @@ public: xmlFree(value); } - // colorMapIndex attribute - value = xmlGetProp(pNode_, (const xmlChar *) "colorMapIndex"); - if (value != nullptr) { - intervalsPropsPtr->setColorMapIndex(atoi((const char*) value)); - xmlFree(value); - } - // add intervals definition to parameter plotOutput->getParameter((const char*)name).addIntervalsProperties(intervalsPropsPtr); } diff --git a/src/ParamOutputImpl/Plot/IntervalsProperties.hh b/src/ParamOutputImpl/Plot/IntervalsProperties.hh index 9c4af92..597058d 100644 --- a/src/ParamOutputImpl/Plot/IntervalsProperties.hh +++ b/src/ParamOutputImpl/Plot/IntervalsProperties.hh @@ -31,24 +31,23 @@ public: void dump(std::ostream& out_, std::string& prefix_); IntervalsProperties() : - DrawingProperties(), _paramId(""), _indexDef(""), _colorMapIndex(0) { + DrawingProperties(), _paramId(""), _indexDef("") { } IntervalsProperties(const DrawingProperties& ref_) : - DrawingProperties(ref_), _paramId(""), _indexDef(""), _colorMapIndex(0) { + DrawingProperties(ref_), _paramId(""), _indexDef("") { } IntervalsProperties(const IntervalsProperties& pParamDrawingProperties_) : DrawingProperties(pParamDrawingProperties_), _paramId(""), - _indexDef(pParamDrawingProperties_._indexDef), _colorMapIndex(pParamDrawingProperties_._colorMapIndex) { + _indexDef(pParamDrawingProperties_._indexDef) { } IntervalsProperties& operator=(const IntervalsProperties& ref_) { DrawingProperties::operator=(ref_); _paramId = ref_._paramId; _indexDef = ref_._indexDef; - _colorMapIndex = ref_._colorMapIndex; return *this; } @@ -81,14 +80,6 @@ public: _indexList = indexList; } - void setColorMapIndex( int colorMapIndex){ - _colorMapIndex = colorMapIndex; - } - - int getColorMapIndex() const{ - return _colorMapIndex; - } - private: /** * @brief Calculated paramId (from resolution). @@ -104,11 +95,6 @@ private: * @brief List of components used by the spectro */ AMDA::Common::ParameterIndexComponentList _indexList; - - /** - * @brief Color Map index to use - */ - int _colorMapIndex; }; } /* namespace plot */ diff --git a/src/ParamOutputImpl/Plot/PanelPlotOutput.cc b/src/ParamOutputImpl/Plot/PanelPlotOutput.cc index ef4608c..54c75ee 100644 --- a/src/ParamOutputImpl/Plot/PanelPlotOutput.cc +++ b/src/ParamOutputImpl/Plot/PanelPlotOutput.cc @@ -1358,16 +1358,20 @@ void PanelPlotOutput::drawLines(LineType pType, LineStyle pStyle, int pWidth, Co /** * Draw a rectangle */ -void PanelPlotOutput::drawRectangle(double xmin, double xmax, double ymin, double ymax, int colorIndex, int colorMapIndex, double alpha) +void PanelPlotOutput::drawRectangle(double xmin, double xmax, double ymin, double ymax, Color& color, double alpha) { - //set color map - std::string lFilePath = ColormapManager::getInstance().get(_panel->_page->_mode, colorMapIndex); - _pls->spal0(lFilePath.c_str()); - - Color lInitialColor; - _pls->gcol0(0, lInitialColor._red, lInitialColor._green, lInitialColor._blue); - + if (!color.isSet()) { + return; + } + + Color lInitialColor; + + // Set color. + lInitialColor = changeColor(_pls, color, _panel->_page->_mode); + + // Draw rectangle PLFLT x[4], y[4]; + x[0] = xmin; x[1] = xmin; x[2] = xmax; @@ -1376,8 +1380,9 @@ void PanelPlotOutput::drawRectangle(double xmin, double xmax, double ymin, doubl y[1] = ymax; y[2] = ymax; y[3] = ymin; - - PLINT icol = (PLINT)colorIndex; + + // Fill rectangle + PLINT icol = 0; PLINT r, g, b = 0; PLFLT a = 0; _pls->gcol0a( icol, r, g, b, a); @@ -1386,12 +1391,6 @@ void PanelPlotOutput::drawRectangle(double xmin, double xmax, double ymin, doubl _pls->col0( icol ); _pls->fill(4, x, y); - - //restore to initial color context - lFilePath = ColormapManager::getInstance().get(_panel->_page->_mode, 0); - _pls->spal0(lFilePath.c_str()); - - _pls->scol0(0, lInitialColor._red, lInitialColor._green, lInitialColor._blue); // Restore color. restoreColor(_pls, lInitialColor, _panel->_page->_mode); diff --git a/src/ParamOutputImpl/Plot/PanelPlotOutput.hh b/src/ParamOutputImpl/Plot/PanelPlotOutput.hh index f116848..a49f785 100644 --- a/src/ParamOutputImpl/Plot/PanelPlotOutput.hh +++ b/src/ParamOutputImpl/Plot/PanelPlotOutput.hh @@ -328,7 +328,7 @@ protected: /** * Draw a rectangle */ - void drawRectangle(double xmin, double xmax, double ymin, double ymax, int colorIndex, int colorMapIndex, double alpha = 1.); + void drawRectangle(double xmin, double xmax, double ymin, double ymax, Color& pColor, double alpha = 1.); /** * Draw errors segments diff --git a/src/ParamOutputImpl/Plot/Time/TimePlot.cc b/src/ParamOutputImpl/Plot/Time/TimePlot.cc index 5b76755..e06c47d 100644 --- a/src/ParamOutputImpl/Plot/Time/TimePlot.cc +++ b/src/ParamOutputImpl/Plot/Time/TimePlot.cc @@ -1016,6 +1016,47 @@ void TimePlot::drawSpectro(double startDate, double stopDate, std::string pParam minValColor, maxValColor, lZAxis->_color._colorMapIndex, FALSE, pSpectro.getUseLog0AsMin()); } +Color TimePlot::getStatusColor(AMDA::Info::ParamInfoSPtr& paramInfo, double value) { + Color color; + + if ((paramInfo != nullptr) && !paramInfo->getStatusDef().empty()) { + for (int s = 0 ; s < (int)paramInfo->getStatusDef().size(); ++s) { + if (value >= paramInfo->getStatusDef()[s].getMinValue() && value <= paramInfo->getStatusDef()[s].getMaxValue()) { + if (!paramInfo->getStatusDef()[s].getColor().empty()) { + std::string colorStr = paramInfo->getStatusDef()[s].getColor(); + createColor(color, colorStr); + return color; + } + } + } + } + + return color; +} + +void TimePlot::drawOneInterval(double tmin, double tmax, Color color) { + if (!color.isSet()) { + return; + } + + //Fill interval + PanelPlotOutput::drawRectangle(tmin, tmax, 0., 1., color, 0.25); + + //Draw borders + PLFLT x[2], y[2]; + x[0] = tmin; + y[0] = 0.; + x[1] = tmin; + y[1] = 1.; + PanelPlotOutput::drawLines(LineType::LINE, LineStyle::PLAIN, 2, color, 2, x, y); + + x[0] = tmax; + y[0] = 0.; + x[1] = tmax; + y[1] = 1.; + PanelPlotOutput::drawLines(LineType::LINE, LineStyle::PLAIN, 2, color, 2, x, y); +} + void TimePlot::drawIntervals(double startDate, double stopDate, std::string pParamId, IntervalsProperties& pIntervals) { LOG4CXX_DEBUG(gLogger, "TimePlot::drawIntervals Drawing intervals for parameter "<(lPlWindow), std::get<3>(lPlWindow)); ParameterData& data = (*_pParameterValues)[pIntervals.getParamId()]; - - std::string lFilePath = ColormapManager::getInstance().get(_panel->_page->_mode, - pIntervals.getColorMapIndex()); - _pls->spal0(lFilePath.c_str()); + + ParameterSPtr p = _parameterManager.getParameter(pIntervals.getParamId()); + AMDA::Info::ParamInfoSPtr paramInfo = AMDA::Info::ParamMgr::getInstance()->getParamInfoFromId(p->getInfoId()); //get computed values int startIndex, nbData; data.getIntervalBounds(startDate, stopDate, startIndex, nbData); + + Color crtColor; // Draw intervals double crtVal = NAN; @@ -1055,10 +1097,11 @@ void TimePlot::drawIntervals(double startDate, double stopDate, std::string pPar tmax = t2; continue; } - - //Draw interval between tmin and tmax - PanelPlotOutput::drawRectangle(tmin, tmax, 0., 1., (int)crtVal, pIntervals.getColorMapIndex(), 0.25); - + + crtColor = getStatusColor(paramInfo, crtVal); + + drawOneInterval(tmin, tmax, crtColor); + tmin = t1; tmax = t2; crtVal = v; @@ -1066,7 +1109,7 @@ void TimePlot::drawIntervals(double startDate, double stopDate, std::string pPar //Draw last interval if need if (!isNAN(crtVal)) { - PanelPlotOutput::drawRectangle(tmin, tmax, 0., 1., (int)crtVal, pIntervals.getColorMapIndex(), 0.25); + drawOneInterval(tmin, tmax, crtColor); } } diff --git a/src/ParamOutputImpl/Plot/Time/TimePlot.hh b/src/ParamOutputImpl/Plot/Time/TimePlot.hh index dbf32b1..7307632 100644 --- a/src/ParamOutputImpl/Plot/Time/TimePlot.hh +++ b/src/ParamOutputImpl/Plot/Time/TimePlot.hh @@ -22,6 +22,8 @@ #include "TimePlotNode.hh" +#include "ParamInfo.hh" + extern "C" { #include } @@ -202,6 +204,10 @@ private: bool colorLessSpecified, Color& colorLess, SeriesProperties &rSeriesProperties); + Color getStatusColor(AMDA::Info::ParamInfoSPtr& paramInfo, double value); + + void drawOneInterval(double tmin, double tmax, Color color); + std::shared_ptr _xdecoratorPtr; bool _startDateDrawn; -- libgit2 0.21.2