diff --git a/src/ParamOutputImpl/Plot/Axis.cc b/src/ParamOutputImpl/Plot/Axis.cc index 291fa97..9db32b2 100644 --- a/src/ParamOutputImpl/Plot/Axis.cc +++ b/src/ParamOutputImpl/Plot/Axis.cc @@ -20,6 +20,7 @@ Axis::Axis(bool isZAxis) : _reverse(false), _tick(), _visible(true), + _used(false), _thickness(1), _legend(), _drawn(false), diff --git a/src/ParamOutputImpl/Plot/Axis.hh b/src/ParamOutputImpl/Plot/Axis.hh index 8acd94d..59f0460 100644 --- a/src/ParamOutputImpl/Plot/Axis.hh +++ b/src/ParamOutputImpl/Plot/Axis.hh @@ -125,6 +125,11 @@ public: bool _visible; /** + * @brief Axis is used for the plot or not + */ + bool _used; + + /** * @brief Axis draw thickness */ int _thickness; diff --git a/src/ParamOutputImpl/Plot/CommonNode.cc b/src/ParamOutputImpl/Plot/CommonNode.cc index 51767c6..1ae49ce 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->calculateRelativeXMargin(element->_orientation, element->_dimension, atof((const char*) value)); + element->_xMargin = atof((const char*) value); xmlFree(value); } // -- vertical margin value = xmlGetProp(pNode, (const xmlChar *) "y"); if (value) { - element->calculateRelativeYMargin(element->_orientation, element->_dimension, atof((const char*) value)); + element->_yMargin = atof((const char*) value); xmlFree(value); } } diff --git a/src/ParamOutputImpl/Plot/Epoch/EpochPlot.cc b/src/ParamOutputImpl/Plot/Epoch/EpochPlot.cc index cdb385d..b0db79b 100644 --- a/src/ParamOutputImpl/Plot/Epoch/EpochPlot.cc +++ b/src/ParamOutputImpl/Plot/Epoch/EpochPlot.cc @@ -70,6 +70,8 @@ void EpochPlot::preparePlotArea(double startTime, double stopTime, int intervalI _epochDecoratorPtr->configure(this, getEpochAxis(), getEpochAxis()->getRange().getMin(), getEpochAxis()->getRange().getMax(), _pParameterValues); + getEpochAxis()->_used = true; + PanelPlotOutput::preparePlotArea(startTime,stopTime,intervalIndex); } @@ -180,6 +182,7 @@ void EpochPlot::configureSeriesAxis() { lError << "EpochPlot::configureSeriesAxis" << ": Y axis with id '" << lSeriesProperties.getYAxisId() << "' not found."; BOOST_THROW_EXCEPTION(PanelPlotOutputException() << AMDA::ex_msg(lError.str())); } + lYAxis->_used = true; Range lRange(lYAxis->getRange()); // If range status for this axis is set by the user do not update range "automatically". @@ -206,6 +209,7 @@ void EpochPlot::configureSeriesAxis() { { if (!lSeriesProperties.getColorParamId().empty()) { + lZAxis->_used = true; Range lRange(lZAxis->getRange()); ParameterAxes* colorSerieParameterAxes = getParameterAxesByColorSerieId(lSeriesProperties.getColorSerieId()); if (colorSerieParameterAxes == NULL) diff --git a/src/ParamOutputImpl/Plot/InstantPlot/InstantPlot.cc b/src/ParamOutputImpl/Plot/InstantPlot/InstantPlot.cc index c9ba3b7..b80b463 100644 --- a/src/ParamOutputImpl/Plot/InstantPlot/InstantPlot.cc +++ b/src/ParamOutputImpl/Plot/InstantPlot/InstantPlot.cc @@ -593,6 +593,8 @@ void InstantPlot::configureSeriesAxis() { BOOST_THROW_EXCEPTION(PanelPlotOutputException() << AMDA::ex_msg(lError.str())); } + lXAxis->_used = true; + boost::shared_ptr lYAxis = _panel->getAxis(_iSerieProperties->getYAxisId()); if (lYAxis.get() == nullptr) { std::stringstream lError; @@ -600,6 +602,8 @@ void InstantPlot::configureSeriesAxis() { BOOST_THROW_EXCEPTION(PanelPlotOutputException() << AMDA::ex_msg(lError.str())); } + lYAxis->_used = true; + if (_iSerieProperties->getTableOnXAxis()) { configureTableAxis (lXAxis, false, 0); @@ -973,6 +977,7 @@ void InstantPlot::configureSpectroAxis() lError << "InstantPlot::configureSpectroAxis" << ": X axis with id '" << _iSpectroProperties->getXAxisId() << "' not found."; BOOST_THROW_EXCEPTION(PanelPlotOutputException() << AMDA::ex_msg(lError.str())); } + lXAxis->_used = true; boost::shared_ptr lYAxis = _panel->getAxis(_iSpectroProperties->getYAxisId()); if (lYAxis.get() == nullptr) { @@ -980,6 +985,7 @@ void InstantPlot::configureSpectroAxis() lError << "InstantPlot::configureSpectroAxis" << ": Y axis with id '" << _iSpectroProperties->getYAxisId() << "' not found."; BOOST_THROW_EXCEPTION(PanelPlotOutputException() << AMDA::ex_msg(lError.str())); } + lYAxis->_used = true; boost::shared_ptr lZAxis = _panel->getAxis(_iSpectroProperties->getZAxisId()); if (lZAxis.get() == nullptr) { @@ -987,6 +993,7 @@ void InstantPlot::configureSpectroAxis() lError << "InstantPlot::configureSpectroAxis" << ": Z axis with id '" << _iSpectroProperties->getYAxisId() << "' not found."; BOOST_THROW_EXCEPTION(PanelPlotOutputException() << AMDA::ex_msg(lError.str())); } + lZAxis->_used = true; if (_iSpectroProperties->getDimOnXAxis() == 0) { diff --git a/src/ParamOutputImpl/Plot/Page.cc b/src/ParamOutputImpl/Plot/Page.cc index 831790c..4724d95 100644 --- a/src/ParamOutputImpl/Plot/Page.cc +++ b/src/ParamOutputImpl/Plot/Page.cc @@ -316,9 +316,13 @@ void Page::writeCopywrite(std::shared_ptr& pls) { void Page::initPageParameters(std::shared_ptr& pls) { // get default margin if not set if (_xMargin == -1) - _xMargin = DefaultPlotConfiguration::getInstance()._defaultPage._xMargin; + calculateRelativeXMargin(_orientation, _dimension, DefaultPlotConfiguration::getInstance()._defaultPage._xMargin); + else + calculateRelativeXMargin(_orientation, _dimension, _xMargin); if (_yMargin == -1) - _yMargin = DefaultPlotConfiguration::getInstance()._defaultPage._yMargin; + calculateRelativeYMargin(_orientation, _dimension, DefaultPlotConfiguration::getInstance()._defaultPage._yMargin); + else + calculateRelativeYMargin(_orientation, _dimension, _yMargin); // set page size according to page format A4 or letter // offset not seams to work diff --git a/src/ParamOutputImpl/Plot/PanelPlotOutput.cc b/src/ParamOutputImpl/Plot/PanelPlotOutput.cc index 4095662..4a1ea4e 100644 --- a/src/ParamOutputImpl/Plot/PanelPlotOutput.cc +++ b/src/ParamOutputImpl/Plot/PanelPlotOutput.cc @@ -173,14 +173,36 @@ void PanelPlotOutput::calculatePlotArea(Bounds& bounds_) { float leftTickMarkSpace = 0; float rightTickMarkSpace = 0; + // ZAxis must be drawn at last! + std::vector>> workingAxesList; + for (Axes::iterator it = _panel->_axes.begin(); it != _panel->_axes.end(); ++it) + { + //Add X and Y axis to the working list + boost::shared_ptr lAxis = it->second; + if (lAxis->_isZAxis) + continue; + workingAxesList.push_back(std::pair>(it->first,lAxis)); + } + for (Axes::iterator it = _panel->_axes.begin(); it != _panel->_axes.end(); ++it) + { + //Add Z axis to the working list + boost::shared_ptr lAxis = it->second; + if (!lAxis->_isZAxis) + continue; + workingAxesList.push_back(std::pair>(it->first,lAxis)); + } + // Get each axes information to create plot area bounds (set space for legends). - for (Axes::iterator it = _panel->_axes.begin(); it != _panel->_axes.end(); ++it) { + for (std::vector>>::iterator it = workingAxesList.begin(); it != workingAxesList.end(); ++it) { boost::shared_ptr lAxis = it->second; if (lAxis == nullptr) continue; + if (!lAxis->_used) + continue; + // Axis space legends is only took into account when axis is visible // otherwise legend is not drawn. if (lAxis->_visible) { @@ -2189,7 +2211,7 @@ void PanelPlotOutput::writeContext(ContextFileWriter& writer) { if (lAxis == nullptr) continue; - if (lAxis->_visible) + if (lAxis->_visible && lAxis->_used) lAxis->writeContext(writer); } } @@ -2247,6 +2269,11 @@ void PanelPlotOutput::draw(double startTime, double stopTime, int intervalIndex, // Sets panel plplot viewport, draw background & title for the panel _panel->draw(_pls); + if (_parameterAxesList.empty()) + { + _pls->mtex("b", -1., 1, 1, std::string("Empty panel").c_str()); + } + if (isFirstInterval) _panel->_paramsLegendProperties.reset(); diff --git a/src/ParamOutputImpl/Plot/Scatter/XYPlot.cc b/src/ParamOutputImpl/Plot/Scatter/XYPlot.cc index 2c02197..b587ced 100644 --- a/src/ParamOutputImpl/Plot/Scatter/XYPlot.cc +++ b/src/ParamOutputImpl/Plot/Scatter/XYPlot.cc @@ -871,6 +871,7 @@ void XYPlot::configureSeriesAxis() { lError << "XYPlot::configureSeriesAxis" << ": X axis with id '" << lSeriesProperties.getXAxisId() << "' not found."; BOOST_THROW_EXCEPTION(PanelPlotOutputException() << AMDA::ex_msg(lError.str())); } + lXAxis->_used = true; Range lXRange(lXAxis->getRange()); // If user didn't set a range, calculate range automatically (based on parameters values). @@ -907,6 +908,7 @@ void XYPlot::configureSeriesAxis() { lError << "XYPlot::configureSeriesAxis" << ": Y axis with id '" << lSeriesProperties.getYAxisId() << "' not found."; BOOST_THROW_EXCEPTION(PanelPlotOutputException() << AMDA::ex_msg(lError.str())); } + lYAxis->_used = true; // Configure range for Y axis. Range lYRange(lYAxis->getRange()); @@ -934,6 +936,7 @@ void XYPlot::configureSeriesAxis() { { if (!lSeriesProperties.getColorParamId().empty()) { + lZAxis->_used = true; Range lRange(lZAxis->getRange()); ParameterAxes* colorSerieParameterAxes = getParameterAxesByColorSerieId(lSeriesProperties.getColorSerieId()); if (colorSerieParameterAxes == NULL) diff --git a/src/ParamOutputImpl/Plot/Time/TimePlot.cc b/src/ParamOutputImpl/Plot/Time/TimePlot.cc index b26916f..265e2ec 100644 --- a/src/ParamOutputImpl/Plot/Time/TimePlot.cc +++ b/src/ParamOutputImpl/Plot/Time/TimePlot.cc @@ -80,6 +80,7 @@ void TimePlot::preparePlotArea(double startTime, double stopTime, int intervalIn // configure X axis getTimeAxisDecorator()->configure(this, getTimeAxis(), startTime, stopTime, _pParameterValues); + getTimeAxis()->_used = true; _pls->timefmt(getTimeAxisDecorator()->getPlFormat().c_str()); PanelPlotOutput::preparePlotArea(startTime,stopTime,intervalIndex); @@ -91,7 +92,7 @@ void TimePlot::draw(double startTime, double stopTime, int intervalIndex, PanelPlotOutput::draw(startTime,stopTime,intervalIndex,isFirstInterval,isLastInterval); // Draw start date - if (!_startDateDrawn) + if (!_startDateDrawn && getTimeAxis()->_used) drawStartDate (getTimeAxis(), startTime,stopTime); _startDateDrawn = true; } @@ -128,6 +129,7 @@ void TimePlot::configureSeriesAxis() { BOOST_THROW_EXCEPTION(PanelPlotOutputException() << AMDA::ex_msg(lError.str())); } + lYAxis->_used = true; Range lRange(lYAxis->getRange()); // If range status for this axis is set by the user do not update range "automatically". if (isnan(lRange.getMin()) && isnan(lRange.getMax())) { @@ -174,6 +176,7 @@ void TimePlot::configureSeriesAxis() { { if (!lSeriesProperties.getColorParamId().empty()) { + lZAxis->_used = true; Range lRange(lZAxis->getRange()); ParameterAxes* colorSerieParameterAxes = getParameterAxesByColorSerieId(lSeriesProperties.getColorSerieId()); if (colorSerieParameterAxes == NULL) @@ -238,6 +241,8 @@ void TimePlot::configureSpectroAxis() { BOOST_THROW_EXCEPTION(PanelPlotOutputException() << AMDA::ex_msg(lError.str())); } + lYAxis->_used = true; + //set Z axis range boost::shared_ptr lZAxis = _panel->getAxis(spectroPropertiesPtr->getZAxisId()); if (lZAxis.get() == nullptr) { @@ -246,6 +251,8 @@ void TimePlot::configureSpectroAxis() { BOOST_THROW_EXCEPTION(PanelPlotOutputException() << AMDA::ex_msg(lError.str())); } + lZAxis->_used = true; + ParameterSPtr p = _parameterManager.getParameter(param._originalParamId); int parameterDimension; if (spectroPropertiesPtr->getRelatedDim() == 0) @@ -947,7 +954,7 @@ void TimePlot::drawSpectro(double startDate, double stopDate, std::string pParam void TimePlot::drawStartDate(TimeAxis* pXAxis, double startTime, double stopTime) { LOG4CXX_DEBUG(gLogger, "Drawing start date."); - if (pXAxis->_showTickMark == false) + if (pXAxis->_showTickMark == false || !pXAxis->_drawn || !pXAxis->_visible) return; // use panel font to draw start date. -- libgit2 0.21.2