Commit 641ba7e41baaceb757b9f711f8b4b6fdce979914
1 parent
401c20f9
Exists in
master
and in
87 other branches
ok for time plot
Showing
5 changed files
with
35 additions
and
11 deletions
Show diff stats
src/ParamOutputImpl/Plot/PanelPlotOutput.cc
... | ... | @@ -36,6 +36,8 @@ const float PanelPlotOutput::DEFAULT_TICK_LENGTH_FACTOR = 0.75; |
36 | 36 | const float PanelPlotOutput::VERTICAL_TICK_LENGTH_LIMIT = 0.5; |
37 | 37 | // Horizontal is for X axis. |
38 | 38 | const float PanelPlotOutput::HORIZONTAL_TICK_LENGTH_LIMIT = 0.75; |
39 | +// margin in case of constante curve | |
40 | +const float YAXISMARGIN = 0.05; | |
39 | 41 | |
40 | 42 | |
41 | 43 | PanelPlotOutput::PanelPlotOutput(AMDA::Parameters::ParameterManager& manager, boost::shared_ptr<Panel> panel, bool isStandalone) : | ... | ... |
src/ParamOutputImpl/Plot/PanelPlotOutput.hh
... | ... | @@ -62,6 +62,7 @@ public: |
62 | 62 | */ |
63 | 63 | static const float VERTICAL_TICK_LENGTH_LIMIT; |
64 | 64 | static const float HORIZONTAL_TICK_LENGTH_LIMIT; |
65 | + static const float YAXISMARGIN; | |
65 | 66 | |
66 | 67 | PanelPlotOutput(AMDA::Parameters::ParameterManager& manager, |
67 | 68 | boost::shared_ptr<Panel> panel, bool isStandalone = true); | ... | ... |
src/ParamOutputImpl/Plot/Range.cc
... | ... | @@ -17,23 +17,24 @@ Range extendRange(Range pRange) { |
17 | 17 | |
18 | 18 | double lMin = pRange.getMin(); |
19 | 19 | double lMax = pRange.getMax(); |
20 | + double margin = pRange.getMargin(); | |
20 | 21 | if(lMin < lMax) { |
21 | 22 | if ( (lMin < 1 && lMin > -1) && |
22 | 23 | (lMax < 1 && lMax > -1) ) { |
23 | - lMin = extend2LowerValue(lMin-0.05*(lMax-lMin)); | |
24 | - lMax = extend2UpperValue(lMax+0.05*(lMax-lMin)); | |
24 | + lMin = extend2LowerValue(lMin-margin*(lMax-lMin)); | |
25 | + lMax = extend2UpperValue(lMax+margin*(lMax-lMin)); | |
25 | 26 | } else { |
26 | - lMax = ceil(lMax+0.05*(lMax-lMin)); | |
27 | - lMin = floor(lMin-0.05*(lMax-lMin)); | |
27 | + lMax = ceil(lMax+margin*(lMax-lMin)); | |
28 | + lMin = floor(lMin-margin*(lMax-lMin)); | |
28 | 29 | } |
29 | 30 | } else { |
30 | 31 | if ( (lMin < 1 && lMin > -1) && |
31 | 32 | (lMax < 1 && lMax > -1) ) { |
32 | - lMin = extend2UpperValue(lMin+0.05*(lMax-lMin)); | |
33 | - lMax = extend2LowerValue(lMax-0.05*(lMax-lMin)); | |
33 | + lMin = extend2UpperValue(lMin+margin*(lMax-lMin)); | |
34 | + lMax = extend2LowerValue(lMax-margin*(lMax-lMin)); | |
34 | 35 | } else { |
35 | - lMin = ceil(lMin+0.05*(lMax-lMin)); | |
36 | - lMax = floor(lMax-0.05*(lMax-lMin)); | |
36 | + lMin = ceil(lMin+margin*(lMax-lMin)); | |
37 | + lMax = floor(lMax-margin*(lMax-lMin)); | |
37 | 38 | } |
38 | 39 | } |
39 | 40 | ... | ... |
src/ParamOutputImpl/Plot/Range.hh
... | ... | @@ -18,14 +18,17 @@ namespace plot { |
18 | 18 | class Range { |
19 | 19 | public: |
20 | 20 | Range() : |
21 | - _extend(true), _range(nan(""), nan("")) { | |
21 | + _extend(true), _margin(0), _range(nan(""), nan("")) { | |
22 | 22 | } |
23 | 23 | Range(double min, double max) : |
24 | - _extend(true), _range(min, max) { | |
24 | + _extend(true), _margin(0), _range(min, max){ | |
25 | + } | |
26 | + Range(double min, double max, double margin) : | |
27 | + _extend(true), _margin(margin) ,_range(min, max){ | |
25 | 28 | } |
26 | 29 | |
27 | 30 | Range(const Range& pRange) : |
28 | - _extend(pRange._extend), _range(pRange._range) { | |
31 | + _extend(pRange._extend), _margin(pRange._margin), _range(pRange._range) { | |
29 | 32 | } |
30 | 33 | virtual ~Range() { |
31 | 34 | } |
... | ... | @@ -43,6 +46,13 @@ public: |
43 | 46 | void setMax(double max) { |
44 | 47 | _range.second = max; |
45 | 48 | } |
49 | + | |
50 | + void setMargin(double margin) { | |
51 | + _margin = margin; | |
52 | + } | |
53 | + double getMargin() { | |
54 | + return _margin; | |
55 | + } | |
46 | 56 | |
47 | 57 | bool isSet() { |
48 | 58 | return !std::isnan(_range.first) || !std::isnan(_range.second); |
... | ... | @@ -54,9 +64,12 @@ public: |
54 | 64 | } |
55 | 65 | |
56 | 66 | bool _extend; |
67 | + | |
68 | + double _margin; | |
57 | 69 | |
58 | 70 | private: |
59 | 71 | std::pair<double, double> _range; |
72 | + | |
60 | 73 | }; |
61 | 74 | |
62 | 75 | inline std::ostream& operator <<(std::ostream& out, const Range& range) { | ... | ... |
src/ParamOutputImpl/Plot/Time/TimePlot.cc
... | ... | @@ -172,10 +172,15 @@ void TimePlot::configureSeriesAxis() { |
172 | 172 | lEstimatedRange.setMin(std::min(lEstimatedRange.getMin(), lParamIndexRange.getMin())); |
173 | 173 | lEstimatedRange.setMax(std::max(lEstimatedRange.getMax(), lParamIndexRange.getMax())); |
174 | 174 | } |
175 | + if(lParamIndexRange.getMin()==lParamIndexRange.getMax()) | |
176 | + lEstimatedRange.setMargin(0.05); | |
175 | 177 | } |
176 | 178 | |
177 | 179 | lEstimatedRange._extend = lRange._extend; |
180 | + | |
181 | + | |
178 | 182 | lAxisRange[lYAxis->_id] = lEstimatedRange; |
183 | + // la | |
179 | 184 | } |
180 | 185 | |
181 | 186 | // Set ZAxis range if a color param is defined for this serie |
... | ... | @@ -205,6 +210,8 @@ void TimePlot::configureSeriesAxis() { |
205 | 210 | lEstimatedRange.setMin(std::min(lEstimatedRange.getMin(), lParamIndexRange.getMin())); |
206 | 211 | lEstimatedRange.setMax(std::max(lEstimatedRange.getMax(), lParamIndexRange.getMax())); |
207 | 212 | } |
213 | + if(lParamIndexRange.getMin()==lParamIndexRange.getMax()) | |
214 | + lEstimatedRange.setMargin(0.05); | |
208 | 215 | lEstimatedRange._extend = lRange._extend; |
209 | 216 | lColorAxeRange = lEstimatedRange; |
210 | 217 | } | ... | ... |