Commit 5e31eec0663e840ae73d16a3187363ca43a9dcad
1 parent
76bfb610
Exists in
master
and in
79 other branches
resolu puissance
Showing
2 changed files
with
477 additions
and
440 deletions
Show diff stats
src/ParamOutputImpl/Plot/AxisLegendManager.cc
1 | 1 | #include "AxisLegendManager.hh" |
2 | +#include <iostream> // std::cout | |
3 | +#include <string> | |
4 | +#include <vector> | |
2 | 5 | |
3 | 6 | using namespace AMDA::Info; |
4 | 7 | |
5 | -namespace plot | |
6 | -{ | |
8 | +namespace plot { | |
7 | 9 | |
8 | -void AxisLegendManager::configureXAxisLegendForSeries( | |
9 | - XYPlot* plot) | |
10 | -{ | |
11 | - // Build list of all indexes used by each parameters for each x axes | |
12 | - std::map<std::string, AxisParamsComponents> axesParamsComponents; | |
10 | + void AxisLegendManager::configureXAxisLegendForSeries( | |
11 | + XYPlot* plot) { | |
12 | + // Build list of all indexes used by each parameters for each x axes | |
13 | + std::map<std::string, AxisParamsComponents> axesParamsComponents; | |
13 | 14 | |
14 | - // Compute nb series to draw by y axis | |
15 | - std::map<std::string,int> nbSeriesByYAxisMap = plot->getNbSeriesByYAxis(); | |
15 | + // Compute nb series to draw by y axis | |
16 | + std::map<std::string, int> nbSeriesByYAxisMap = plot->getNbSeriesByYAxis(); | |
16 | 17 | |
17 | - SeriesProperties lSeriesProperties; | |
18 | - for (auto param: plot->_parameterAxesList) { | |
19 | - for(auto lSeriesProperties : param.getYSeriePropertiesList()) { | |
20 | - if(!lSeriesProperties.hasYAxis() || !lSeriesProperties.hasXAxis()) | |
21 | - continue; | |
18 | + SeriesProperties lSeriesProperties; | |
19 | + for (auto param : plot->_parameterAxesList) { | |
20 | + for (auto lSeriesProperties : param.getYSeriePropertiesList()) { | |
21 | + if (!lSeriesProperties.hasYAxis() || !lSeriesProperties.hasXAxis()) | |
22 | + continue; | |
22 | 23 | |
23 | - bool moreThanOneSerieForAxis = (nbSeriesByYAxisMap[lSeriesProperties.getYAxisId()] > 1); | |
24 | + bool moreThanOneSerieForAxis = (nbSeriesByYAxisMap[lSeriesProperties.getYAxisId()] > 1); | |
24 | 25 | |
25 | - ParameterAxes* xParameter = plot->getParameterAxesByXSerieId(lSeriesProperties.getXId()); | |
26 | + ParameterAxes* xParameter = plot->getParameterAxesByXSerieId(lSeriesProperties.getXId()); | |
26 | 27 | |
27 | - XSeriesProperties xSerie = xParameter->getXSeriePropertiesById(lSeriesProperties.getXId()); | |
28 | + XSeriesProperties xSerie = xParameter->getXSeriePropertiesById(lSeriesProperties.getXId()); | |
28 | 29 | |
29 | - std::string xAxisId = lSeriesProperties.getXAxisId(); | |
30 | + std::string xAxisId = lSeriesProperties.getXAxisId(); | |
30 | 31 | |
31 | - boost::shared_ptr<Axis> lXAxis = plot->_panel->getAxis(xAxisId); | |
32 | - if (lXAxis.get() == nullptr) { | |
33 | - continue; | |
34 | - } | |
32 | + boost::shared_ptr<Axis> lXAxis = plot->_panel->getAxis(xAxisId); | |
33 | + if (lXAxis.get() == nullptr) { | |
34 | + continue; | |
35 | + } | |
36 | + | |
37 | + Color compLegendColor = lXAxis->_color; | |
38 | + if (moreThanOneSerieForAxis && (lSeriesProperties.getColorSerieId() == -1) && (!plot->_panel->_page->_superposeMode)) { | |
39 | + compLegendColor = plot->getSerieLineColor(lSeriesProperties, moreThanOneSerieForAxis); | |
40 | + } | |
41 | + | |
42 | + ParameterIndexComponentColor xIndex = ParameterIndexComponentColor(xSerie.getIndex(), compLegendColor); | |
43 | + pushComponentInList(xSerie.getParamId(), xIndex, axesParamsComponents[xAxisId]); | |
44 | + } | |
45 | + } | |
46 | + | |
47 | + if (!plot->_panel->_page->_superposeMode) { | |
48 | + plot->resetAutomaticSerieColorCursor(); | |
49 | + } | |
50 | + | |
51 | + std::list<std::string> legendLines; | |
52 | + for (auto axisParamsComponents : axesParamsComponents) { | |
53 | + boost::shared_ptr<Axis> lXAxis = plot->_panel->getAxis(axisParamsComponents.first); | |
54 | + setAxisLegendForSeries(plot, lXAxis, axisParamsComponents.second); | |
55 | + } | |
56 | + } | |
57 | + | |
58 | + void AxisLegendManager::configureYAxisLegendForSpectro( | |
59 | + PanelPlotOutput* plot) { | |
60 | + for (auto param : plot->_parameterAxesList) { | |
61 | + std::shared_ptr<SpectroProperties> spectroPropertiesPtr = param.getSpectroProperties(); | |
62 | + if (spectroPropertiesPtr == nullptr) | |
63 | + continue; //no spectro defined | |
64 | + | |
65 | + if (!spectroPropertiesPtr->hasYAxis()) | |
66 | + continue; | |
67 | + | |
68 | + std::string yAxisId = spectroPropertiesPtr->getYAxisId(); | |
69 | + boost::shared_ptr<Axis> lYAxis = plot->_panel->getAxis(yAxisId); | |
70 | + if (lYAxis.get() == nullptr) | |
71 | + continue; | |
72 | + | |
73 | + if (!lYAxis->_legend.isEmpty()) | |
74 | + continue; | |
75 | + | |
76 | + setAxisLegendForTable(plot, lYAxis, param._originalParamId, spectroPropertiesPtr->getParamId(), spectroPropertiesPtr->getIndexes(), spectroPropertiesPtr->getRelatedDim()); | |
77 | + return; | |
78 | + } | |
79 | + } | |
80 | + | |
81 | + void AxisLegendManager::configureYAxisLegendForSeries( | |
82 | + PanelPlotOutput* plot) { | |
83 | + SeriesProperties lSeriesProperties; | |
84 | + | |
85 | + // Compute nb series to draw by y axis | |
86 | + std::map<std::string, int> nbSeriesByYAxisMap = plot->getNbSeriesByYAxis(); | |
87 | + | |
88 | + // Build list of all indexes used by each parameters for each y axes | |
89 | + std::map<std::string, AxisParamsComponents> axesParamsComponents; | |
90 | + if (!plot->_panel->_page->_superposeMode) { | |
91 | + plot->resetAutomaticSerieColorCursor(); | |
92 | + } | |
93 | + for (auto param : plot->_parameterAxesList) { | |
94 | + for (auto lSeriesProperties : param.getYSeriePropertiesList()) { | |
95 | + if (!lSeriesProperties.hasYAxis()) | |
96 | + continue; | |
97 | + | |
98 | + bool moreThanOneSerieForAxis = (nbSeriesByYAxisMap[lSeriesProperties.getYAxisId()] > 1); | |
99 | + | |
100 | + std::string yAxisId = lSeriesProperties.getYAxisId(); | |
101 | + boost::shared_ptr<Axis> lYAxis = plot->_panel->getAxis(yAxisId); | |
102 | + if (lYAxis.get() == nullptr) { | |
103 | + continue; | |
104 | + } | |
105 | + | |
106 | + for (auto index : lSeriesProperties.getIndexList(plot->_pParameterValues)) { | |
107 | + Color compLegendColor = lYAxis->_color; | |
108 | + if (moreThanOneSerieForAxis && (lSeriesProperties.getColorSerieId() == -1) && (!plot->_panel->_page->_superposeMode)) { | |
109 | + compLegendColor = plot->getSerieLineColor(lSeriesProperties, moreThanOneSerieForAxis); | |
110 | + } | |
111 | + ParameterIndexComponentColor yIndex = ParameterIndexComponentColor(index, compLegendColor); | |
112 | + pushComponentInList(lSeriesProperties.getParamId(), yIndex, axesParamsComponents[yAxisId]); | |
113 | + } | |
114 | + } | |
115 | + } | |
116 | + if (!plot->_panel->_page->_superposeMode) { | |
117 | + plot->resetAutomaticSerieColorCursor(); | |
118 | + } | |
119 | + | |
120 | + std::list<std::string> legendLines; | |
121 | + for (auto axisParamsComponents : axesParamsComponents) { | |
122 | + boost::shared_ptr<Axis> lYAxis = plot->_panel->getAxis(axisParamsComponents.first); | |
123 | + setAxisLegendForSeries(plot, lYAxis, axisParamsComponents.second); | |
124 | + } | |
125 | + } | |
126 | + | |
127 | + void AxisLegendManager::configureColorAxisLegendForSeries( | |
128 | + PanelPlotOutput* plot) { | |
129 | + SeriesProperties lSeriesProperties; | |
130 | + ColorSeriesProperties lColorSerieProperties; | |
131 | + boost::shared_ptr<Axis> lZAxis = plot->_panel->getColorAxis(); | |
132 | + | |
133 | + if (lZAxis.get() == nullptr) { | |
134 | + return; | |
135 | + } | |
136 | + | |
137 | + // Build list of all indexes used by each parameters for each y axes | |
138 | + AxisParamsComponents axisParamsComponents; | |
139 | + for (auto param : plot->_parameterAxesList) { | |
140 | + for (auto lSeriesProperties : param.getYSeriePropertiesList()) { | |
141 | + if (!lSeriesProperties.hasYAxis()) | |
142 | + continue; | |
143 | + | |
144 | + std::string yParamId = lSeriesProperties.getParamId(); | |
145 | + | |
146 | + //check if a colored param is defined for this serie | |
147 | + if (lSeriesProperties.getColorParamId().empty()) | |
148 | + continue; | |
149 | + | |
150 | + ParameterAxes* colorSerieParameterAxes = plot->getParameterAxesByColorSerieId(lSeriesProperties.getColorSerieId()); | |
151 | + | |
152 | + if (colorSerieParameterAxes == NULL) | |
153 | + continue; | |
154 | + | |
155 | + lColorSerieProperties = colorSerieParameterAxes->getColorSeriePropertiesById(lSeriesProperties.getColorSerieId()); | |
156 | + | |
157 | + ParameterIndexComponentColor colorSerieIndex = ParameterIndexComponentColor(-1, -1, lZAxis->_color); | |
158 | + if (lColorSerieProperties.getIndex() > -1) | |
159 | + colorSerieIndex = ParameterIndexComponentColor(lColorSerieProperties.getIndex(), -1, lZAxis->_color); | |
160 | + pushComponentInList(lColorSerieProperties.getColorParamIds()[yParamId], colorSerieIndex, axisParamsComponents); | |
161 | + } | |
162 | + } | |
163 | + | |
164 | + setAxisLegendForSeries(plot, lZAxis, axisParamsComponents); | |
165 | + } | |
166 | + | |
167 | + void AxisLegendManager::configureColorAxisLegendForSpectro( | |
168 | + PanelPlotOutput* plot) { | |
169 | + boost::shared_ptr<Axis> lZAxis = plot->_panel->getColorAxis(); | |
170 | + | |
171 | + if (lZAxis.get() == nullptr) { | |
172 | + return; | |
173 | + } | |
35 | 174 | |
36 | - Color compLegendColor = lXAxis->_color; | |
37 | - if (moreThanOneSerieForAxis && (lSeriesProperties.getColorSerieId() == -1) && (!plot->_panel->_page->_superposeMode)) { | |
38 | - compLegendColor = plot->getSerieLineColor(lSeriesProperties, moreThanOneSerieForAxis); | |
39 | - } | |
175 | + for (auto param : plot->_parameterAxesList) { | |
176 | + std::shared_ptr<SpectroProperties> spectroPropertiesPtr = param.getSpectroProperties(); | |
177 | + if (spectroPropertiesPtr == nullptr) | |
178 | + continue; //no spectro defined | |
40 | 179 | |
41 | - ParameterIndexComponentColor xIndex = ParameterIndexComponentColor(xSerie.getIndex(), compLegendColor); | |
42 | - pushComponentInList(xSerie.getParamId(), xIndex, axesParamsComponents[xAxisId]); | |
43 | - } | |
44 | - } | |
180 | + if (!spectroPropertiesPtr->hasZAxis()) | |
181 | + continue; | |
45 | 182 | |
46 | - if (!plot->_panel->_page->_superposeMode) { | |
47 | - plot->resetAutomaticSerieColorCursor(); | |
48 | - } | |
183 | + setAxisLegendForSpectro(plot, lZAxis, param._originalParamId); | |
184 | + break; | |
185 | + } | |
186 | + } | |
187 | + | |
188 | + void AxisLegendManager::pushComponentInList(std::string paramId, ParameterIndexComponentColor& index, AxisParamsComponents& axisParamsComponents) { | |
189 | + if (index.getDim1Index() == -1 && index.getDim2Index() == -1) { | |
190 | + //All indexes of this parameter are used | |
191 | + axisParamsComponents[paramId].clear(); | |
192 | + axisParamsComponents[paramId].push_back(index); | |
193 | + } else { | |
194 | + if (axisParamsComponents[paramId].size() > 0) { | |
195 | + if (axisParamsComponents[paramId].front().getDim1Index() == -1 && axisParamsComponents[paramId].front().getDim2Index() == -1) { | |
196 | + //Skip. All components already defined for this paramter on this axis | |
197 | + return; | |
198 | + } | |
199 | + } | |
200 | + for (auto crtIndex : axisParamsComponents[paramId]) { | |
201 | + if ((crtIndex.getDim1Index() == index.getDim1Index()) && (crtIndex.getDim2Index() == index.getDim2Index())) { | |
202 | + //Component already exists | |
203 | + return; | |
204 | + } | |
205 | + } | |
206 | + //Add this components for this axis | |
207 | + axisParamsComponents[paramId].push_back(index); | |
208 | + } | |
209 | + | |
210 | + } | |
211 | + | |
212 | + void AxisLegendManager::setAxisLegendForSeries(PanelPlotOutput* plot, boost::shared_ptr<Axis>& pAxis, AxisParamsComponents& axisParamsComponents) { | |
213 | + if (pAxis == nullptr || !pAxis->_legend.isEmpty()) { | |
214 | + return; | |
215 | + } | |
216 | + | |
217 | + // Retrieve ParamInfo Manager | |
218 | + ParamMgr* piMgr = ParamMgr::getInstance(); | |
219 | + | |
220 | + for (auto paramsComponents : axisParamsComponents) { | |
221 | + ParameterSPtr p = plot->_parameterManager.getParameter(paramsComponents.first); | |
222 | + ParamInfoSPtr paramInfo = piMgr->getParamInfoFromId(p->getInfoId()); | |
223 | + if (paramsComponents.second.size() == p->getDataWriterTemplate()->getParamData()->getDim1() * p->getDataWriterTemplate()->getParamData()->getDim2()) { | |
224 | + //All components of this parameter are used by this axis => merge | |
225 | + Color color = paramsComponents.second.front().getColor(); | |
226 | + paramsComponents.second.clear(); | |
227 | + paramsComponents.second.push_back(ParameterIndexComponentColor(-1, -1, color)); | |
228 | + } | |
229 | + bool isFirstComponent = true; | |
230 | + for (auto components : paramsComponents.second) { | |
231 | + if (paramInfo == nullptr) | |
232 | + continue; | |
233 | + Label label(pAxis->_legend.getFont(), components.getColor()); | |
234 | + if (axisParamsComponents.size() == 1) { | |
235 | + if (isFirstComponent) { | |
236 | + std::string info = getMissionInstrumentInfo(paramInfo); | |
237 | + if (!info.empty()) { | |
238 | + label._text = info; | |
239 | + addBreakLine(label._text); | |
240 | + } | |
241 | + } | |
242 | + } else { | |
243 | + std::string info = getMissionInfo(paramInfo); | |
244 | + if (!info.empty()) { | |
245 | + label._text = info + ", "; | |
246 | + } | |
247 | + } | |
248 | + label._text += getParamLegend(paramInfo, components); | |
249 | + pAxis->_legend.pushLabel(label); | |
250 | + isFirstComponent = false; | |
251 | + } | |
252 | + } | |
253 | + } | |
254 | + | |
255 | + void AxisLegendManager::setAxisLegendForSpectro(PanelPlotOutput* plot, boost::shared_ptr<Axis>& pAxis, std::string originalParamId) { | |
256 | + if (pAxis == nullptr || !pAxis->_legend.isEmpty()) { | |
257 | + return; | |
258 | + } | |
259 | + | |
260 | + // Retrieve ParamInfo Manager | |
261 | + ParamMgr* piMgr = ParamMgr::getInstance(); | |
262 | + | |
263 | + ParameterSPtr p = plot->_parameterManager.getParameter(originalParamId); | |
264 | + AMDA::Info::ParamInfoSPtr paramInfo = piMgr->getParamInfoFromId(p->getInfoId()); | |
265 | + if (paramInfo == nullptr) | |
266 | + return; | |
49 | 267 | |
50 | - std::list<std::string> legendLines; | |
51 | - for (auto axisParamsComponents : axesParamsComponents) { | |
52 | - boost::shared_ptr<Axis> lXAxis = plot->_panel->getAxis(axisParamsComponents.first); | |
53 | - setAxisLegendForSeries(plot, lXAxis, axisParamsComponents.second); | |
268 | + Label label(pAxis->_legend.getFont(), pAxis->_legend.getColor()); | |
269 | + addInfoPart(label._text, paramInfo->getShortName()); | |
270 | + addInfoPart(label._text, getTransformedUnits(paramInfo->getUnits())); | |
271 | + pAxis->_legend.setLabel(label); | |
272 | + } | |
273 | + | |
274 | + void AxisLegendManager::setAxisLegendForTable(PanelPlotOutput* plot, boost::shared_ptr<Axis>& pAxis, std::string originalParamId, std::string paramId, AMDA::Common::ParameterIndexComponentList& indexes, int relatedDim) { | |
275 | + if (pAxis == nullptr || !pAxis->_legend.isEmpty()) { | |
276 | + return; | |
54 | 277 | } |
55 | -} | |
56 | - | |
57 | -void AxisLegendManager::configureYAxisLegendForSpectro( | |
58 | - PanelPlotOutput* plot) | |
59 | -{ | |
60 | - for (auto param: plot->_parameterAxesList) { | |
61 | - std::shared_ptr<SpectroProperties> spectroPropertiesPtr = param.getSpectroProperties(); | |
62 | - if (spectroPropertiesPtr == nullptr) | |
63 | - continue; //no spectro defined | |
64 | - | |
65 | - if(!spectroPropertiesPtr->hasYAxis()) | |
66 | - continue; | |
67 | - | |
68 | - std::string yAxisId = spectroPropertiesPtr->getYAxisId(); | |
69 | - boost::shared_ptr<Axis> lYAxis = plot->_panel->getAxis(yAxisId); | |
70 | - if (lYAxis.get() == nullptr) | |
71 | - continue; | |
72 | - | |
73 | - if (!lYAxis->_legend.isEmpty()) | |
74 | - continue; | |
75 | - | |
76 | - setAxisLegendForTable(plot, lYAxis, param._originalParamId, spectroPropertiesPtr->getParamId(), spectroPropertiesPtr->getIndexes(), spectroPropertiesPtr->getRelatedDim()); | |
77 | - return; | |
78 | - } | |
79 | -} | |
80 | - | |
81 | -void AxisLegendManager::configureYAxisLegendForSeries( | |
82 | - PanelPlotOutput* plot) | |
83 | -{ | |
84 | - SeriesProperties lSeriesProperties; | |
85 | - | |
86 | - // Compute nb series to draw by y axis | |
87 | - std::map<std::string,int> nbSeriesByYAxisMap = plot->getNbSeriesByYAxis(); | |
88 | - | |
89 | - // Build list of all indexes used by each parameters for each y axes | |
90 | - std::map<std::string, AxisParamsComponents> axesParamsComponents; | |
91 | - if (!plot->_panel->_page->_superposeMode) { | |
92 | - plot->resetAutomaticSerieColorCursor(); | |
93 | - } | |
94 | - for (auto param: plot->_parameterAxesList) | |
95 | - { | |
96 | - for(auto lSeriesProperties : param.getYSeriePropertiesList()) { | |
97 | - if(!lSeriesProperties.hasYAxis()) | |
98 | - continue; | |
99 | - | |
100 | - bool moreThanOneSerieForAxis = (nbSeriesByYAxisMap[lSeriesProperties.getYAxisId()] > 1); | |
101 | - | |
102 | - std::string yAxisId = lSeriesProperties.getYAxisId(); | |
103 | - boost::shared_ptr<Axis> lYAxis = plot->_panel->getAxis(yAxisId); | |
104 | - if (lYAxis.get() == nullptr) { | |
105 | - continue; | |
106 | - } | |
107 | - | |
108 | - for (auto index : lSeriesProperties.getIndexList(plot->_pParameterValues)) { | |
109 | - Color compLegendColor = lYAxis->_color; | |
110 | - if (moreThanOneSerieForAxis && (lSeriesProperties.getColorSerieId() == -1) && (!plot->_panel->_page->_superposeMode)) { | |
111 | - compLegendColor = plot->getSerieLineColor(lSeriesProperties, moreThanOneSerieForAxis); | |
112 | - } | |
113 | - ParameterIndexComponentColor yIndex = ParameterIndexComponentColor(index, compLegendColor); | |
114 | - pushComponentInList(lSeriesProperties.getParamId(), yIndex, axesParamsComponents[yAxisId]); | |
115 | - } | |
116 | - } | |
117 | - } | |
118 | - if (!plot->_panel->_page->_superposeMode) { | |
119 | - plot->resetAutomaticSerieColorCursor(); | |
120 | - } | |
121 | - | |
122 | - std::list<std::string> legendLines; | |
123 | - for (auto axisParamsComponents : axesParamsComponents) { | |
124 | - boost::shared_ptr<Axis> lYAxis = plot->_panel->getAxis(axisParamsComponents.first); | |
125 | - setAxisLegendForSeries(plot, lYAxis, axisParamsComponents.second); | |
126 | - } | |
127 | -} | |
128 | - | |
129 | -void AxisLegendManager::configureColorAxisLegendForSeries( | |
130 | - PanelPlotOutput* plot) | |
131 | -{ | |
132 | - SeriesProperties lSeriesProperties; | |
133 | - ColorSeriesProperties lColorSerieProperties; | |
134 | - boost::shared_ptr<Axis> lZAxis = plot->_panel->getColorAxis(); | |
135 | - | |
136 | - if (lZAxis.get() == nullptr) { | |
137 | - return; | |
138 | - } | |
139 | - | |
140 | - // Build list of all indexes used by each parameters for each y axes | |
141 | - AxisParamsComponents axisParamsComponents; | |
142 | - for (auto param: plot->_parameterAxesList) { | |
143 | - for(auto lSeriesProperties : param.getYSeriePropertiesList()) { | |
144 | - if(!lSeriesProperties.hasYAxis()) | |
145 | - continue; | |
146 | - | |
147 | - std::string yParamId = lSeriesProperties.getParamId(); | |
148 | - | |
149 | - //check if a colored param is defined for this serie | |
150 | - if(lSeriesProperties.getColorParamId().empty()) | |
151 | - continue; | |
152 | - | |
153 | - ParameterAxes* colorSerieParameterAxes = plot->getParameterAxesByColorSerieId(lSeriesProperties.getColorSerieId()); | |
154 | - | |
155 | - if (colorSerieParameterAxes == NULL) | |
156 | - continue; | |
157 | - | |
158 | - lColorSerieProperties = colorSerieParameterAxes->getColorSeriePropertiesById(lSeriesProperties.getColorSerieId()); | |
159 | - | |
160 | - ParameterIndexComponentColor colorSerieIndex = ParameterIndexComponentColor(-1, -1, lZAxis->_color); | |
161 | - if (lColorSerieProperties.getIndex() > -1) | |
162 | - colorSerieIndex = ParameterIndexComponentColor(lColorSerieProperties.getIndex(), -1, lZAxis->_color); | |
163 | - pushComponentInList(lColorSerieProperties.getColorParamIds()[yParamId], colorSerieIndex, axisParamsComponents); | |
164 | - } | |
165 | - } | |
166 | - | |
167 | - setAxisLegendForSeries(plot, lZAxis, axisParamsComponents); | |
168 | -} | |
169 | - | |
170 | -void AxisLegendManager::configureColorAxisLegendForSpectro( | |
171 | - PanelPlotOutput* plot) | |
172 | -{ | |
173 | - boost::shared_ptr<Axis> lZAxis = plot->_panel->getColorAxis(); | |
174 | - | |
175 | - if (lZAxis.get() == nullptr) { | |
176 | - return; | |
177 | - } | |
178 | - | |
179 | - for (auto param: plot->_parameterAxesList) { | |
180 | - std::shared_ptr<SpectroProperties> spectroPropertiesPtr = param.getSpectroProperties(); | |
181 | - if (spectroPropertiesPtr == nullptr) | |
182 | - continue; //no spectro defined | |
183 | - | |
184 | - if(!spectroPropertiesPtr->hasZAxis()) | |
185 | - continue; | |
186 | - | |
187 | - setAxisLegendForSpectro(plot, lZAxis, param._originalParamId); | |
188 | - break; | |
189 | - } | |
190 | -} | |
191 | - | |
192 | -void AxisLegendManager::pushComponentInList(std::string paramId, ParameterIndexComponentColor& index, AxisParamsComponents& axisParamsComponents) { | |
193 | - if (index.getDim1Index() == -1 && index.getDim2Index() == -1) { | |
194 | - //All indexes of this parameter are used | |
195 | - axisParamsComponents[paramId].clear(); | |
196 | - axisParamsComponents[paramId].push_back(index); | |
197 | - } | |
198 | - else { | |
199 | - if (axisParamsComponents[paramId].size() > 0) { | |
200 | - if (axisParamsComponents[paramId].front().getDim1Index() == -1 && axisParamsComponents[paramId].front().getDim2Index() == -1) { | |
201 | - //Skip. All components already defined for this paramter on this axis | |
202 | - return; | |
203 | - } | |
204 | - } | |
205 | - for (auto crtIndex : axisParamsComponents[paramId]) { | |
206 | - if ((crtIndex.getDim1Index() == index.getDim1Index()) && (crtIndex.getDim2Index() == index.getDim2Index())) { | |
207 | - //Component already exists | |
208 | - return; | |
209 | - } | |
210 | - } | |
211 | - //Add this components for this axis | |
212 | - axisParamsComponents[paramId].push_back(index); | |
213 | - } | |
214 | - | |
215 | -} | |
216 | - | |
217 | -void AxisLegendManager::setAxisLegendForSeries(PanelPlotOutput* plot, boost::shared_ptr<Axis>& pAxis, AxisParamsComponents& axisParamsComponents) { | |
218 | - if (pAxis == nullptr || !pAxis->_legend.isEmpty()) { | |
219 | - return; | |
220 | - } | |
221 | - | |
222 | - // Retrieve ParamInfo Manager | |
223 | - ParamMgr* piMgr = ParamMgr::getInstance(); | |
224 | - | |
225 | - for (auto paramsComponents : axisParamsComponents) { | |
226 | - ParameterSPtr p = plot->_parameterManager.getParameter(paramsComponents.first); | |
227 | - ParamInfoSPtr paramInfo = piMgr->getParamInfoFromId(p->getInfoId()); | |
228 | - if (paramsComponents.second.size() == p->getDataWriterTemplate()->getParamData()->getDim1() * p->getDataWriterTemplate()->getParamData()->getDim2()) { | |
229 | - //All components of this parameter are used by this axis => merge | |
230 | - Color color = paramsComponents.second.front().getColor(); | |
231 | - paramsComponents.second.clear(); | |
232 | - paramsComponents.second.push_back(ParameterIndexComponentColor(-1,-1, color)); | |
233 | - } | |
234 | - bool isFirstComponent = true; | |
235 | - for (auto components : paramsComponents.second) { | |
236 | - if (paramInfo == nullptr) | |
237 | - continue; | |
238 | - Label label(pAxis->_legend.getFont(), components.getColor()); | |
239 | - if (axisParamsComponents.size() == 1) { | |
240 | - if (isFirstComponent) { | |
241 | - std::string info = getMissionInstrumentInfo(paramInfo); | |
242 | - if (!info.empty()) { | |
243 | - label._text = info; | |
244 | - addBreakLine(label._text); | |
245 | - } | |
246 | - } | |
247 | - } | |
248 | - else { | |
249 | - std::string info = getMissionInfo(paramInfo); | |
250 | - if (!info.empty()) { | |
251 | - label._text = info + ", "; | |
252 | - } | |
253 | - } | |
254 | - label._text += getParamLegend(paramInfo, components); | |
255 | - pAxis->_legend.pushLabel(label); | |
256 | - isFirstComponent = false; | |
257 | - } | |
258 | - } | |
259 | -} | |
260 | - | |
261 | -void AxisLegendManager::setAxisLegendForSpectro(PanelPlotOutput* plot, boost::shared_ptr<Axis>& pAxis, std::string originalParamId) { | |
262 | - if (pAxis == nullptr || !pAxis->_legend.isEmpty()) { | |
263 | - return; | |
264 | - } | |
265 | - | |
266 | - // Retrieve ParamInfo Manager | |
267 | - ParamMgr* piMgr = ParamMgr::getInstance(); | |
268 | - | |
269 | - ParameterSPtr p = plot->_parameterManager.getParameter(originalParamId); | |
270 | - AMDA::Info::ParamInfoSPtr paramInfo = piMgr->getParamInfoFromId(p->getInfoId()); | |
271 | - if (paramInfo == nullptr) | |
272 | - return; | |
273 | - | |
274 | - Label label(pAxis->_legend.getFont(), pAxis->_legend.getColor()); | |
275 | - addInfoPart(label._text, paramInfo->getShortName()); | |
276 | - addInfoPart(label._text, paramInfo->getUnits()); | |
277 | - pAxis->_legend.setLabel(label); | |
278 | -} | |
279 | - | |
280 | -void AxisLegendManager::setAxisLegendForTable(PanelPlotOutput* plot, boost::shared_ptr<Axis>& pAxis, std::string originalParamId, std::string paramId, AMDA::Common::ParameterIndexComponentList& indexes, int relatedDim) { | |
281 | - if (pAxis == nullptr || !pAxis->_legend.isEmpty()) { | |
282 | - return; | |
283 | - } | |
284 | - | |
285 | - // Retrieve ParamInfo Manager | |
286 | - ParamMgr* piMgr = ParamMgr::getInstance(); | |
287 | - | |
288 | - ParameterSPtr p = plot->_parameterManager.getParameter(originalParamId); | |
289 | - AMDA::Info::ParamInfoSPtr paramInfo = piMgr->getParamInfoFromId(p->getInfoId()); | |
290 | - | |
291 | - if (paramInfo == nullptr) | |
292 | - return; | |
293 | - | |
294 | - Label label(pAxis->_legend.getFont(), pAxis->_legend.getColor()); | |
295 | - std::string info = getMissionInstrumentInfo(paramInfo); | |
296 | - if (!info.empty()) { | |
297 | - addInfoPart(label._text, info); | |
298 | - addBreakLine(label._text); | |
299 | - } | |
300 | - | |
301 | - boost::shared_ptr<AMDA::Info::ParamTable> tableSPtr; | |
302 | - tableSPtr = paramInfo->getTable(relatedDim); | |
303 | - | |
304 | - if (tableSPtr == nullptr) { | |
305 | - std::string tableInfo = "Table "; | |
306 | - tableInfo += std::to_string(relatedDim); | |
307 | - tableInfo += " indexes"; | |
308 | - addInfoPart(label._text, tableInfo); | |
309 | - pAxis->_legend.pushLabel(label); | |
310 | - return; | |
311 | - } | |
312 | - | |
313 | - if (((*plot->_pParameterValues)[paramId].getDim1Size() > 0) && | |
314 | - ((*plot->_pParameterValues)[paramId].getDim2Size() > 0) && | |
315 | - !indexes.empty()) | |
316 | - { | |
317 | - boost::shared_ptr<AMDA::Info::ParamTable> otherTableSPtr; | |
318 | - int otherDimIndex; | |
319 | - if (relatedDim == 0) | |
320 | - { | |
321 | - otherTableSPtr = paramInfo->getTable(1); | |
322 | - otherDimIndex = indexes.front().getDim2Index(); | |
323 | - } | |
324 | - else | |
325 | - { | |
326 | - otherTableSPtr = paramInfo->getTable(0); | |
327 | - otherDimIndex = indexes.front().getDim1Index(); | |
328 | - } | |
329 | - if ((otherTableSPtr != nullptr) && !otherTableSPtr->isVariable(&plot->_parameterManager)) | |
330 | - { | |
331 | - if (otherTableSPtr->getName(&plot->_parameterManager).empty()) | |
332 | - addInfoPart(label._text, "Table bounds"); | |
333 | - else | |
334 | - addInfoPart(label._text, otherTableSPtr->getName(&plot->_parameterManager)); | |
335 | - | |
336 | - AMDA::Info::t_TableBound crtBound = otherTableSPtr->getBound(&plot->_parameterManager, otherDimIndex); | |
337 | - addBoundsPart(label._text, crtBound.min, crtBound.max); | |
338 | - addInfoPart(label._text, otherTableSPtr->getUnits(&plot->_parameterManager)); | |
339 | - } | |
340 | - else | |
341 | - { | |
342 | - std::string part = "Table Index: "; | |
343 | - part += std::to_string(otherDimIndex); | |
344 | - addInfoPart(label._text, part); | |
345 | - } | |
346 | - addBreakLine(label._text); | |
347 | - } | |
348 | - addInfoPart(label._text, tableSPtr->getName(&plot->_parameterManager)); | |
349 | - addInfoPart(label._text, tableSPtr->getUnits(&plot->_parameterManager)); | |
350 | - pAxis->_legend.pushLabel(label); | |
351 | -} | |
352 | - | |
353 | -void AxisLegendManager::addInfoPart(std::string& legend, std::string info) { | |
354 | - if (!info.empty()) { | |
355 | - if (!legend.empty()) { | |
356 | - if (legend.length() >= Label::DELIMITER.length()) { | |
357 | - if (legend.compare(legend.length() - Label::DELIMITER.length(), Label::DELIMITER.length(), Label::DELIMITER) != 0) { | |
358 | - legend += ", "; | |
359 | - } | |
360 | - } | |
361 | - else { | |
362 | - legend += ", "; | |
363 | - } | |
364 | - } | |
365 | - legend += info; | |
366 | - } | |
367 | -} | |
368 | - | |
369 | -void AxisLegendManager::addIndexPart(std::string& legend, ParameterIndexComponentColor& index) { | |
370 | - legend += "["; | |
371 | - legend += std::to_string(index.getDim1Index()); | |
372 | - if (index.getDim2Index() != -1) { | |
373 | - legend += ","; | |
374 | - legend += std::to_string(index.getDim2Index()); | |
375 | - } | |
376 | - legend += "]"; | |
377 | -} | |
378 | - | |
379 | -void AxisLegendManager::addIndexPart(std::string& legend, int index) { | |
380 | - legend += "["; | |
381 | - legend += std::to_string(index); | |
382 | - legend += "]"; | |
383 | -} | |
384 | - | |
385 | -void AxisLegendManager::addBoundsPart(std::string& legend, PLFLT min, PLFLT max) { | |
386 | - legend += " "; | |
387 | - | |
388 | - char minCount[1024]; | |
389 | - char maxCount[1024]; | |
390 | - | |
278 | + | |
279 | + // Retrieve ParamInfo Manager | |
280 | + ParamMgr* piMgr = ParamMgr::getInstance(); | |
281 | + | |
282 | + ParameterSPtr p = plot->_parameterManager.getParameter(originalParamId); | |
283 | + AMDA::Info::ParamInfoSPtr paramInfo = piMgr->getParamInfoFromId(p->getInfoId()); | |
284 | + | |
285 | + if (paramInfo == nullptr) | |
286 | + return; | |
287 | + | |
288 | + Label label(pAxis->_legend.getFont(), pAxis->_legend.getColor()); | |
289 | + std::string info = getMissionInstrumentInfo(paramInfo); | |
290 | + if (!info.empty()) { | |
291 | + addInfoPart(label._text, info); | |
292 | + addBreakLine(label._text); | |
293 | + } | |
294 | + | |
295 | + boost::shared_ptr<AMDA::Info::ParamTable> tableSPtr; | |
296 | + tableSPtr = paramInfo->getTable(relatedDim); | |
297 | + | |
298 | + if (tableSPtr == nullptr) { | |
299 | + std::string tableInfo = "Table "; | |
300 | + tableInfo += std::to_string(relatedDim); | |
301 | + tableInfo += " indexes"; | |
302 | + addInfoPart(label._text, tableInfo); | |
303 | + pAxis->_legend.pushLabel(label); | |
304 | + return; | |
305 | + } | |
306 | + | |
307 | + if (((*plot->_pParameterValues)[paramId].getDim1Size() > 0) && | |
308 | + ((*plot->_pParameterValues)[paramId].getDim2Size() > 0) && | |
309 | + !indexes.empty()) { | |
310 | + boost::shared_ptr<AMDA::Info::ParamTable> otherTableSPtr; | |
311 | + int otherDimIndex; | |
312 | + if (relatedDim == 0) { | |
313 | + otherTableSPtr = paramInfo->getTable(1); | |
314 | + otherDimIndex = indexes.front().getDim2Index(); | |
315 | + } else { | |
316 | + otherTableSPtr = paramInfo->getTable(0); | |
317 | + otherDimIndex = indexes.front().getDim1Index(); | |
318 | + } | |
319 | + if ((otherTableSPtr != nullptr) && !otherTableSPtr->isVariable(&plot->_parameterManager)) { | |
320 | + if (otherTableSPtr->getName(&plot->_parameterManager).empty()) | |
321 | + addInfoPart(label._text, "Table bounds"); | |
322 | + else | |
323 | + addInfoPart(label._text, otherTableSPtr->getName(&plot->_parameterManager)); | |
324 | + | |
325 | + AMDA::Info::t_TableBound crtBound = otherTableSPtr->getBound(&plot->_parameterManager, otherDimIndex); | |
326 | + addBoundsPart(label._text, crtBound.min, crtBound.max); | |
327 | + std::string rawUnit = otherTableSPtr->getUnits(&plot->_parameterManager); | |
328 | + addInfoPart(label._text, getTransformedUnits(rawUnit)); | |
329 | + } else { | |
330 | + std::string part = "Table Index: "; | |
331 | + part += std::to_string(otherDimIndex); | |
332 | + addInfoPart(label._text, part); | |
333 | + } | |
334 | + addBreakLine(label._text); | |
335 | + } | |
336 | + addInfoPart(label._text, tableSPtr->getName(&plot->_parameterManager)); | |
337 | + std::string rawUnit = tableSPtr->getUnits(&plot->_parameterManager); | |
338 | + addInfoPart(label._text, getTransformedUnits(rawUnit)); | |
339 | + pAxis->_legend.pushLabel(label); | |
340 | + } | |
341 | + | |
342 | + void AxisLegendManager::addInfoPart(std::string& legend, std::string info) { | |
343 | + if (!info.empty()) { | |
344 | + if (!legend.empty()) { | |
345 | + if (legend.length() >= Label::DELIMITER.length()) { | |
346 | + if (legend.compare(legend.length() - Label::DELIMITER.length(), Label::DELIMITER.length(), Label::DELIMITER) != 0) { | |
347 | + legend += ", "; | |
348 | + } | |
349 | + } else { | |
350 | + legend += ", "; | |
351 | + } | |
352 | + } | |
353 | + legend += info; | |
354 | + } | |
355 | + } | |
356 | + | |
357 | + void AxisLegendManager::addIndexPart(std::string& legend, ParameterIndexComponentColor& index) { | |
358 | + legend += "["; | |
359 | + legend += std::to_string(index.getDim1Index()); | |
360 | + if (index.getDim2Index() != -1) { | |
361 | + legend += ","; | |
362 | + legend += std::to_string(index.getDim2Index()); | |
363 | + } | |
364 | + legend += "]"; | |
365 | + } | |
366 | + | |
367 | + void AxisLegendManager::addIndexPart(std::string& legend, int index) { | |
368 | + legend += "["; | |
369 | + legend += std::to_string(index); | |
370 | + legend += "]"; | |
371 | + } | |
372 | + | |
373 | + void AxisLegendManager::addBoundsPart(std::string& legend, PLFLT min, PLFLT max) { | |
374 | + legend += " "; | |
375 | + | |
376 | + char minCount[1024]; | |
377 | + char maxCount[1024]; | |
378 | + | |
391 | 379 | int precision = computeScientificFormatPrecision(min, max); |
392 | - | |
380 | + | |
393 | 381 | getDigitalLabel(min, precision, minCount, 1024); |
394 | 382 | getDigitalLabel(max, precision, maxCount, 1024); |
395 | 383 | |
396 | - legend += std::string(minCount); | |
397 | - legend += ", "; | |
398 | - legend += std::string(maxCount); | |
399 | -} | |
400 | - | |
401 | -void AxisLegendManager::addBreakLine(std::string& legend) { | |
402 | - if (!legend.empty()) { | |
403 | - legend += Label::DELIMITER; | |
404 | - } | |
405 | -} | |
406 | - | |
407 | -std::string AxisLegendManager::getParamLegend(AMDA::Info::ParamInfoSPtr paramInfo, ParameterIndexComponentColor& index) { | |
408 | - std::string legend; | |
409 | - addInfoPart(legend, paramInfo->getShortName()); | |
410 | - | |
411 | - if ((index.getDim1Index() != -1) || (index.getDim2Index() != -1)) { | |
412 | - AMDA::Common::ParameterIndexComponent paramIndex(index.getDim1Index(), index.getDim2Index()); | |
413 | - if (paramInfo->getComponents(paramIndex).empty() == false) | |
414 | - addInfoPart(legend, paramInfo->getComponents(paramIndex)); | |
415 | - else | |
416 | - { | |
417 | - addInfoPart(legend, paramInfo->getShortName()); | |
418 | - addIndexPart(legend, index); | |
419 | - } | |
420 | - } | |
421 | - | |
422 | - addInfoPart(legend, paramInfo->getUnits()); | |
423 | - addInfoPart(legend, paramInfo->getCoordinatesSystem()); | |
424 | - | |
425 | - return legend; | |
426 | -} | |
427 | - | |
428 | -/*std::string AxisLegendManager::getParamLegend(AMDA::Info::ParamInfoSPtr paramInfo, int index) { | |
429 | - std::string legend; | |
430 | - addInfoPart(legend, paramInfo->getShortName()); | |
431 | - | |
432 | - if ((index.getDim1Index() != -1) || (index.getDim2Index() != -1)) { | |
433 | - if (paramInfo->getComponents(index).empty() == false) | |
434 | - addInfoPart(legend, paramInfo->getComponents(index)); | |
435 | - else | |
436 | - { | |
437 | - addInfoPart(legend, paramInfo->getShortName()); | |
438 | - addIndexPart(legend, index); | |
439 | - } | |
384 | + legend += std::string(minCount); | |
385 | + legend += ", "; | |
386 | + legend += std::string(maxCount); | |
387 | + } | |
388 | + | |
389 | + void AxisLegendManager::addBreakLine(std::string& legend) { | |
390 | + if (!legend.empty()) { | |
391 | + legend += Label::DELIMITER; | |
392 | + } | |
393 | + } | |
394 | + | |
395 | + std::string AxisLegendManager::getParamLegend(AMDA::Info::ParamInfoSPtr paramInfo, ParameterIndexComponentColor& index) { | |
396 | + std::string legend; | |
397 | + addInfoPart(legend, paramInfo->getShortName()); | |
398 | + | |
399 | + if ((index.getDim1Index() != -1) || (index.getDim2Index() != -1)) { | |
400 | + AMDA::Common::ParameterIndexComponent paramIndex(index.getDim1Index(), index.getDim2Index()); | |
401 | + if (paramInfo->getComponents(paramIndex).empty() == false) | |
402 | + addInfoPart(legend, paramInfo->getComponents(paramIndex)); | |
403 | + else { | |
404 | + addInfoPart(legend, paramInfo->getShortName()); | |
405 | + addIndexPart(legend, index); | |
406 | + } | |
440 | 407 | } |
441 | 408 | |
442 | - addInfoPart(legend, paramInfo->getUnits()); | |
409 | + addInfoPart(legend, getTransformedUnits(paramInfo->getUnits())); | |
443 | 410 | addInfoPart(legend, paramInfo->getCoordinatesSystem()); |
444 | 411 | |
445 | 412 | return legend; |
446 | -}*/ | |
447 | - | |
448 | -std::string AxisLegendManager::getMissionInstrumentInfo(AMDA::Info::ParamInfoSPtr paramInfo) { | |
449 | - std::string info = paramInfo->getInstrumentId(); | |
450 | - if (info.empty()) | |
451 | - return info; | |
452 | - std::replace(info.begin(), info.end(), '_', ' '); | |
453 | - std::transform(info.begin(), info.end(), info.begin(), ::toupper); | |
454 | - return info; | |
455 | -} | |
456 | - | |
457 | -std::string AxisLegendManager::getMissionInfo(AMDA::Info::ParamInfoSPtr paramInfo) { | |
458 | - std::string info = paramInfo->getInstrumentId(); | |
459 | - if (info.empty()) | |
460 | - return info; | |
461 | - if (info.find('_') != std::string::npos) { | |
462 | - info = info.substr(0, info.find('_')); | |
463 | - } | |
464 | - std::transform(info.begin(), info.end(), info.begin(), ::toupper); | |
465 | - return info; | |
466 | -} | |
413 | + } | |
414 | + | |
415 | + /*std::string AxisLegendManager::getParamLegend(AMDA::Info::ParamInfoSPtr paramInfo, int index) { | |
416 | + std::string legend; | |
417 | + addInfoPart(legend, paramInfo->getShortName()); | |
418 | + | |
419 | + if ((index.getDim1Index() != -1) || (index.getDim2Index() != -1)) { | |
420 | + if (paramInfo->getComponents(index).empty() == false) | |
421 | + addInfoPart(legend, paramInfo->getComponents(index)); | |
422 | + else | |
423 | + { | |
424 | + addInfoPart(legend, paramInfo->getShortName()); | |
425 | + addIndexPart(legend, index); | |
426 | + } | |
427 | + } | |
428 | + | |
429 | + addInfoPart(legend, paramInfo->getUnits()); | |
430 | + addInfoPart(legend, paramInfo->getCoordinatesSystem()); | |
431 | + | |
432 | + return legend; | |
433 | + }*/ | |
434 | + | |
435 | + std::string AxisLegendManager::getMissionInstrumentInfo(AMDA::Info::ParamInfoSPtr paramInfo) { | |
436 | + std::string info = paramInfo->getInstrumentId(); | |
437 | + if (info.empty()) | |
438 | + return info; | |
439 | + std::replace(info.begin(), info.end(), '_', ' '); | |
440 | + std::transform(info.begin(), info.end(), info.begin(), ::toupper); | |
441 | + return info; | |
442 | + } | |
443 | + | |
444 | + std::string AxisLegendManager::getMissionInfo(AMDA::Info::ParamInfoSPtr paramInfo) { | |
445 | + std::string info = paramInfo->getInstrumentId(); | |
446 | + if (info.empty()) | |
447 | + return info; | |
448 | + if (info.find('_') != std::string::npos) { | |
449 | + info = info.substr(0, info.find('_')); | |
450 | + } | |
451 | + std::transform(info.begin(), info.end(), info.begin(), ::toupper); | |
452 | + return info; | |
453 | + } | |
454 | + | |
455 | + std::string AxisLegendManager::getTransformedUnits(const std::string& rawUnit) { | |
456 | + std::string unit = rawUnit; | |
457 | + if (unit.find("^")) | |
458 | + unit = transformPower(unit, "^"); | |
459 | + if (unit.find("**")) | |
460 | + unit = transformPower(unit, "**"); | |
461 | + return unit; | |
462 | + } | |
463 | + | |
464 | + std::string AxisLegendManager::transformPower(std::string& unit, std::string pattern) { | |
465 | + std::map<size_t, size_t> positions; // holds all the positions that pattern occurs within unit | |
466 | + size_t pos_first = unit.find(pattern, 0); | |
467 | + size_t pos_last; | |
468 | + while (pos_first != std::string::npos) { | |
469 | + char afterPattern = unit[pos_first + pattern.length()]; | |
470 | + pos_last = pos_first + pattern.length(); | |
471 | + if(afterPattern == '+' || afterPattern =='-'){ | |
472 | + afterPattern = unit[pos_first + pattern.length()+1]; | |
473 | + pos_last ++; | |
474 | + } | |
475 | + if (afterPattern == '('){ | |
476 | + pos_last = unit.find(")", pos_first + pattern.length())+1; | |
477 | + }else if(afterPattern == '|'){ | |
478 | + pos_last = unit.find("|", pos_first + pattern.length()+2)+1; | |
479 | + } | |
480 | + else if( isdigit(afterPattern) || afterPattern == '.'){ | |
481 | + pos_last ++; | |
482 | + while(isdigit(unit[pos_last]) || unit[pos_last] == '.'){ | |
483 | + pos_last ++; | |
484 | + } | |
485 | + }else{ | |
486 | + pos_last ++; | |
487 | + } | |
488 | + positions.insert(std::pair<size_t, size_t>(pos_first, pos_last)); | |
489 | + pos_first = unit.find(pattern, pos_first + pattern.length()); | |
490 | + } | |
491 | + std::map<size_t, size_t>::reverse_iterator it; | |
492 | + for (it = positions.rbegin(); it != positions.rend(); ++it) { | |
493 | + unit.insert(it->second, "#d"); | |
494 | + unit.erase(it->first, pattern.length()); | |
495 | + unit.insert(it->first, "#u"); | |
496 | + } | |
497 | + return unit; | |
498 | + } | |
499 | + | |
467 | 500 | |
468 | 501 | } /* namespace plot */ | ... | ... |
src/ParamOutputImpl/Plot/AxisLegendManager.hh
... | ... | @@ -91,6 +91,10 @@ class AxisLegendManager { |
91 | 91 | static std::string getMissionInstrumentInfo(AMDA::Info::ParamInfoSPtr paramInfo); |
92 | 92 | |
93 | 93 | static std::string getMissionInfo(AMDA::Info::ParamInfoSPtr paramInfo); |
94 | + | |
95 | + static std::string getTransformedUnits(const std::string& rawUnit); | |
96 | + | |
97 | + static std::string transformPower(std::string& unit, std::string pattern); | |
94 | 98 | }; |
95 | 99 | |
96 | 100 | } | ... | ... |