Blame view

src/ParamOutputImpl/Plot/Page.hh 5.57 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
	Label* getTitle() {
		return &_title;
	}

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

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

760db061   Erdogan Furkan   #11242- Done, wit...
91
92
93
94

	int getIntIndex(){return _intIndex;}
	void setIntIndex(int index){_intIndex  = index;}

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

	void getDrawableBoundsInPlPage(Bounds& pBounds);

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

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

fbe3c2bb   Benjamin Renard   First commit
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
	/*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...
133
134
135
136
137
138
139
140
141
142
	 * Page horizontal loaded margin
	 */
	float _xLoadedMargin;

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

	/**
fbe3c2bb   Benjamin Renard   First commit
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
	 * 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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
	 * 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 ...
175
176
177
178
179
	/**
	 * @brief The name of the file data
	 *
	 */
	std::string fileDataName;
fbe3c2bb   Benjamin Renard   First commit
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203

	/**
	 * 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...
204
205
206
207
208
	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
209
private:
f6eaec4e   Benjamin Renard   Optimize plot ele...
210
211
212
213
214
215
216
217
218
	/**
	 * Page font
	 */
	Font _font;

	/**
	 * Page title
	 */
	Label _title;
fbe3c2bb   Benjamin Renard   First commit
219

760db061   Erdogan Furkan   #11242- Done, wit...
220
221
	int _intIndex;

fbe3c2bb   Benjamin Renard   First commit
222
223
	void initPageParameters(std::shared_ptr<plstream>& pls);

f6eaec4e   Benjamin Renard   Optimize plot ele...
224
225
226
	void drawCopyright(std::shared_ptr<plstream>& pls);

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

fbe3c2bb   Benjamin Renard   First commit
228
229
230
231
232
233
234
235
236
237
238
239
240
};

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
241
242
243
244
245
246
247
248
249
250
251
252
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_ */