Commit e803aecf1e84e688319c0c47c750f087b833d95f
1 parent
b15cd226
Exists in
master
and in
49 other branches
7616 - Adding modifications of the Kernel part
Showing
6 changed files
with
129 additions
and
85 deletions
Show diff stats
config/xsd/request/statusPlot.xsd
... | ... | @@ -18,6 +18,7 @@ |
18 | 18 | </xs:documentation> |
19 | 19 | </xs:annotation> |
20 | 20 | <xs:complexType> |
21 | + <xs:attribute name="color" type="xs:string" use="optional"></xs:attribute> | |
21 | 22 | <xs:attribute name="index" type="xs:string"/> |
22 | 23 | <xs:attribute name="resolution" type="xs:integer"/> |
23 | 24 | </xs:complexType> | ... | ... |
src/ParamOutputImpl/Plot/AbstractPlotConfigNode.hh
... | ... | @@ -91,7 +91,7 @@ protected: |
91 | 91 | xmlFree(value); |
92 | 92 | } |
93 | 93 | // -- default color |
94 | - updateColor( props_.getColor(), pNode_,(const xmlChar*)"color",(const xmlChar*)"colorMapIndex"); | |
94 | + // updateColor( props_.getColor(), pNode_,(const xmlChar*)"color",(const xmlChar*)"colorMapIndex"); | |
95 | 95 | } |
96 | 96 | |
97 | 97 | }; | ... | ... |
src/ParamOutputImpl/Plot/DecoratorPlot/AbstractDecoratorPlotNode.cc
... | ... | @@ -128,67 +128,84 @@ void DecoratorSeriesNode::parseAttributes(xmlNodePtr pNode_, |
128 | 128 | ((SeriesProperties&) props_).setIndex(AMDA::Common::ParameterIndexComponent(-1,-1)); // default case: if no index attribute, we use default index value -1 which means for all series. |
129 | 129 | } |
130 | 130 | |
131 | - // -- parameter resolution | |
132 | - /*value = xmlGetProp(pNode_, (const xmlChar *) "resolution"); | |
133 | - if (value) { | |
134 | - props_.setMaxResolution(atoi((const char*) value)); | |
131 | + // -- color | |
132 | + Color color(0, 255, 0); | |
133 | + value = xmlGetProp(pNode_, (const xmlChar *)"color"); | |
134 | + if (value) | |
135 | + { | |
136 | + try | |
137 | + { | |
138 | + std::string strValue((const char *)value); | |
139 | + createColor(color, strValue); | |
140 | + ((SeriesProperties &)props_).setColor(color); | |
141 | + } | |
142 | + catch (std::logic_error &e) | |
143 | + { | |
144 | + LOG4CXX_WARN(gLogger, "StatusBar Color : " << e.what()); | |
145 | + } | |
135 | 146 | xmlFree(value); |
136 | - }*/ | |
147 | + } | |
137 | 148 | } |
138 | 149 | |
139 | -DecoratorParamsNode::DecoratorParamsNode() : | |
140 | - AMDA::XMLConfigurator::NodeGrpCfg() { | |
150 | +DecoratorParamsNode::DecoratorParamsNode() : AMDA::XMLConfigurator::NodeGrpCfg() | |
151 | +{ | |
141 | 152 | getChildList()["param"] = AMDA::XMLConfigurator::NodeCfgSPtr( |
142 | - new DecoratorParamNode()); | |
153 | + new DecoratorParamNode()); | |
143 | 154 | } |
144 | 155 | |
145 | -DecoratorParamsNode::~DecoratorParamsNode() { | |
146 | -} | |
156 | + DecoratorParamsNode::~DecoratorParamsNode() | |
157 | + { | |
158 | + } | |
147 | 159 | |
148 | -DecoratorParamNode::DecoratorParamNode() : | |
149 | - AMDA::XMLConfigurator::NodeGrpCfg() { | |
150 | - getChildList()["serie"] = AMDA::XMLConfigurator::NodeCfgSPtr( | |
160 | + DecoratorParamNode::DecoratorParamNode() : AMDA::XMLConfigurator::NodeGrpCfg() | |
161 | + { | |
162 | + getChildList()["serie"] = AMDA::XMLConfigurator::NodeCfgSPtr( | |
151 | 163 | new DecoratorSeriesNode()); |
152 | -} | |
153 | - | |
154 | -DecoratorParamNode::~DecoratorParamNode() { | |
155 | -} | |
164 | + } | |
156 | 165 | |
157 | -void DecoratorParamNode::proceed(xmlNodePtr pNode, | |
158 | - const AMDA::Parameters::CfgContext& pContext) { | |
159 | - LOG4CXX_DEBUG(gLogger, "DecoratorParamNode::proceed"); | |
160 | - DecoratorPlot* plotOutput = pContext.get<DecoratorPlot*>(); | |
161 | - xmlChar* name = NULL; | |
162 | - // -- param id | |
163 | - name = xmlGetProp(pNode, (const xmlChar *) "id"); | |
164 | - if (name) { | |
165 | - plotOutput->addParam((const char*) name); | |
166 | + DecoratorParamNode::~DecoratorParamNode() | |
167 | + { | |
166 | 168 | } |
167 | 169 | |
168 | - // initialize drawing default properties object: | |
169 | - DrawingProperties props; | |
170 | - // take default value during init... | |
171 | - DefaultPlotConfiguration::getInstance().applyDefaultDrawingProperties( | |
170 | + void DecoratorParamNode::proceed(xmlNodePtr pNode, | |
171 | + const AMDA::Parameters::CfgContext &pContext) | |
172 | + { | |
173 | + LOG4CXX_DEBUG(gLogger, "DecoratorParamNode::proceed"); | |
174 | + DecoratorPlot *plotOutput = pContext.get<DecoratorPlot *>(); | |
175 | + xmlChar *name = NULL; | |
176 | + // -- param id | |
177 | + name = xmlGetProp(pNode, (const xmlChar *)"id"); | |
178 | + if (name) | |
179 | + { | |
180 | + plotOutput->addParam((const char *)name); | |
181 | + } | |
182 | + | |
183 | + // initialize drawing default properties object: | |
184 | + DrawingProperties props; | |
185 | + // take default value during init... | |
186 | + DefaultPlotConfiguration::getInstance().applyDefaultDrawingProperties( | |
172 | 187 | plotOutput->typeName(), props); |
173 | - // add default properties to parameter | |
174 | - plotOutput->getParameter((const char*) name).setDefaultProperties(props); | |
188 | + // add default properties to parameter | |
189 | + plotOutput->getParameter((const char *)name).setDefaultProperties(props); | |
175 | 190 | |
176 | - AMDA::Parameters::CfgContext context; | |
177 | - context.push<xmlChar*>(name); | |
178 | - context.push<DecoratorPlot*>(plotOutput); | |
179 | - AMDA::XMLConfigurator::NodeGrpCfg::proceed(pNode, context); | |
191 | + AMDA::Parameters::CfgContext context; | |
192 | + context.push<xmlChar *>(name); | |
193 | + context.push<DecoratorPlot *>(plotOutput); | |
194 | + AMDA::XMLConfigurator::NodeGrpCfg::proceed(pNode, context); | |
180 | 195 | |
181 | - if (name) { | |
182 | - xmlFree(name); | |
196 | + if (name) | |
197 | + { | |
198 | + xmlFree(name); | |
199 | + } | |
183 | 200 | } |
184 | -} | |
185 | 201 | |
186 | -DecoratorAxesNode::DecoratorAxesNode() : | |
187 | - AMDA::XMLConfigurator::NodeGrpCfg() { | |
188 | - getChildList()["xAxis"] = AMDA::XMLConfigurator::NodeCfgSPtr( | |
202 | + DecoratorAxesNode::DecoratorAxesNode() : AMDA::XMLConfigurator::NodeGrpCfg() | |
203 | + { | |
204 | + getChildList()["xAxis"] = AMDA::XMLConfigurator::NodeCfgSPtr( | |
189 | 205 | new XAxisNode()); |
190 | -} | |
191 | -DecoratorAxesNode::~DecoratorAxesNode() { | |
192 | -} | |
206 | + } | |
207 | + DecoratorAxesNode::~DecoratorAxesNode() | |
208 | + { | |
209 | + } | |
193 | 210 | |
194 | 211 | } /* namespace plot */ | ... | ... |
src/ParamOutputImpl/Plot/StatusPlot/StatusBarDecorator.cc
... | ... | @@ -236,39 +236,48 @@ void StatusBarDecorator::draw(PanelPlotOutput* pplot_, Axis* axis_, |
236 | 236 | //Working list of pair used to build the legend |
237 | 237 | std::vector<std::pair<Color,std::string>> legend; |
238 | 238 | |
239 | - //legend configuration | |
239 | + // legend configuration | |
240 | 240 | if ((paramInfo != nullptr) && !paramInfo->getStatusDef().empty()) |
241 | 241 | { |
242 | - for (int s = 0 ; s < (int)paramInfo->getStatusDef().size(); ++s) | |
242 | + for (int s = 0; s < (int)paramInfo->getStatusDef().size(); ++s) | |
243 | 243 | { |
244 | 244 | std::string colorStr = paramInfo->getStatusDef()[s].getColor(); |
245 | - Color color; | |
246 | - if (!colorStr.empty()) { | |
245 | + if (_barInfoList[i]._color.isSet()) // we use the color set by the user | |
246 | + { | |
247 | + Color color; | |
248 | + color = _barInfoList[i]._color; | |
249 | + legend.push_back(std::make_pair(color, paramInfo->getStatusDef()[s].getName())); | |
250 | + } | |
251 | + else if (!colorStr.empty()) // if the color is not set by the user we take the StatusDef | |
252 | + { | |
253 | + Color color; | |
254 | + | |
247 | 255 | createColor(color, colorStr); |
256 | + legend.push_back(std::make_pair(color, paramInfo->getStatusDef()[s].getName())); | |
248 | 257 | } |
249 | - else { | |
250 | - color = Color(_colorMapIndex, s); | |
258 | + else // if none of them is given, we set the colorMapIndex color | |
259 | + { | |
260 | + Color color(_colorMapIndex, s); | |
261 | + legend.push_back(std::make_pair(color, paramInfo->getStatusDef()[s].getName())); | |
251 | 262 | } |
252 | - legend.push_back(std::make_pair(color,paramInfo->getStatusDef()[s].getName())); | |
253 | 263 | } |
254 | 264 | } |
255 | 265 | |
256 | - | |
257 | - //set color map | |
266 | + // set color map | |
258 | 267 | pls_->spal1( |
259 | 268 | ColormapManager::getInstance().getColorAxis(_colorMapIndex).c_str(), true); |
260 | 269 | |
261 | 270 | Color lInitialColor; |
262 | 271 | pls_->gcol0(0, lInitialColor._red, lInitialColor._green, lInitialColor._blue); |
263 | 272 | |
264 | - //Draw Status data | |
273 | + // Draw Status data | |
265 | 274 | PLFLT x[4], y[4]; |
266 | - for (int t = 0; t < _barInfoList[i]._dataPtr->getSize() - 1;++t) | |
275 | + for (int t = 0; t < _barInfoList[i]._dataPtr->getSize() - 1; ++t) | |
267 | 276 | { |
268 | 277 | x[0] = _barInfoList[i]._dataPtr->getTimes()[t]; |
269 | 278 | x[1] = _barInfoList[i]._dataPtr->getTimes()[t]; |
270 | - x[2] = _barInfoList[i]._dataPtr->getTimes()[t+1]; | |
271 | - x[3] = _barInfoList[i]._dataPtr->getTimes()[t+1]; | |
279 | + x[2] = _barInfoList[i]._dataPtr->getTimes()[t + 1]; | |
280 | + x[3] = _barInfoList[i]._dataPtr->getTimes()[t + 1]; | |
272 | 281 | y[0] = 0.; |
273 | 282 | y[1] = 1.; |
274 | 283 | y[2] = 1.; |
... | ... | @@ -276,76 +285,87 @@ void StatusBarDecorator::draw(PanelPlotOutput* pplot_, Axis* axis_, |
276 | 285 | |
277 | 286 | double paramValue = _barInfoList[i]._dataPtr->getValues(_barInfoList[i]._index)[t]; |
278 | 287 | |
279 | - if (isNAN(paramValue)) { | |
288 | + if (isNAN(paramValue)) | |
289 | + { | |
280 | 290 | continue; |
281 | 291 | } |
282 | 292 | if ((paramInfo != nullptr) && !paramInfo->getStatusDef().empty()) |
283 | 293 | { |
284 | - for (int s = 0 ; s < (int)paramInfo->getStatusDef().size(); ++s) | |
294 | + for (int s = 0; s < (int)paramInfo->getStatusDef().size(); ++s) | |
285 | 295 | { |
286 | 296 | if ((paramValue >= paramInfo->getStatusDef()[s].getMinValue()) && |
287 | 297 | (paramValue <= paramInfo->getStatusDef()[s].getMaxValue())) |
288 | 298 | { |
289 | 299 | std::string colorStr = paramInfo->getStatusDef()[s].getColor(); |
290 | - if (!colorStr.empty()) { | |
291 | - Color dataValueColor; | |
292 | - createColor(dataValueColor, colorStr); | |
293 | - restoreColor(pls_, dataValueColor, pplot_->_panel->_page->_mode); | |
300 | + if (_barInfoList[i]._color.isSet()) // we use the color set by the user | |
301 | + { | |
302 | + restoreColor(pls_, _barInfoList[i]._color, pplot_->_panel->_page->_mode); | |
303 | + pls_->fill(4, x, y); | |
304 | + pls_->spal1(ColormapManager::getInstance().getColorAxis(_colorMapIndex).c_str(), true); | |
305 | + } | |
306 | + else if (!colorStr.empty()) // if the color is not set by the user we take the StatusDef | |
307 | + { | |
308 | + Color color; | |
309 | + | |
310 | + createColor(color, colorStr); | |
311 | + restoreColor(pls_, color, pplot_->_panel->_page->_mode); | |
294 | 312 | pls_->fill(4, x, y); |
295 | 313 | pls_->spal1(ColormapManager::getInstance().getColorAxis(_colorMapIndex).c_str(), true); |
296 | 314 | } |
297 | - else { | |
315 | + else // if none of them is given, we set the colorMapIndex color | |
316 | + { | |
298 | 317 | Color dataValueColor(_colorMapIndex, s); |
299 | 318 | restoreColor(pls_, dataValueColor, pplot_->_panel->_page->_mode); |
300 | 319 | pls_->fill(4, x, y); |
301 | 320 | pls_->spal1(ColormapManager::getInstance().getColorAxis(_colorMapIndex).c_str(), true); |
302 | 321 | } |
303 | - break; | |
304 | 322 | } |
305 | 323 | } |
306 | 324 | } |
307 | 325 | } |
308 | 326 | |
309 | - //restore to initial color context | |
327 | + // restore to initial color context | |
310 | 328 | pls_->spal1( |
311 | - ColormapManager::getInstance().get(pplot_->_panel->_page->_mode, | |
312 | - ColormapManager::DEFAULT_COLORMAP_1).c_str(), true); | |
329 | + ColormapManager::getInstance().get(pplot_->_panel->_page->_mode, | |
330 | + ColormapManager::DEFAULT_COLORMAP_1) | |
331 | + .c_str(), | |
332 | + true); | |
313 | 333 | pls_->scol0(0, lInitialColor._red, lInitialColor._green, lInitialColor._blue); |
314 | 334 | // Restore color. |
315 | 335 | restoreColor(pls_, lInitialColor, pplot_->_panel->_page->_mode); |
316 | 336 | |
317 | - //draw bar box | |
337 | + // draw bar box | |
318 | 338 | pls_->box("bc", 0, 0, "bc", 0, 0); |
319 | 339 | |
320 | - //draw legend | |
340 | + // draw legend | |
321 | 341 | PlPlotUtil::setPlFont(legendFont); |
322 | 342 | std::string legendText = _barInfoList[i]._name; |
323 | 343 | legendText += ": "; |
324 | - //plot parameter name | |
325 | - pls_->mtex("t",1,0,0,legendText.c_str()); | |
344 | + // plot parameter name | |
345 | + pls_->mtex("t", 1, 0, 0, legendText.c_str()); | |
326 | 346 | |
327 | - PLFLT xmin2,xmax2,ymin2,ymax2; | |
328 | - pls_->gspa(xmin2,xmax2,ymin2,ymax2); | |
347 | + PLFLT xmin2, xmax2, ymin2, ymax2; | |
348 | + pls_->gspa(xmin2, xmax2, ymin2, ymax2); | |
329 | 349 | |
330 | - double textFactor = (xmax2-xmin2) * vpBounds._width ; | |
350 | + double textFactor = (xmax2 - xmin2) * vpBounds._width; | |
331 | 351 | |
332 | 352 | double legendPos = plstrl(legendText.c_str()) / textFactor; |
333 | 353 | std::string separator = ", "; |
334 | - //plot each status name with the associated color | |
354 | + // plot each status name with the associated color | |
335 | 355 | for (int p = 0; p < (int)legend.size(); ++p) |
336 | 356 | { |
337 | 357 | Color initColor = changeColor(pls_, legend[p].first, pplot_->_panel->_page->_mode); |
338 | - pls_->mtex("t",1,legendPos,0,legend[p].second.c_str()); | |
358 | + pls_->mtex("t", 1, legendPos, 0, legend[p].second.c_str()); | |
339 | 359 | legendPos += plstrl(legend[p].second.c_str()) / textFactor; |
340 | 360 | restoreColor(pls_, initColor, pplot_->_panel->_page->_mode); |
341 | 361 | if (p != (int)legend.size() - 1) |
342 | 362 | { |
343 | - pls_->mtex("t",1,legendPos,0,separator.c_str()); | |
363 | + pls_->mtex("t", 1, legendPos, 0, separator.c_str()); | |
344 | 364 | legendPos += plstrl(separator.c_str()) / textFactor; |
345 | 365 | } |
346 | 366 | } |
347 | 367 | |
348 | - delta += (BAR_HEIGHT+BAR_SPACE+1.5*legendCharSize.second); | |
368 | + delta += (BAR_HEIGHT + BAR_SPACE + 1.5 * legendCharSize.second); | |
349 | 369 | } |
350 | 370 | |
351 | 371 | // restore viewport. |
... | ... | @@ -401,6 +421,7 @@ void StatusBarDecorator::buildBarList() { |
401 | 421 | barInfo._index = index; |
402 | 422 | barInfo._dataPtr = &(*_pParameterValues)[lSeriesProperties.getParamId()]; |
403 | 423 | barInfo._paramInfoSPtr = paramInfo; |
424 | + barInfo._color = lSeriesProperties.getColor(); | |
404 | 425 | _barInfoList.push_back(barInfo); |
405 | 426 | } |
406 | 427 | } | ... | ... |
src/ParamOutputImpl/Plot/StatusPlot/StatusBarDecorator.hh
... | ... | @@ -44,6 +44,7 @@ public: |
44 | 44 | void setColorMapIndex( int colorMapIndex_){ |
45 | 45 | _colorMapIndex = colorMapIndex_; |
46 | 46 | } |
47 | + | |
47 | 48 | int getColorMapIndex() const{ |
48 | 49 | return _colorMapIndex; |
49 | 50 | } |
... | ... | @@ -101,6 +102,11 @@ private: |
101 | 102 | * @brief pointer to the parameter info |
102 | 103 | */ |
103 | 104 | ParamInfoSPtr _paramInfoSPtr; |
105 | + | |
106 | + /* | |
107 | + * @brief Given color | |
108 | + */ | |
109 | + Color _color; | |
104 | 110 | }; |
105 | 111 | |
106 | 112 | /** |
... | ... | @@ -146,8 +152,7 @@ private: |
146 | 152 | /** |
147 | 153 | * @brief Plot that owns parameter values. |
148 | 154 | */ |
149 | - PanelPlotOutput* _decoratorPlot; | |
150 | - | |
155 | + PanelPlotOutput *_decoratorPlot; | |
151 | 156 | }; |
152 | 157 | |
153 | 158 | /** | ... | ... |
src/ParamOutputImpl/Plot/Time/TimePlot.cc
... | ... | @@ -1819,7 +1819,7 @@ namespace plot |
1819 | 1819 | continue; |
1820 | 1820 | } |
1821 | 1821 | |
1822 | - crtColor = getStatusColor(paramInfo, crtVal); | |
1822 | + crtColor = pIntervals.getColor(); | |
1823 | 1823 | |
1824 | 1824 | drawOneInterval(tmin, tmax, crtColor); |
1825 | 1825 | |
... | ... | @@ -1832,7 +1832,7 @@ namespace plot |
1832 | 1832 | //Draw last interval if need |
1833 | 1833 | if ((tmin != tmax) && !isNAN(crtVal)) |
1834 | 1834 | { |
1835 | - crtColor = getStatusColor(paramInfo, crtVal); | |
1835 | + crtColor = pIntervals.getColor(); | |
1836 | 1836 | drawOneInterval(tmin, tmax, crtColor); |
1837 | 1837 | } |
1838 | 1838 | } | ... | ... |