[Kst] branches/work/kst/portto4/kst/src/libkstapp
Barth Netterfield
netterfield at astro.utoronto.ca
Tue Jun 16 01:18:28 CEST 2009
SVN commit 982487 by netterfield:
Improve axis number roundoff a little. There is more to go!
M +14 -10 plotaxis.cpp
--- branches/work/kst/portto4/kst/src/libkstapp/plotaxis.cpp #982486:982487
@@ -93,7 +93,7 @@
value /= 365.25;
value += 1900.0;
label = i18n("J");
- label += QString::number(value, 'g', FULL_PRECISION);
+ label += QString::number(value, 'g', FULL_PRECISION-2);
label += " [years]";
break;
case AXIS_DISPLAY_YYMMDDHHMMSS_SS:
@@ -113,19 +113,19 @@
break;
case AXIS_DISPLAY_JD:
label = i18n("JD");
- label += QString::number(value, 'g', FULL_PRECISION);
+ label += QString::number(value, 'g', FULL_PRECISION-2);
label += " [days]";
break;
case AXIS_DISPLAY_MJD:
value -= JD_MJD;
label = i18n("MJD");
- label += QString::number(value, 'g', FULL_PRECISION);
+ label += QString::number(value, 'g', FULL_PRECISION-2);
label += " [days]";
break;
case AXIS_DISPLAY_RJD:
value -= JD_RJD;
label = i18n("RJD");
- label += QString::number(value, 'g', FULL_PRECISION);
+ label += QString::number(value, 'g', FULL_PRECISION-2);
label += " [days]";
break;
}
@@ -658,7 +658,7 @@
if (majorPoint == 0) majorPoint = -350;
if (i >= min && i <= max) {
*MajorTicks << majorPoint;
- *Labels->insert(majorPoint, QString::number(majorPoint, 'g', FULL_PRECISION));
+ *Labels->insert(majorPoint, QString::number(majorPoint, 'g', FULL_PRECISION-2));
}
if (tick == 1.0) {
@@ -670,7 +670,7 @@
if (minorPoint >= powMin && minorPoint <= powMax) {
*MinorTicks << minorPoint;
if (minorLabels && first) {
- *Labels->insert(minorPoint, QString::number(minorPoint, 'g', FULL_PRECISION));
+ *Labels->insert(minorPoint, QString::number(minorPoint, 'g', FULL_PRECISION-2));
first = false;
}
}
@@ -681,7 +681,7 @@
qreal lastMinorTick = MinorTicks->last();
if (MajorTicks->isEmpty() || MajorTicks->last() < lastMinorTick) {
if (!Labels->contains(lastMinorTick)) {
- *Labels->insert(lastMinorTick, QString::number(lastMinorTick, 'g', FULL_PRECISION));
+ *Labels->insert(lastMinorTick, QString::number(lastMinorTick, 'g', FULL_PRECISION-2));
}
}
}
@@ -819,7 +819,9 @@
if (nextTick > max)
break;
ticks << nextTick;
- labels.insert(nextTick, QString::number(nextTick, 'g', FULL_PRECISION));
+ // FILL_PRECISION - 2 because round off errors mean you never actually quite get
+ // full precision...
+ labels.insert(nextTick, QString::number(nextTick, 'g', FULL_PRECISION-2));
}
qreal minorTickSpacing = 0;
@@ -876,7 +878,9 @@
}
}
- if (_axisBaseOffset || _axisInterpret || (longest > _axisSignificantDigits) || _axisBaseOffsetOverride ) {
+ // (shortest > 3) so that you don't use automatic base/offset mode when
+ // it wouldn't actually take up less space.
+ if (_axisBaseOffset || _axisInterpret || ((longest > _axisSignificantDigits)&&(shortest>3)) || _axisBaseOffsetOverride ) {
if (_axisInterpret) {
_baseLabel = interpretLabel(_axisInterpretation, _axisDisplay, base, (_axisMajorTicks).last());
} else {
@@ -889,7 +893,7 @@
if (_axisInterpret) {
offset = interpretOffset(_axisInterpretation, _axisDisplay, base, i.key());
} else {
- offset = i.key() - base;
+ offset = i.key() - base; // FIX round off error for base/offet mode here
}
QString label;
if (offset < 0) {
More information about the Kst
mailing list