Commit b96aa97588371e78c898c7de7a5c258d12933b4a

Authored by Benjamin Renard
1 parent 08ec1dde

Draw border around empty panel

Fix another bug with page margin definition
src/ParamOutputImpl/Plot/CommonNode.cc
... ... @@ -21,14 +21,14 @@ void MarginNode::proceed(xmlNodePtr pNode,
21 21 // -- horizontal margin
22 22 value = xmlGetProp(pNode, (const xmlChar *) "x");
23 23 if (value) {
24   - element->_xMargin = atof((const char*) value);
  24 + element->_xLoadedMargin = atof((const char*) value);
25 25 xmlFree(value);
26 26 }
27 27  
28 28 // -- vertical margin
29 29 value = xmlGetProp(pNode, (const xmlChar *) "y");
30 30 if (value) {
31   - element->_yMargin = atof((const char*) value);
  31 + element->_yLoadedMargin = atof((const char*) value);
32 32 xmlFree(value);
33 33 }
34 34 }
... ...
src/ParamOutputImpl/Plot/Page.cc
... ... @@ -36,6 +36,8 @@ Page::Page() :
36 36 _format(),
37 37 _xMargin(-1),
38 38 _yMargin(-1),
  39 + _xLoadedMargin(-1),
  40 + _yLoadedMargin(-1),
39 41 _orientation(PlotCommon::Orientation::LANDSCAPE),
40 42 _mode(PlotCommon::Mode::COLOR),
41 43 _dimension(PlotCommon::Dimension::ISO_A4),
... ... @@ -72,6 +74,8 @@ Page::Page(DefaultPlotConfiguration& defaults) :
72 74 _format(defaults._defaultPage._format),
73 75 _xMargin(-1),
74 76 _yMargin(-1),
  77 + _xLoadedMargin(-1),
  78 + _yLoadedMargin(-1),
75 79 _orientation(defaults._defaultPage._orientation),
76 80 _mode(defaults._defaultPage._mode),
77 81 _dimension(defaults._defaultPage._dimension),
... ... @@ -107,6 +111,8 @@ Page::Page(const Page& page) :
107 111 _format(page._format),
108 112 _xMargin(-1),
109 113 _yMargin(-1),
  114 + _xLoadedMargin(-1),
  115 + _yLoadedMargin(-1),
110 116 _orientation(page._orientation),
111 117 _mode(page._mode),
112 118 _dimension(page._dimension),
... ... @@ -315,14 +321,17 @@ void Page::writeCopywrite(std::shared_ptr<plstream>& pls) {
315 321  
316 322 void Page::initPageParameters(std::shared_ptr<plstream>& pls) {
317 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 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 331 else
325   - calculateRelativeYMargin(_orientation, _dimension, _yMargin);
  332 + calculateRelativeYMargin(_orientation, _dimension, _yLoadedMargin);
  333 +
  334 +
326 335  
327 336 // set page size according to page format A4 or letter
328 337 // offset not seams to work
... ... @@ -387,6 +396,7 @@ void Page::calculateRelativeYMargin(PlotCommon::Orientation&amp; orientation,
387 396 ylengthInMm = Page::A4_X_LENGTH_IN_MM;
388 397 }
389 398 }
  399 +
390 400 _yMargin = yMarginInMm / ylengthInMm;
391 401 }
392 402  
... ...
src/ParamOutputImpl/Plot/Page.hh
... ... @@ -103,6 +103,16 @@ public:
103 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 116 * Page orientation : landscape, portrait
107 117 */
108 118 PlotCommon::Orientation _orientation;
... ...
src/ParamOutputImpl/Plot/Panel.cc
... ... @@ -212,6 +212,37 @@ void Panel::fillBackground(std::shared_ptr&lt;plstream&gt;&amp; 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 246 Bounds Panel::getCoordinateInPlPage(plstream* pls, const Bounds& pBounds, Page* pPage) {
216 247 Bounds lBounds;
217 248  
... ...
src/ParamOutputImpl/Plot/Panel.hh
... ... @@ -235,6 +235,8 @@ public:
235 235  
236 236 float getTitlePositionUnits (void);
237 237  
  238 + void drawEmptyPanel(std::shared_ptr<plstream>& pls);
  239 +
238 240 private:
239 241  
240 242 void fillBackground(std::shared_ptr<plstream>& pls, Bounds& pBounds) const;
... ...
src/ParamOutputImpl/Plot/PanelPlotOutput.cc
... ... @@ -143,6 +143,13 @@ void PanelPlotOutput::calculatePlotArea(Bounds&amp; bounds_) {
143 143 CharSize lCharSizePanelTitle(getCharacterSize(lFontFactorPanelTitle));
144 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 153 // Set space between panel title and graduation number.
147 154 if (_panel->_title._text.empty() == false) {
148 155 LabelRowInfo splittedLegend = Label::getRowNumber(_panel->_title);
... ... @@ -179,7 +186,7 @@ void PanelPlotOutput::calculatePlotArea(Bounds&amp; bounds_) {
179 186 {
180 187 //Add X and Y axis to the working list
181 188 boost::shared_ptr<Axis> lAxis = it->second;
182   - if (lAxis->_isZAxis)
  189 + if ((lAxis == nullptr) || (lAxis->_isZAxis))
183 190 continue;
184 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&amp; bounds_) {
187 194 {
188 195 //Add Z axis to the working list
189 196 boost::shared_ptr<Axis> lAxis = it->second;
190   - if (!lAxis->_isZAxis)
  197 + if ((lAxis == nullptr) || (!lAxis->_isZAxis))
191 198 continue;
192 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 2277 _panel->draw(_pls);
2271 2278  
2272 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 2282 if (isFirstInterval)
2278 2283 _panel->_paramsLegendProperties.reset();
... ...
src/ParamOutputImpl/Plot/Time/TimePlot.cc
... ... @@ -92,7 +92,7 @@ void TimePlot::draw(double startTime, double stopTime, int intervalIndex,
92 92 PanelPlotOutput::draw(startTime,stopTime,intervalIndex,isFirstInterval,isLastInterval);
93 93  
94 94 // Draw start date
95   - if (!_startDateDrawn && getTimeAxis()->_used)
  95 + if (!_startDateDrawn /*&& getTimeAxis()->_used*/)
96 96 drawStartDate (getTimeAxis(), startTime,stopTime);
97 97 _startDateDrawn = true;
98 98 }
... ...