Commit abded81cd6c2490efbdbb999df0255e73c9c38ea
1 parent
cf0ebe91
Exists in
master
and in
100 other branches
Plot area alignment with manual layout when two panels have the same left position
Showing
3 changed files
with
64 additions
and
8 deletions
Show diff stats
src/ParamOutputImpl/Plot/PanelPlotOutput.cc
... | ... | @@ -2207,6 +2207,8 @@ int PanelPlotOutput::getLeftAxisTickMarkWidth (void) { |
2207 | 2207 | void PanelPlotOutput::forceLeftAxisTickMarkWidth(int leftAxisTickMarkWidth) { |
2208 | 2208 | for (Axes::iterator it = _panel->_axes.begin(); it != _panel->_axes.end(); ++it) { |
2209 | 2209 | boost::shared_ptr<Axis> lAxis = it->second; |
2210 | + if (lAxis == nullptr) | |
2211 | + continue; | |
2210 | 2212 | // Look for a visible fleft Axis with legend and |
2211 | 2213 | if ((lAxis->_visible) && (lAxis->_position == PlotCommon::Position::POS_LEFT)) { |
2212 | 2214 | lAxis->setFixedTickMarkWidth(leftAxisTickMarkWidth); | ... | ... |
src/ParamOutputImpl/Plot/PlotOutput.cc
... | ... | @@ -11,6 +11,7 @@ |
11 | 11 | #include "PlotLogger.hh" |
12 | 12 | #include "LayoutAuto.hh" |
13 | 13 | #include "LayoutVertical.hh" |
14 | +#include "TimePlotNode.hh" | |
14 | 15 | |
15 | 16 | namespace plot { |
16 | 17 | |
... | ... | @@ -366,10 +367,14 @@ void PlotOutput::computePanelBounds(void) { |
366 | 367 | } |
367 | 368 | |
368 | 369 | void PlotOutput::computePanelPlotAreaBounds(void) { |
369 | - // Nothing to plot -> nothing to compute ! | |
370 | - // Nothing to compute if layout type is manual | |
371 | - if ((_plots.empty() == true) || | |
372 | - (_page->_layoutProperties.getType() == LayoutType::MANUAL)) { | |
370 | + if ((_plots.empty() == true)) { | |
371 | + // Nothing to plot -> nothing to compute | |
372 | + return; | |
373 | + } | |
374 | + | |
375 | + if (_page->_layoutProperties.getType() == LayoutType::MANUAL) { | |
376 | + //Specific treatment for manual layout | |
377 | + computePanelPlotAreaBoundsForManualLayout(); | |
373 | 378 | return; |
374 | 379 | } |
375 | 380 | |
... | ... | @@ -399,11 +404,50 @@ void PlotOutput::computePanelPlotAreaBounds(void) { |
399 | 404 | } |
400 | 405 | } |
401 | 406 | |
402 | -void PlotOutput::computePanelLegendPosition(void) { | |
407 | +void PlotOutput::computePanelPlotAreaBoundsForManualLayout(void) { | |
403 | 408 | // Nothing to plot -> nothing to compute ! |
404 | - // Nothing to compute if layout type is manual | |
409 | + // Can be used only for a plot with manual layout | |
405 | 410 | if ((_plots.empty() == true) || |
406 | - (_page->_layoutProperties.getType() == LayoutType::MANUAL)) { | |
411 | + (_page->_layoutProperties.getType() != LayoutType::MANUAL)) { | |
412 | + return; | |
413 | + } | |
414 | + | |
415 | + LOG4CXX_DEBUG(gLogger,"PlotOutput::computePanelPlotAreaBoundsForManualLayout..."); | |
416 | + | |
417 | + //Regroup panels by left positions (only for timePlot) | |
418 | + std::map<double, std::vector<boost::shared_ptr<PanelPlotOutput>>> leftPanelsPosList; | |
419 | + for (auto plot : _plots) { | |
420 | + if (plot->typeName() != TIMEPLOT_NODENAME) | |
421 | + continue; | |
422 | + leftPanelsPosList[plot->_panel->_bounds._x].push_back(plot); | |
423 | + } | |
424 | + | |
425 | + //Align plot area | |
426 | + Bounds plotAreaBounds; | |
427 | + for (auto leftPanelPos : leftPanelsPosList) { | |
428 | + double plotAreaLeftPos = 0; | |
429 | + double plotAreaRightPos = 1; | |
430 | + for (auto plot : leftPanelPos.second) { | |
431 | + plot->getPlotAreaBounds(plotAreaBounds); | |
432 | + | |
433 | + if (plotAreaBounds._x > plotAreaLeftPos) | |
434 | + plotAreaLeftPos = plotAreaBounds._x; | |
435 | + | |
436 | + if ((plotAreaBounds._x + plotAreaBounds._width) < plotAreaRightPos) | |
437 | + plotAreaRightPos = (plotAreaBounds._x + plotAreaBounds._width); | |
438 | + | |
439 | + } | |
440 | + | |
441 | + for (auto plot : leftPanelPos.second) { | |
442 | + plot->getPlotAreaBounds(plotAreaBounds); | |
443 | + plot->forcePlotAreaPosAndWidth(plotAreaLeftPos, plotAreaRightPos - plotAreaLeftPos); | |
444 | + } | |
445 | + } | |
446 | +} | |
447 | + | |
448 | +void PlotOutput::computePanelLegendPosition(void) { | |
449 | + // Nothing to plot -> nothing to compute ! | |
450 | + if ((_plots.empty() == true)) { | |
407 | 451 | return; |
408 | 452 | } |
409 | 453 | |
... | ... | @@ -414,6 +458,9 @@ void PlotOutput::computePanelLegendPosition(void) { |
414 | 458 | int maxLeftAxisTickMarkWitdh = 0; |
415 | 459 | int leftAxisTickMarkWitdh = 0; |
416 | 460 | for (auto plot : _plots) { |
461 | + //if manual layout => only apply on timePlots | |
462 | + if ((_page->_layoutProperties.getType() == LayoutType::MANUAL) && (plot->typeName() != TIMEPLOT_NODENAME)) | |
463 | + continue; | |
417 | 464 | if (plot->getLayoutConstraint() == PanelConstraint::MaxWidth) { |
418 | 465 | leftAxisTickMarkWitdh = plot->getLeftAxisTickMarkWidth(); |
419 | 466 | |
... | ... | @@ -421,9 +468,11 @@ void PlotOutput::computePanelLegendPosition(void) { |
421 | 468 | maxLeftAxisTickMarkWitdh = leftAxisTickMarkWitdh; |
422 | 469 | } |
423 | 470 | } |
424 | - | |
425 | 471 | // Force plot left axis tickmark max width for panels with MaxWidth constraint |
426 | 472 | for (auto plot : _plots) { |
473 | + //if manual layout => only apply on timePlots | |
474 | + if ((_page->_layoutProperties.getType() == LayoutType::MANUAL) && (plot->typeName() != TIMEPLOT_NODENAME)) | |
475 | + continue; | |
427 | 476 | if (plot->getLayoutConstraint() == PanelConstraint::MaxWidth) { |
428 | 477 | plot->forceLeftAxisTickMarkWidth(maxLeftAxisTickMarkWitdh); |
429 | 478 | } | ... | ... |
src/ParamOutputImpl/Plot/PlotOutput.hh
... | ... | @@ -188,6 +188,11 @@ protected: |
188 | 188 | virtual void computePanelPlotAreaBounds (void); |
189 | 189 | |
190 | 190 | /** |
191 | + * @brief Compute panel plot area position for manual layout | |
192 | + */ | |
193 | + virtual void computePanelPlotAreaBoundsForManualLayout(void); | |
194 | + | |
195 | + /** | |
191 | 196 | * @brief Compute legend position depending on the panel constraints |
192 | 197 | */ |
193 | 198 | virtual void computePanelLegendPosition (void); | ... | ... |