[Kst] branches/work/kst/portto4/kst/src/libkstapp
Adam Treat
treat at kde.org
Thu Oct 11 20:47:37 CEST 2007
SVN commit 724215 by treat:
* Properly initialize the Auto zoom mode.
M +16 -8 plotrenderitem.cpp
--- branches/work/kst/portto4/kst/src/libkstapp/plotrenderitem.cpp #724214:724215
@@ -796,13 +796,14 @@
void PlotRenderItem::computeAuto(Qt::Orientation orientation, qreal *min, qreal *max) const {
+ //The previous values are of no consequence as this algorithm does not depend
+ //on the previous values. So start over so that first active relation initializes.
+ qreal minimum;
+ qreal maximum;
+ bool unInitialized = true;
+
bool axisLog = orientation == Qt::Horizontal ? isXAxisLog() : isYAxisLog();
- //The previous values are of no consequence as this algorithm does not depend
- //on the previous values. So start over...
- qreal minimum = axisLog ? 0.0 : -0.1;
- qreal maximum = 0.1;
-
foreach (RelationPtr relation, relationList()) {
if (relation->ignoreAutoScale())
continue;
@@ -814,13 +815,20 @@
//If the axis is in log mode, the lower extent will be the
//minimum value larger than zero.
if (axisLog)
- minimum = minimum <= 0.0 ? minPos_ : qMin(minPos_, minimum);
+ minimum = unInitialized ? minPos_ : qMin(minPos_, minimum);
else
- minimum = qMin(min_, minimum);
+ minimum = unInitialized ? min_ : qMin(min_, minimum);
- maximum = qMax(max_, maximum);
+ maximum = unInitialized ? max_ : qMax(max_, maximum);
+
+ unInitialized = false;
}
+ if (unInitialized || maximum <= minimum) {
+ minimum = axisLog ? 0.0 : -0.1;
+ minimum = 0.1;
+ }
+
*min = minimum;
*max = maximum;
}
More information about the Kst
mailing list