diff --git a/src/ParamOutputImpl/Plot/DrawingProperties.cc b/src/ParamOutputImpl/Plot/DrawingProperties.cc index 99055f3..9e0c2b9 100644 --- a/src/ParamOutputImpl/Plot/DrawingProperties.cc +++ b/src/ParamOutputImpl/Plot/DrawingProperties.cc @@ -21,6 +21,7 @@ DrawingProperties::DrawingProperties() : _errorBarProperties(), _xAxisId(""), _yAxisId(""), + _yleftAxisId(""), _zAxisId(""), _color(), _min(nan("")), @@ -36,6 +37,7 @@ DrawingProperties::DrawingProperties(const DrawingProperties& ref_) : _errorBarProperties(ref_._errorBarProperties), _xAxisId(ref_._xAxisId), _yAxisId(ref_._yAxisId), + _yleftAxisId(ref_._yleftAxisId), _zAxisId(ref_._zAxisId), _color(ref_._color), _min(ref_._min), @@ -58,6 +60,7 @@ DrawingProperties& DrawingProperties::operator=(const DrawingProperties& ref_) { _xAxisId = ref_._xAxisId; _yAxisId = ref_._yAxisId; + _yleftAxisId = ref_._yleftAxisId; _zAxisId = ref_._zAxisId; _lineProperties = ref_._lineProperties; _symbolProperties = ref_._symbolProperties; @@ -174,6 +177,16 @@ void DrawingProperties::setYAxisId(const std::string& axisId) _yAxisId = axisId; } +const std::string& DrawingProperties::getYleftAxisId() const +{ + return _yleftAxisId; +} + +void DrawingProperties::setYleftAxisId(const std::string& axisId) +{ + _yleftAxisId = axisId; +} + const std::string& DrawingProperties::getZAxisId() const { return _zAxisId; diff --git a/src/ParamOutputImpl/Plot/DrawingProperties.hh b/src/ParamOutputImpl/Plot/DrawingProperties.hh index 3973d72..681fe2c 100644 --- a/src/ParamOutputImpl/Plot/DrawingProperties.hh +++ b/src/ParamOutputImpl/Plot/DrawingProperties.hh @@ -62,6 +62,9 @@ public: const std::string& getYAxisId() const; void setYAxisId(const std::string& axisId); + + const std::string& getYleftAxisId() const; + void setYleftAxisId(const std::string& axisId); const std::string& getZAxisId() const; void setZAxisId(const std::string& axisId); @@ -92,10 +95,11 @@ private: ErrorBarProperties _errorBarProperties; std::string _xAxisId; std::string _yAxisId; + std::string _yleftAxisId; std::string _zAxisId; Color _color; - double _min; - double _max; + double _min; + double _max; /** diff --git a/src/ParamOutputImpl/Plot/DrawingPropertiesNode.hh b/src/ParamOutputImpl/Plot/DrawingPropertiesNode.hh index 171b9cf..5be9842 100644 --- a/src/ParamOutputImpl/Plot/DrawingPropertiesNode.hh +++ b/src/ParamOutputImpl/Plot/DrawingPropertiesNode.hh @@ -81,6 +81,14 @@ protected: props_.setYAxisId(std::string((const char*)value)); xmlFree(value); } + + // -- yleftAxis information + value = xmlGetProp(pNode_, (const xmlChar *) "yleftAxis"); + if( value ){ + props_.setYleftAxisId(std::string((const char*)value)); + xmlFree(value); + } + // -- zAxis information value = xmlGetProp(pNode_, (const xmlChar *) "zAxis"); if( value ){ diff --git a/src/ParamOutputImpl/Plot/PanelPlotOutput.cc b/src/ParamOutputImpl/Plot/PanelPlotOutput.cc index 0c92e19..bd4afad 100644 --- a/src/ParamOutputImpl/Plot/PanelPlotOutput.cc +++ b/src/ParamOutputImpl/Plot/PanelPlotOutput.cc @@ -1491,7 +1491,7 @@ void PanelPlotOutput::drawMatrix(MatrixGrid& matrixGrid, double minDataVal, doub /* * @brief Draw a sauvaud - */ + void PanelPlotOutput::draw2DMatrix(SauvaudGrid& sauvaudGrid, double minDataVal, double maxDataVal, Color minValColor, Color maxValColor, int colorMapIndex, bool useLog0AsMin) { @@ -1578,7 +1578,7 @@ void PanelPlotOutput::draw2DMatrix(SauvaudGrid& sauvaudGrid, double minDataVal, // Restore color. restoreColor(_pls, lInitialColor, _panel->_page->_mode); -} +}*/ /** * Draw errors segments @@ -2165,12 +2165,17 @@ void PanelPlotOutput::writeContext(ContextFileWriter& writer) { if (!_parameterAxesList.empty()) { bool hasSpectro = false; + bool hasSauvaud = false; for (auto parameter : _parameterAxesList) { if (parameter.getSpectroProperties() != nullptr) { hasSpectro = true; break; } + if (parameter.getSauvaudProperties() != nullptr) { + hasSauvaud = true; + break; + } } @@ -2191,6 +2196,7 @@ void PanelPlotOutput::writeContext(ContextFileWriter& writer) { } writer.addAttribute("hasSpectro", hasSpectro ? "true" : "false"); + writer.addAttribute("hasSauvaud", hasSauvaud ? "true" : "false"); for (Axes::iterator it = _panel->_axes.begin(); it != _panel->_axes.end(); ++it) { boost::shared_ptr lAxis = it->second; @@ -2313,7 +2319,7 @@ bool PanelPlotOutput::draw(double startTime, double stopTime, int intervalIndex, //Draw spectro for (auto parameter : _parameterAxesList) { - if (parameter.getSpectroProperties() != nullptr) { + if (parameter.getSpectroProperties() != nullptr) { //draw spectro LOG4CXX_DEBUG(gLogger, "Draw a spectro for parameter " << parameter._originalParamId); // Draw (configure) window for this series. @@ -2321,18 +2327,36 @@ bool PanelPlotOutput::draw(double startTime, double stopTime, int intervalIndex, ParameterData &data = (*_pParameterValues)[parameter.getSpectroProperties()->getParamId()]; - if (parameter.getSpectroProperties()->getIndexes().empty()) { + if (parameter.getSpectroProperties()->getIndexes().empty()) { + noData = data.noData(); + } + else { + for (auto index : parameter.getSpectroProperties()->getIndexes()) { + if (noData) + noData = data.noData(index); + } + } + } + if (parameter.getSauvaudProperties() != nullptr) { + //draw sauvaud + LOG4CXX_DEBUG(gLogger, "Draw a sauvaud for parameter " << parameter._originalParamId); + // Draw (configure) window for this series. + drawSauvaud(startTime, stopTime, parameter._originalParamId, *(parameter.getSauvaudProperties())); + + ParameterData &data = (*_pParameterValues)[parameter.getSauvaudProperties()->getParamId()]; + + if (parameter.getSauvaudProperties()->getIndexes().empty()) { noData = data.noData(); } else { - for (auto index : parameter.getSpectroProperties()->getIndexes()) { + for (auto index : parameter.getSauvaudProperties()->getIndexes()) { if (noData) noData = data.noData(index); } } } } - + //Draw intervals for (auto parameter : _parameterAxesList) { if (parameter.getIntervalsProperties() != nullptr) { @@ -2405,6 +2429,7 @@ void PanelPlotOutput::drawSauvaud(double /*startDate*/, double /*stopDate*/, std boost::shared_ptr lXAxis(_panel->getAxis(pSauvaud.getXAxisId())); boost::shared_ptr lYAxis(_panel->getAxis(pSauvaud.getYAxisId())); boost::shared_ptr lZAxis(_panel->getAxis(pSauvaud.getZAxisId())); + PlWindow lPlWindow; Range lXRange, lYRange, lZRange; @@ -2741,6 +2766,30 @@ void PanelPlotOutput::drawAdditionalObjects() { lXAxis->_additionalObjDrawn = true; lYAxis->_additionalObjDrawn = true; } + if (parameter.getSauvaudProperties() != nullptr) { + boost::shared_ptr lXAxis(_panel->getAxis(parameter.getSauvaudProperties()->getXAxisId())); + boost::shared_ptr lYAxis(_panel->getAxis(parameter.getSauvaudProperties()->getYAxisId())); + + if ((lXAxis == nullptr) || (lYAxis == nullptr)) + continue; + + Range lXRange = lXAxis->getRange(); + Range lYRange = lYAxis->getRange(); + + PlWindow lPlWindow = PlWindow(lXRange.getMin(), lXRange.getMax(), lYRange.getMin(), lYRange.getMax()); + + if (!lXAxis->_additionalObjDrawn) + drawXConstantLines (lXAxis, lPlWindow); + + if (!lYAxis->_additionalObjDrawn) + drawYConstantLines (lYAxis, lPlWindow); + + if (!lXAxis->_additionalObjDrawn || !lYAxis->_additionalObjDrawn) + drawTextPlots (lXAxis, lYAxis, lPlWindow, _panel->_textPlots); + + lXAxis->_additionalObjDrawn = true; + lYAxis->_additionalObjDrawn = true; + } } SeriesProperties lSeries; @@ -3116,6 +3165,68 @@ void PanelPlotOutput::createParameters(std::list& usedParametersId_ } } + + //For sauvaud if defined + std::shared_ptr pSauvaudProp = it->getSauvaudProperties(); + if (pSauvaudProp != nullptr) + { + AMDA::Info::ParamInfoSPtr paramInfo = AMDA::Info::ParamMgr::getInstance()->getParamInfoFromId(originalParam->getInfoId()); + boost::shared_ptr tableSPtr; + if (paramInfo != nullptr) + tableSPtr = paramInfo->getTable(pSauvaudProp->getRelatedDim()); + //get corrected sampling value in relation with max resolution + double correctedSamplingValue = getCorrectedSamplingValue(pSauvaudProp->getMaxResolution(), samplingValue); + AMDA::Parameters::ParameterSPtr usedParam; + + if (abs(samplingValue - correctedSamplingValue) > 1.) + { + //more than one second between samplingValue and correctedSamplingValue + //=> use resampling parameter + usedParam = createSampledParameter(originalParam, correctedSamplingValue); + if ((tableSPtr != nullptr) && tableSPtr->isVariable(&_parameterManager)) + { + for (std::map::iterator it = tableSPtr->getTableParams(&_parameterManager).begin(); it != tableSPtr->getTableParams(&_parameterManager).end(); ++it) + { + std::string tableParamKey = it->first; + std::string tableParamName = it->second; + + AMDA::Parameters::ParameterSPtr originalTableParam = _parameterManager.getParameter(tableParamName); + AMDA::Parameters::ParameterSPtr usedTableParam = createSampledParameter(originalTableParam, correctedSamplingValue); + pSauvaudProp->addTableParam(tableParamKey, usedTableParam->getId()); + } + } + } + else + { + //use original parameter + usedParam = originalParam; + if ((tableSPtr != nullptr) && tableSPtr->isVariable(&_parameterManager)) + { + for (std::map::iterator it = tableSPtr->getTableParams(&_parameterManager).begin(); it != tableSPtr->getTableParams(&_parameterManager).end(); ++it) + { + std::string tableParamKey = it->first; + std::string tableParamName = it->second; + + AMDA::Parameters::ParameterSPtr originalTableParam = _parameterManager.getParameter(tableParamName); + pSauvaudProp->addTableParam(tableParamKey, originalTableParam->getId()); + } + } + } + + //Add used parameter to parameters list + if (std::find (usedParametersId_.begin(),usedParametersId_.end(),usedParam->getId()) == usedParametersId_.end()) + usedParametersId_.push_back(usedParam->getId()); + pSauvaudProp->setParamId(usedParam->getId()); + //Add table parameters to parameters list + for (std::map::iterator it = pSauvaudProp->getTableParams().begin(); it != pSauvaudProp->getTableParams().end(); ++it) + { + std::string tableParamId = it->second; + + if (std::find (usedParametersId_.begin(),usedParametersId_.end(),tableParamId) == usedParametersId_.end()) + usedParametersId_.push_back(tableParamId); + } + + } //For intervals if defined std::shared_ptr pIntProp = it->getIntervalsProperties(); @@ -3218,6 +3329,30 @@ std::vector PanelPlotOutput::getParamUsed } } } + + //get indexes for spectro + std::shared_ptr pSauvaudProp = paramAxeIt->getSauvaudProperties(); + if (pSauvaudProp != nullptr) + { + if (pSauvaudProp->getParamId() == paramId) + { + if (pSauvaudProp->getIndexes().empty()) + { + //get used indexes by the spectro thanks to the index definition in the request + AMDA::Common::ParameterIndexComponentList indexList; + AMDA::Common::ParameterIndexesTool::parse(pSauvaudProp->getIndexDef(), + dim1Size, dim2Size, indexList); + pSauvaudProp->setIndexes(indexList); + } + + for (auto index : pSauvaudProp->getIndexes()) + { + if (std::find(indexes.begin(),indexes.end(),index) != indexes.end()) + continue; + indexes.push_back(index); + } + } + } //get indexes for intervals std::shared_ptr pIntProp = paramAxeIt->getIntervalsProperties(); diff --git a/src/ParamOutputImpl/Plot/ParamsNode.hh b/src/ParamOutputImpl/Plot/ParamsNode.hh index 51e8b87..0f19fae 100644 --- a/src/ParamOutputImpl/Plot/ParamsNode.hh +++ b/src/ParamOutputImpl/Plot/ParamsNode.hh @@ -16,6 +16,7 @@ #include "DrawingPropertiesNode.hh" #include "SeriesNode.hh" #include "SpectroNode.hh" +#include "SauvaudNode.hh" #include "IntervalsNode.hh" namespace plot { @@ -31,6 +32,8 @@ public: new SeriesNode()); getChildList()["spectro"] = AMDA::XMLConfigurator::NodeCfgSPtr( new SpectroNode()); + getChildList()["sauvaud"] = AMDA::XMLConfigurator::NodeCfgSPtr( + new SauvaudNode()); getChildList()["intervals"] = AMDA::XMLConfigurator::NodeCfgSPtr( new IntervalsNode()); getChildList()["colorserie"] = AMDA::XMLConfigurator::NodeCfgSPtr( diff --git a/src/ParamOutputImpl/Plot/PlotTools.hh b/src/ParamOutputImpl/Plot/PlotTools.hh new file mode 100644 index 0000000..775e446 --- /dev/null +++ b/src/ParamOutputImpl/Plot/PlotTools.hh @@ -0,0 +1,91 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ + +/* + * File: PlotTools.hh + * Author: hacene + * + * Created on January 7, 2022, 4:30 PM + */ + +#ifndef PLOTTOOLS_HH +#define PLOTTOOLS_HH + +#include"ParamTable.hh" +#include "Range.hh" +#include "Axis.hh" +namespace plot { + +class PlotTools{ +public: + PlotTools(){ + } + ~ PlotTools(){ + } + + static void configureAxisRangeFromTable(Range & lYAxisRange, boost::shared_ptr lYAxis,boost::shared_ptr leftTableSPtr) +{ + AMDA::Info::t_TableBound crtBound; + if (!tableSPtr->isVariable(&_parameterManager)) + { + for (int i = 0; i < parameterDimension; ++i) + { + crtBound = tableSPtr->getBound(&_parameterManager, i); + if (!std::isnan(crtBound.min)) + { + if (!((lYAxis->_scale == Axis::Scale::LOGARITHMIC) && (crtBound.min <= 0))) + lYAxisRange.setMin(std::min(crtBound.min, lYAxisRange.getMin())); + } + if (!std::isnan(crtBound.max)) + { + if (!((lYAxis->_scale == Axis::Scale::LOGARITHMIC) && (crtBound.max <= 0))) + lYAxisRange.setMax(std::max(crtBound.max, lYAxisRange.getMax())); + } + } + } + else + { + //Variable table => we need to loop under all records to find axis min & max values + for (int i = 0; i < (*_pParameterValues)[sauvaudPropertiesPtr->getParamId()].getSize(); ++i) + { + std::map> paramsTableData; + for (std::map::iterator it = sauvaudPropertiesPtr->getTableParams().begin(); it != sauvaudPropertiesPtr->getTableParams().end(); ++it) + { + ParameterData &data = (*_pParameterValues)[it->second]; + std::vector paramTableValues; + for (int j = 0; j < data.getDim1Size(); ++j) + { + if (i < data.getSize()) + { + double *values = data.getValues(AMDA::Common::ParameterIndexComponent(j), i); + paramTableValues.push_back((*values)); + } + } + paramsTableData[it->first] = paramTableValues; + } + for (int j = 0; j < parameterDimension; ++j) + { + crtBound = tableSPtr->getBound(&_parameterManager, j, ¶msTableData); + if (!std::isnan(crtBound.min)) + { + if (!((lYAxis->_scale == Axis::Scale::LOGARITHMIC) && (crtBound.min <= 0))) + lYAxisRange.setMin(std::min(crtBound.min, lYAxisRange.getMin())); + } + if (!std::isnan(crtBound.max)) + { + if (!((lYAxis->_scale == Axis::Scale::LOGARITHMIC) && (crtBound.max <= 0))) + lYAxisRange.setMax(std::max(crtBound.max, lYAxisRange.getMax())); + } + } + } + } + } + +}; +} + +#endif /* PLOTTOOLS_HH */ + diff --git a/src/ParamOutputImpl/Plot/SauvaudNode.hh b/src/ParamOutputImpl/Plot/SauvaudNode.hh index 4fd72d3..2f14791 100644 --- a/src/ParamOutputImpl/Plot/SauvaudNode.hh +++ b/src/ParamOutputImpl/Plot/SauvaudNode.hh @@ -47,7 +47,7 @@ namespace plot DrawingPropertiesNode::parseAttributes(pNode_, defaultProps); // spectro properties - std::shared_ptr spectroPropsPtr = + std::shared_ptr sauvaudPropsPtr = std::shared_ptr(new SauvaudProperties(defaultProps)); xmlChar *value = NULL; @@ -56,7 +56,7 @@ namespace plot value = xmlGetProp(pNode_, (const xmlChar *)"resolution"); if (value) { - spectroPropsPtr->setMaxResolution(atoi((const char *)value)); + sauvaudPropsPtr->setMaxResolution(atoi((const char *)value)); xmlFree(value); } @@ -64,12 +64,12 @@ namespace plot value = xmlGetProp(pNode_, (const xmlChar *)"index"); if (value) { - spectroPropsPtr->setIndexDef((const char *)value); + sauvaudPropsPtr->setIndexDef((const char *)value); xmlFree(value); } //set related dim - spectroPropsPtr->setRelatedDim(AMDA::Common::ParameterIndexesTool::getRelatedDimForTab2D(spectroPropsPtr->getIndexDef())); + sauvaudPropsPtr->setRelatedDim(AMDA::Common::ParameterIndexesTool::getRelatedDimForTab2D(sauvaudPropsPtr->getIndexDef())); // read uselog0asmin value = xmlGetProp(pNode_, (const xmlChar *)"uselog0asmin"); @@ -81,7 +81,7 @@ namespace plot std::istringstream is(strValue); bool uselog0asmin; is >> std::boolalpha >> uselog0asmin; - spectroPropsPtr->setUseLog0AsMin(uselog0asmin); + sauvaudPropsPtr->setUseLog0AsMin(uselog0asmin); xmlFree(value); } @@ -89,7 +89,7 @@ namespace plot value = xmlGetProp(pNode_, (const xmlChar *)"normalization"); if (value) { - spectroPropsPtr->setNormalization((const char *)value); + sauvaudPropsPtr->setNormalization((const char *)value); xmlFree(value); } @@ -100,11 +100,11 @@ namespace plot if (strcmp(valueString, BACKGROUND_SUB_TYPE_BY_CHANNEL) == 0) { - spectroPropsPtr->setBackgroundSubType(SauvaudProperties::BackgroundSubType::BYCHANNEL); + sauvaudPropsPtr->setBackgroundSubType(SauvaudProperties::BackgroundSubType::BYCHANNEL); } else if (strcmp(valueString, BACKGROUND_SUB_TYPE_BY_FIXED_VALUE) == 0) { - spectroPropsPtr->setBackgroundSubType(SauvaudProperties::BackgroundSubType::FIXEDVALUE); + sauvaudPropsPtr->setBackgroundSubType(SauvaudProperties::BackgroundSubType::FIXEDVALUE); } xmlFree(value); @@ -115,7 +115,7 @@ namespace plot { char *newValueBrut = (char *)value; double newValue = std::stod(newValueBrut); - spectroPropsPtr->setBackgroundSubValue(newValue); + sauvaudPropsPtr->setBackgroundSubValue(newValue); xmlFree(value); } //setRelatedDim @@ -124,11 +124,11 @@ namespace plot { char *newValueBrut = (char *)value; int newValue = std::stoi(newValueBrut); - spectroPropsPtr->setBackgroundSubDim(newValue); + sauvaudPropsPtr->setBackgroundSubDim(newValue); xmlFree(value); } // add spectro definition to parameter - plotOutput->getParameter((const char *)name).addSauvaudProperties(spectroPropsPtr); + plotOutput->getParameter((const char *)name).addSauvaudProperties(sauvaudPropsPtr); } }; diff --git a/src/ParamOutputImpl/Plot/SauvaudProperties.hh b/src/ParamOutputImpl/Plot/SauvaudProperties.hh index 1e39db2..c725f5b 100644 --- a/src/ParamOutputImpl/Plot/SauvaudProperties.hh +++ b/src/ParamOutputImpl/Plot/SauvaudProperties.hh @@ -14,27 +14,52 @@ #ifndef SAUVAUDPROPERTIES_HH #define SAUVAUDPROPERTIES_HH #include "SpectroProperties.hh" -namespace plot -{ -class SauvaudProperties: public SpectroProperties{ - -public: - SauvaudProperties() : SpectroProperties(){ - - } - - SauvaudProperties(const SpectroProperties& orig) : SpectroProperties(orig){ +namespace plot { + + class SauvaudProperties : public SpectroProperties { + public: + + SauvaudProperties() : SpectroProperties(),_rightDim(0),_hasYleftAxis(true) { + + } + + SauvaudProperties(const SpectroProperties& orig) : SpectroProperties(orig) { + + } + + SauvaudProperties(const SauvaudProperties& orig) : SpectroProperties(orig) { + + } + + virtual ~SauvaudProperties() { + + } + + int getRightDim() { + return _rightDim; + } + + void setRightDim(int dim) { + _rightDim = dim; + } + + bool hasYleftAxis() const { + return _hasYleftAxis; + } + + void setYAxis(bool hasYAxis) { + _hasYleftAxis = hasYAxis; + } - } - - SauvaudProperties(const SauvaudProperties& orig) : SpectroProperties(orig){ + private: - } - virtual ~SauvaudProperties(){ + /***/ + int _rightDim; + + bool _hasYleftAxis; - } + }; -}; } /* namespace plot */ #endif /* SAUVAUDPROPERTIES_HH */ diff --git a/src/ParamOutputImpl/Plot/Time/TimePlot.cc b/src/ParamOutputImpl/Plot/Time/TimePlot.cc index a58e858..2518bb3 100644 --- a/src/ParamOutputImpl/Plot/Time/TimePlot.cc +++ b/src/ParamOutputImpl/Plot/Time/TimePlot.cc @@ -24,6 +24,7 @@ #include #include #include +#include "PlotTools.hh" #include #include @@ -481,6 +482,7 @@ namespace plot LOG4CXX_DEBUG(gLogger, "Sauvaud Y axis is " << sauvaudPropertiesPtr->getYAxisId()); boost::shared_ptr lYAxis = _panel->getAxis(sauvaudPropertiesPtr->getYAxisId()); + boost::shared_ptr lYleftAxis = _panel->getAxis(sauvaudPropertiesPtr->getYleftAxisId()); if (lYAxis.get() == nullptr) { std::stringstream lError; @@ -490,6 +492,17 @@ namespace plot } lYAxis->_used = true; + + if (lYleftAxis.get() == nullptr) + { + std::stringstream lError; + lError << "TimePlot::configureSauvaudAxis" + << ": Y left axis with id '" << sauvaudPropertiesPtr->getYAxisId() << "' not found."; + BOOST_THROW_EXCEPTION(PanelPlotOutputException() << AMDA::ex_msg(lError.str())); + } + + lYleftAxis->_used = true; + //set Z axis range boost::shared_ptr lZAxis = _panel->getAxis(sauvaudPropertiesPtr->getZAxisId()); @@ -520,90 +533,23 @@ namespace plot if (isnan(lYAxisRequestRange.getMin()) && isnan(lYAxisRequestRange.getMax())) { - boost::shared_ptr tableSPtr; - if (paramInfo != nullptr) - tableSPtr = paramInfo->getTable(sauvaudPropertiesPtr->getRelatedDim()); - - if (tableSPtr == nullptr){ - // look for unique embedded table - boost::shared_ptr linkedTableSPtr; - int counter = 0; - for (auto pInfo :paramInfo->getLinkedParamList()){ - linkedTableSPtr = AMDA::Info::ParamMgr::getInstance()->getParamInfoFromId(pInfo)->getTable(sauvaudPropertiesPtr->getRelatedDim()); - if (linkedTableSPtr == nullptr) - continue; - counter ++; - } - if(linkedTableSPtr == nullptr || counter !=1){ - LOG4CXX_DEBUG(gLogger, "table cannot be defined from linked info params"); - }else{ - tableSPtr = linkedTableSPtr; - } + boost::shared_ptr rightTableSPtr; + boost::shared_ptr leftTableSPtr; + if (paramInfo != nullptr){ + int rightDim = pSauvaud.getRightDim(); + int leftDim = (rightDim ==0) ? 1 :0; + rightTableSPtr = paramInfo->getTable(rightDim); + leftTableSPtr = paramInfo->getTable(leftDim); + } - - if (tableSPtr == nullptr) + if (rightTableSPtr == nullptr) { LOG4CXX_DEBUG(gLogger, "No table defined => use index"); lYAxisRange.setMin(std::min(0., lYAxisRange.getMin())); lYAxisRange.setMax(std::max((double)parameterDimension, lYAxisRange.getMax())); } else - { - AMDA::Info::t_TableBound crtBound; - if (!tableSPtr->isVariable(&_parameterManager)) - { - for (int i = 0; i < parameterDimension; ++i) - { - crtBound = tableSPtr->getBound(&_parameterManager, i); - if (!std::isnan(crtBound.min)) - { - if (!((lYAxis->_scale == Axis::Scale::LOGARITHMIC) && (crtBound.min <= 0))) - lYAxisRange.setMin(std::min(crtBound.min, lYAxisRange.getMin())); - } - if (!std::isnan(crtBound.max)) - { - if (!((lYAxis->_scale == Axis::Scale::LOGARITHMIC) && (crtBound.max <= 0))) - lYAxisRange.setMax(std::max(crtBound.max, lYAxisRange.getMax())); - } - } - } - else - { - //Variable table => we need to loop under all records to find axis min & max values - for (int i = 0; i < (*_pParameterValues)[sauvaudPropertiesPtr->getParamId()].getSize(); ++i) - { - std::map> paramsTableData; - for (std::map::iterator it = sauvaudPropertiesPtr->getTableParams().begin(); it != sauvaudPropertiesPtr->getTableParams().end(); ++it) - { - ParameterData &data = (*_pParameterValues)[it->second]; - std::vector paramTableValues; - for (int j = 0; j < data.getDim1Size(); ++j) - { - if (i < data.getSize()) - { - double *values = data.getValues(AMDA::Common::ParameterIndexComponent(j), i); - paramTableValues.push_back((*values)); - } - } - paramsTableData[it->first] = paramTableValues; - } - for (int j = 0; j < parameterDimension; ++j) - { - crtBound = tableSPtr->getBound(&_parameterManager, j, ¶msTableData); - if (!std::isnan(crtBound.min)) - { - if (!((lYAxis->_scale == Axis::Scale::LOGARITHMIC) && (crtBound.min <= 0))) - lYAxisRange.setMin(std::min(crtBound.min, lYAxisRange.getMin())); - } - if (!std::isnan(crtBound.max)) - { - if (!((lYAxis->_scale == Axis::Scale::LOGARITHMIC) && (crtBound.max <= 0))) - lYAxisRange.setMax(std::max(crtBound.max, lYAxisRange.getMax())); - } - } - } - } - } + PlotTools::configureAxisRangeFromTable(lYAxisRange,lYAxis, rightTableSPtr ); } //do not extend the axis @@ -1381,59 +1327,41 @@ namespace plot ParameterData &data = (*_pParameterValues)[pSauvaud.getParamId()]; - boost::shared_ptr tableSPtr; + boost::shared_ptr rightTableSPtr; + boost::shared_ptr leftTableSPtr; AMDA::Info::ParamInfoSPtr paramInfo = AMDA::Info::ParamMgr::getInstance()->getParamInfoFromId(p->getInfoId()); - if (paramInfo != nullptr) - tableSPtr = paramInfo->getTable(pSauvaud.getRelatedDim()); - - if (tableSPtr == nullptr){ - boost::shared_ptr linkedTableSPtr; - int counter = 0; - // work on this - for (auto pInfo :paramInfo->getLinkedParamList()){ - linkedTableSPtr = AMDA::Info::ParamMgr::getInstance()->getParamInfoFromId(pInfo)->getTable(pSauvaud.getRelatedDim()); - if (linkedTableSPtr == nullptr) - continue; - counter ++; - } - if(linkedTableSPtr == nullptr || counter !=1){ - LOG4CXX_DEBUG(gLogger, "table cannot be defined from linked info params"); - }else{ - tableSPtr = linkedTableSPtr; - } - } - + if (paramInfo != nullptr){ + int rightDim = pSauvaud.getRightDim(); + int leftDim = (rightDim ==0) ? 1 :0; + rightTableSPtr = paramInfo->getTable(rightDim); + leftTableSPtr = paramInfo->getTable(leftDim); + } + //get axis boost::shared_ptr lXAxis = _panel->getAxis(pSauvaud.getXAxisId()); boost::shared_ptr lYAxis = _panel->getAxis(pSauvaud.getYAxisId()); + boost::shared_ptr lYAxis = _panel->getAxis(pSauvaud.getYleftAxisId()); boost::shared_ptr lZAxis = _panel->getColorAxis(); + + int dim1Size = data.getDim1Size() ; + + int dim2Size = data.getDim2Size() ; - //Check dimensions - if (pSauvaud.getRelatedDim() == 0) - { - if (data.getDim1Size() + 1 <= 0) - { - LOG4CXX_INFO(gLogger, "TimePlot::drawSauvaud - No data to plot"); - return; - } - } - else - { - if (data.getDim2Size() + 1 <= 0) - { - LOG4CXX_INFO(gLogger, "TimePlot::drawSauvaud - No data to plot"); - return; - } - } + + if ( dim1Size < 0 && dim2Size<0 ) + { + LOG4CXX_INFO(gLogger, "TimePlot::drawSauvaud - No data to plot"); + return; + } LOG4CXX_DEBUG(gLogger, "TimePlot::drawSauvaud - Build data grid"); - SauvaudGrid sauvaudGrid; + MatrixGrid matrixGrid; //get specific colors for min / max values Color minValColor = lZAxis->getMinValColor(); Color maxValColor = lZAxis->getMaxValColor(); - if ((tableSPtr == nullptr) || !tableSPtr->isVariable(&_parameterManager)) + if ((rightTableSPtr == nullptr) || !rightTableSPtr->isVariable(&_parameterManager)) { int startIndex; int nbValues; @@ -1441,7 +1369,7 @@ namespace plot for (auto index : pSauvaud.getIndexes()) { GridPart part; - if (tableSPtr == nullptr) + if ( rightTableSPtr== nullptr) { if (pSauvaud.getRelatedDim() == 0) part.y[0] = index.getDim1Index(); @@ -1453,9 +1381,9 @@ namespace plot { AMDA::Info::t_TableBound crtBound; if (pSauvaud.getRelatedDim() == 0) - crtBound = tableSPtr->getBound(&_parameterManager, index.getDim1Index()); + crtBound = rightTableSPtr->getBound(&_parameterManager, index.getDim1Index()); else - crtBound = tableSPtr->getBound(&_parameterManager, index.getDim2Index()); + crtBound = rightTableSPtr->getBound(&_parameterManager, index.getDim2Index()); if (std::isnan(crtBound.min) || std::isnan(crtBound.max)) continue; part.y[0] = crtBound.min; @@ -1501,7 +1429,7 @@ namespace plot std::string normalization = pSauvaud.getNormalization(); if (!normalization.empty()) normalize(matrixGrid, normalization); - draw2DMatrix(matrixGrid, pSauvaud.getMin(), pSauvaud.getMax(), + drawMatrix(matrixGrid, pSauvaud.getMin(), pSauvaud.getMax(), minValColor, maxValColor, lZAxis->_color._colorMapIndex, pSauvaud.getUseLog0AsMin()); matrixGrid.clear(); } @@ -1540,9 +1468,9 @@ namespace plot part.value = data.getValues(index, startIndex)[i]; if (pSauvaud.getRelatedDim() == 0) - crtBound = tableSPtr->getBound(&_parameterManager, index.getDim1Index(), ¶msTableData); + crtBound = rightTableSPtr->getBound(&_parameterManager, index.getDim1Index(), ¶msTableData); else - crtBound = tableSPtr->getBound(&_parameterManager, index.getDim2Index(), ¶msTableData); + crtBound = rightTableSPtr->getBound(&_parameterManager, index.getDim2Index(), ¶msTableData); part.y[0] = crtBound.min; part.y[1] = crtBound.max; diff --git a/src/ParamOutputImpl/Plot/Time/TimePlot.hh b/src/ParamOutputImpl/Plot/Time/TimePlot.hh index 3832a69..fab3428 100644 --- a/src/ParamOutputImpl/Plot/Time/TimePlot.hh +++ b/src/ParamOutputImpl/Plot/Time/TimePlot.hh @@ -119,6 +119,10 @@ namespace 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); + /** * @overload PanelPlotOutput::drawIntervals(double startDate, double stopDate, std::string pParamId, IntervalsProperties& pIntervals) -- libgit2 0.21.2