Commit 9f7344d97920aaa33bb1c51133c9e9b595bc9781

Authored by Benjamin Renard
1 parent 0f321c54

Simplify tickplot drawing

Showing 1 changed file with 6 additions and 22 deletions   Show diff stats
src/ParamOutputImpl/Plot/TickPlot/TickMarkDecorator.cc
... ... @@ -270,21 +270,18 @@ void TickMarkDecorator::draw(PanelPlotOutput* pplot_, Axis* axis_,
270 270 PlPlotUtil::setPlFont(legendFont);
271 271 CharSize legendCharSize = PlPlotUtil::getCharacterSizeInPlPage(pplot_->_panel->_page);
272 272  
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;
  273 + double yInc = legendCharSize.second * 1.2;
276 274  
277 275 std::string options = "";
278 276 int start;
279 277 int end;
280 278 int dir;
  279 + double yDelta = 0;
281 280  
282 281 PlPlotUtil::setPlFont(legendFont);
283 282  
284 283 if (pAxis->_position == PlotCommon::POS_TOP) {
285 284 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 :
288 285 start = _seriesInfoList.size() - 1;
289 286 end = -1;
290 287 dir = -1;
... ... @@ -294,23 +291,11 @@ void TickMarkDecorator::draw(PanelPlotOutput* pplot_, Axis* axis_,
294 291 end = _seriesInfoList.size();
295 292 dir = 1;
296 293 }
297   - LOG4CXX_DEBUG(_logger, " viewport translation:"<<yDelta);
298   - LOG4CXX_DEBUG(_logger, " virtual axis options:"<<options);
299 294  
300   - // store initial delta, as it is also the increment to add to delta at each new serie (see below).
301   - double yInc = yDelta;
  295 + yDelta = yInc * dir;
302 296  
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   - }
  297 + LOG4CXX_DEBUG(_logger, " viewport translation:"<<yDelta);
  298 + LOG4CXX_DEBUG(_logger, " virtual axis options:"<<options);
314 299  
315 300 for (int i = start; i != end; i += dir) {
316 301 LOG4CXX_TRACE(_logger, " virtual axis ["<<i<<"]");
... ... @@ -318,14 +303,13 @@ void TickMarkDecorator::draw(PanelPlotOutput* pplot_, Axis* axis_,
318 303 pls_->slabelfunc(generateYLabel, _seriesInfoList[i].get());
319 304 // translate viewport :
320 305 pls_->vpor(vpBounds._x, vpBounds._x + vpBounds._width,
321   - vpBounds._y + yDelta, vpBounds._y + vpBounds._height + yDelta);
  306 + vpBounds._y - yDelta * dir, vpBounds._y + vpBounds._height - yDelta * dir);
322 307 // sets windows for new viewport :
323 308 pls_->wind(winBounds._x, winBounds._x + winBounds._width, winBounds._y,
324 309 winBounds._y + winBounds._height);
325 310 pls_->box(options.c_str(), xtick, nxsub, "", 0, 0);
326 311  
327 312 yDelta = yDelta + yInc;
328   -
329 313 }
330 314  
331 315 // restore viewport.
... ...