From 641ba7e41baaceb757b9f711f8b4b6fdce979914 Mon Sep 17 00:00:00 2001 From: Hacene SI HADJ MOHAND Date: Tue, 3 Sep 2019 14:36:19 +0200 Subject: [PATCH] ok for time plot --- src/ParamOutputImpl/Plot/PanelPlotOutput.cc | 2 ++ src/ParamOutputImpl/Plot/PanelPlotOutput.hh | 1 + src/ParamOutputImpl/Plot/Range.cc | 17 +++++++++-------- src/ParamOutputImpl/Plot/Range.hh | 19 ++++++++++++++++--- src/ParamOutputImpl/Plot/Time/TimePlot.cc | 7 +++++++ 5 files changed, 35 insertions(+), 11 deletions(-) diff --git a/src/ParamOutputImpl/Plot/PanelPlotOutput.cc b/src/ParamOutputImpl/Plot/PanelPlotOutput.cc index bcba8e9..8c5f220 100644 --- a/src/ParamOutputImpl/Plot/PanelPlotOutput.cc +++ b/src/ParamOutputImpl/Plot/PanelPlotOutput.cc @@ -36,6 +36,8 @@ const float PanelPlotOutput::DEFAULT_TICK_LENGTH_FACTOR = 0.75; const float PanelPlotOutput::VERTICAL_TICK_LENGTH_LIMIT = 0.5; // Horizontal is for X axis. const float PanelPlotOutput::HORIZONTAL_TICK_LENGTH_LIMIT = 0.75; +// margin in case of constante curve +const float YAXISMARGIN = 0.05; PanelPlotOutput::PanelPlotOutput(AMDA::Parameters::ParameterManager& manager, boost::shared_ptr panel, bool isStandalone) : diff --git a/src/ParamOutputImpl/Plot/PanelPlotOutput.hh b/src/ParamOutputImpl/Plot/PanelPlotOutput.hh index 487b0c5..b23e449 100644 --- a/src/ParamOutputImpl/Plot/PanelPlotOutput.hh +++ b/src/ParamOutputImpl/Plot/PanelPlotOutput.hh @@ -62,6 +62,7 @@ public: */ static const float VERTICAL_TICK_LENGTH_LIMIT; static const float HORIZONTAL_TICK_LENGTH_LIMIT; + static const float YAXISMARGIN; PanelPlotOutput(AMDA::Parameters::ParameterManager& manager, boost::shared_ptr panel, bool isStandalone = true); diff --git a/src/ParamOutputImpl/Plot/Range.cc b/src/ParamOutputImpl/Plot/Range.cc index e7316be..0cd6c1f 100644 --- a/src/ParamOutputImpl/Plot/Range.cc +++ b/src/ParamOutputImpl/Plot/Range.cc @@ -17,23 +17,24 @@ Range extendRange(Range pRange) { double lMin = pRange.getMin(); double lMax = pRange.getMax(); + double margin = pRange.getMargin(); if(lMin < lMax) { if ( (lMin < 1 && lMin > -1) && (lMax < 1 && lMax > -1) ) { - lMin = extend2LowerValue(lMin-0.05*(lMax-lMin)); - lMax = extend2UpperValue(lMax+0.05*(lMax-lMin)); + lMin = extend2LowerValue(lMin-margin*(lMax-lMin)); + lMax = extend2UpperValue(lMax+margin*(lMax-lMin)); } else { - lMax = ceil(lMax+0.05*(lMax-lMin)); - lMin = floor(lMin-0.05*(lMax-lMin)); + lMax = ceil(lMax+margin*(lMax-lMin)); + lMin = floor(lMin-margin*(lMax-lMin)); } } else { if ( (lMin < 1 && lMin > -1) && (lMax < 1 && lMax > -1) ) { - lMin = extend2UpperValue(lMin+0.05*(lMax-lMin)); - lMax = extend2LowerValue(lMax-0.05*(lMax-lMin)); + lMin = extend2UpperValue(lMin+margin*(lMax-lMin)); + lMax = extend2LowerValue(lMax-margin*(lMax-lMin)); } else { - lMin = ceil(lMin+0.05*(lMax-lMin)); - lMax = floor(lMax-0.05*(lMax-lMin)); + lMin = ceil(lMin+margin*(lMax-lMin)); + lMax = floor(lMax-margin*(lMax-lMin)); } } diff --git a/src/ParamOutputImpl/Plot/Range.hh b/src/ParamOutputImpl/Plot/Range.hh index 8174ace..8d5fdfa 100644 --- a/src/ParamOutputImpl/Plot/Range.hh +++ b/src/ParamOutputImpl/Plot/Range.hh @@ -18,14 +18,17 @@ namespace plot { class Range { public: Range() : - _extend(true), _range(nan(""), nan("")) { + _extend(true), _margin(0), _range(nan(""), nan("")) { } Range(double min, double max) : - _extend(true), _range(min, max) { + _extend(true), _margin(0), _range(min, max){ + } + Range(double min, double max, double margin) : + _extend(true), _margin(margin) ,_range(min, max){ } Range(const Range& pRange) : - _extend(pRange._extend), _range(pRange._range) { + _extend(pRange._extend), _margin(pRange._margin), _range(pRange._range) { } virtual ~Range() { } @@ -43,6 +46,13 @@ public: void setMax(double max) { _range.second = max; } + + void setMargin(double margin) { + _margin = margin; + } + double getMargin() { + return _margin; + } bool isSet() { return !std::isnan(_range.first) || !std::isnan(_range.second); @@ -54,9 +64,12 @@ public: } bool _extend; + + double _margin; private: std::pair _range; + }; inline std::ostream& operator <<(std::ostream& out, const Range& range) { diff --git a/src/ParamOutputImpl/Plot/Time/TimePlot.cc b/src/ParamOutputImpl/Plot/Time/TimePlot.cc index ca105df..96f80c2 100644 --- a/src/ParamOutputImpl/Plot/Time/TimePlot.cc +++ b/src/ParamOutputImpl/Plot/Time/TimePlot.cc @@ -172,10 +172,15 @@ void TimePlot::configureSeriesAxis() { lEstimatedRange.setMin(std::min(lEstimatedRange.getMin(), lParamIndexRange.getMin())); lEstimatedRange.setMax(std::max(lEstimatedRange.getMax(), lParamIndexRange.getMax())); } + if(lParamIndexRange.getMin()==lParamIndexRange.getMax()) + lEstimatedRange.setMargin(0.05); } lEstimatedRange._extend = lRange._extend; + + lAxisRange[lYAxis->_id] = lEstimatedRange; + // la } // Set ZAxis range if a color param is defined for this serie @@ -205,6 +210,8 @@ void TimePlot::configureSeriesAxis() { lEstimatedRange.setMin(std::min(lEstimatedRange.getMin(), lParamIndexRange.getMin())); lEstimatedRange.setMax(std::max(lEstimatedRange.getMax(), lParamIndexRange.getMax())); } + if(lParamIndexRange.getMin()==lParamIndexRange.getMax()) + lEstimatedRange.setMargin(0.05); lEstimatedRange._extend = lRange._extend; lColorAxeRange = lEstimatedRange; } -- libgit2 0.21.2