Commit be4a57f6c5f6b3e8732b2393277eb549bd1354a6
1 parent
9f7344d9
Exists in
master
and in
88 other branches
Revert "Simplify tickplot drawing"
This reverts commit 9f7344d97920aaa33bb1c51133c9e9b595bc9781.
Showing
1 changed file
with
22 additions
and
6 deletions
Show diff stats
src/ParamOutputImpl/Plot/TickPlot/TickMarkDecorator.cc
... | ... | @@ -270,18 +270,21 @@ void TickMarkDecorator::draw(PanelPlotOutput* pplot_, Axis* axis_, |
270 | 270 | PlPlotUtil::setPlFont(legendFont); |
271 | 271 | CharSize legendCharSize = PlPlotUtil::getCharacterSizeInPlPage(pplot_->_panel->_page); |
272 | 272 | |
273 | - double yInc = legendCharSize.second * 1.2; | |
273 | + // delta is negative when axis is at bottom (which is the default case). positive otherwise. | |
274 | + // (viewport origin is in the left bottom corner of the page). | |
275 | + double yDelta = -legendCharSize.second * 2; | |
274 | 276 | |
275 | 277 | std::string options = ""; |
276 | 278 | int start; |
277 | 279 | int end; |
278 | 280 | int dir; |
279 | - double yDelta = 0; | |
280 | 281 | |
281 | 282 | PlPlotUtil::setPlFont(legendFont); |
282 | 283 | |
283 | 284 | if (pAxis->_position == PlotCommon::POS_TOP) { |
284 | 285 | options = "mxo"; // options means : m=display above axe, x=do not plot ticks, o=user label function provided. |
286 | + yDelta = -yDelta; // if axis is displayed on top of graph we have to use an inverse translation delta. | |
287 | + // reverse direction : | |
285 | 288 | start = _seriesInfoList.size() - 1; |
286 | 289 | end = -1; |
287 | 290 | dir = -1; |
... | ... | @@ -291,25 +294,38 @@ void TickMarkDecorator::draw(PanelPlotOutput* pplot_, Axis* axis_, |
291 | 294 | end = _seriesInfoList.size(); |
292 | 295 | dir = 1; |
293 | 296 | } |
294 | - | |
295 | - yDelta = yInc * dir; | |
296 | - | |
297 | 297 | LOG4CXX_DEBUG(_logger, " viewport translation:"<<yDelta); |
298 | 298 | LOG4CXX_DEBUG(_logger, " virtual axis options:"<<options); |
299 | 299 | |
300 | + // store initial delta, as it is also the increment to add to delta at each new serie (see below). | |
301 | + double yInc = yDelta; | |
302 | + | |
303 | + // at this point, we change viewport to be able to plot each virtual axis | |
304 | + // (only labels are plotted)... | |
305 | + | |
306 | + // We need to take into account tick length. | |
307 | + if (pAxis->_tick._position == Tick::TickPosition::OUTWARDS) { | |
308 | + // set room for tick, tickmarks (graduation) and extra space between tickmarks (graduation) and data time. | |
309 | + yDelta = getVerticalTickLength(pAxis, panelCharSize.second) + yDelta + (0.5 * yInc); | |
310 | + } else { | |
311 | + // for the first serie, we add an extra space (half of yInc) to add a sepration with time labels | |
312 | + yDelta = yDelta + (0.5 * yInc); | |
313 | + } | |
314 | + | |
300 | 315 | for (int i = start; i != end; i += dir) { |
301 | 316 | LOG4CXX_TRACE(_logger, " virtual axis ["<<i<<"]"); |
302 | 317 | // install label generator specific for that virtual axis |
303 | 318 | pls_->slabelfunc(generateYLabel, _seriesInfoList[i].get()); |
304 | 319 | // translate viewport : |
305 | 320 | pls_->vpor(vpBounds._x, vpBounds._x + vpBounds._width, |
306 | - vpBounds._y - yDelta * dir, vpBounds._y + vpBounds._height - yDelta * dir); | |
321 | + vpBounds._y + yDelta, vpBounds._y + vpBounds._height + yDelta); | |
307 | 322 | // sets windows for new viewport : |
308 | 323 | pls_->wind(winBounds._x, winBounds._x + winBounds._width, winBounds._y, |
309 | 324 | winBounds._y + winBounds._height); |
310 | 325 | pls_->box(options.c_str(), xtick, nxsub, "", 0, 0); |
311 | 326 | |
312 | 327 | yDelta = yDelta + yInc; |
328 | + | |
313 | 329 | } |
314 | 330 | |
315 | 331 | // restore viewport. | ... | ... |