Blame view

src/ParamOutputImpl/Plot/AxisLegendManager.cc 14.9 KB
fbe3c2bb   Benjamin Renard   First commit
1
2
#include "AxisLegendManager.hh"

fbe3c2bb   Benjamin Renard   First commit
3
4
5
6
7
using namespace AMDA::Info;

namespace plot
{

5ee90a58   Benjamin Renard   Use AxisLegendMan...
8
9
10
11
12
13
14
15
16
17
18
19
void AxisLegendManager::configureXAxisLegendForSeries(
		XYPlot* plot)
{
	// Build list of all indexes used by each parameters for each x axes
	std::map<std::string, AxisParamsComponents> axesParamsComponents;

	SeriesProperties lSeriesProperties;
	for (auto param: plot->_parameterAxesList) {
		for(auto index: param.getYSerieIndexList(plot->_pParameterValues)) {
			lSeriesProperties = param.getYSeriePropertiesAt(index);
			if(!lSeriesProperties.hasYAxis() || !lSeriesProperties.hasXAxis())
				continue;
5ee90a58   Benjamin Renard   Use AxisLegendMan...
20
21
22
23
24
25
26
27
28
29
30
31
32
			ParameterAxes& xParameter = plot->getParameterAxeOnXAxis(lSeriesProperties.getXAxisId());

			std::string yParamId = lSeriesProperties.getParamId();

			XSeriesProperties& xSerie = plot->getSerieOnXAxisfromParameter(lSeriesProperties.getXAxisId(), xParameter);

			std::string xAxisId = xSerie.getAxisId();

			boost::shared_ptr<Axis> lXAxis = plot->_panel->getAxis(xAxisId);
			if (lXAxis.get() == nullptr) {
				continue;
			}

8bb0f02b   Benjamin Renard   Set colors in axi...
33
			ParameterIndexComponentColor xIndex = ParameterIndexComponentColor(xSerie.getIndex(), lXAxis->_color);
5ee90a58   Benjamin Renard   Use AxisLegendMan...
34
35
36
37
38
39
40
41
42
43
44
			pushComponentInList(xSerie.getXParamIds()[yParamId], xIndex, axesParamsComponents[xAxisId]);
		}
	}

	std::list<std::string> legendLines;
	for (auto axisParamsComponents : axesParamsComponents) {
		boost::shared_ptr<Axis> lXAxis = plot->_panel->getAxis(axisParamsComponents.first);
		setAxisLegendForSeries(plot, lXAxis, axisParamsComponents.second);
        }
}

c2fa3b5d   Benjamin Renard   Rework of legend ...
45
46
void AxisLegendManager::configureYAxisLegendForSpectro(
                PanelPlotOutput* plot)
fbe3c2bb   Benjamin Renard   First commit
47
{
c2fa3b5d   Benjamin Renard   Rework of legend ...
48
49
50
51
	for (auto param: plot->_parameterAxesList) {
		std::shared_ptr<SpectroProperties> spectroPropertiesPtr = param.getSpectroProperties();
		if (spectroPropertiesPtr == nullptr)
			continue; //no spectro defined
fbe3c2bb   Benjamin Renard   First commit
52

c2fa3b5d   Benjamin Renard   Rework of legend ...
53
54
		if(!spectroPropertiesPtr->hasYAxis())
			continue;
fbe3c2bb   Benjamin Renard   First commit
55

c2fa3b5d   Benjamin Renard   Rework of legend ...
56
57
58
59
		std::string yAxisId = spectroPropertiesPtr->getYAxisId();
		boost::shared_ptr<Axis> lYAxis = plot->_panel->getAxis(yAxisId);
		if (lYAxis.get() == nullptr)
			continue;
fbe3c2bb   Benjamin Renard   First commit
60

df45df5e   Benjamin Renard   Introduce AxisLeg...
61
		if (!lYAxis->_legend.isEmpty())
c2fa3b5d   Benjamin Renard   Rework of legend ...
62
			continue;
5ee90a58   Benjamin Renard   Use AxisLegendMan...
63
64
		
		setAxisLegendForTable(plot, lYAxis, param._originalParamId, spectroPropertiesPtr->getParamId(), spectroPropertiesPtr->getIndexes(), spectroPropertiesPtr->getRelatedDim());
c2fa3b5d   Benjamin Renard   Rework of legend ...
65
		return;
fbe3c2bb   Benjamin Renard   First commit
66
	}
c2fa3b5d   Benjamin Renard   Rework of legend ...
67
68
69
70
71
72
}

void AxisLegendManager::configureYAxisLegendForSeries(
		PanelPlotOutput* plot)
{
	SeriesProperties lSeriesProperties;
fbe3c2bb   Benjamin Renard   First commit
73

8bb0f02b   Benjamin Renard   Set colors in axi...
74
75
76
	// Compute nb series to draw by y axis
	std::map<std::string,int> nbSeriesByYAxisMap = plot->getNbSeriesByYAxis();

c2fa3b5d   Benjamin Renard   Rework of legend ...
77
78
	// Build list of all indexes used by each parameters for each y axes
	std::map<std::string, AxisParamsComponents> axesParamsComponents;
8bb0f02b   Benjamin Renard   Set colors in axi...
79
80
81
	if (!plot->_panel->_page->_superposeMode) {
		plot->resetAutomaticSerieColorCursor();
	}
fbe3c2bb   Benjamin Renard   First commit
82
83
	for (auto param: plot->_parameterAxesList)
	{
fbe3c2bb   Benjamin Renard   First commit
84
85
86
87
88
89
		for(auto index: param.getYSerieIndexList(plot->_pParameterValues))
		{
			lSeriesProperties = param.getYSeriePropertiesAt(index);
			if(!lSeriesProperties.hasYAxis())
				continue;

8bb0f02b   Benjamin Renard   Set colors in axi...
90
91
			bool moreThanOneSerieForAxis = (nbSeriesByYAxisMap[lSeriesProperties.getYAxisId()] > 1);

fbe3c2bb   Benjamin Renard   First commit
92
			std::string yAxisId = lSeriesProperties.getYAxisId();
fbe3c2bb   Benjamin Renard   First commit
93
94
			boost::shared_ptr<Axis> lYAxis = plot->_panel->getAxis(yAxisId);
			if (lYAxis.get() == nullptr) {
fbe3c2bb   Benjamin Renard   First commit
95
				continue;
c2fa3b5d   Benjamin Renard   Rework of legend ...
96
 			}
fbe3c2bb   Benjamin Renard   First commit
97

8bb0f02b   Benjamin Renard   Set colors in axi...
98
99
100
101
102
103
			Color compLegendColor = lYAxis->_color;
			if (moreThanOneSerieForAxis && (lSeriesProperties.getColorSerieId() == -1) && (!plot->_panel->_page->_superposeMode)) {
				compLegendColor = plot->getSerieLineColor(lSeriesProperties, moreThanOneSerieForAxis);
			}
			ParameterIndexComponentColor yIndex = ParameterIndexComponentColor(index, compLegendColor);
			pushComponentInList(lSeriesProperties.getParamId(), yIndex, axesParamsComponents[yAxisId]);
c2fa3b5d   Benjamin Renard   Rework of legend ...
104
105
		}
	}
8bb0f02b   Benjamin Renard   Set colors in axi...
106
107
108
	if (!plot->_panel->_page->_superposeMode) {
		plot->resetAutomaticSerieColorCursor();
	}
fbe3c2bb   Benjamin Renard   First commit
109

c2fa3b5d   Benjamin Renard   Rework of legend ...
110
111
112
113
114
115
	std::list<std::string> legendLines;
	for (auto axisParamsComponents : axesParamsComponents) {
		boost::shared_ptr<Axis> lYAxis = plot->_panel->getAxis(axisParamsComponents.first);
		setAxisLegendForSeries(plot, lYAxis, axisParamsComponents.second);
	}
}
fbe3c2bb   Benjamin Renard   First commit
116

5ee90a58   Benjamin Renard   Use AxisLegendMan...
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
void AxisLegendManager::configureColorAxisLegendForSeries(
		PanelPlotOutput* plot)
{
	SeriesProperties lSeriesProperties;
	ColorSeriesProperties lColorSerieProperties;
	boost::shared_ptr<Axis> lZAxis = plot->_panel->getColorAxis();
	
	if (lZAxis.get() == nullptr) {
		return;
 	}

	// Build list of all indexes used by each parameters for each y axes
	AxisParamsComponents axisParamsComponents;
	for (auto param: plot->_parameterAxesList) {
		for(auto index: param.getYSerieIndexList(plot->_pParameterValues)) {
			lSeriesProperties = param.getYSeriePropertiesAt(index);

			if(!lSeriesProperties.hasYAxis())
				continue;

			std::string yParamId = lSeriesProperties.getParamId();

			//check if a colored param is defined for this serie
			if(lSeriesProperties.getColorParamId().empty())
				continue;

			ParameterAxes* colorSerieParameterAxes = plot->getParameterAxesByColorSerieId(lSeriesProperties.getColorSerieId());

			if (colorSerieParameterAxes == NULL)
				continue;

			lColorSerieProperties = colorSerieParameterAxes->getColorSeriePropertiesById(lSeriesProperties.getColorSerieId());

8bb0f02b   Benjamin Renard   Set colors in axi...
150
			ParameterIndexComponentColor colorSerieIndex = ParameterIndexComponentColor(-1, -1, lZAxis->_color);
5ee90a58   Benjamin Renard   Use AxisLegendMan...
151
			if (lColorSerieProperties.getIndex() > -1)
8bb0f02b   Benjamin Renard   Set colors in axi...
152
				colorSerieIndex = ParameterIndexComponentColor(lColorSerieProperties.getIndex(), -1, lZAxis->_color);
5ee90a58   Benjamin Renard   Use AxisLegendMan...
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
			pushComponentInList(lColorSerieProperties.getColorParamIds()[yParamId], colorSerieIndex, axisParamsComponents);
		}
	}

	setAxisLegendForSeries(plot, lZAxis, axisParamsComponents);
}

void AxisLegendManager::configureColorAxisLegendForSpectro(
		PanelPlotOutput* plot)
{
	boost::shared_ptr<Axis> lZAxis = plot->_panel->getColorAxis();
		
	if (lZAxis.get() == nullptr) {
		return;
 	}

	for (auto param: plot->_parameterAxesList) {
		std::shared_ptr<SpectroProperties> spectroPropertiesPtr = param.getSpectroProperties();
		if (spectroPropertiesPtr == nullptr)
			continue; //no spectro defined

		if(!spectroPropertiesPtr->hasZAxis())
			continue;
		
		setAxisLegendForSpectro(plot, lZAxis, param._originalParamId);
		break;
	}
}

8bb0f02b   Benjamin Renard   Set colors in axi...
182
183
void AxisLegendManager::pushComponentInList(std::string paramId, ParameterIndexComponentColor& index, AxisParamsComponents& axisParamsComponents) {
	if (index.getDim1Index() == -1 && index.getDim2Index() == -1) {
c2fa3b5d   Benjamin Renard   Rework of legend ...
184
185
186
187
188
189
		//All indexes of this parameter are used
		axisParamsComponents[paramId].clear();
		axisParamsComponents[paramId].push_back(index);
	}
	else {
		if (axisParamsComponents[paramId].size() > 0) {
8bb0f02b   Benjamin Renard   Set colors in axi...
190
			if (axisParamsComponents[paramId].front().getDim1Index() == -1 && axisParamsComponents[paramId].front().getDim2Index() == -1) {
c2fa3b5d   Benjamin Renard   Rework of legend ...
191
192
				//Skip. All components already defined for this paramter on this axis
				return;
fbe3c2bb   Benjamin Renard   First commit
193
			}
c2fa3b5d   Benjamin Renard   Rework of legend ...
194
		}
8bb0f02b   Benjamin Renard   Set colors in axi...
195
196
197
198
199
		for (auto crtIndex : axisParamsComponents[paramId]) {
			if ((crtIndex.getDim1Index() == index.getDim1Index()) && (crtIndex.getDim2Index() == index.getDim2Index())) {
				//Component already exists
				return;
			}
c2fa3b5d   Benjamin Renard   Rework of legend ...
200
		}
8bb0f02b   Benjamin Renard   Set colors in axi...
201
202
		//Add this components for this axis
		axisParamsComponents[paramId].push_back(index);
c2fa3b5d   Benjamin Renard   Rework of legend ...
203
	}
fbe3c2bb   Benjamin Renard   First commit
204

c2fa3b5d   Benjamin Renard   Rework of legend ...
205
}
fbe3c2bb   Benjamin Renard   First commit
206

c2fa3b5d   Benjamin Renard   Rework of legend ...
207
void AxisLegendManager::setAxisLegendForSeries(PanelPlotOutput* plot, boost::shared_ptr<Axis>& pAxis, AxisParamsComponents& axisParamsComponents) {
df45df5e   Benjamin Renard   Introduce AxisLeg...
208
	if (pAxis == nullptr || !pAxis->_legend.isEmpty()) {
c2fa3b5d   Benjamin Renard   Rework of legend ...
209
210
		return;
	}
fbe3c2bb   Benjamin Renard   First commit
211

c2fa3b5d   Benjamin Renard   Rework of legend ...
212
213
	// Retrieve ParamInfo Manager
	ParamMgr* piMgr = ParamMgr::getInstance();
fbe3c2bb   Benjamin Renard   First commit
214

c2fa3b5d   Benjamin Renard   Rework of legend ...
215
216
217
218
219
	for (auto paramsComponents : axisParamsComponents) {
		ParameterSPtr p = plot->_parameterManager.getParameter(paramsComponents.first);
		ParamInfoSPtr   paramInfo = piMgr->getParamInfoFromId(p->getInfoId());
		if (paramsComponents.second.size() == p->getDataWriterTemplate()->getParamData()->getDim1() * p->getDataWriterTemplate()->getParamData()->getDim2()) {
			//All components of this parameter are used by this axis => merge
8bb0f02b   Benjamin Renard   Set colors in axi...
220
			Color color = paramsComponents.second.front().getColor();
c2fa3b5d   Benjamin Renard   Rework of legend ...
221
			paramsComponents.second.clear();
8bb0f02b   Benjamin Renard   Set colors in axi...
222
			paramsComponents.second.push_back(ParameterIndexComponentColor(-1,-1, color));
c2fa3b5d   Benjamin Renard   Rework of legend ...
223
		}
8c8ac7bf   Benjamin Renard   Write mission/ins...
224
		bool isFirstComponent = true;
c2fa3b5d   Benjamin Renard   Rework of legend ...
225
226
227
		for (auto components : paramsComponents.second) {
			if (paramInfo == nullptr)
				continue;
8bb0f02b   Benjamin Renard   Set colors in axi...
228
229
230
231
232
233
234
235
236
237
238
239
			Label label(pAxis->_legend.getFont(), components.getColor());
			if (axisParamsComponents.size() == 1) {
				if (isFirstComponent) {
					std::string info = getMissionInstrumentInfo(paramInfo);
					if (!info.empty()) {
						label._text = info;
						addBreakLine(label._text);
					}
				}
			}
			else {
				std::string info = getMissionInfo(paramInfo);
8c8ac7bf   Benjamin Renard   Write mission/ins...
240
				if (!info.empty()) {
8bb0f02b   Benjamin Renard   Set colors in axi...
241
					label._text = info + ", ";
8c8ac7bf   Benjamin Renard   Write mission/ins...
242
243
				}
			}
df45df5e   Benjamin Renard   Introduce AxisLeg...
244
			label._text += getParamLegend(paramInfo, components);
8bb0f02b   Benjamin Renard   Set colors in axi...
245
			pAxis->_legend.pushLabel(label);
8c8ac7bf   Benjamin Renard   Write mission/ins...
246
			isFirstComponent = false;
fbe3c2bb   Benjamin Renard   First commit
247
		}
fbe3c2bb   Benjamin Renard   First commit
248
249
250
	}
}

5ee90a58   Benjamin Renard   Use AxisLegendMan...
251
void AxisLegendManager::setAxisLegendForSpectro(PanelPlotOutput* plot, boost::shared_ptr<Axis>& pAxis, std::string originalParamId) {
df45df5e   Benjamin Renard   Introduce AxisLeg...
252
	if (pAxis == nullptr || !pAxis->_legend.isEmpty()) {
5ee90a58   Benjamin Renard   Use AxisLegendMan...
253
		return;
fbe3c2bb   Benjamin Renard   First commit
254
	}
fbe3c2bb   Benjamin Renard   First commit
255

5ee90a58   Benjamin Renard   Use AxisLegendMan...
256
257
258
259
260
261
262
	// Retrieve ParamInfo Manager
	ParamMgr* piMgr = ParamMgr::getInstance();
	
	ParameterSPtr p = plot->_parameterManager.getParameter(originalParamId);
	AMDA::Info::ParamInfoSPtr paramInfo = piMgr->getParamInfoFromId(p->getInfoId());
	if (paramInfo == nullptr)
		return;
c2fa3b5d   Benjamin Renard   Rework of legend ...
263

df45df5e   Benjamin Renard   Introduce AxisLeg...
264
265
266
267
	Label label(pAxis->_legend.getFont(), pAxis->_legend.getColor());
	addInfoPart(label._text, paramInfo->getShortName());
	addInfoPart(label._text, paramInfo->getUnits());
	pAxis->_legend.setLabel(label);
c2fa3b5d   Benjamin Renard   Rework of legend ...
268
269
}

5ee90a58   Benjamin Renard   Use AxisLegendMan...
270
void AxisLegendManager::setAxisLegendForTable(PanelPlotOutput* plot, boost::shared_ptr<Axis>& pAxis, std::string originalParamId, std::string paramId, AMDA::Common::ParameterIndexComponentList& indexes, int relatedDim) {
df45df5e   Benjamin Renard   Introduce AxisLeg...
271
	if (pAxis == nullptr || !pAxis->_legend.isEmpty()) {
5ee90a58   Benjamin Renard   Use AxisLegendMan...
272
273
		return;
	}
fbe3c2bb   Benjamin Renard   First commit
274

5ee90a58   Benjamin Renard   Use AxisLegendMan...
275
276
277
278
279
280
281
282
	// Retrieve ParamInfo Manager
	ParamMgr* piMgr = ParamMgr::getInstance();
	
	ParameterSPtr p = plot->_parameterManager.getParameter(originalParamId);
	AMDA::Info::ParamInfoSPtr paramInfo = piMgr->getParamInfoFromId(p->getInfoId());
	
	if (paramInfo == nullptr)
			return;
fbe3c2bb   Benjamin Renard   First commit
283

df45df5e   Benjamin Renard   Introduce AxisLeg...
284
	Label label(pAxis->_legend.getFont(), pAxis->_legend.getColor());
fb96d5d5   Benjamin Renard   Add mission name ...
285
286
	std::string info = getMissionInstrumentInfo(paramInfo);
	if (!info.empty()) {
df45df5e   Benjamin Renard   Introduce AxisLeg...
287
288
		addInfoPart(label._text, info);
		addBreakLine(label._text);
fb96d5d5   Benjamin Renard   Add mission name ...
289
290
	}

5ee90a58   Benjamin Renard   Use AxisLegendMan...
291
292
	boost::shared_ptr<AMDA::Info::ParamTable> tableSPtr;
	tableSPtr = paramInfo->getTable(relatedDim);
fbe3c2bb   Benjamin Renard   First commit
293

5ee90a58   Benjamin Renard   Use AxisLegendMan...
294
295
296
297
	if (tableSPtr == nullptr) {
		std::string tableInfo = "Table ";
		tableInfo += std::to_string(relatedDim);
		tableInfo += " indexes";
df45df5e   Benjamin Renard   Introduce AxisLeg...
298
299
		addInfoPart(label._text, tableInfo);
		pAxis->_legend.pushLabel(label);
5ee90a58   Benjamin Renard   Use AxisLegendMan...
300
301
		return;
	}
fbe3c2bb   Benjamin Renard   First commit
302

5ee90a58   Benjamin Renard   Use AxisLegendMan...
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
	if (((*plot->_pParameterValues)[paramId].getDim1Size() > 0) &&
		((*plot->_pParameterValues)[paramId].getDim2Size() > 0) &&
		!indexes.empty())
	{
		boost::shared_ptr<AMDA::Info::ParamTable> otherTableSPtr;
		int otherDimIndex;
		if (relatedDim == 0)
		{
			otherTableSPtr = paramInfo->getTable(1);
			otherDimIndex = indexes.front().getDim2Index();
		}
		else
		{
			otherTableSPtr = paramInfo->getTable(0);
			otherDimIndex = indexes.front().getDim1Index();
		}
e7ea756d   Benjamin Renard   Implements tables...
319
		if ((otherTableSPtr != nullptr) && !otherTableSPtr->isVariable(&plot->_parameterManager))
5ee90a58   Benjamin Renard   Use AxisLegendMan...
320
		{
e7ea756d   Benjamin Renard   Implements tables...
321
			if (otherTableSPtr->getName(&plot->_parameterManager).empty())
df45df5e   Benjamin Renard   Introduce AxisLeg...
322
				addInfoPart(label._text, "Table bounds");
5ee90a58   Benjamin Renard   Use AxisLegendMan...
323
			else
e7ea756d   Benjamin Renard   Implements tables...
324
				addInfoPart(label._text, otherTableSPtr->getName(&plot->_parameterManager));
5ee90a58   Benjamin Renard   Use AxisLegendMan...
325
326
				
			AMDA::Info::t_TableBound crtBound = otherTableSPtr->getBound(&plot->_parameterManager, otherDimIndex);
df45df5e   Benjamin Renard   Introduce AxisLeg...
327
			addBoundsPart(label._text, crtBound.min, crtBound.max);
e7ea756d   Benjamin Renard   Implements tables...
328
			addInfoPart(label._text, otherTableSPtr->getUnits(&plot->_parameterManager));
5ee90a58   Benjamin Renard   Use AxisLegendMan...
329
330
331
332
333
		}
		else
		{
			std::string part = "Table Index: ";
			part += otherDimIndex;
df45df5e   Benjamin Renard   Introduce AxisLeg...
334
			addInfoPart(label._text, part);
c2fa3b5d   Benjamin Renard   Rework of legend ...
335
		}
df45df5e   Benjamin Renard   Introduce AxisLeg...
336
		addBreakLine(label._text);
c2fa3b5d   Benjamin Renard   Rework of legend ...
337
	}
e7ea756d   Benjamin Renard   Implements tables...
338
339
	addInfoPart(label._text, tableSPtr->getName(&plot->_parameterManager));
	addInfoPart(label._text, tableSPtr->getUnits(&plot->_parameterManager));
df45df5e   Benjamin Renard   Introduce AxisLeg...
340
	pAxis->_legend.pushLabel(label);
c2fa3b5d   Benjamin Renard   Rework of legend ...
341
}
fbe3c2bb   Benjamin Renard   First commit
342

c2fa3b5d   Benjamin Renard   Rework of legend ...
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
void AxisLegendManager::addInfoPart(std::string& legend, std::string info) {
	if (!info.empty()) {
		if (!legend.empty()) {
			if (legend.length() >= Label::DELIMITER.length()) {
				if (legend.compare(legend.length() - Label::DELIMITER.length(), Label::DELIMITER.length(), Label::DELIMITER) != 0) {
					legend += ", ";
				}
			}
			else {
				legend += ", ";
			}
		}
		legend += info;
	}
}
fbe3c2bb   Benjamin Renard   First commit
358

8bb0f02b   Benjamin Renard   Set colors in axi...
359
void AxisLegendManager::addIndexPart(std::string& legend, ParameterIndexComponentColor& index) {
c2fa3b5d   Benjamin Renard   Rework of legend ...
360
361
362
363
364
365
366
367
	legend += "[";
	legend += std::to_string(index.getDim1Index());
	if (index.getDim2Index() != -1) {
		legend += ",";
		legend += std::to_string(index.getDim2Index());
	}
	legend += "]";
}
fbe3c2bb   Benjamin Renard   First commit
368

c2fa3b5d   Benjamin Renard   Rework of legend ...
369
370
371
372
373
void AxisLegendManager::addIndexPart(std::string& legend, int index) {
	legend += "[";
	legend += std::to_string(index);
	legend += "]";
}
fbe3c2bb   Benjamin Renard   First commit
374

c2fa3b5d   Benjamin Renard   Rework of legend ...
375
376
void AxisLegendManager::addBoundsPart(std::string& legend, PLFLT min, PLFLT max) {
	legend += " ";
fbe3c2bb   Benjamin Renard   First commit
377

c2fa3b5d   Benjamin Renard   Rework of legend ...
378
379
380
381
	PLINT axis = 0;
	PLPointer data = NULL;
	char minCount[1024];
	char maxCount[1024];
fbe3c2bb   Benjamin Renard   First commit
382

c2fa3b5d   Benjamin Renard   Rework of legend ...
383
384
	generateDigitalLabel(axis, min, minCount, 1024, data);
	generateDigitalLabel(axis, max, maxCount, 1024, data);
fbe3c2bb   Benjamin Renard   First commit
385

c2fa3b5d   Benjamin Renard   Rework of legend ...
386
387
388
389
	legend += std::string(minCount);
	legend += ", ";
	legend += std::string(maxCount);
}
fbe3c2bb   Benjamin Renard   First commit
390

c2fa3b5d   Benjamin Renard   Rework of legend ...
391
392
393
void AxisLegendManager::addBreakLine(std::string& legend) {
	if (!legend.empty()) {
		legend += Label::DELIMITER;
fbe3c2bb   Benjamin Renard   First commit
394
	}
c2fa3b5d   Benjamin Renard   Rework of legend ...
395
}
fbe3c2bb   Benjamin Renard   First commit
396

8bb0f02b   Benjamin Renard   Set colors in axi...
397
std::string AxisLegendManager::getParamLegend(AMDA::Info::ParamInfoSPtr paramInfo, ParameterIndexComponentColor& index) {
c2fa3b5d   Benjamin Renard   Rework of legend ...
398
399
400
401
	std::string legend;
	addInfoPart(legend, paramInfo->getShortName());

	if ((index.getDim1Index() != -1) || (index.getDim2Index() != -1)) {
8bb0f02b   Benjamin Renard   Set colors in axi...
402
403
404
		AMDA::Common::ParameterIndexComponent paramIndex(index.getDim1Index(), index.getDim2Index());
		if (paramInfo->getComponents(paramIndex).empty() == false)
			addInfoPart(legend, paramInfo->getComponents(paramIndex));
c2fa3b5d   Benjamin Renard   Rework of legend ...
405
		else
fbe3c2bb   Benjamin Renard   First commit
406
		{
c2fa3b5d   Benjamin Renard   Rework of legend ...
407
408
			addInfoPart(legend, paramInfo->getShortName());
			addIndexPart(legend, index);
fbe3c2bb   Benjamin Renard   First commit
409
		}
fbe3c2bb   Benjamin Renard   First commit
410
	}
c2fa3b5d   Benjamin Renard   Rework of legend ...
411
412
413
414
415
416
417

	addInfoPart(legend, paramInfo->getUnits());
	addInfoPart(legend, paramInfo->getCoordinatesSystem());
	
	return legend;
}

5ee90a58   Benjamin Renard   Use AxisLegendMan...
418
/*std::string AxisLegendManager::getParamLegend(AMDA::Info::ParamInfoSPtr paramInfo, int index) {
c2fa3b5d   Benjamin Renard   Rework of legend ...
419
420
421
	std::string legend;
	addInfoPart(legend, paramInfo->getShortName());

5ee90a58   Benjamin Renard   Use AxisLegendMan...
422
	if ((index.getDim1Index() != -1) || (index.getDim2Index() != -1)) {
c2fa3b5d   Benjamin Renard   Rework of legend ...
423
424
425
426
427
428
429
430
431
432
433
                if (paramInfo->getComponents(index).empty() == false)
                        addInfoPart(legend, paramInfo->getComponents(index));
                else
                {
                        addInfoPart(legend, paramInfo->getShortName());
                        addIndexPart(legend, index);
                }
        }

        addInfoPart(legend, paramInfo->getUnits());
        addInfoPart(legend, paramInfo->getCoordinatesSystem());
5ee90a58   Benjamin Renard   Use AxisLegendMan...
434

c2fa3b5d   Benjamin Renard   Rework of legend ...
435
        return legend;
5ee90a58   Benjamin Renard   Use AxisLegendMan...
436
}*/
fbe3c2bb   Benjamin Renard   First commit
437

8c8ac7bf   Benjamin Renard   Write mission/ins...
438
439
440
441
442
443
444
445
446
std::string AxisLegendManager::getMissionInstrumentInfo(AMDA::Info::ParamInfoSPtr paramInfo) {
	std::string info = paramInfo->getInstrumentId();
	if (info.empty())
		return info;
	std::replace(info.begin(), info.end(), '_', ' ');
	std::transform(info.begin(), info.end(), info.begin(), ::toupper);
	return info;
}

8bb0f02b   Benjamin Renard   Set colors in axi...
447
448
449
450
451
452
453
454
455
456
457
std::string AxisLegendManager::getMissionInfo(AMDA::Info::ParamInfoSPtr paramInfo) {
	std::string info = paramInfo->getInstrumentId();
	if (info.empty())
		return info;
	if (info.find('_') != std::string::npos) {
		info = info.substr(0, info.find('_'));
	}
	std::transform(info.begin(), info.end(), info.begin(), ::toupper);
	return info;
}

fbe3c2bb   Benjamin Renard   First commit
458
} /* namespace plot */