From 6d60c154fba374e563d863618ef45c679b46c4ff Mon Sep 17 00:00:00 2001 From: Andy Bryson Date: Fri, 30 Nov 2012 08:17:15 +0000 Subject: [PATCH] 361 - Y axis is still unclear --- src/AllPlot.cpp | 53 ++++++++++++++++++++++++++++++++++++++++--------- src/AllPlot.h | 2 ++ 2 files changed, 46 insertions(+), 9 deletions(-) diff --git a/src/AllPlot.cpp b/src/AllPlot.cpp index af553cdd0..1c4482bf1 100644 --- a/src/AllPlot.cpp +++ b/src/AllPlot.cpp @@ -852,14 +852,7 @@ AllPlot::setYMax() int step = 100; while( ( qCeil(maxY / step) * labelWidth ) > axisHeight ) { - if( step == 100 || step == 150 ) - { - step += 50; - } - else - { - step += 100; - } + nextStep(step); } QwtValueList xytick[QwtScaleDiv::NTickTypes]; @@ -952,7 +945,24 @@ AllPlot::setYMax() ymin = referencePlot->altCurve->minYValue(); ymax = qMax(ymin + 100, 1.05 * referencePlot->altCurve->maxYValue()); } - setAxisScale(yRight2, ymin, ymax); + ymin = ( qRound(ymin) / 100 ) * 100; + + int axisHeight = qRound( plotLayout()->canvasRect().height() ); + QFontMetrics labelWidthMetric = QFontMetrics( QwtPlot::axisFont(yLeft) ); + int labelWidth = labelWidthMetric.width( (ymax > 1000) ? " 8888 " : " 888 " ); + + int step = 10; + while( ( qCeil( (ymax - ymin ) / step) * labelWidth ) > axisHeight ) + { + nextStep(step); + } + + QwtValueList xytick[QwtScaleDiv::NTickTypes]; + for (int i=ymin;isetBaseline(ymin); @@ -1614,3 +1624,28 @@ AllPlot::pointHover(QwtPlotCurve *curve, int index) tooltip->setText(""); } } + +void +AllPlot::nextStep( int& step ) +{ + if( step < 50 ) + { + step += 10; + } + else if( step == 50 ) + { + step = 100; + } + else if( step >= 100 && step < 1000 ) + { + step += 100; + } + else if( step >= 1000 && step < 5000) + { + step += 500; + } + else + { + step += 1000; + } +} diff --git a/src/AllPlot.h b/src/AllPlot.h index 8a4484cac..3b03d4aa2 100644 --- a/src/AllPlot.h +++ b/src/AllPlot.h @@ -172,6 +172,8 @@ class AllPlot : public QwtPlot AllPlotWindow *parent; LTMToolTip *tooltip; LTMCanvasPicker *_canvasPicker; // allow point selection/hover + + static void nextStep( int& step ); }; #endif // _GC_AllPlot_h