From dd42b8f4b5822d07fa4c52404344152716e883d5 Mon Sep 17 00:00:00 2001 From: Furkan Date: Tue, 26 Mar 2024 13:02:27 +0000 Subject: [PATCH] #7857 - Done --- src/ParamOutputImpl/Plot/AxisLegendManager.cc | 38 +++++++++++++++++++++++++------------- src/ParamOutputImpl/Plot/AxisLegendManager.hh | 2 +- src/ParamOutputImpl/Plot/InstantPlot/InstantPlot.cc | 4 +++- 3 files changed, 29 insertions(+), 15 deletions(-) diff --git a/src/ParamOutputImpl/Plot/AxisLegendManager.cc b/src/ParamOutputImpl/Plot/AxisLegendManager.cc index 10dd1b8..a7c2661 100644 --- a/src/ParamOutputImpl/Plot/AxisLegendManager.cc +++ b/src/ParamOutputImpl/Plot/AxisLegendManager.cc @@ -13,7 +13,8 @@ namespace plot { // Build list of all indexes used by each parameters for each x axes std::map axesParamsComponents; - + // Keep an order of the legends + std::vector insertionOrder; // Compute nb series to draw by y axis std::map nbSeriesByYAxisMap = plot->getNbSeriesByYAxis(); @@ -53,6 +54,7 @@ namespace plot compLegendColor = pHistogramProperties->getColor(); ParameterIndexComponentColor xIndex = ParameterIndexComponentColor(xIndexComp, compLegendColor); pushComponentInList(xParamId, xIndex, axesParamsComponents[xAxisId]); + insertionOrder.push_back(xParamId); } } @@ -83,6 +85,7 @@ namespace plot ParameterIndexComponentColor xIndex = ParameterIndexComponentColor(xSerie.getIndex(), compLegendColor); pushComponentInList(xSerie.getParamId(), xIndex, axesParamsComponents[xAxisId]); + insertionOrder.push_back(xSerie.getParamId()); } } @@ -95,7 +98,7 @@ namespace plot for (auto axisParamsComponents : axesParamsComponents) { boost::shared_ptr lXAxis = plot->_panel->getAxis(axisParamsComponents.first); - setAxisLegendForSeries(plot, lXAxis, axisParamsComponents.second); + setAxisLegendForSeries(plot, lXAxis, axisParamsComponents.second, insertionOrder); } } @@ -136,6 +139,9 @@ namespace plot std::map axesParamsComponents; std::map axesHistoParamsComponents; std::map yAxisTextLegendHisto; + + // Keeping the order of the legends + std::vector insertionOrder; if (!plot->_panel->_page->_superposeMode) { plot->resetAutomaticSerieColorCursor(); @@ -179,6 +185,7 @@ namespace plot compLegendColor = pHistogramProperties->getColor(); ParameterIndexComponentColor yIndex = ParameterIndexComponentColor(yIndexComp, compLegendColor); pushComponentInList(yParamId, yIndex, axesHistoParamsComponents[yAxisId]); + insertionOrder.push_back(yParamId); } } for (auto lSeriesProperties : param.getYSeriePropertiesList()) @@ -203,7 +210,9 @@ namespace plot compLegendColor = plot->getSerieLineColor(lSeriesProperties, moreThanOneSerieForAxis); } ParameterIndexComponentColor yIndex = ParameterIndexComponentColor(index, compLegendColor); + std::cout << " --- " < lYAxis = plot->_panel->getAxis(axisParamsComponents.first); - setAxisLegendForSeries(plot, lYAxis, axisParamsComponents.second,yAxisTextLegend); + setAxisLegendForSeries(plot, lYAxis, axisParamsComponents.second,insertionOrder, yAxisTextLegend); } for (auto axisHistoParamsComponents : axesHistoParamsComponents) { boost::shared_ptr lYAxis = plot->_panel->getAxis(axisHistoParamsComponents.first); - setAxisLegendForSeries(plot, lYAxis, axisHistoParamsComponents.second, yAxisTextLegendHisto[axisHistoParamsComponents.first] ); + setAxisLegendForSeries(plot, lYAxis, axisHistoParamsComponents.second, insertionOrder, yAxisTextLegendHisto[axisHistoParamsComponents.first] ); } } @@ -241,6 +250,7 @@ namespace plot // Build list of all indexes used by each parameters for each y axes AxisParamsComponents axisParamsComponents; + std::vector insertionOrder; for (auto param : plot->_parameterAxesList) { for (auto pHistogramProperties : param.getHistogramSeriesPropertiesList()) @@ -265,6 +275,7 @@ namespace plot if (pHistogramProperties->getHistotypeProperties().getIndex() > -1) colorSerieIndex = ParameterIndexComponentColor(pHistogramProperties->getHistotypeProperties().getIndex(), -1, lZAxis->_color); pushComponentInList(pHistogramProperties->getHistotypeProperties().getParamId(), colorSerieIndex, axisParamsComponents); + insertionOrder.push_back(pHistogramProperties->getHistotypeProperties().getParamId()); } } for (auto lSeriesProperties : param.getYSeriePropertiesList()) @@ -289,10 +300,11 @@ namespace plot if (lColorSerieProperties.getIndex() > -1) colorSerieIndex = ParameterIndexComponentColor(lColorSerieProperties.getIndex(), -1, lZAxis->_color); pushComponentInList(lColorSerieProperties.getColorParamIds()[yParamId], colorSerieIndex, axisParamsComponents); + insertionOrder.push_back(lColorSerieProperties.getColorParamIds()[yParamId]); } } - setAxisLegendForSeries(plot, lZAxis, axisParamsComponents, zAxisTextLegend); + setAxisLegendForSeries(plot, lZAxis, axisParamsComponents, insertionOrder,zAxisTextLegend); } void AxisLegendManager::configureColorAxisLegendForSpectro( @@ -364,7 +376,7 @@ namespace plot } void AxisLegendManager::setAxisLegendForSeries(PanelPlotOutput *plot, boost::shared_ptr &pAxis, AxisParamsComponents &axisParamsComponents, - std::string legendPrefix) + std::vector insertionOrder, std::string legendPrefix) { if (pAxis == nullptr || !pAxis->_legend.isEmpty()) { @@ -374,21 +386,21 @@ namespace plot // Retrieve ParamInfo Manager ParamMgr *piMgr = ParamMgr::getInstance(); - for (auto paramsComponents : axisParamsComponents) + for (auto paramsComponents : insertionOrder) { - ParameterSPtr p = plot->_parameterManager.getParameter(paramsComponents.first); + ParameterSPtr p = plot->_parameterManager.getParameter(paramsComponents); if (p == nullptr) continue; ParamInfoSPtr paramInfo = piMgr->getParamInfoFromId(p->getInfoId()); - if (paramsComponents.second.size() == p->getDataWriterTemplate()->getParamData()->getDim1() * p->getDataWriterTemplate()->getParamData()->getDim2()) + if (axisParamsComponents[paramsComponents].size() == p->getDataWriterTemplate()->getParamData()->getDim1() * p->getDataWriterTemplate()->getParamData()->getDim2()) { // All components of this parameter are used by this axis => merge - Color color = paramsComponents.second.front().getColor(); - paramsComponents.second.clear(); - paramsComponents.second.push_back(ParameterIndexComponentColor(-1, -1, color)); + Color color = axisParamsComponents[paramsComponents].front().getColor(); + axisParamsComponents[paramsComponents].clear(); + axisParamsComponents[paramsComponents].push_back(ParameterIndexComponentColor(-1, -1, color)); } bool isFirstComponent = true; - for (auto components : paramsComponents.second) + for (auto components : axisParamsComponents[paramsComponents]) { if (paramInfo == nullptr) continue; diff --git a/src/ParamOutputImpl/Plot/AxisLegendManager.hh b/src/ParamOutputImpl/Plot/AxisLegendManager.hh index e52207a..aae14d1 100644 --- a/src/ParamOutputImpl/Plot/AxisLegendManager.hh +++ b/src/ParamOutputImpl/Plot/AxisLegendManager.hh @@ -75,7 +75,7 @@ namespace plot static void configureXAxisLegendForSeries(PanelPlotOutput *plot); - static void setAxisLegendForSeries(PanelPlotOutput *plot, boost::shared_ptr &pAxis, AxisParamsComponents &axisParamsComponents, std::string legendPrefix=""); + static void setAxisLegendForSeries(PanelPlotOutput *plot, boost::shared_ptr &pAxis, AxisParamsComponents &axisParamsComponents, std::vector insertionOrder, std::string legendPrefix=""); static void setAxisLegendForSpectro(PanelPlotOutput *plot, boost::shared_ptr &pAxis, std::string originalParamId); diff --git a/src/ParamOutputImpl/Plot/InstantPlot/InstantPlot.cc b/src/ParamOutputImpl/Plot/InstantPlot/InstantPlot.cc index 6ec9668..8787ff5 100644 --- a/src/ParamOutputImpl/Plot/InstantPlot/InstantPlot.cc +++ b/src/ParamOutputImpl/Plot/InstantPlot/InstantPlot.cc @@ -968,8 +968,10 @@ void InstantPlot::configureDataAxisLegend(boost::shared_ptr axisSPtr, bool else { AxisLegendManager::AxisParamsComponents axisParamsComponents; + std::vector insertionOrder; axisParamsComponents[_originalParamId].push_back(ParameterIndexComponentColor(-1,-1, axisSPtr->_color)); - AxisLegendManager::setAxisLegendForSeries(this, axisSPtr, axisParamsComponents); + insertionOrder.push_back(_originalParamId); + AxisLegendManager::setAxisLegendForSeries(this, axisSPtr, axisParamsComponents, insertionOrder); } } -- libgit2 0.21.2