Commit dd42b8f4b5822d07fa4c52404344152716e883d5

Authored by Erdogan Furkan
1 parent 0e6678fa

#7857 - Done

src/ParamOutputImpl/Plot/AxisLegendManager.cc
... ... @@ -13,7 +13,8 @@ namespace plot
13 13 {
14 14 // Build list of all indexes used by each parameters for each x axes
15 15 std::map<std::string, AxisParamsComponents> axesParamsComponents;
16   -
  16 + // Keep an order of the legends
  17 + std::vector<std::string> insertionOrder;
17 18 // Compute nb series to draw by y axis
18 19 std::map<std::string, int> nbSeriesByYAxisMap = plot->getNbSeriesByYAxis();
19 20  
... ... @@ -53,6 +54,7 @@ namespace plot
53 54 compLegendColor = pHistogramProperties->getColor();
54 55 ParameterIndexComponentColor xIndex = ParameterIndexComponentColor(xIndexComp, compLegendColor);
55 56 pushComponentInList(xParamId, xIndex, axesParamsComponents[xAxisId]);
  57 + insertionOrder.push_back(xParamId);
56 58 }
57 59 }
58 60  
... ... @@ -83,6 +85,7 @@ namespace plot
83 85  
84 86 ParameterIndexComponentColor xIndex = ParameterIndexComponentColor(xSerie.getIndex(), compLegendColor);
85 87 pushComponentInList(xSerie.getParamId(), xIndex, axesParamsComponents[xAxisId]);
  88 + insertionOrder.push_back(xSerie.getParamId());
86 89 }
87 90 }
88 91  
... ... @@ -95,7 +98,7 @@ namespace plot
95 98 for (auto axisParamsComponents : axesParamsComponents)
96 99 {
97 100 boost::shared_ptr<Axis> lXAxis = plot->_panel->getAxis(axisParamsComponents.first);
98   - setAxisLegendForSeries(plot, lXAxis, axisParamsComponents.second);
  101 + setAxisLegendForSeries(plot, lXAxis, axisParamsComponents.second, insertionOrder);
99 102 }
100 103 }
101 104  
... ... @@ -136,6 +139,9 @@ namespace plot
136 139 std::map<std::string, AxisParamsComponents> axesParamsComponents;
137 140 std::map<std::string, AxisParamsComponents> axesHistoParamsComponents;
138 141 std::map<std::string,std::string> yAxisTextLegendHisto;
  142 +
  143 + // Keeping the order of the legends
  144 + std::vector<std::string> insertionOrder;
139 145 if (!plot->_panel->_page->_superposeMode)
140 146 {
141 147 plot->resetAutomaticSerieColorCursor();
... ... @@ -179,6 +185,7 @@ namespace plot
179 185 compLegendColor = pHistogramProperties->getColor();
180 186 ParameterIndexComponentColor yIndex = ParameterIndexComponentColor(yIndexComp, compLegendColor);
181 187 pushComponentInList(yParamId, yIndex, axesHistoParamsComponents[yAxisId]);
  188 + insertionOrder.push_back(yParamId);
182 189 }
183 190 }
184 191 for (auto lSeriesProperties : param.getYSeriePropertiesList())
... ... @@ -203,7 +210,9 @@ namespace plot
203 210 compLegendColor = plot->getSerieLineColor(lSeriesProperties, moreThanOneSerieForAxis);
204 211 }
205 212 ParameterIndexComponentColor yIndex = ParameterIndexComponentColor(index, compLegendColor);
  213 + std::cout << " --- " <<lSeriesProperties.getParamId() << std::endl;
206 214 pushComponentInList(lSeriesProperties.getParamId(), yIndex, axesParamsComponents[yAxisId]);
  215 + insertionOrder.push_back(lSeriesProperties.getParamId());
207 216 }
208 217 }
209 218 }
... ... @@ -216,12 +225,12 @@ namespace plot
216 225 for (auto axisParamsComponents : axesParamsComponents)
217 226 {
218 227 boost::shared_ptr<Axis> lYAxis = plot->_panel->getAxis(axisParamsComponents.first);
219   - setAxisLegendForSeries(plot, lYAxis, axisParamsComponents.second,yAxisTextLegend);
  228 + setAxisLegendForSeries(plot, lYAxis, axisParamsComponents.second,insertionOrder, yAxisTextLegend);
220 229 }
221 230 for (auto axisHistoParamsComponents : axesHistoParamsComponents)
222 231 {
223 232 boost::shared_ptr<Axis> lYAxis = plot->_panel->getAxis(axisHistoParamsComponents.first);
224   - setAxisLegendForSeries(plot, lYAxis, axisHistoParamsComponents.second, yAxisTextLegendHisto[axisHistoParamsComponents.first] );
  233 + setAxisLegendForSeries(plot, lYAxis, axisHistoParamsComponents.second, insertionOrder, yAxisTextLegendHisto[axisHistoParamsComponents.first] );
225 234  
226 235 }
227 236 }
... ... @@ -241,6 +250,7 @@ namespace plot
241 250  
242 251 // Build list of all indexes used by each parameters for each y axes
243 252 AxisParamsComponents axisParamsComponents;
  253 + std::vector<std::string> insertionOrder;
