Commit 1235356861702a93f8405c5027a007ba2e4526ec

Authored by Benjamin Renard
1 parent 3234c60f

Add layout property to draw time axes only for the lower time plot (#5493)

config/xsd/request/plot.xsd
... ... @@ -429,6 +429,10 @@
429 429 <xs:attribute name="expand"
430 430 type="xs:boolean">
431 431 </xs:attribute>
  432 + <xs:attribute name="onlyLowerTimeAxesLegend"
  433 + type="xs:boolean">
  434 +
  435 + </xs:attribute>
432 436 </xs:complexType>
433 437 </xs:element>
434 438 <xs:element name="panelDefaults"
... ...
src/ParamOutputImpl/Plot/Layout.hh
... ... @@ -38,12 +38,13 @@ enum class PanelConstraint {
38 38 */
39 39 class Layout {
40 40 public:
41   - Layout(double panelHeight, double panelSpacing, double firstPanelHeightFactor = 1.0, bool autoExpand = true, double xyRatio = 1.0) :
  41 + Layout(double panelHeight, double panelSpacing, double firstPanelHeightFactor = 1.0, bool autoExpand = true, double xyRatio = 1.0, bool onlyLowerTimeAxesLegend = false) :
42 42 _requestPanelHeight (panelHeight),
43 43 _requestPanelSpacing(panelSpacing),
44 44 _firstPanelHeightFactor(firstPanelHeightFactor),
45 45 _autoExpand (autoExpand),
46   - _xyRatio (xyRatio)
  46 + _xyRatio (xyRatio),
  47 + _onlyLowerTimeAxesLegend(onlyLowerTimeAxesLegend)
47 48 {
48 49 }
49 50  
... ... @@ -58,6 +59,7 @@ protected:
58 59 double _firstPanelHeightFactor;
59 60 bool _autoExpand;
60 61 double _xyRatio;
  62 + bool _onlyLowerTimeAxesLegend;
61 63 };
62 64  
63 65 } /* namespace plot */
... ...
src/ParamOutputImpl/Plot/LayoutAuto.hh
... ... @@ -21,8 +21,8 @@ namespace plot {
21 21 */
22 22 class LayoutAuto : public Layout {
23 23 public:
24   - LayoutAuto(double panelHeight, double panelSpacing, double firstPanelHeightFactor = 1.0, bool autoExpand = true, double xyRatio = 1.0) :
25   - Layout (panelHeight, panelSpacing, firstPanelHeightFactor, autoExpand, xyRatio),
  24 + LayoutAuto(double panelHeight, double panelSpacing, double firstPanelHeightFactor = 1.0, bool autoExpand = true, double xyRatio = 1.0, bool onlyLowerTimeAxesLegend = false) :
  25 + Layout (panelHeight, panelSpacing, firstPanelHeightFactor, autoExpand, xyRatio, onlyLowerTimeAxesLegend),
26 26 _nbMaxWidthPanel(0),
27 27 _nbSquarePanel(0),
28 28 _curMaxWidthPanel(0),
... ...
src/ParamOutputImpl/Plot/LayoutNode.cc
... ... @@ -72,6 +72,13 @@ void LayoutNode::proceed(xmlNodePtr pNode_,const AMDA::Parameters::CfgContext&amp; p
72 72 page->_layoutProperties.setExpand( strcasecmp ((const char*)value, "true") == 0);
73 73 xmlFree(value);
74 74 }
  75 +
  76 + // onlyLowerTimeAxesLegend
  77 + value = xmlGetProp(pNode_, (const xmlChar *)"onlyLowerTimeAxesLegend");
  78 + if( value ){
  79 + page->_layoutProperties.setOnlyLowerTimeAxesLegend( strcasecmp ((const char*)value, "true") == 0);
  80 + xmlFree(value);
  81 + }
75 82 }
76 83  
77 84 } /* namespace plot */
... ...
src/ParamOutputImpl/Plot/LayoutProperties.hh
... ... @@ -44,7 +44,7 @@ public:
44 44  
45 45  
46 46 LayoutProperties() :
47   - _type(LayoutType::MANUAL), _panelHeight(0.5), _panelSpacing(0.05), _firstPanelHeightFactor(1.0), _expand(false)
  47 + _type(LayoutType::MANUAL), _panelHeight(0.5), _panelSpacing(0.05), _firstPanelHeightFactor(1.0), _expand(false), _onlyLowerTimeAxesLegend(false)
48 48 {
49 49 }
50 50  
... ... @@ -53,7 +53,8 @@ public:
53 53 _panelHeight(pLayoutProperties_._panelHeight),
54 54 _panelSpacing(pLayoutProperties_._panelSpacing),
55 55 _firstPanelHeightFactor(pLayoutProperties_._firstPanelHeightFactor),
56   - _expand(pLayoutProperties_._expand)
  56 + _expand(pLayoutProperties_._expand),
  57 + _onlyLowerTimeAxesLegend(pLayoutProperties_._onlyLowerTimeAxesLegend)
57 58 {
58 59 }
59 60  
... ... @@ -63,6 +64,7 @@ public:
63 64 _panelSpacing = pLayoutProperties_._panelSpacing;
64 65 _firstPanelHeightFactor = pLayoutProperties_._firstPanelHeightFactor;
65 66 _expand = pLayoutProperties_._expand;
  67 + _onlyLowerTimeAxesLegend = pLayoutProperties_._onlyLowerTimeAxesLegend;
66 68 return *this;
67 69 }
68 70  
... ... @@ -109,6 +111,14 @@ public:
109 111 _expand = expand;
110 112 }
111 113  
  114 + bool isOnlyLowerTimeAxesLegend() const {
  115 + return _onlyLowerTimeAxesLegend;
  116 + }
  117 +
  118 + void setOnlyLowerTimeAxesLegend(bool onlyLowerTimeAxesLegend) {
  119 + _onlyLowerTimeAxesLegend = onlyLowerTimeAxesLegend;
  120 + }
  121 +
