Page.hh
4.86 KB
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
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
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
/*
* 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"
#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;
/* externalized
static const PLINT A4_X_LENGTH_IN_PX;
static const PLINT A4_Y_LENGTH_IN_PX;
static const PLINT LETTER_X_LENGTH_IN_PX;
static const PLINT LETTER_Y_LENGTH_IN_PX;
static const PLINT DPI;*/
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);
void draw(std::shared_ptr<plstream>& pls, bool newFile, const char *plotFilePrefix);
/*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;
/**
* Page orientation : landscape, portrait
*/
PlotCommon::Orientation _orientation;
/**
* Page mode : color, greyscale
*/
PlotCommon::Mode _mode;
/**
* Page dimension : a4, letter
*/
PlotCommon::Dimension _dimension;
/**
* Page, panel etc. default font
*/
Font _font;
/**
* Page title
*/
Label _title;
/**
* 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;
/**
* 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;
private:
void initPageParameters(std::shared_ptr<plstream>& pls);
void writeCopywrite(std::shared_ptr<plstream>& pls);
void calculateXMargin(PlotCommon::Orientation& orientation,
PlotCommon::Dimension& dimension);
void calculateYMargin(PlotCommon::Orientation& orientation,
PlotCommon::Dimension& dimension);
};
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);
PLFLT getPlVportYmin(PlotCommon::Position& position);
PLFLT getPlVportYmax(PlotCommon::Position& position);
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_ */