Blame view

src/ParamOutputImpl/Plot/Page.hh 5.46 KB
fbe3c2bb   Benjamin Renard   First commit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
/*
 * Page.hh
 *
 *  Created on: 28 oct. 2013
 *      Author: CS
 */

#ifndef PAGE_HH_
#define PAGE_HH_

#include "Panel.hh"
#include "Font.hh"
#include "PlotCommon.hh"
#include "LayoutProperties.hh"
8499fbdd   Benjamin Renard   Context file gene...
15
#include "ContextFileWriter.hh"
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

#include <boost/shared_ptr.hpp>
#include <vector>
#include <tuple>
#include <memory>

#include "plplot/plstream.h"

namespace plot {

class Page {
public:

	static const PLINT A4_X_LENGTH_IN_MM;
	static const PLINT A4_Y_LENGTH_IN_MM;
	static const PLINT LETTER_X_LENGTH_IN_MM;
	static const PLINT LETTER_Y_LENGTH_IN_MM;

	static const PLFLT A4_X_LENGTH_IN_INCHES;
	static const PLFLT A4_Y_LENGTH_IN_INCHES;
	static const PLFLT LETTER_X_LENGTH_IN_INCHES;
	static const PLFLT LETTER_Y_LENGTH_IN_INCHES;

	static const PLINT A4_X_LENGTH_IN_PT;
	static const PLINT A4_Y_LENGTH_IN_PT;
	static const PLINT LETTER_X_LENGTH_IN_PT;
	static const PLINT LETTER_Y_LENGTH_IN_PT;

fbe3c2bb   Benjamin Renard   First commit
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
	Page();
	Page(DefaultPlotConfiguration& defaults);
	Page(const Page& page);
	virtual ~Page();

	/**
	 * @brief Get page size in millimeter.
	 * @return Return a tuple which contain page size in x coordinate and then page size in y coordinate.
	 */
	std::tuple<float, float> getSizeInMm();

	/**
	 * @brief Get page size in current coordinate (point or pixel) according to device.
	 * @return Return a tuple which contain page size in x coordinate and then page size in y coordinate.
	 */
	std::tuple<float, float> getSize();

	void setFont(std::string pname, int psize) {
		_font = Font(pname, psize);
	}

	void setDimension(const std::string& pdimension);

	void setOrientation(const std::string& porientation);

	void setMode(const std::string& pmode);

f6eaec4e   Benjamin Renard   Optimize plot ele...
71
72
73
74
75
76
77
78
	const Font& getFont() const {
		return _font;
	}

	void setFont(const Font& font) {
		_font = font;
	}

f6eaec4e   Benjamin Renard   Optimize plot ele...
79
80
81
82
83
84
85
86
87
88
89
90
91
92
	Label* getTitle() {
		return &_title;
	}

	const Label* getTitle() const {
		return &_title;
	}

	void setTitleText(const char* titleText) {
		_title._text = titleText;
	}

	Font getTitleFont() {
		Font titleFont(_title.getFont());
df45df5e   Benjamin Renard   Introduce AxisLeg...
93
94
95
96
		if (titleFont.getName() == "")
			titleFont.setName(_font.getName());
		if (titleFont.getSize() == 0)
			titleFont.setSize(_font.getSize());
f6eaec4e   Benjamin Renard   Optimize plot ele...
97
98
99
100
101
		return titleFont;
	}

	void getDrawableBoundsInPlPage(Bounds& pBounds);

fbe3c2bb   Benjamin Renard   First commit
102
103
	void draw(std::shared_ptr<plstream>& pls, bool newFile, const char *plotFilePrefix);

8499fbdd   Benjamin Renard   Context file gene...
104
105
	void writeContext(ContextFileWriter& writer);

fbe3c2bb   Benjamin Renard   First commit
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
	/*void addPanel(boost::shared_ptr<Panel> panel){
	 _panels.push_back(panel);
	 }*/
public:

	//std::vector<boost::shared_ptr<Panel>> _panels;

	/**
	 * Page format : png, ps etc.
	 */
	std::string _format;

	/**
	 * Page horizontal margin
	 */
	float _xMargin;

	/**
	 * Page vertical margin
	 */
	float _yMargin;

	/**
b96aa975   Benjamin Renard   Draw border aroun...
129
130
131
132
133
134
135
136
137
138
	 * Page horizontal loaded margin
	 */
	float _xLoadedMargin;

