Commit 5d98ca3d122c05bbaaf2afc046bab404db716052
1 parent
677db865
Exists in
master
and in
90 other branches
Draw intervals in a status bar
Showing
5 changed files
with
75 additions
and
55 deletions
Show diff stats
src/ParamOutputImpl/Plot/InstantPlot/InstantPlot.cc
... | ... | @@ -1113,6 +1113,7 @@ void InstantPlot::drawSpectro(double startDate, double stopDate, std::string pPa |
1113 | 1113 | part.y[1] = log10(part.y[1]); |
1114 | 1114 | } |
1115 | 1115 | |
1116 | + part.isColorIndex = false; | |
1116 | 1117 | if (_iSpectroProperties->getDimOnXAxis() == 0) { |
1117 | 1118 | part.value = data.getInterpolatedValue(_time, AMDA::Common::ParameterIndexComponent(i,j)); |
1118 | 1119 | } | ... | ... |
src/ParamOutputImpl/Plot/PanelPlotOutput.cc
... | ... | @@ -1389,7 +1389,6 @@ void PanelPlotOutput::drawRectangle(double xmin, double xmax, double ymin, doubl |
1389 | 1389 | a = alpha; |
1390 | 1390 | _pls->scol0a( icol, r, g, b, a ); |
1391 | 1391 | _pls->col0( icol ); |
1392 | - | |
1393 | 1392 | _pls->fill(4, x, y); |
1394 | 1393 | |
1395 | 1394 | // Restore color. |
... | ... | @@ -1400,7 +1399,7 @@ void PanelPlotOutput::drawRectangle(double xmin, double xmax, double ymin, doubl |
1400 | 1399 | * @brief Draw a matrix |
1401 | 1400 | */ |
1402 | 1401 | void PanelPlotOutput::drawMatrix(MatrixGrid& matrixGrid, double minDataVal, double maxDataVal, |
1403 | - Color minValColor, Color maxValColor, int colorMapIndex, bool dataValueIsColorIndex, bool useLog0AsMin) | |
1402 | + Color minValColor, Color maxValColor, int colorMapIndex, bool useLog0AsMin) | |
1404 | 1403 | { |
1405 | 1404 | //set color map |
1406 | 1405 | _pls->spal1( |
... | ... | @@ -1428,7 +1427,7 @@ void PanelPlotOutput::drawMatrix(MatrixGrid& matrixGrid, double minDataVal, doub |
1428 | 1427 | if (isNAN(part.value)) |
1429 | 1428 | continue; |
1430 | 1429 | |
1431 | - if (!dataValueIsColorIndex) | |
1430 | + if (!part.isColorIndex) | |
1432 | 1431 | { |
1433 | 1432 | if (!getColoredValue(part.value, minDataVal, maxDataVal, useLog0AsMin, col)) |
1434 | 1433 | continue; | ... | ... |
src/ParamOutputImpl/Plot/PanelPlotOutput.hh
... | ... | @@ -264,6 +264,7 @@ public: |
264 | 264 | double x[2]; |
265 | 265 | double y[2]; |
266 | 266 | double value; |
267 | + double isColorIndex; | |
267 | 268 | }; |
268 | 269 | |
269 | 270 | typedef std::vector<GridPart> MatrixGrid; |
... | ... | @@ -272,7 +273,7 @@ public: |
272 | 273 | * @brief Draw a matrix |
273 | 274 | */ |
274 | 275 | void drawMatrix(MatrixGrid& matrixGrid, double minDataVal, double maxDataVal, |
275 | - Color minValColor, Color maxValColor, int colorMapIndex, bool dataValueIsColorIndex = false, bool useLog0AsMin = false); | |
276 | + Color minValColor, Color maxValColor, int colorMapIndex, bool useLog0AsMin = false); | |
276 | 277 | |
277 | 278 | /** |
278 | 279 | * @brief Reset cursor used to attribute automatically a color to a serie |
... | ... | @@ -281,6 +282,11 @@ public: |
281 | 282 | _automaticSerieColorCursor = 0; |
282 | 283 | } |
283 | 284 | |
285 | + /** | |
286 | + * Draw a rectangle | |
287 | + */ | |
288 | + void drawRectangle(double xmin, double xmax, double ymin, double ymax, Color& pColor, double alpha = 1.); | |
289 | + | |
284 | 290 | AMDA::Parameters::ParameterManager& _parameterManager; |
285 | 291 | |
286 | 292 | std::map<std::string, ParameterData> *_pParameterValues; |
... | ... | @@ -325,11 +331,6 @@ protected: |
325 | 331 | int pNbData, double* pXData, double* pYData, |
326 | 332 | double* pZData = NULL, double filterZMin = -DBL_MAX, double filterZMax = DBL_MAX); |
327 | 333 | |
328 | - /** | |
329 | - * Draw a rectangle | |
330 | - */ | |
331 | - void drawRectangle(double xmin, double xmax, double ymin, double ymax, Color& pColor, double alpha = 1.); | |
332 | - | |
333 | 334 | /** |
334 | 335 | * Draw errors segments |
335 | 336 | */ | ... | ... |
src/ParamOutputImpl/Plot/StatusPlot/StatusBarDecorator.cc
... | ... | @@ -25,6 +25,7 @@ |
25 | 25 | #include "ColormapManager.hh" |
26 | 26 | #include "ParamMgr.hh" |
27 | 27 | #include "PlPlotUtil.hh" |
28 | +#include "CommonNode.hh" | |
28 | 29 | |
29 | 30 | #define BAR_HEIGHT 0.02 |
30 | 31 | #define BAR_SPACE 0.005 |
... | ... | @@ -235,66 +236,85 @@ void StatusBarDecorator::draw(PanelPlotOutput* pplot_, Axis* axis_, |
235 | 236 | ParamInfoSPtr paramInfo = _barInfoList[i]._paramInfoSPtr; |
236 | 237 | |
237 | 238 | //Working list of pair used to build the legend |
238 | - std::vector<std::pair<int,std::string>> legend; | |
239 | + std::vector<std::pair<Color,std::string>> legend; | |
239 | 240 | |
240 | 241 | //legend configuration |
241 | 242 | if ((paramInfo != nullptr) && !paramInfo->getStatusDef().empty()) |
242 | 243 | { |
243 | 244 | for (int s = 0 ; s < (int)paramInfo->getStatusDef().size(); ++s) |
244 | 245 | { |
245 | - legend.push_back(std::make_pair(s,paramInfo->getStatusDef()[s].getName())); | |
246 | + std::string colorStr = paramInfo->getStatusDef()[s].getColor(); | |
247 | + Color color; | |
248 | + if (!colorStr.empty()) { | |
249 | + createColor(color, colorStr); | |
250 | + } | |
251 | + else { | |
252 | + color = Color(_colorMapIndex, s); | |
253 | + } | |
254 | + legend.push_back(std::make_pair(color,paramInfo->getStatusDef()[s].getName())); | |
246 | 255 | } |
247 | 256 | } |
248 | 257 | |
258 | + | |
259 | + //set color map | |
260 | + pls_->spal1( | |
261 | + ColormapManager::getInstance().getColorAxis(_colorMapIndex).c_str(), true); | |
262 | + | |
263 | + Color lInitialColor; | |
264 | + pls_->gcol0(0, lInitialColor._red, lInitialColor._green, lInitialColor._blue); | |
265 | + | |
249 | 266 | //Draw Status data |
250 | - PanelPlotOutput::MatrixGrid matrixGrid; | |
267 | + PLFLT x[4], y[4]; | |
251 | 268 | for (int t = 0; t < _barInfoList[i]._dataPtr->getSize() - 1;++t) |
252 | 269 | { |
253 | - PanelPlotOutput::GridPart part; | |
254 | - part.x[0] = _barInfoList[i]._dataPtr->getTimes()[t]; | |
255 | - part.x[1] = _barInfoList[i]._dataPtr->getTimes()[t+1]; | |
256 | - part.y[0] = 0; | |
257 | - part.y[1] = 1; | |
270 | + x[0] = _barInfoList[i]._dataPtr->getTimes()[t]; | |
271 | + x[1] = _barInfoList[i]._dataPtr->getTimes()[t]; | |
272 | + x[2] = _barInfoList[i]._dataPtr->getTimes()[t+1]; | |
273 | + x[3] = _barInfoList[i]._dataPtr->getTimes()[t+1]; | |
274 | + y[0] = 0.; | |
275 | + y[1] = 1.; | |
276 | + y[2] = 1.; | |
277 | + y[3] = 0.; | |
258 | 278 | |
259 | 279 | double paramValue = _barInfoList[i]._dataPtr->getValues(_barInfoList[i]._index)[t]; |
260 | 280 | |
261 | - if (isNAN(paramValue)) | |
262 | - part.value = NAN; | |
263 | - else | |
281 | + if (isNAN(paramValue)) { | |
282 | + continue; | |
283 | + } | |
284 | + if ((paramInfo != nullptr) && !paramInfo->getStatusDef().empty()) | |
264 | 285 | { |
265 | - if ((paramInfo != nullptr) && !paramInfo->getStatusDef().empty()) | |
286 | + for (int s = 0 ; s < (int)paramInfo->getStatusDef().size(); ++s) | |
266 | 287 | { |
267 | - bool valid = false; | |
268 | - for (int s = 0 ; s < (int)paramInfo->getStatusDef().size(); ++s) | |
288 | + if ((paramValue >= paramInfo->getStatusDef()[s].getMinValue()) && | |
289 | + (paramValue <= paramInfo->getStatusDef()[s].getMaxValue())) | |
269 | 290 | { |
270 | - if ((paramValue >= paramInfo->getStatusDef()[s].getMinValue()) && | |
271 | - (paramValue <= paramInfo->getStatusDef()[s].getMaxValue())) | |
272 | - { | |
273 | - valid = true; | |
274 | - part.value = s; | |
275 | - break; | |
291 | + std::string colorStr = paramInfo->getStatusDef()[s].getColor(); | |
292 | + if (!colorStr.empty()) { | |
293 | + Color dataValueColor; | |
294 | + createColor(dataValueColor, colorStr); | |
295 | + restoreColor(pls_, dataValueColor, pplot_->_panel->_page->_mode); | |
296 | + pls_->fill(4, x, y); | |
297 | + pls_->spal1(ColormapManager::getInstance().getColorAxis(_colorMapIndex).c_str(), true); | |
298 | + } | |
299 | + else { | |
300 | + Color dataValueColor(_colorMapIndex, s); | |
301 | + restoreColor(pls_, dataValueColor, pplot_->_panel->_page->_mode); | |
302 | + pls_->fill(4, x, y); | |
303 | + pls_->spal1(ColormapManager::getInstance().getColorAxis(_colorMapIndex).c_str(), true); | |
276 | 304 | } |
305 | + break; | |
277 | 306 | } |
278 | - | |
279 | - if (!valid) | |
280 | - part.value = NAN; | |
281 | 307 | } |
282 | - else | |
283 | - //status definition is given by the paramInfo | |
284 | - part.value = NAN; | |
285 | 308 | } |
286 | - | |
287 | - matrixGrid.push_back(part); | |
288 | 309 | } |
289 | 310 | |
290 | - Color minValColor; | |
291 | - Color maxValColor; | |
292 | - | |
293 | - //draw spectro | |
294 | - pplot_->drawMatrix(matrixGrid, | |
295 | - _barInfoList[i]._dataPtr->getMin(), | |
296 | - _barInfoList[i]._dataPtr->getMin(), | |
297 | - minValColor, maxValColor, _colorMapIndex, true); | |
311 | + //restore to initial color context | |
312 | + pls_->spal1( | |
313 | + ColormapManager::getInstance().get(pplot_->_panel->_page->_mode, | |
314 | + ColormapManager::DEFAULT_COLORMAP_1).c_str(), true); | |
315 | + pls_->scol0(0, lInitialColor._red, lInitialColor._green, lInitialColor._blue); | |
316 | + // Restore color. | |
317 | + restoreColor(pls_, lInitialColor, pplot_->_panel->_page->_mode); | |
298 | 318 | |
299 | 319 | //draw bar box |
300 | 320 | pls_->box("bc", 0, 0, "bc", 0, 0); |
... | ... | @@ -306,18 +326,17 @@ void StatusBarDecorator::draw(PanelPlotOutput* pplot_, Axis* axis_, |
306 | 326 | //plot parameter name |
307 | 327 | pls_->mtex("t",1,0,0,legendText.c_str()); |
308 | 328 | |
309 | - PLFLT xmin,xmax,ymin,ymax; | |
310 | - pls_->gspa(xmin,xmax,ymin,ymax); | |
329 | + PLFLT xmin2,xmax2,ymin2,ymax2; | |
330 | + pls_->gspa(xmin2,xmax2,ymin2,ymax2); | |
311 | 331 | |
312 | - double textFactor = (xmax-xmin) * vpBounds._width ; | |
332 | + double textFactor = (xmax2-xmin2) * vpBounds._width ; | |
313 | 333 | |
314 | 334 | double legendPos = plstrl(legendText.c_str()) / textFactor; |
315 | 335 | std::string separator = ", "; |
316 | 336 | //plot each status name with the associated color |
317 | 337 | for (int p = 0; p < (int)legend.size(); ++p) |
318 | 338 | { |
319 | - Color partColor(_colorMapIndex, (int)legend[p].first); | |
320 | - Color initColor = changeColor(pls_, partColor, pplot_->_panel->_page->_mode); | |
339 | + Color initColor = changeColor(pls_, legend[p].first, pplot_->_panel->_page->_mode); | |
321 | 340 | pls_->mtex("t",1,legendPos,0,legend[p].second.c_str()); |
322 | 341 | legendPos += plstrl(legend[p].second.c_str()) / textFactor; |
323 | 342 | restoreColor(pls_, initColor, pplot_->_panel->_page->_mode); | ... | ... |
src/ParamOutputImpl/Plot/Time/TimePlot.cc
... | ... | @@ -942,7 +942,7 @@ void TimePlot::drawSpectro(double startDate, double stopDate, std::string pParam |
942 | 942 | { |
943 | 943 | part.x[0] = data.getTimes()[startIndex+i]; |
944 | 944 | part.x[1] = data.getTimes()[startIndex+i+1]; |
945 | - | |
945 | + part.isColorIndex = false; | |
946 | 946 | part.value = data.getValues(index, startIndex)[i]; |
947 | 947 | matrixGrid.push_back(part); |
948 | 948 | } |
... | ... | @@ -978,6 +978,7 @@ void TimePlot::drawSpectro(double startDate, double stopDate, std::string pParam |
978 | 978 | |
979 | 979 | for (auto index : pSpectro.getIndexes()) |
980 | 980 | { |
981 | + part.isColorIndex = false; | |
981 | 982 | part.value = data.getValues(index,startIndex)[i]; |
982 | 983 | |
983 | 984 | if (pSpectro.getRelatedDim() == 0) |
... | ... | @@ -1013,7 +1014,7 @@ void TimePlot::drawSpectro(double startDate, double stopDate, std::string pParam |
1013 | 1014 | //draw spectro |
1014 | 1015 | LOG4CXX_DEBUG(gLogger, "TimePlot::drawSpectro - Draw data grid"); |
1015 | 1016 | drawMatrix(matrixGrid, pSpectro.getMin(), pSpectro.getMax(), |
1016 | - minValColor, maxValColor, lZAxis->_color._colorMapIndex, FALSE, pSpectro.getUseLog0AsMin()); | |
1017 | + minValColor, maxValColor, lZAxis->_color._colorMapIndex, pSpectro.getUseLog0AsMin()); | |
1017 | 1018 | } |
1018 | 1019 | |
1019 | 1020 | Color TimePlot::getStatusColor(AMDA::Info::ParamInfoSPtr& paramInfo, double value) { |
... | ... | @@ -1105,12 +1106,11 @@ void TimePlot::drawIntervals(double startDate, double stopDate, std::string pPar |
1105 | 1106 | tmin = t1; |
1106 | 1107 | tmax = t2; |
1107 | 1108 | crtVal = v; |
1109 | + crtColor = Color(); | |
1108 | 1110 | } |
1109 | 1111 | |
1110 | 1112 | //Draw last interval if need |
1111 | - if (!isNAN(crtVal)) { | |
1112 | - drawOneInterval(tmin, tmax, crtColor); | |
1113 | - } | |
1113 | + drawOneInterval(tmin, tmax, crtColor); | |
1114 | 1114 | } |
1115 | 1115 | |
1116 | 1116 | /** | ... | ... |