Blame view

src/ParamOutputImpl/Plot/Panel.hh 4.96 KB
fbe3c2bb   Benjamin Renard   First commit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/*
 * Panel.hh
 *
 *  Created on: 28 oct. 2013
 *      Author: CS
 */

#ifndef PANEL_HH_
#define PANEL_HH_

#include <string>
#include "Bounds.hh"
#include "Font.hh"
#include "Color.hh"
#include "PlotCommon.hh"
#include <boost/shared_ptr.hpp>
#include <memory>
#include <map>
#include "plplot/plstream.h"
#include "Axis.hh"
#include "ColorAxis.hh"
#include "TextPlot.hh"
#include "CurvePlot.hh"
#include "FillSerieConstant.hh"
#include "FillSerieSerie.hh"
#include "ParamsLegendProperties.hh"
#include "TextLegendProperties.hh"
#include "Layout.hh"
8499fbdd   Benjamin Renard   Context file gene...
29
#include "ContextFileWriter.hh"
fbe3c2bb   Benjamin Renard   First commit
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

namespace plot {

class Page;
class DefaultPlotConfiguration;

typedef std::map<std::string, boost::shared_ptr<Axis>> Axes;
typedef std::list<boost::shared_ptr<TextPlot>> TextPlots;
typedef std::list<boost::shared_ptr<CurvePlot>> CurvePlots;
typedef std::list<boost::shared_ptr<FillSerieConstant>> FillSerieConstants;
typedef std::list<boost::shared_ptr<FillSerieSerie>> FillSerieSeries;
typedef std::list<boost::shared_ptr<TextLegendProperties>> TextLegendPropertiesList;

/**
 * @brief A panel is a part of Page and owns a plot (and eventually 
 *        its decorator).
 */
class Panel {
public:

	static const float TEXT_FACTOR;

	static const float LINE_SPACE_TITLE;

	/**
	 * @brief Counter for panel unique id
	 */
	static int PANEL_COUNTER;

	/**
	 * @brief Transform coordinate from AMDA page to Plplot page.
	 */
	static Bounds getCoordinateInPlPage(plstream* pls, const Bounds& pBounds, Page* pPage);

	Panel();
	Panel(DefaultPlotConfiguration& defaults);
	Panel(Page* page);
	virtual ~Panel();

	/**
	 * @brief Draws panel.
	 */
	void draw(std::shared_ptr<plstream>& pls);

	/**
8499fbdd   Benjamin Renard   Context file gene...
75
76
77
78
79
	 * @brief Write panel context
	 */
	void writeContext(std::shared_ptr<plstream>& pls, ContextFileWriter& writer);

	/**
fbe3c2bb   Benjamin Renard   First commit
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
150
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
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
	 * @brief Adds axis to panel, depends on plot type.
	 */
	void addAxis(const std::string& pAxisId, boost::shared_ptr<Axis> pAxis) {
		_axes[pAxisId] = pAxis; }

	/**
	 * @brief Gets Axis from id, new axis is created if not found.
	 */
	boost::shared_ptr<Axis> getAxis(const std::string& pAxisId) { return _axes[pAxisId]; }

	/**
	 * @brief Adds color axis to panel
	 */
	void addColorAxis(const std::string& pAxisId, boost::shared_ptr<ColorAxis> pColorAxis) {
		_colorAxis = pColorAxis;
		_axes[pAxisId] = pColorAxis;
	}

	/**
	 * @brief Reset for next time interval plot
	 */
	void reset() {
		for (auto axe : _axes)
		{
			if (axe.second != nullptr)
				axe.second->reset();
		}
		_paramsLegendProperties.reset();
		for (auto legend : _textLegendPropertiesList)
			legend->reset();
		for (auto text : _textPlots)
			text->reset();
		for (auto curve : _curvePlots)
			curve->reset();
		_drawn = false;
	}

	/**
	 * @brief Gets color axis
	 */
	boost::shared_ptr<ColorAxis> getColorAxis(void) { return _colorAxis; }


	/**
	 * @brief Panel unique identifier
	 */
	int _id;

	/**
	 * @brief Number of points per plot
	 */
	int _resolution;

	/**
	 * @brief Panel font, may be different from page font
	 */
	Font _font;

	/**
	 * @brief Panel title, may be empty
	 */
	Label _title;

	/**
	 * @brief Flag to know if the title must be updated during the next interval plot
	 */
	bool _updateTitleOnNextInterval;

	/**
	 * @brief Panel position and size.
	 */
	Bounds _bounds;

	/**
	 * @brief Background color
	 */
	Color _backgroundColor;

	/**
	 * @brief Panel title Align (center, left, right)
	 */
	PlotCommon::Align _titleAlign;

	/**
	 * @brief Panel title Position (top, bottom)
	 */
	PlotCommon::Position _titlePosition;

	/**
	 * @brief _drawn Define if panel is already drawn (true) or not (false).
	 */
	bool _drawn;

	/**
	 * @brief Page container
	 */
	Page* _page;

	/**
	 * @brief List of axis.
	 */
	Axes _axes;

	/**
	 * @brief List of axis.
	 */
	boost::shared_ptr<ColorAxis> _colorAxis;

	/**
	 * @brief Prefered panel width and height.
	 * @note Number set is in unit of panel character width or height.
	 */
	double _preferedWidth;
	double _preferedHeight;

	/**
	 * @brief Space between border of panel and border of plot area.
	 * @note Number set is in unit of panel character height.
	 */
	int _leftMargin;
	int _rightMargin;
	int _topMargin;
	int _bottomMargin;

	/**
	 * @brief List of textplots.
	 */
	TextPlots _textPlots;

	/**
	 * @brief List of curveplots.
	 */
	CurvePlots _curvePlots;

	/**
	 * @brief List of FillSerieConstant.
	 */
	FillSerieConstants _fillSerieConstants;

	/**
	 * @brief List of FillSerieSerie.
	 */
	FillSerieSeries _fillSerieSeries;


	/**
	 * @brief Parameter legend properties
	 */
	ParamsLegendProperties _paramsLegendProperties;

	/**
	 * @brief Text legend properties list
	 */
	TextLegendPropertiesList _textLegendPropertiesList;


	float getTitlePositionUnits (void);

b96aa975   Benjamin Renard   Draw border aroun...
238
239
	void drawEmptyPanel(std::shared_ptr<plstream>& pls);

fbe3c2bb   Benjamin Renard   First commit
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
private:

	void fillBackground(std::shared_ptr<plstream>& pls, Bounds& pBounds) const;

	/**
	 * @brief Position in units of the title character height
	 */
	float _titlePositionUnits;


};

std::ostream& operator <<(std::ostream& out, Panel& panel);

} /* namespace plot */
#endif /* PANEL_HH_ */