112 122 private:
113 123  
114 124 LayoutType _type;
... ... @@ -116,6 +126,7 @@ private:
116 126 double _panelSpacing;
117 127 double _firstPanelHeightFactor;
118 128 bool _expand;
  129 + bool _onlyLowerTimeAxesLegend;
119 130 };
120 131  
121 132  
... ...
src/ParamOutputImpl/Plot/LayoutVertical.hh
... ... @@ -39,8 +39,8 @@ public:
39 39 */
40 40 class LayoutVertical : public Layout {
41 41 public:
42   - LayoutVertical(double panelHeight, double panelSpacing, double firstPanelHeightFactor = 1.0, bool autoExpand = true, double xyRatio = 1.0) :
43   - Layout (panelHeight, panelSpacing, firstPanelHeightFactor, autoExpand, xyRatio),
  42 + LayoutVertical(double panelHeight, double panelSpacing, double firstPanelHeightFactor = 1.0, bool autoExpand = true, double xyRatio = 1.0, bool onlyLowerTimeAxesLegend = false) :
  43 + Layout (panelHeight, panelSpacing, firstPanelHeightFactor, autoExpand, xyRatio, onlyLowerTimeAxesLegend),
44 44 _curPanel(0),
45 45 _curYPosition(0),
46 46 _maxWidthConstraintFound(false),
... ...
src/ParamOutputImpl/Plot/PlotOutput.cc
... ... @@ -12,6 +12,9 @@
12 12 #include "LayoutAuto.hh"
13 13 #include "LayoutVertical.hh"
14 14 #include "TimePlotNode.hh"
  15 +#include "Time/TimePlot.hh"
  16 +
  17 +#include <boost/range/adaptor/reversed.hpp>
15 18  
16 19 namespace plot {
17 20  
... ... @@ -195,6 +198,9 @@ void PlotOutput::drawOneIntervalByPage()
195 198 // Compute panel position depending on the page layout
196 199 computePanelBounds();
197 200  
  201 + // Fix time axes legend visibility in relation with the request
  202 + fixPanelTimeAxesVisibility();
  203 +
198 204 // Initialize panel plot
199 205 for (auto plot : _plots) {
200 206 // set current plplot stream for plot,
... ... @@ -290,6 +296,9 @@ void PlotOutput::drawAllIntervalsInOnePage()
290 296 //Compute panel position depending on the page layout
291 297 computePanelBounds();
292 298  
  299 + // Fix time axes legend visibility in relation with the request
  300 + fixPanelTimeAxesVisibility();
  301 +
293 302 //Initialize panel plot
294 303 for (auto plot : _plots)
295 304 {
... ... @@ -412,14 +421,16 @@ void PlotOutput::computePanelBounds(void) {
412 421 _page->_layoutProperties.getPanelSpacing(),
413 422 _page->_layoutProperties.getFirstPanelHeightFactor(),
414 423 _page->_layoutProperties.isExpand(),
415   - xyRatio);
  424 + xyRatio,
  425 + _page->_layoutProperties.isOnlyLowerTimeAxesLegend());
416 426 } else {
417 427 pLayout = new LayoutVertical (
418 428 _page->_layoutProperties.getPanelHeight(),
419 429 _page->_layoutProperties.getPanelSpacing(),
420 430 _page->_layoutProperties.getFirstPanelHeightFactor(),
421 431 _page->_layoutProperties.isExpand(),
422   - xyRatio);
  432 + xyRatio,
  433 + _page->_layoutProperties.isOnlyLowerTimeAxesLegend());
423 434 }
424 435  
425 436 // Compute panel bounds depending on the constraints
... ... @@ -507,6 +518,32 @@ void PlotOutput::computePanelPlotAreaBoundsForManualLayout(void) {
507 518 }
508 519 }
509 520  
  521 +void PlotOutput::fixPanelTimeAxesVisibility(void) {
  522 + if ((_plots.empty() == true) ||
  523 + (_page->_layoutProperties.getType() == LayoutType::MANUAL) ||
  524 + !_page->_layoutProperties.isOnlyLowerTimeAxesLegend()) {
  525 + return;
  526 + }
  527 +
  528 + LOG4CXX_DEBUG(gLogger,"PlotOutput::fixPanelTimeAxesVisibility...");
  529 +
  530 + bool isFirstTimePlot = true;
  531 + for (auto plot : boost::adaptors::reverse(_plots)) {
  532 + if (plot->typeName() != TIMEPLOT_NODENAME) {
  533 + continue;
  534 + }
  535 + if (isFirstTimePlot) {
  536 + isFirstTimePlot = false;
  537 + continue;
  538 + }
  539 +
  540 + TimePlot* timePlot = reinterpret_cast<TimePlot*>(plot.get());
  541 + TimeAxis* timeAxis = timePlot->getTimeAxis();
  542 + timeAxis->setShowLegend(false);
  543 + timeAxis->setShowTickMark(false);
  544 + }
  545 +}
  546 +
510 547 void PlotOutput::computePanelLegendPosition(void) {
511 548 // Nothing to plot -> nothing to compute !
512 549 if ((_plots.empty() == true)) {
... ...
src/ParamOutputImpl/Plot/PlotOutput.hh
... ... @@ -217,6 +217,11 @@ protected:
217 217 virtual void computePanelPlotAreaBoundsForManualLayout(void);
218 218  
219 219 /**
  220 + * @brief Fix time axes visibility in relation with the request
  221 + */
  222 + virtual void fixPanelTimeAxesVisibility(void);
  223 +
  224 + /**
220 225 * @brief Compute legend position depending on the panel constraints
221 226 */
222 227 virtual void computePanelLegendPosition (void);
... ...