Blame view

src/ParamOutputImpl/Plot/ParamsLegendProperties.hh 6.07 KB
fbe3c2bb   Benjamin Renard   First commit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
/*
 * ParamsLegendProperties.hh
 *
 *  Created on: 18 sep. 2014
 *      Author: AKKA
 */

#ifndef PARAMSLEGENDPROPERTIES_HH_
#define PARAMSLEGENDPROPERTIES_HH_

#define LEGEND_NB_SYMBOLS_TO_DRAW 4
#define LEGEND_TEXT_OFFSET        1.0
#define LEGEND_TEXT_SPACING       2.0
#define LEGEND_TEXT_JUSTIFICATION 0.0
8b6d84db   Benjamin Renard   Fix legend positi...
15
#define LEGEND_OUTSIDE_OFFSET      0.005
fbe3c2bb   Benjamin Renard   First commit
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
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
#define LEGEND_INSIDE_OFFSET      0.005
#define LEGEND_LINE_SYM_WIDTH     0.05

#include <list>
#include <vector>

#include "plplot/plstream.h"

#include "Color.hh"
#include "SymbolProperties.hh"
#include "LineProperties.hh"
#include "ParameterAxes.hh"
#include "SeriesProperties.hh"

namespace plot
{
	typedef enum {POS_INSIDE, POS_OUTSIDE} ParamsLegendPosition;

	/*
	 * @brief Class for properties of a legend line
	 */
	class LegendLineProperties
	{
	public:
		/*
		 * @brief Constructor
		 */
		LegendLineProperties(void);

		/*
		 * @brief Destructor
		 */
		virtual ~LegendLineProperties(void);

		/*
		 * @brief Get symbol
		 */
		const SymbolProperties& getSymbolProperties(void) const;

		/*
		 * @brief Set symbol
		 */
		void setSymbolProperties(const SymbolProperties& symbolProperties);

		/*
		 * @brief Get line
		 */
		const LineProperties& getLineProperties(void) const;

		/*
		 * @brief Set line
		 */
		void setLineProperties(const LineProperties& lineProperties);

		/*
		 * @brief Get legend line text
		 */
		const char *getText(void) const;

		/*
		 * @brief Set legend line text
		 */
		void setText(const char *text);

		/*
		 * @brief Set the default color
		 */
		void setDefaultTextColor(const Color &textColor);

		/*
		 * @brief Get the color to use for this legend line.
		 */
		Color getTextColor(bool autoTextColor);

		/*
		 * @brief Show line
		 */
		bool isLineVisible(void);

		/*
		 * @brief Show symbol
		 */
		bool isSymbolsVisible(void);

	private:
		/*
		 * @brief Symbol properties
		 */
		SymbolProperties _symbolProperties;

		/*
		 * @brief Line properties
		 */
		LineProperties   _lineProperties;

		/*
		 * @brief Legend line text
		 */
		std::string _text;

		/*
		 * @brief Text color
		 */
		Color _textColor;
	};


	/*
	 * @brief Class to describe a params legend
	 */
	class ParamsLegendProperties
	{
	public:
		/*
		 * @brief Enumerate to know how to represent an interval in the legend
		 */
		enum IntervalInfoType {
			INDEX,
			STARTSTOP
		};

		/*
		 * @brief Constructor
		 */
		ParamsLegendProperties(void);

		/*
		 * @brief Destructor
		 */
		virtual ~ParamsLegendProperties(void);

		/*
		 * @brief Remove all legend lines and prepare for a next plot
		 */
20fef3b6   Benjamin Renard   Fix reset functio...
150
		void resetPlot(void);
fbe3c2bb   Benjamin Renard   First commit
151
152
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

		/*
		 * @brief Add a serie to the legend
		 */
		void addSerie(SeriesProperties &serie,const char *text, Color lineColor, Color symbolColor);

		/*
		 * @brief Get the associated color index from a given color
		 */
		int getColorIndex(plstream *pls, Color color);

		/*
		 * @brief Set only text option (don't show line and symbol)
		 */
		void setOnlyText(bool onlyText);

