Commit 337411e46c8d018bc02c6c794f4cf04ac0582750
1 parent
3b531e56
Exists in
master
and in
46 other branches
#5390 - Kernel part done
Showing
6 changed files
with
141 additions
and
68 deletions
Show diff stats
config/xsd/request/plot.xsd
... | ... | @@ -570,6 +570,7 @@ |
570 | 570 | </xs:sequence> |
571 | 571 | <xs:attribute name="backgroundColor" |
572 | 572 | type="xs:string" /> |
573 | + <xs:attribute name="plotAreaBackgroundColor" type="xs:string"/> | |
573 | 574 | <xs:attribute name="colorMapIndex" |
574 | 575 | type="xs:integer" /> |
575 | 576 | <xs:attribute name="preferedWidth" | ... | ... |
src/ParamOutputImpl/Plot/Panel.cc
... | ... | @@ -18,77 +18,75 @@ namespace plot { |
18 | 18 | //Auto id set to a negative number to preserve id defined in request |
19 | 19 | int Panel::PANEL_COUNTER = -1; |
20 | 20 | |
21 | -Panel::Panel() : | |
22 | - _id(--PANEL_COUNTER), | |
23 | - _index(-1), | |
24 | - _resolution(0), | |
25 | - _updateTitleOnNextInterval(false), | |
26 | - _bounds(Bounds()), | |
27 | - _backgroundColor(Color()), | |
28 | - _titleAlign(PlotCommon::Align::CENTER), | |
29 | - _titlePosition(PlotCommon::Position::POS_TOP), | |
30 | - _drawn(false), | |
31 | - _page(), | |
32 | - _preferedWidth(-1), | |
33 | - _preferedHeight(-1), | |
34 | - _leftMargin(-1), | |
35 | - _rightMargin(-1), | |
36 | - _topMargin(-1), | |
37 | - _bottomMargin(-1), | |
38 | - _paramsLegendProperties(), | |
39 | - _textLegendPropertiesList(), | |
40 | - _font(Font("", 0)), | |
41 | - _title(Font("", 0)) | |
21 | +Panel::Panel() : _id(--PANEL_COUNTER), | |
22 | + _index(-1), | |
23 | + _resolution(0), | |
24 | + _updateTitleOnNextInterval(false), | |
25 | + _bounds(Bounds()), | |
26 | + _backgroundColor(Color()), | |
27 | + _plotAreaBackgroundColor(Color()), | |
28 | + _titleAlign(PlotCommon::Align::CENTER), | |
29 | + _titlePosition(PlotCommon::Position::POS_TOP), | |
30 | + _drawn(false), | |
31 | + _page(), | |
32 | + _preferedWidth(-1), | |
33 | + _preferedHeight(-1), | |
34 | + _leftMargin(-1), | |
35 | + _rightMargin(-1), | |
36 | + _topMargin(-1), | |
37 | + _bottomMargin(-1), | |
38 | + _paramsLegendProperties(), | |
39 | + _textLegendPropertiesList(), | |
40 | + _font(Font("", 0)), | |
41 | + _title(Font("", 0)) | |
42 | 42 | { |
43 | 43 | } |
44 | 44 | |
45 | -Panel::Panel(DefaultPlotConfiguration& defaults) : | |
46 | - _id(--PANEL_COUNTER), | |
47 | - _index(defaults._defaultPanel._index), | |
48 | - _resolution(defaults._defaultPanel._resolution), | |
49 | - _updateTitleOnNextInterval(false), | |
50 | - _bounds(Bounds()), | |
51 | - _backgroundColor(defaults._defaultPanel._backgroundColor), | |
52 | - _titleAlign(defaults._defaultPanel._titleAlign), | |
53 | - _titlePosition(defaults._defaultPanel._titlePosition), | |
54 | - _drawn(false), | |
55 | - _page(), | |
56 | - _preferedWidth(defaults._defaultPanel._preferedWidth), | |
57 | - _preferedHeight(defaults._defaultPanel._preferedHeight), | |
58 | - _leftMargin(defaults._defaultPanel._leftMargin), | |
59 | - _rightMargin(defaults._defaultPanel._rightMargin), | |
60 | - _topMargin(defaults._defaultPanel._topMargin), | |
61 | - _bottomMargin(defaults._defaultPanel._bottomMargin), | |
62 | - _textLegendPropertiesList(defaults._defaultPanel._textLegendPropertiesList), | |
63 | - _font(defaults._defaultPanel.getFont()), | |
64 | - _title(defaults._defaultPanel.getFont()) | |
45 | +Panel::Panel(DefaultPlotConfiguration &defaults) : _id(--PANEL_COUNTER), | |
46 | + _index(defaults._defaultPanel._index), | |
47 | + _resolution(defaults._defaultPanel._resolution), | |
48 | + _updateTitleOnNextInterval(false), | |
49 | + _bounds(Bounds()), | |
50 | + _backgroundColor(defaults._defaultPanel._backgroundColor), | |
51 | + _plotAreaBackgroundColor(defaults._defaultPanel._backgroundColor), | |
52 | + _titleAlign(defaults._defaultPanel._titleAlign), | |
53 | + _titlePosition(defaults._defaultPanel._titlePosition), | |
54 | + _drawn(false), | |
55 | + _page(), | |
56 | + _preferedWidth(defaults._defaultPanel._preferedWidth), | |
57 | + _preferedHeight(defaults._defaultPanel._preferedHeight), | |
58 | + _leftMargin(defaults._defaultPanel._leftMargin), | |
59 | + _rightMargin(defaults._defaultPanel._rightMargin), | |
60 | + _topMargin(defaults._defaultPanel._topMargin), | |
61 | + _bottomMargin(defaults._defaultPanel._bottomMargin), | |
62 | + _textLegendPropertiesList(defaults._defaultPanel._textLegendPropertiesList), | |
63 | + _font(defaults._defaultPanel.getFont()), | |
64 | + _title(defaults._defaultPanel.getFont()) | |
65 | 65 | { |
66 | 66 | } |
67 | 67 | |
68 | -Panel::Panel(Page* page) : | |
69 | - _id(--PANEL_COUNTER), | |
70 | - _index(-1), | |
71 | - _resolution(DefaultPlotConfiguration::getInstance()._defaultPanel._resolution), | |
72 | - _updateTitleOnNextInterval(false), | |
73 | - _bounds(Bounds()), | |
74 | - _backgroundColor(DefaultPlotConfiguration::getInstance()._defaultPanel._backgroundColor), | |
75 | - _titleAlign(DefaultPlotConfiguration::getInstance()._defaultPanel._titleAlign), | |
76 | - _titlePosition(DefaultPlotConfiguration::getInstance()._defaultPanel._titlePosition), | |
77 | - _drawn(false), | |
78 | - _page(page), | |
79 | - _preferedWidth(DefaultPlotConfiguration::getInstance()._defaultPanel._preferedWidth), | |
80 | - _preferedHeight(DefaultPlotConfiguration::getInstance()._defaultPanel._preferedHeight), | |
81 | - _leftMargin(DefaultPlotConfiguration::getInstance()._defaultPanel._leftMargin), | |
82 | - _rightMargin(DefaultPlotConfiguration::getInstance()._defaultPanel._rightMargin), | |
83 | - _topMargin(DefaultPlotConfiguration::getInstance()._defaultPanel._topMargin), | |
84 | - _bottomMargin(DefaultPlotConfiguration::getInstance()._defaultPanel._bottomMargin), | |
85 | - _textLegendPropertiesList(DefaultPlotConfiguration::getInstance()._defaultPanel._textLegendPropertiesList), | |
86 | - _font(Font( | |
87 | - DefaultPlotConfiguration::getInstance()._defaultPanel.getFont().getName().empty() ? | |
88 | - page->getFont().getName() : DefaultPlotConfiguration::getInstance()._defaultPanel.getFont().getName(), | |
89 | - DefaultPlotConfiguration::getInstance()._defaultPanel.getFont().getSize() != 0 ? | |
90 | - DefaultPlotConfiguration::getInstance()._defaultPanel.getFont().getSize() : page->getFont().getSize())), | |
91 | - _title(_font) | |
68 | +Panel::Panel(Page *page) : _id(--PANEL_COUNTER), | |
69 | + _index(-1), | |
70 | + _resolution(DefaultPlotConfiguration::getInstance()._defaultPanel._resolution), | |
71 | + _updateTitleOnNextInterval(false), | |
72 | + _bounds(Bounds()), | |
73 | + _backgroundColor(DefaultPlotConfiguration::getInstance()._defaultPanel._backgroundColor), | |
74 | + _plotAreaBackgroundColor(DefaultPlotConfiguration::getInstance()._defaultPanel._backgroundColor), | |
75 | + _titleAlign(DefaultPlotConfiguration::getInstance()._defaultPanel._titleAlign), | |
76 | + _titlePosition(DefaultPlotConfiguration::getInstance()._defaultPanel._titlePosition), | |
77 | + _drawn(false), | |
78 | + _page(page), | |
79 | + _preferedWidth(DefaultPlotConfiguration::getInstance()._defaultPanel._preferedWidth), | |
80 | + _preferedHeight(DefaultPlotConfiguration::getInstance()._defaultPanel._preferedHeight), | |
81 | + _leftMargin(DefaultPlotConfiguration::getInstance()._defaultPanel._leftMargin), | |
82 | + _rightMargin(DefaultPlotConfiguration::getInstance()._defaultPanel._rightMargin), | |
83 | + _topMargin(DefaultPlotConfiguration::getInstance()._defaultPanel._topMargin), | |
84 | + _bottomMargin(DefaultPlotConfiguration::getInstance()._defaultPanel._bottomMargin), | |
85 | + _textLegendPropertiesList(DefaultPlotConfiguration::getInstance()._defaultPanel._textLegendPropertiesList), | |
86 | + _font(Font( | |
87 | + DefaultPlotConfiguration::getInstance()._defaultPanel.getFont().getName().empty() ? page->getFont().getName() : DefaultPlotConfiguration::getInstance()._defaultPanel.getFont().getName(), | |
88 | + DefaultPlotConfiguration::getInstance()._defaultPanel.getFont().getSize() != 0 ? DefaultPlotConfiguration::getInstance()._defaultPanel.getFont().getSize() : page->getFont().getSize())), | |
89 | + _title(_font) | |
92 | 90 | { |
93 | 91 | } |
94 | 92 | ... | ... |
src/ParamOutputImpl/Plot/Panel.hh
... | ... | @@ -165,6 +165,11 @@ public: |
165 | 165 | Color _backgroundColor; |
166 | 166 | |
167 | 167 | /** |
168 | + * @brief Plot Area Background color | |
169 | + */ | |
170 | + Color _plotAreaBackgroundColor; | |
171 | + | |
172 | + /** | |
168 | 173 | * @brief Panel title Align (center, left, right) |
169 | 174 | */ |
170 | 175 | PlotCommon::Align _titleAlign; | ... | ... |
src/ParamOutputImpl/Plot/PanelNode.cc
... | ... | @@ -87,6 +87,25 @@ void PanelNode::proceed(xmlNodePtr pNode, |
87 | 87 | DefaultPlotConfiguration::getInstance()._defaultPanel._backgroundColor; |
88 | 88 | } |
89 | 89 | |
90 | + // -- plot area color | |
91 | + Color pabgcolor; | |
92 | + value = xmlGetProp(pNode, (const xmlChar *)"plotAreaBackgroundColor"); | |
93 | + if (value) | |
94 | + { | |
95 | + try | |
96 | + { | |
97 | + std::string strValue((const char *)value); | |
98 | + createColor(pabgcolor, strValue); | |
99 | + } | |
100 | + catch (std::logic_error &e) | |
101 | + { | |
102 | + LOG4CXX_WARN(gLogger, "Plot Area BackgroundColor : " << e.what()); | |
103 | + } | |
104 | + xmlFree(value); | |
105 | + } | |
106 | + | |
107 | + panel->_plotAreaBackgroundColor = pabgcolor; | |
108 | + | |
90 | 109 | // -- color map index |
91 | 110 | value = xmlGetProp(pNode, (const xmlChar *) "colorMapIndex"); |
92 | 111 | if (value) { | ... | ... |
src/ParamOutputImpl/Plot/PanelPlotOutput.cc
... | ... | @@ -2212,6 +2212,46 @@ void PanelPlotOutput::preparePlotArea(double /*startTime*/, double /*stopTime*/, |
2212 | 2212 | _panel->_paramsLegendProperties.resetPlot(); |
2213 | 2213 | } |
2214 | 2214 | |
2215 | +void PanelPlotOutput::fillBackground(std::shared_ptr<plstream> &pls) | |
2216 | +{ | |
2217 | + if (_panel->_plotAreaBackgroundColor._red != -1 && _panel->_plotAreaBackgroundColor._green != -1 && _panel->_plotAreaBackgroundColor._blue != -1) | |
2218 | + { | |
2219 | + Color plotAreaBackgroundColor = _panel->_plotAreaBackgroundColor; | |
2220 | + | |
2221 | + PLINT lInitialRed = -1, lInitialGreen = -1, lInitialBlue = -1; | |
2222 | + // Store initial color in first index. | |
2223 | + pls->gcol0(0, lInitialRed, lInitialGreen, lInitialBlue); | |
2224 | + pls->scol0(0, plotAreaBackgroundColor._red, plotAreaBackgroundColor._green, | |
2225 | + plotAreaBackgroundColor._blue); | |
2226 | + pls->col0(0); | |
2227 | + | |
2228 | + // Compute panel coordinate in the page | |
2229 | + Bounds lBounds = _plotAreaBounds; | |
2230 | + // Specify viewport for the panel | |
2231 | + pls->vpor(_plotAreaBounds._x, _plotAreaBounds._x + _plotAreaBounds._width, | |
2232 | + _plotAreaBounds._y, _plotAreaBounds._y + _plotAreaBounds._height); | |
2233 | + | |
2234 | + // Set window size. | |
2235 | + pls->wind(0, 1, 0, 1); | |
2236 | + | |
2237 | + // Fill background. | |
2238 | + PLFLT px[] = {0, 0, 1, 1}; | |
2239 | + PLFLT py[] = {0, 1, 1, 0}; | |
2240 | + pls->fill(4, px, py); | |
2241 | + | |
2242 | + pls->col0(0); | |
2243 | + | |
2244 | + if (lInitialRed != -1 && lInitialGreen != -1 && lInitialBlue != -1) | |
2245 | + { | |
2246 | + pls->scol0(0, lInitialRed, lInitialGreen, lInitialBlue); | |
2247 | + } | |
2248 | + } | |
2249 | + else | |
2250 | + { | |
2251 | + return; | |
2252 | + } | |
2253 | +} | |
2254 | + | |
2215 | 2255 | /** |
2216 | 2256 | * @brief Retrieve plot area bounds for the panel |
2217 | 2257 | */ |
... | ... | @@ -2281,11 +2321,13 @@ bool PanelPlotOutput::draw(double startTime, double stopTime, int intervalIndex, |
2281 | 2321 | bool isFirstInterval, bool isLastInterval) { |
2282 | 2322 | // Sets panel plplot viewport, draw background & title for the panel |
2283 | 2323 | _panel->draw(_pls); |
2324 | + fillBackground(_pls); | |
2284 | 2325 | |
2285 | - bool noData = true; | |
2326 | + bool noData = true; | |
2286 | 2327 | |
2287 | - if (_parameterAxesList.empty()) { | |
2288 | - noData = false; //Do not draw No Data if the panel is empty | |
2328 | + if (_parameterAxesList.empty()) | |
2329 | + { | |
2330 | + noData = false; // Do not draw No Data if the panel is empty | |
2289 | 2331 | _panel->drawEmptyPanel(_pls); |
2290 | 2332 | } |
2291 | 2333 | ... | ... |
src/ParamOutputImpl/Plot/PanelPlotOutput.hh
... | ... | @@ -529,6 +529,14 @@ protected: |
529 | 529 | */ |
530 | 530 | virtual void dump(std::ostream& out_); |
531 | 531 | |
532 | + /** | |
533 | + * @brief Fill the background of the plot area | |
534 | + * | |
535 | + * @param pls | |
536 | + */ | |
537 | + | |
538 | + void fillBackground(std::shared_ptr<plstream> &pls); | |
539 | + | |
532 | 540 | private: |
533 | 541 | |
534 | 542 | void drawAxis(boost::shared_ptr<Axis> pAxis, TickConf& pTickConf, std::string pXAxisOptions, | ... | ... |