	/**
	 * Page vertical loaded margin
	 */
	float _yLoadedMargin;

	/**
fbe3c2bb   Benjamin Renard   First commit
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
	 * Page orientation : landscape, portrait
	 */
	PlotCommon::Orientation _orientation;

	/**
	 * Page mode : color, greyscale
	 */
	PlotCommon::Mode _mode;

	/**
	 * Page dimension : a4, letter
	 */
	PlotCommon::Dimension _dimension;

	/**
fbe3c2bb   Benjamin Renard   First commit
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
	 * Page align : left, center, right
	 */
	PlotCommon::Align _titleAlign;

	/**
	 * Page position : top, bottom
	 */
	PlotCommon::Position _titlePosition;
	
	int _dpi;

	LayoutProperties _layoutProperties;

	/**
	 * Page file name
	 */
	std::string _fileName;
27bb729a   Menouard AZIB   add fileDataName ...
171
172
173
174
175
	/**
	 * @brief The name of the file data
	 *
	 */
	std::string fileDataName;
fbe3c2bb   Benjamin Renard   First commit
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199

	/**
	 * Default TimePlot and XYPLot width and height (used by vertical layout)
	 * Default TimePlot and XYPlot margins (used to fix plot area size)
	 */
	double _defaultTimePlotWidth;
	double _defaultTimePlotHeight;
	double _defaultTimePlotLeftMargin;
	double _defaultTimePlotRightMargin;
	double _defaultTimePlotTopMargin;
	double _defaultTimePlotBottomMargin;

	double _defaultXYPlotWidth;
	double _defaultXYPlotHeight;
	double _defaultXYPlotLeftMargin;
	double _defaultXYPlotRightMargin;
	double _defaultXYPlotTopMargin;
	double _defaultXYPlotBottomMargin;

	/**
	 * Superpose draw of all intervals in the same page
	 */
	bool _superposeMode;

8d19d171   Benjamin Renard   Fix bug with rela...
200
201
202
203
204
	void calculateRelativeXMargin(PlotCommon::Orientation& orientation,
				PlotCommon::Dimension& dimension, float xMarginInMm);
	void calculateRelativeYMargin(PlotCommon::Orientation& orientation,
				PlotCommon::Dimension& dimension, float yMarginInMm);

fbe3c2bb   Benjamin Renard   First commit
205
private:
f6eaec4e   Benjamin Renard   Optimize plot ele...
206
207
208
209
210
211
212
213
214
	/**
	 * Page font
	 */
	Font _font;

	/**
	 * Page title
	 */
	Label _title;
fbe3c2bb   Benjamin Renard   First commit
215
216
217

	void initPageParameters(std::shared_ptr<plstream>& pls);

f6eaec4e   Benjamin Renard   Optimize plot ele...
218
219
220
	void drawCopyright(std::shared_ptr<plstream>& pls);

	void drawTitle(std::shared_ptr<plstream>& pls);
fbe3c2bb   Benjamin Renard   First commit
221

fbe3c2bb   Benjamin Renard   First commit
222
223
224
225
226
227
228
229
230
231
232
233
234
};

std::ostream& operator <<(std::ostream& out, Page& page);
std::ostream& operator <<(std::ostream& out, PlotCommon::Dimension& dimension);
std::ostream& operator <<(std::ostream& out,
		PlotCommon::Orientation& orientation);
std::ostream& operator <<(std::ostream& out, PlotCommon::Mode& mode);

const std::string getPlSide(PlotCommon::Position& position);
PLFLT getPlPos(PlotCommon::Align& align);
PLFLT getPlJust(PlotCommon::Align& align);
PLFLT getPlColor(PlotCommon::Mode& mode);
const std::string getPlDev(const std::string& format);
fbe3c2bb   Benjamin Renard   First commit
235
236
237
238
239
240
241
242
243
244
245
246
PLINT getPlDevXLength(const std::string& format,
		PlotCommon::Dimension& dimension, int dpi);
PLINT getPlDevYLength(const std::string& format,
		PlotCommon::Dimension& dimension, int dpi);

Color changeColor(std::shared_ptr<plstream>& pls, Color& color, PlotCommon::Mode mode, int cmap = 0);
void restoreColor(std::shared_ptr<plstream>& pls, Color& color, PlotCommon::Mode mode, int cmap = 0);

void getDefaultColor(PlotCommon::Mode mode, int& cursor, Color& color);

} /* namespace plot */
#endif /* PAGE_HH_ */