diff --git a/src/ParamOutputImpl/Plot/CommonNode.cc b/src/ParamOutputImpl/Plot/CommonNode.cc index 1ae49ce..18f0071 100644 --- a/src/ParamOutputImpl/Plot/CommonNode.cc +++ b/src/ParamOutputImpl/Plot/CommonNode.cc @@ -21,14 +21,14 @@ void MarginNode::proceed(xmlNodePtr pNode, // -- horizontal margin value = xmlGetProp(pNode, (const xmlChar *) "x"); if (value) { - element->_xMargin = atof((const char*) value); + element->_xLoadedMargin = atof((const char*) value); xmlFree(value); } // -- vertical margin value = xmlGetProp(pNode, (const xmlChar *) "y"); if (value) { - element->_yMargin = atof((const char*) value); + element->_yLoadedMargin = atof((const char*) value); xmlFree(value); } } diff --git a/src/ParamOutputImpl/Plot/Page.cc b/src/ParamOutputImpl/Plot/Page.cc index 4724d95..004fa39 100644 --- a/src/ParamOutputImpl/Plot/Page.cc +++ b/src/ParamOutputImpl/Plot/Page.cc @@ -36,6 +36,8 @@ Page::Page() : _format(), _xMargin(-1), _yMargin(-1), + _xLoadedMargin(-1), + _yLoadedMargin(-1), _orientation(PlotCommon::Orientation::LANDSCAPE), _mode(PlotCommon::Mode::COLOR), _dimension(PlotCommon::Dimension::ISO_A4), @@ -72,6 +74,8 @@ Page::Page(DefaultPlotConfiguration& defaults) : _format(defaults._defaultPage._format), _xMargin(-1), _yMargin(-1), + _xLoadedMargin(-1), + _yLoadedMargin(-1), _orientation(defaults._defaultPage._orientation), _mode(defaults._defaultPage._mode), _dimension(defaults._defaultPage._dimension), @@ -107,6 +111,8 @@ Page::Page(const Page& page) : _format(page._format), _xMargin(-1), _yMargin(-1), + _xLoadedMargin(-1), + _yLoadedMargin(-1), _orientation(page._orientation), _mode(page._mode), _dimension(page._dimension), @@ -315,14 +321,17 @@ void Page::writeCopywrite(std::shared_ptr& pls) { void Page::initPageParameters(std::shared_ptr& pls) { // get default margin if not set - if (_xMargin == -1) - calculateRelativeXMargin(_orientation, _dimension, DefaultPlotConfiguration::getInstance()._defaultPage._xMargin); + if (_xLoadedMargin == -1) + calculateRelativeXMargin(_orientation, _dimension, DefaultPlotConfiguration::getInstance()._defaultPage._xLoadedMargin); else - calculateRelativeXMargin(_orientation, _dimension, _xMargin); - if (_yMargin == -1) - calculateRelativeYMargin(_orientation, _dimension, DefaultPlotConfiguration::getInstance()._defaultPage._yMargin); + calculateRelativeXMargin(_orientation, _dimension, _xLoadedMargin); + + if (_yLoadedMargin == -1) + calculateRelativeYMargin(_orientation, _dimension, DefaultPlotConfiguration::getInstance()._defaultPage._yLoadedMargin); else - calculateRelativeYMargin(_orientation, _dimension, _yMargin); + calculateRelativeYMargin(_orientation, _dimension, _yLoadedMargin); + + // set page size according to page format A4 or letter // offset not seams to work @@ -387,6 +396,7 @@ void Page::calculateRelativeYMargin(PlotCommon::Orientation& orientation, ylengthInMm = Page::A4_X_LENGTH_IN_MM; } } + _yMargin = yMarginInMm / ylengthInMm; } diff --git a/src/ParamOutputImpl/Plot/Page.hh b/src/ParamOutputImpl/Plot/Page.hh index d569588..9f73949 100644 --- a/src/ParamOutputImpl/Plot/Page.hh +++ b/src/ParamOutputImpl/Plot/Page.hh @@ -103,6 +103,16 @@ public: float _yMargin; /** + * Page horizontal loaded margin + */ + float _xLoadedMargin; + + /** + * Page vertical loaded margin + */ + float _yLoadedMargin; + + /** * Page orientation : landscape, portrait */ PlotCommon::Orientation _orientation; diff --git a/src/ParamOutputImpl/Plot/Panel.cc b/src/ParamOutputImpl/Plot/Panel.cc index 9473d59..ad71548 100644 --- a/src/ParamOutputImpl/Plot/Panel.cc +++ b/src/ParamOutputImpl/Plot/Panel.cc @@ -212,6 +212,37 @@ void Panel::fillBackground(std::shared_ptr& pls, } } +void Panel::drawEmptyPanel(std::shared_ptr& pls) +{ + Bounds lBounds = getCoordinateInPlPage(pls.get(), _bounds, _page); + + // Specify viewport for the panel + pls->vpor(lBounds._x, lBounds._x + lBounds._width, + lBounds._y, lBounds._y + lBounds._height); + + // Set window size. + pls->wind(0, 1, 0, 1); + + + pls->col0(0); + + //Draw panel border + PLFLT xBorder[5] = {0,0,1,1,0}; + PLFLT yBorder[5] = {0,1,1,0,0}; + + pls->lsty(static_cast(getPlLineStyle(LineStyle::LONG_SPACED_DOT))); + pls->width(1); + pls->line(5,xBorder,yBorder); + + //Draw text + pls->schr(getPlFontDef(_font), getPlFontScaleFactor(_font)); + pls->ptex (0.5, 0.5, 0.5, 0, 0.5, std::string("Empty panel").c_str()); + + // Set window size. + pls->wind(lBounds._x, lBounds._x + lBounds._width, + lBounds._y, lBounds._y + lBounds._height); +} + Bounds Panel::getCoordinateInPlPage(plstream* pls, const Bounds& pBounds, Page* pPage) { Bounds lBounds; diff --git a/src/ParamOutputImpl/Plot/Panel.hh b/src/ParamOutputImpl/Plot/Panel.hh index 7d01c34..dd648ba 100644 --- a/src/ParamOutputImpl/Plot/Panel.hh +++ b/src/ParamOutputImpl/Plot/Panel.hh @@ -235,6 +235,8 @@ public: float getTitlePositionUnits (void); + void drawEmptyPanel(std::shared_ptr& pls); + private: void fillBackground(std::shared_ptr& pls, Bounds& pBounds) const; diff --git a/src/ParamOutputImpl/Plot/PanelPlotOutput.cc b/src/ParamOutputImpl/Plot/PanelPlotOutput.cc index 4a1ea4e..ea8d4d7 100644 --- a/src/ParamOutputImpl/Plot/PanelPlotOutput.cc +++ b/src/ParamOutputImpl/Plot/PanelPlotOutput.cc @@ -143,6 +143,13 @@ void PanelPlotOutput::calculatePlotArea(Bounds& bounds_) { CharSize lCharSizePanelTitle(getCharacterSize(lFontFactorPanelTitle)); double panelTitleCharHeight = lCharSizePanelTitle.second; + //Init + _plotAreaSideSet[PlotCommon::Position::POS_TOP] = false; + _plotAreaSideSet[PlotCommon::Position::POS_BOTTOM] = false; + _plotAreaSideSet[PlotCommon::Position::POS_RIGHT] = false; + _plotAreaSideSet[PlotCommon::Position::POS_LEFT] = false; + _plotAreaSideSet[PlotCommon::Position::POS_CENTER] = false; + // Set space between panel title and graduation number. if (_panel->_title._text.empty() == false) { LabelRowInfo splittedLegend = Label::getRowNumber(_panel->_title); @@ -179,7 +186,7 @@ void PanelPlotOutput::calculatePlotArea(Bounds& bounds_) { { //Add X and Y axis to the working list boost::shared_ptr lAxis = it->second; - if (lAxis->_isZAxis) + if ((lAxis == nullptr) || (lAxis->_isZAxis)) continue; workingAxesList.push_back(std::pair>(it->first,lAxis)); } @@ -187,7 +194,7 @@ void PanelPlotOutput::calculatePlotArea(Bounds& bounds_) { { //Add Z axis to the working list boost::shared_ptr lAxis = it->second; - if (!lAxis->_isZAxis) + if ((lAxis == nullptr) || (!lAxis->_isZAxis)) continue; workingAxesList.push_back(std::pair>(it->first,lAxis)); } @@ -2270,9 +2277,7 @@ void PanelPlotOutput::draw(double startTime, double stopTime, int intervalIndex, _panel->draw(_pls); if (_parameterAxesList.empty()) - { - _pls->mtex("b", -1., 1, 1, std::string("Empty panel").c_str()); - } + _panel->drawEmptyPanel(_pls); if (isFirstInterval) _panel->_paramsLegendProperties.reset(); diff --git a/src/ParamOutputImpl/Plot/Time/TimePlot.cc b/src/ParamOutputImpl/Plot/Time/TimePlot.cc index 265e2ec..1edd762 100644 --- a/src/ParamOutputImpl/Plot/Time/TimePlot.cc +++ b/src/ParamOutputImpl/Plot/Time/TimePlot.cc @@ -92,7 +92,7 @@ void TimePlot::draw(double startTime, double stopTime, int intervalIndex, PanelPlotOutput::draw(startTime,stopTime,intervalIndex,isFirstInterval,isLastInterval); // Draw start date - if (!_startDateDrawn && getTimeAxis()->_used) + if (!_startDateDrawn /*&& getTimeAxis()->_used*/) drawStartDate (getTimeAxis(), startTime,stopTime); _startDateDrawn = true; } -- libgit2 0.21.2