244 254 for (auto param : plot->_parameterAxesList)
245 255 {
246 256 for (auto pHistogramProperties : param.getHistogramSeriesPropertiesList())
... ... @@ -265,6 +275,7 @@ namespace plot
265 275 if (pHistogramProperties->getHistotypeProperties().getIndex() > -1)
266 276 colorSerieIndex = ParameterIndexComponentColor(pHistogramProperties->getHistotypeProperties().getIndex(), -1, lZAxis->_color);
267 277 pushComponentInList(pHistogramProperties->getHistotypeProperties().getParamId(), colorSerieIndex, axisParamsComponents);
  278 + insertionOrder.push_back(pHistogramProperties->getHistotypeProperties().getParamId());
268 279 }
269 280 }
270 281 for (auto lSeriesProperties : param.getYSeriePropertiesList())
... ... @@ -289,10 +300,11 @@ namespace plot
289 300 if (lColorSerieProperties.getIndex() > -1)
290 301 colorSerieIndex = ParameterIndexComponentColor(lColorSerieProperties.getIndex(), -1, lZAxis->_color);
291 302 pushComponentInList(lColorSerieProperties.getColorParamIds()[yParamId], colorSerieIndex, axisParamsComponents);
  303 + insertionOrder.push_back(lColorSerieProperties.getColorParamIds()[yParamId]);
292 304 }
293 305 }
294 306  
295   - setAxisLegendForSeries(plot, lZAxis, axisParamsComponents, zAxisTextLegend);
  307 + setAxisLegendForSeries(plot, lZAxis, axisParamsComponents, insertionOrder,zAxisTextLegend);
296 308 }
297 309  
298 310 void AxisLegendManager::configureColorAxisLegendForSpectro(
... ... @@ -364,7 +376,7 @@ namespace plot
364 376 }
365 377  
366 378 void AxisLegendManager::setAxisLegendForSeries(PanelPlotOutput *plot, boost::shared_ptr<Axis> &pAxis, AxisParamsComponents &axisParamsComponents,
367   - std::string legendPrefix)
  379 + std::vector<std::string> insertionOrder, std::string legendPrefix)
368 380 {
369 381 if (pAxis == nullptr || !pAxis->_legend.isEmpty())
370 382 {
... ... @@ -374,21 +386,21 @@ namespace plot
374 386 // Retrieve ParamInfo Manager
375 387 ParamMgr *piMgr = ParamMgr::getInstance();
376 388  
377   - for (auto paramsComponents : axisParamsComponents)
  389 + for (auto paramsComponents : insertionOrder)
378 390 {
379   - ParameterSPtr p = plot->_parameterManager.getParameter(paramsComponents.first);
  391 + ParameterSPtr p = plot->_parameterManager.getParameter(paramsComponents);
380 392 if (p == nullptr)
381 393 continue;
382 394 ParamInfoSPtr paramInfo = piMgr->getParamInfoFromId(p->getInfoId());
383   - if (paramsComponents.second.size() == p->getDataWriterTemplate()->getParamData()->getDim1() * p->getDataWriterTemplate()->getParamData()->getDim2())
  395 + if (axisParamsComponents[paramsComponents].size() == p->getDataWriterTemplate()->getParamData()->getDim1() * p->getDataWriterTemplate()->getParamData()->getDim2())
384 396 {
385 397 // All components of this parameter are used by this axis => merge
386   - Color color = paramsComponents.second.front().getColor();
387   - paramsComponents.second.clear();
388   - paramsComponents.second.push_back(ParameterIndexComponentColor(-1, -1, color));
  398 + Color color = axisParamsComponents[paramsComponents].front().getColor();
  399 + axisParamsComponents[paramsComponents].clear();
  400 + axisParamsComponents[paramsComponents].push_back(ParameterIndexComponentColor(-1, -1, color));
389 401 }
390 402 bool isFirstComponent = true;
391   - for (auto components : paramsComponents.second)
  403 + for (auto components : axisParamsComponents[paramsComponents])
392 404 {
393 405 if (paramInfo == nullptr)
394 406 continue;
... ...
src/ParamOutputImpl/Plot/AxisLegendManager.hh
... ... @@ -75,7 +75,7 @@ namespace plot
75 75  
76 76 static void configureXAxisLegendForSeries(PanelPlotOutput *plot);
77 77  
78   - static void setAxisLegendForSeries(PanelPlotOutput *plot, boost::shared_ptr<Axis> &pAxis, AxisParamsComponents &axisParamsComponents, std::string legendPrefix="");
  78 + static void setAxisLegendForSeries(PanelPlotOutput *plot, boost::shared_ptr<Axis> &pAxis, AxisParamsComponents &axisParamsComponents, std::vector<std::string> insertionOrder, std::string legendPrefix="");
79 79  
80 80 static void setAxisLegendForSpectro(PanelPlotOutput *plot, boost::shared_ptr<Axis> &pAxis, std::string originalParamId);
81 81  
... ...
src/ParamOutputImpl/Plot/InstantPlot/InstantPlot.cc
... ... @@ -968,8 +968,10 @@ void InstantPlot::configureDataAxisLegend(boost::shared_ptr&lt;Axis&gt; axisSPtr, bool
968 968 else
969 969 {
970 970 AxisLegendManager::AxisParamsComponents axisParamsComponents;
  971 + std::vector<std::string> insertionOrder;
971 972 axisParamsComponents[_originalParamId].push_back(ParameterIndexComponentColor(-1,-1, axisSPtr->_color));
972   - AxisLegendManager::setAxisLegendForSeries(this, axisSPtr, axisParamsComponents);
  973 + insertionOrder.push_back(_originalParamId);
  974 + AxisLegendManager::setAxisLegendForSeries(this, axisSPtr, axisParamsComponents, insertionOrder);
973 975 }
974 976 }
975 977  
... ...