Commit 86a2f0f011b25e68ed131a43849bcecc3de4efde
1 parent
02c97233
Exists in
master
and in
88 other branches
Tickbar at top of a time serie (need to be improved)
Showing
2 changed files
with
22 additions
and
12 deletions
Show diff stats
src/ParamOutputImpl/Plot/TickPlot/TickMarkDecorator.cc
... | ... | @@ -256,23 +256,24 @@ void TickMarkDecorator::draw(PanelPlotOutput* pplot_, Axis* axis_, |
256 | 256 | int end; |
257 | 257 | int dir; |
258 | 258 | double yDelta = 0; |
259 | + bool top = (pAxis->_position == PlotCommon::POS_TOP); | |
259 | 260 | |
260 | 261 | PlPlotUtil::setPlFont(legendFont); |
261 | 262 | |
262 | - if (pAxis->_position == PlotCommon::POS_TOP) { | |
263 | + if (top) { | |
263 | 264 | options = "mxo"; // options means : m=display above axe, x=do not plot ticks, o=user label function provided. |
264 | 265 | start = _seriesInfoList.size() - 1; |
265 | 266 | end = -1; |
266 | 267 | dir = -1; |
268 | + yDelta = 0; | |
267 | 269 | } else { |
268 | 270 | options = "nxo";// options means : n=display below axe, x=do not plot ticks, o=user label function provided. |
269 | 271 | start = 0; |
270 | 272 | end = _seriesInfoList.size(); |
271 | 273 | dir = 1; |
274 | + yDelta = yInc; | |
272 | 275 | } |
273 | 276 | |
274 | - yDelta = yInc * dir; | |
275 | - | |
276 | 277 | LOG4CXX_DEBUG(_logger, " viewport translation:"<<yDelta); |
277 | 278 | LOG4CXX_DEBUG(_logger, " virtual axis options:"<<options); |
278 | 279 | |
... | ... | @@ -280,23 +281,31 @@ void TickMarkDecorator::draw(PanelPlotOutput* pplot_, Axis* axis_, |
280 | 281 | LOG4CXX_TRACE(_logger, " virtual axis ["<<i<<"]"); |
281 | 282 | // install label generator specific for that virtual axis |
282 | 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 | + } | |
283 | 290 | if (!_seriesInfoList[i]->_description.empty()) { |
284 | 291 | // draw additionnal description |
285 | - drawVirtualAxis(yDelta * dir, yInc, _seriesInfoList[i]->_description.c_str(), 0, 0, "", pls_); | |
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_); | |
286 | 299 | // increment offset |
287 | 300 | yDelta = yDelta + yInc; |
288 | 301 | } |
289 | - // draw virtual axis | |
290 | - drawVirtualAxis(yDelta * dir, yInc, _seriesInfoList[i]->_name.c_str(), xtick, nxsub, options.c_str(), pls_); | |
291 | - // increment offset | |
292 | - yDelta = yDelta + yInc; | |
293 | 302 | } |
294 | 303 | |
295 | 304 | // Restore initial color. |
296 | 305 | restoreColor(pls_, lInitialColor, pplot_->_panel->_page->_mode); |
297 | 306 | } |
298 | 307 | |
299 | -void TickMarkDecorator::drawVirtualAxis(double offset, double height, const char* legend, double xtick, int nxsub, const char* options, std::shared_ptr<plstream> pls_) { | |
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_) { | |
300 | 309 | // Get plot area viewport |
301 | 310 | PLFLT lXMin, lXMax, lYMin, lYMax; |
302 | 311 | pls_->gvpd(lXMin, lXMax, lYMin, lYMax); |
... | ... | @@ -306,7 +315,8 @@ void TickMarkDecorator::drawVirtualAxis(double offset, double height, const char |
306 | 315 | pls_->gvpw(xwmin, xwmax, ywmin, ywmax); |
307 | 316 | |
308 | 317 | // translate viewport : |
309 | - pls_->vpor(lXMin, lXMax, lYMin - offset, lYMin - offset + height); | |
318 | + double position = top ? lYMax : lYMin; | |
319 | + pls_->vpor(lXMin, lXMax, position - offset, position - offset + height); | |
310 | 320 | |
311 | 321 | // sets windows for new viewport : |
312 | 322 | pls_->wind(xwmin, xwmax, 0, 1); |
... | ... | @@ -315,7 +325,7 @@ void TickMarkDecorator::drawVirtualAxis(double offset, double height, const char |
315 | 325 | pls_->box(options, xtick, nxsub, "", 0, 0); |
316 | 326 | |
317 | 327 | // draw legend |
318 | - pls_->mtex("lv", 3, -1, 1, legend); | |
328 | + pls_->mtex("lv", 3, top ? 2 : -1, 1, legend); | |
319 | 329 | |
320 | 330 | // restore viewport |
321 | 331 | pls_->vpor(lXMin, lXMax, lYMin, lYMax); | ... | ... |
src/ParamOutputImpl/Plot/TickPlot/TickMarkDecorator.hh
... | ... | @@ -130,7 +130,7 @@ private: |
130 | 130 | /** |
131 | 131 | * @brief Draw virtual axis |
132 | 132 | */ |
133 | - void drawVirtualAxis(double offset, double height, const char* legend, double xtick, int nxsub, const char* options, std::shared_ptr<plstream> pls_); | |
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 | 134 | |
135 | 135 | /** |
136 | 136 | * @brief Calculates plot area for date display | ... | ... |