Commit b96aa97588371e78c898c7de7a5c258d12933b4a
1 parent
08ec1dde
Exists in
master
and in
100 other branches
Draw border around empty panel
Fix another bug with page margin definition
Showing
7 changed files
with
72 additions
and
14 deletions
Show diff stats
src/ParamOutputImpl/Plot/CommonNode.cc
@@ -21,14 +21,14 @@ void MarginNode::proceed(xmlNodePtr pNode, | @@ -21,14 +21,14 @@ void MarginNode::proceed(xmlNodePtr pNode, | ||
21 | // -- horizontal margin | 21 | // -- horizontal margin |
22 | value = xmlGetProp(pNode, (const xmlChar *) "x"); | 22 | value = xmlGetProp(pNode, (const xmlChar *) "x"); |
23 | if (value) { | 23 | if (value) { |
24 | - element->_xMargin = atof((const char*) value); | 24 | + element->_xLoadedMargin = atof((const char*) value); |
25 | xmlFree(value); | 25 | xmlFree(value); |
26 | } | 26 | } |
27 | 27 | ||
28 | // -- vertical margin | 28 | // -- vertical margin |
29 | value = xmlGetProp(pNode, (const xmlChar *) "y"); | 29 | value = xmlGetProp(pNode, (const xmlChar *) "y"); |
30 | if (value) { | 30 | if (value) { |
31 | - element->_yMargin = atof((const char*) value); | 31 | + element->_yLoadedMargin = atof((const char*) value); |
32 | xmlFree(value); | 32 | xmlFree(value); |
33 | } | 33 | } |
34 | } | 34 | } |
src/ParamOutputImpl/Plot/Page.cc
@@ -36,6 +36,8 @@ Page::Page() : | @@ -36,6 +36,8 @@ Page::Page() : | ||
36 | _format(), | 36 | _format(), |
37 | _xMargin(-1), | 37 | _xMargin(-1), |
38 | _yMargin(-1), | 38 | _yMargin(-1), |
39 | + _xLoadedMargin(-1), | ||
40 | + _yLoadedMargin(-1), | ||
39 | _orientation(PlotCommon::Orientation::LANDSCAPE), | 41 | _orientation(PlotCommon::Orientation::LANDSCAPE), |
40 | _mode(PlotCommon::Mode::COLOR), | 42 | _mode(PlotCommon::Mode::COLOR), |
41 | _dimension(PlotCommon::Dimension::ISO_A4), | 43 | _dimension(PlotCommon::Dimension::ISO_A4), |
@@ -72,6 +74,8 @@ Page::Page(DefaultPlotConfiguration& defaults) : | @@ -72,6 +74,8 @@ Page::Page(DefaultPlotConfiguration& defaults) : | ||
72 | _format(defaults._defaultPage._format), | 74 | _format(defaults._defaultPage._format), |
73 | _xMargin(-1), | 75 | _xMargin(-1), |
74 | _yMargin(-1), | 76 | _yMargin(-1), |
77 | + _xLoadedMargin(-1), | ||
78 | + _yLoadedMargin(-1), | ||
75 | _orientation(defaults._defaultPage._orientation), | 79 | _orientation(defaults._defaultPage._orientation), |
76 | _mode(defaults._defaultPage._mode), | 80 | _mode(defaults._defaultPage._mode), |
77 | _dimension(defaults._defaultPage._dimension), | 81 | _dimension(defaults._defaultPage._dimension), |
@@ -107,6 +111,8 @@ Page::Page(const Page& page) : | @@ -107,6 +111,8 @@ Page::Page(const Page& page) : | ||
107 | _format(page._format), | 111 | _format(page._format), |
108 | _xMargin(-1), | 112 | _xMargin(-1), |
109 | _yMargin(-1), | 113 | _yMargin(-1), |
114 | + _xLoadedMargin(-1), | ||
115 | + _yLoadedMargin(-1), | ||
110 | _orientation(page._orientation), | 116 | _orientation(page._orientation), |
111 | _mode(page._mode), | 117 | _mode(page._mode), |
112 | _dimension(page._dimension), | 118 | _dimension(page._dimension), |
@@ -315,14 +321,17 @@ void Page::writeCopywrite(std::shared_ptr<plstream>& pls) { | @@ -315,14 +321,17 @@ void Page::writeCopywrite(std::shared_ptr<plstream>& pls) { | ||
315 | 321 | ||
316 | void Page::initPageParameters(std::shared_ptr<plstream>& pls) { | 322 | void Page::initPageParameters(std::shared_ptr<plstream>& pls) { |
317 | // get default margin if not set | 323 | // get default margin if not set |
318 | - if (_xMargin == -1) | ||
319 | - calculateRelativeXMargin(_orientation, _dimension, DefaultPlotConfiguration::getInstance()._defaultPage._xMargin); | 324 | + if (_xLoadedMargin == -1) |
325 | + calculateRelativeXMargin(_orientation, _dimension, DefaultPlotConfiguration::getInstance()._defaultPage._xLoadedMargin); | ||
320 | else | 326 | else |
321 | - calculateRelativeXMargin(_orientation, _dimension, _xMargin); | ||
322 | - if (_yMargin == -1) | ||
323 | - calculateRelativeYMargin(_orientation, _dimension, DefaultPlotConfiguration::getInstance()._defaultPage._yMargin); | 327 | + calculateRelativeXMargin(_orientation, _dimension, _xLoadedMargin); |
328 | + | ||
329 | + if (_yLoadedMargin == -1) | ||
330 | + calculateRelativeYMargin(_orientation, _dimension, DefaultPlotConfiguration::getInstance()._defaultPage._yLoadedMargin); | ||
324 | else | 331 | else |
325 | - calculateRelativeYMargin(_orientation, _dimension, _yMargin); | 332 | + calculateRelativeYMargin(_orientation, _dimension, _yLoadedMargin); |
333 | + | ||
334 | + | ||
326 | 335 | ||
327 | // set page size according to page format A4 or letter | 336 | // set page size according to page format A4 or letter |
328 | // offset not seams to work | 337 | // offset not seams to work |
@@ -387,6 +396,7 @@ void Page::calculateRelativeYMargin(PlotCommon::Orientation& orientation, | @@ -387,6 +396,7 @@ void Page::calculateRelativeYMargin(PlotCommon::Orientation& orientation, | ||
387 | ylengthInMm = Page::A4_X_LENGTH_IN_MM; | 396 | ylengthInMm = Page::A4_X_LENGTH_IN_MM; |
388 | } | 397 | } |
389 | } | 398 | } |
399 | + | ||
390 | _yMargin = yMarginInMm / ylengthInMm; | 400 | _yMargin = yMarginInMm / ylengthInMm; |
391 | } | 401 | } |
392 | 402 |
src/ParamOutputImpl/Plot/Page.hh
@@ -103,6 +103,16 @@ public: | @@ -103,6 +103,16 @@ public: | ||
103 | float _yMargin; | 103 | float _yMargin; |
104 | 104 | ||
105 | /** | 105 | /** |
106 | + * Page horizontal loaded margin | ||
107 | + */ | ||
108 | + float _xLoadedMargin; | ||
109 | + | ||
110 | + /** | ||
111 | + * Page vertical loaded margin | ||
112 | + */ | ||
113 | + float _yLoadedMargin; | ||
114 | + | ||
115 | + /** | ||
106 | * Page orientation : landscape, portrait | 116 | * Page orientation : landscape, portrait |
107 | */ | 117 | */ |
108 | PlotCommon::Orientation _orientation; | 118 | PlotCommon::Orientation _orientation; |
src/ParamOutputImpl/Plot/Panel.cc
@@ -212,6 +212,37 @@ void Panel::fillBackground(std::shared_ptr<plstream>& pls, | @@ -212,6 +212,37 @@ void Panel::fillBackground(std::shared_ptr<plstream>& pls, | ||
212 | } | 212 | } |
213 | } | 213 | } |
214 | 214 | ||
215 | +void Panel::drawEmptyPanel(std::shared_ptr<plstream>& pls) | ||
216 | +{ | ||
217 | + Bounds lBounds = getCoordinateInPlPage(pls.get(), _bounds, _page); | ||
218 | + | ||
219 | + // Specify viewport for the panel | ||
220 | + pls->vpor(lBounds._x, lBounds._x + lBounds._width, | ||
221 | + lBounds._y, lBounds._y + lBounds._height); | ||
222 | + | ||
223 | + // Set window size. | ||
224 | + pls->wind(0, 1, 0, 1); | ||
225 | + | ||
226 | + | ||
227 | + pls->col0(0); | ||
228 | + | ||
229 | + //Draw panel border | ||
230 | + PLFLT xBorder[5] = {0,0,1,1,0}; | ||
231 | + PLFLT yBorder[5] = {0,1,1,0,0}; | ||
232 | + | ||
233 | + pls->lsty(static_cast<int>(getPlLineStyle(LineStyle::LONG_SPACED_DOT))); | ||
234 | + pls->width(1); | ||
235 | + pls->line(5,xBorder,yBorder); | ||
236 | + | ||
237 | + //Draw text | ||
238 | + pls->schr(getPlFontDef(_font), getPlFontScaleFactor(_font)); | ||
239 | + pls->ptex (0.5, 0.5, 0.5, 0, 0.5, std::string("Empty panel").c_str()); | ||
240 | + | ||
241 | + // Set window size. | ||
242 | + pls->wind(lBounds._x, lBounds._x + lBounds._width, | ||
243 | + lBounds._y, lBounds._y + lBounds._height); | ||
244 | +} | ||
245 | + | ||
215 | Bounds Panel::getCoordinateInPlPage(plstream* pls, const Bounds& pBounds, Page* pPage) { | 246 | Bounds Panel::getCoordinateInPlPage(plstream* pls, const Bounds& pBounds, Page* pPage) { |
216 | Bounds lBounds; | 247 | Bounds lBounds; |
217 | 248 |
src/ParamOutputImpl/Plot/Panel.hh
@@ -235,6 +235,8 @@ public: | @@ -235,6 +235,8 @@ public: | ||
235 | 235 | ||
236 | float getTitlePositionUnits (void); | 236 | float getTitlePositionUnits (void); |
237 | 237 | ||
238 | + void drawEmptyPanel(std::shared_ptr<plstream>& pls); | ||
239 | + | ||
238 | private: | 240 | private: |
239 | 241 | ||
240 | void fillBackground(std::shared_ptr<plstream>& pls, Bounds& pBounds) const; | 242 | void fillBackground(std::shared_ptr<plstream>& pls, Bounds& pBounds) const; |
src/ParamOutputImpl/Plot/PanelPlotOutput.cc
@@ -143,6 +143,13 @@ void PanelPlotOutput::calculatePlotArea(Bounds& bounds_) { | @@ -143,6 +143,13 @@ void PanelPlotOutput::calculatePlotArea(Bounds& bounds_) { | ||
143 | CharSize lCharSizePanelTitle(getCharacterSize(lFontFactorPanelTitle)); | 143 | CharSize lCharSizePanelTitle(getCharacterSize(lFontFactorPanelTitle)); |
144 | double panelTitleCharHeight = lCharSizePanelTitle.second; | 144 | double panelTitleCharHeight = lCharSizePanelTitle.second; |
145 | 145 | ||
146 | + //Init | ||
147 | + _plotAreaSideSet[PlotCommon::Position::POS_TOP] = false; | ||
148 | + _plotAreaSideSet[PlotCommon::Position::POS_BOTTOM] = false; | ||
149 | + _plotAreaSideSet[PlotCommon::Position::POS_RIGHT] = false; | ||
150 | + _plotAreaSideSet[PlotCommon::Position::POS_LEFT] = false; | ||
151 | + _plotAreaSideSet[PlotCommon::Position::POS_CENTER] = false; | ||
152 | + | ||
146 | // Set space between panel title and graduation number. | 153 | // Set space between panel title and graduation number. |
147 | if (_panel->_title._text.empty() == false) { | 154 | if (_panel->_title._text.empty() == false) { |
148 | LabelRowInfo splittedLegend = Label::getRowNumber(_panel->_title); | 155 | LabelRowInfo splittedLegend = Label::getRowNumber(_panel->_title); |
@@ -179,7 +186,7 @@ void PanelPlotOutput::calculatePlotArea(Bounds& bounds_) { | @@ -179,7 +186,7 @@ void PanelPlotOutput::calculatePlotArea(Bounds& bounds_) { | ||
179 | { | 186 | { |
180 | //Add X and Y axis to the working list | 187 | //Add X and Y axis to the working list |
181 | boost::shared_ptr<Axis> lAxis = it->second; | 188 | boost::shared_ptr<Axis> lAxis = it->second; |
182 | - if (lAxis->_isZAxis) | 189 | + if ((lAxis == nullptr) || (lAxis->_isZAxis)) |
183 | continue; | 190 | continue; |
184 | workingAxesList.push_back(std::pair<std::string,boost::shared_ptr<Axis>>(it->first,lAxis)); | 191 | workingAxesList.push_back(std::pair<std::string,boost::shared_ptr<Axis>>(it->first,lAxis)); |
185 | } | 192 | } |
@@ -187,7 +194,7 @@ void PanelPlotOutput::calculatePlotArea(Bounds& bounds_) { | @@ -187,7 +194,7 @@ void PanelPlotOutput::calculatePlotArea(Bounds& bounds_) { | ||
187 | { | 194 | { |
188 | //Add Z axis to the working list | 195 | //Add Z axis to the working list |
189 | boost::shared_ptr<Axis> lAxis = it->second; | 196 | boost::shared_ptr<Axis> lAxis = it->second; |
190 | - if (!lAxis->_isZAxis) | 197 | + if ((lAxis == nullptr) || (!lAxis->_isZAxis)) |
191 | continue; | 198 | continue; |
192 | workingAxesList.push_back(std::pair<std::string,boost::shared_ptr<Axis>>(it->first,lAxis)); | 199 | workingAxesList.push_back(std::pair<std::string,boost::shared_ptr<Axis>>(it->first,lAxis)); |
193 | } | 200 | } |
@@ -2270,9 +2277,7 @@ void PanelPlotOutput::draw(double startTime, double stopTime, int intervalIndex, | @@ -2270,9 +2277,7 @@ void PanelPlotOutput::draw(double startTime, double stopTime, int intervalIndex, | ||
2270 | _panel->draw(_pls); | 2277 | _panel->draw(_pls); |
2271 | 2278 | ||
2272 | if (_parameterAxesList.empty()) | 2279 | if (_parameterAxesList.empty()) |
2273 | - { | ||
2274 | - _pls->mtex("b", -1., 1, 1, std::string("Empty panel").c_str()); | ||
2275 | - } | 2280 | + _panel->drawEmptyPanel(_pls); |
2276 | 2281 | ||
2277 | if (isFirstInterval) | 2282 | if (isFirstInterval) |
2278 | _panel->_paramsLegendProperties.reset(); | 2283 | _panel->_paramsLegendProperties.reset(); |
src/ParamOutputImpl/Plot/Time/TimePlot.cc
@@ -92,7 +92,7 @@ void TimePlot::draw(double startTime, double stopTime, int intervalIndex, | @@ -92,7 +92,7 @@ void TimePlot::draw(double startTime, double stopTime, int intervalIndex, | ||
92 | PanelPlotOutput::draw(startTime,stopTime,intervalIndex,isFirstInterval,isLastInterval); | 92 | PanelPlotOutput::draw(startTime,stopTime,intervalIndex,isFirstInterval,isLastInterval); |
93 | 93 | ||
94 | // Draw start date | 94 | // Draw start date |
95 | - if (!_startDateDrawn && getTimeAxis()->_used) | 95 | + if (!_startDateDrawn /*&& getTimeAxis()->_used*/) |
96 | drawStartDate (getTimeAxis(), startTime,stopTime); | 96 | drawStartDate (getTimeAxis(), startTime,stopTime); |
97 | _startDateDrawn = true; | 97 | _startDateDrawn = true; |
98 | } | 98 | } |