		/*
		 * @brief Legend is in only text mode?
		 */
		bool isOnlyText(void);

		/*
		 * @brief Set legend font
		 */
		void setFont(Font font);

		/*
		 * @brief Get legend font
		 */
		Font& getFont(void);

fbe3c2bb   Benjamin Renard   First commit
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
		/*
		 * @brief Set default text color
		 */
		void setDefaultTextColor(const Color& color);

		/*
		 * @brief Set legend border color
		 */
		void setBorderColor(const Color& color);

		/*
		 * @brief Get legend border color
		 */
		Color getBorderColor(void);

		/*
		 * @brief Set visibility of the border
		 */
		void setIsBorderVisible(bool boderVisible);

		/*
		 * @brief Get if the border is visible
		 */
		bool isBorderVisible(void);

		/*
		 * @brief Get if the legend is visible
		 */
		bool isVisible(void);

		/*
		 * @brief Set visibility of the legend
		 */
		void setIsVisible(bool isVisible);

		/*
		 * @brief Get legend position
		 */
		ParamsLegendPosition getPosition(void);

		/*
		 * @brief Set legend position
		 */
		void setPosition(ParamsLegendPosition position);

		/*
		 * @brief Get legend lines list
		 */
		const std::list<LegendLineProperties>& getLegendLines(void) const;

		/*
		 * @brief Get associated legend color map
		 */
		const std::vector<Color>& getColorsMap(void) const;

		/*
		 * @brief Estimate the width of the legend
		 */
		double getEstimateWidth(double charSize);

		/*
		 * @brief Get left offset
		 */
		double getLeftOffset(void);

		/*
		 * @brief Set left offset
		 */
		void setLeftOffset(double offset);

		/*
		 * @brief Legend already drawn?
		 */
		bool isDrawn(void);

		/*
		 * @brief Set legend already drawn propertie
		 */
		void setDrawn(bool drawn);

		/*
		 * @brief Set visibility of param info
		 */
		void setParamInfoVisible(bool isVisible);

		/*
		 * @brief Get visibility of param info
		 */
		bool isParamInfoVisible(void);

		/*
		 * @brief Set visibility of interval info
		 */
		void setIntervalInfoVisible(bool isVisible);

		/*
		 * @brief Get visibility of interval info
		 */
		bool isIntervalInfoVisible(void);

		/*
		 * @brief Set the type of the interval info (interval index or start/stop time)
		 */
		void setIntervalInfoType(IntervalInfoType type);

		/*
		 * @brief Get interval info type
		 */
		IntervalInfoType getIntervalInfoType(void);

fbe3c2bb   Benjamin Renard   First commit
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
	private:
		/*
		 * @brief Legend lines
		 */
		std::list<LegendLineProperties> _lines;

		/*
		 * @brief Legend colors
		 */
		std::vector<Color> _colors;

		/*
		 * @brief show only text
		 */
		bool _isOnlyText;

		/*
		 * @brief Default color
		 */
		Color _defaultTextColor;

		/*
		 * @brief Border visibility
		 */
		bool _isBorderVisible;

		/*
		 * @brief Border color
		 */
		Color _borderColor;

		/*
		 * @brief Legend visibility
		 */
		bool _isVisible;

		/*
		 * @brief Legend position
		 */
		ParamsLegendPosition _position;

		/*
f6eaec4e   Benjamin Renard   Optimize plot ele...
334
335
336
337
338
		 * @brief Legend font
		 */
		Font _font;

		/*
fbe3c2bb   Benjamin Renard   First commit
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
		 * @brief Legend left offset
		 */
		double _leftOffset;

		/*
		 * @brief Legend drawn
		 */
		bool _drawn;

		/*
		 * @brief Param info visibility
		 */
		bool _isParamInfoVisible;

		/*
		 * @brief Interval info visibility
		 */
		bool _isIntervalInfoVisible;

		/*
		 * @brief Interval info type
		 */
		IntervalInfoType _intervalInfoType;
	};
}

#endif /* PARAMSLEGENDPROPERTIES_HH_ */