From 46858100de6f31fbd111f82a883cad1b55f2bd0c Mon Sep 17 00:00:00 2001 From: Benjamin Renard Date: Fri, 17 May 2019 11:20:23 +0200 Subject: [PATCH] Tickplot: Add mission name and frame --- src/ParamOutputImpl/Plot/TickPlot/TickMarkDecorator.cc | 54 ++++++++++++++++++++++++++++++++++++++++++++++-------- src/ParamOutputImpl/Plot/TickPlot/TickMarkDecorator.hh | 11 ++++++----- 2 files changed, 52 insertions(+), 13 deletions(-) diff --git a/src/ParamOutputImpl/Plot/TickPlot/TickMarkDecorator.cc b/src/ParamOutputImpl/Plot/TickPlot/TickMarkDecorator.cc index a54ef92..139e234 100644 --- a/src/ParamOutputImpl/Plot/TickPlot/TickMarkDecorator.cc +++ b/src/ParamOutputImpl/Plot/TickPlot/TickMarkDecorator.cc @@ -56,7 +56,6 @@ TickMarkDecorator& TickMarkDecorator::operator=(const TickMarkDecorator& ref_) { } else { _pTimeInfo->_timeFormat = ref_._pTimeInfo->_timeFormat; _pTimeInfo->_timeTitle = ref_._pTimeInfo->_timeTitle; - _pTimeInfo->_isFirstLabel = ref_._pTimeInfo->_isFirstLabel; _pTimeInfo->_maxLen = ref_._pTimeInfo->_maxLen; } _seriesInfoList = ref_._seriesInfoList; @@ -281,6 +280,12 @@ void TickMarkDecorator::draw(PanelPlotOutput* pplot_, Axis* axis_, LOG4CXX_TRACE(_logger, " virtual axis ["<slabelfunc(generateYLabel, _seriesInfoList[i].get()); + if (!_seriesInfoList[i]->_description.empty()) { + // draw additionnal description + drawVirtualAxis(yDelta * dir, yInc, _seriesInfoList[i]->_description.c_str(), 0, 0, "", pls_); + // increment offset + yDelta = yDelta + yInc; + } // draw virtual axis drawVirtualAxis(yDelta * dir, yInc, _seriesInfoList[i]->_name.c_str(), xtick, nxsub, options.c_str(), pls_); // increment offset @@ -327,7 +332,6 @@ void TickMarkDecorator::installLabelGenerator(PanelPlotOutput* /*pplot_*/, TimeA // install time format _pTimeInfo->_timeFormat = getPlFormat(); _pTimeInfo->_timeTitle = timeAxis_->_legend.getText(); - _pTimeInfo->_isFirstLabel = true; unsigned int maxNameLen = _pTimeInfo->_timeTitle.size(); // init maximum value len with formatted time : @@ -348,19 +352,18 @@ void TickMarkDecorator::installLabelGenerator(PanelPlotOutput* /*pplot_*/, TimeA const std::string name = p._originalParamId; LOG4CXX_DEBUG(_logger, " inspecting parameter : " << name); for(auto lSeriesProperties : p.getYSeriePropertiesList()) { + bool isFirstIndex = true; for (auto index : lSeriesProperties.getIndexList(_pParameterValues)) { boost::shared_ptr pSerie = boost::shared_ptr(new SeriesInfo()); + AMDA::Parameters::ParameterSPtr param = _decoratorPlot->_parameterManager.getParameter(lSeriesProperties.getParamId()); AMDA::Info::ParamMgr* piMgr = AMDA::Info::ParamMgr::getInstance(); - AMDA::Info::ParamInfoSPtr paramInfo = piMgr->getParamInfoFromId(lSeriesProperties.getParamId()); + AMDA::Info::ParamInfoSPtr paramInfo = piMgr->getParamInfoFromId(param->getInfoId()); std::ostringstream osstr; bool skipIndex = false; - if (paramInfo == nullptr) { - osstr << name; - } - else { + if (paramInfo != nullptr) { if (paramInfo->getComponents(index).empty() == false) { osstr << paramInfo->getComponents(index); skipIndex = true; @@ -370,6 +373,10 @@ void TickMarkDecorator::installLabelGenerator(PanelPlotOutput* /*pplot_*/, TimeA } } + if (osstr.str().empty()) { + osstr << name; + } + if (!skipIndex) { if(index.getDim1Index() != -1){ osstr << "[" << index.getDim1Index() ; @@ -390,7 +397,37 @@ void TickMarkDecorator::installLabelGenerator(PanelPlotOutput* /*pplot_*/, TimeA if (pSerie->_name.size() > maxNameLen) { maxNameLen = pSerie->_name.size(); } - pSerie->_isFirstLabel = true; + + if (isFirstIndex) { + std::string description; + if (paramInfo != nullptr) { + description = paramInfo->getInstrumentId(); + if (!description.empty()) { + if (description.find('_') != std::string::npos) { + description = description.substr(0, description.find('_')); + } + std::transform(description.begin(), description.end(), description.begin(), ::toupper); + } + else { + description = paramInfo->getShortName(); + } + } + + if ((index.getDim1Index() != -1) || (index.getDim2Index() != -1)) { + if (description.empty()) { + description = name; + } + if ((paramInfo != nullptr) && (paramInfo->getCoordinatesSystem().empty() == false)) { + description += ", "; + description += paramInfo->getCoordinatesSystem(); + } + } + pSerie->_description = description; + if (pSerie->_description.size() > maxNameLen) { + maxNameLen = pSerie->_description.size(); + } + } + pSerie->_valuesFormat = getValuesFormat(); //Compute max len @@ -403,6 +440,7 @@ void TickMarkDecorator::installLabelGenerator(PanelPlotOutput* /*pplot_*/, TimeA } _seriesInfoList.push_back(pSerie); + isFirstIndex = false; } } } diff --git a/src/ParamOutputImpl/Plot/TickPlot/TickMarkDecorator.hh b/src/ParamOutputImpl/Plot/TickPlot/TickMarkDecorator.hh index 8434e41..6dea1b4 100644 --- a/src/ParamOutputImpl/Plot/TickPlot/TickMarkDecorator.hh +++ b/src/ParamOutputImpl/Plot/TickPlot/TickMarkDecorator.hh @@ -28,6 +28,12 @@ struct SeriesInfo{ * @brief name of that series (i.e. name of parameter and index if not a scalar parameter). */ std::string _name; + + /** + * @brief description + */ + std::string _description; + /** * @brief maximum len for name. */ @@ -42,11 +48,6 @@ struct SeriesInfo{ unsigned int _maxValueLen; /** - * @brief to know if it's the first label to draw - */ - bool _isFirstLabel; - - /** * @brief link to the parameter data */ ParameterData* _parameterData; -- libgit2 0.21.2