Commit 06e9bdd5dcc2df38d318d81084653deec05a806b

Authored by Benjamin Renard
1 parent 86a2f0f0

Improve tickplot draw

src/ParamOutputImpl/Plot/TickPlot/TickMarkDecorator.cc
... ... @@ -274,64 +274,71 @@ void TickMarkDecorator::draw(PanelPlotOutput* pplot_, Axis* axis_,
274 274 yDelta = yInc;
275 275 }
276 276  
277   - LOG4CXX_DEBUG(_logger, " viewport translation:"<<yDelta);
278   - LOG4CXX_DEBUG(_logger, " virtual axis options:"<<options);
279   -
  277 + bool isFirst = true;
280 278 for (int i = start; i != end; i += dir) {
281   - LOG4CXX_TRACE(_logger, " virtual axis ["<<i<<"]");
282   - // install label generator specific for that virtual axis
283   - pls_->slabelfunc(generateYLabel, _seriesInfoList[i].get());
284   - if (top) {
285   - // draw virtual axis
286   - drawVirtualAxis(top, yDelta * dir, yInc, _seriesInfoList[i]->_name.c_str(), xtick, nxsub, options.c_str(), pls_);
287   - // increment offset
288   - yDelta = yDelta + yInc;
289   - }
290   - if (!_seriesInfoList[i]->_description.empty()) {
291   - // draw additionnal description
292   - drawVirtualAxis(top, yDelta * dir, yInc, _seriesInfoList[i]->_description.c_str(), 0, 0, "", pls_);
293   - // increment offset
294   - yDelta = yDelta + yInc;
295   - }
296   - if (!top) {
297   - // draw virtual axis
298   - drawVirtualAxis(top, yDelta * dir, yInc, _seriesInfoList[i]->_name.c_str(), xtick, nxsub, options.c_str(), pls_);
299   - // increment offset
300   - yDelta = yDelta + yInc;
  279 + // Get plot area viewport
  280 + PLFLT lXMin, lXMax, lYMin, lYMax;
  281 + pls_->gvpd(lXMin, lXMax, lYMin, lYMax);
  282 +
  283 + // Get window
  284 + PLFLT xwmin, xwmax, ywmin, ywmax;
  285 + pls_->gvpw(xwmin, xwmax, ywmin, ywmax);
  286 +
  287 + double position = top ? lYMax : lYMin;
  288 +
  289 + if (isFirst) {
  290 + //Draw time axis legend
  291 + if (top) {
  292 + pls_->vpor(lXMin, lXMax, position - yInc, position);
  293 + }
  294 + else {
  295 + pls_->vpor(lXMin, lXMax, position, position + yInc);
  296 + }
  297 + pls_->wind(xwmin, xwmax, 0, 1);
  298 + pls_->mtex("lv", 4, top ? 2 : -1, 1, _pTimeInfo->_timeTitle.c_str());
  299 + isFirst = false;
301 300 }
302   - }
303 301  
304   - // Restore initial color.
305   - restoreColor(pls_, lInitialColor, pplot_->_panel->_page->_mode);
306   -}
307 302  
308   -void TickMarkDecorator::drawVirtualAxis(bool top, double offset, double height, const char* legend, double xtick, int nxsub, const char* options, std::shared_ptr<plstream> pls_) {
309   - // Get plot area viewport
310   - PLFLT lXMin, lXMax, lYMin, lYMax;
311   - pls_->gvpd(lXMin, lXMax, lYMin, lYMax);
  303 + position -= yDelta * dir;
  304 +
  305 + if (!_seriesInfoList[i]->_description.empty()) {
  306 + // Draw description
  307 + if (top) {
  308 + pls_->vpor(lXMin, lXMax, position + yInc, position + 2*yInc);
  309 + }
  310 + else {
  311 + pls_->vpor(lXMin, lXMax, position, position + yInc);
  312 + position -= yInc;
  313 + }
  314 + pls_->wind(xwmin, xwmax, 0, 1);
  315 + pls_->mtex("lv", 4, top ? 2 : -1, 1, _seriesInfoList[i]->_description.c_str());
  316 + }
312 317  
313   - // Get window
314   - PLFLT xwmin, xwmax, ywmin, ywmax;
315   - pls_->gvpw(xwmin, xwmax, ywmin, ywmax);
  318 + pls_->vpor(lXMin, lXMax, position, position + yInc);
  319 + pls_->wind(xwmin, xwmax, 0, 1);
  320 +
  321 + // install label generator specific for that virtual axis
  322 + pls_->slabelfunc(generateYLabel, _seriesInfoList[i].get());
316 323  
317   - // translate viewport :
318   - double position = top ? lYMax : lYMin;
319   - pls_->vpor(lXMin, lXMax, position - offset, position - offset + height);
  324 + // draw virtual axis
  325 + pls_->box(options.c_str(), xtick, nxsub, "", 0, 0);
320 326  
321   - // sets windows for new viewport :
322   - pls_->wind(xwmin, xwmax, 0, 1);
  327 + // draw legend
  328 + pls_->mtex("lv", 4, top ? 2 : -1, 1, _seriesInfoList[i]->_name.c_str());
323 329  
324   - // draw virtual axis
325   - pls_->box(options, xtick, nxsub, "", 0, 0);
  330 + // restore viewport
  331 + pls_->vpor(lXMin, lXMax, lYMin, lYMax);
326 332  
327   - // draw legend
328   - pls_->mtex("lv", 3, top ? 2 : -1, 1, legend);
  333 + // restore window
  334 + pls_->wind(xwmin, xwmax, ywmin, ywmax);
329 335  
330   - // restore viewport
331   - pls_->vpor(lXMin, lXMax, lYMin, lYMax);
  336 + // increment offset
  337 + yDelta = yDelta + (_seriesInfoList[i]->_description.empty() ? 1 : 2) * yInc;
  338 + }
332 339  
333   - // restore window
334   - pls_->wind(xwmin, xwmax, ywmin, ywmax);
  340 + // Restore initial color.
  341 + restoreColor(pls_, lInitialColor, pplot_->_panel->_page->_mode);
335 342 }
336 343  
337 344 void TickMarkDecorator::installLabelGenerator(PanelPlotOutput* /*pplot_*/, TimeAxis* timeAxis_) {
... ...
src/ParamOutputImpl/Plot/TickPlot/TickMarkDecorator.hh
... ... @@ -128,11 +128,6 @@ protected:
128 128 private:
129 129  
130 130 /**
131   - * @brief Draw virtual axis
132   - */
133   - void drawVirtualAxis(bool top, double offset, double height, const char* legend, double xtick, int nxsub, const char* options, std::shared_ptr<plstream> pls_);
134   -
135   - /**
136 131 * @brief Calculates plot area for date display
137 132 */
138 133 double computeStartDateWidth(PanelPlotOutput* pplot_, TimeAxis* pAxis_);
... ...