[Kst] extragear/graphics/kst/src/libkstapp
Barth Netterfield
netterfield at astro.utoronto.ca
Wed Jan 31 12:29:52 CET 2007
SVN commit 628776 by netterfield:
Some fixes to log mode:
-don't use log base 2 - the minor ticks can't make sense, and
where the selection was being made was wrong.
-don't ever switch to linear tick mode.... if the user zooms in so
much that there are no ticks at all... so be it.
This leads to much more stable behavior.
M +19 -26 kst2dplot.cpp
--- trunk/extragear/graphics/kst/src/libkstapp/kst2dplot.cpp #628775:628776
@@ -779,15 +779,17 @@
bool Kst2DPlot::setLXScale(double xmin_in, double xmax_in) {
if (checkLRange(xmin_in, xmax_in, _xLog, _xLogBase)) {
if (_xLog) {
- if (_xLogBase == 10.0 && xmax_in - xmin_in < 1.5) {
+ // don't do auto scale change... this is the wrong place to do it
+ // and it acts spooky!
+/* if (_xLogBase == 10.0 && xmax_in - xmin_in < 1.1) {
_xLogBase = 2.0;
xmin_in *= 1.0/log10(2.0);
xmax_in *= 1.0/log10(2.0);
- } else if (_xLogBase == 2.0 && xmax_in - xmin_in > 4.0) {
+ } else if (_xLogBase == 2.0 && xmax_in - xmin_in > 1.5) {
_xLogBase = 10.0;
xmin_in *= log10(2.0);
xmax_in *= log10(2.0);
- }
+ }*/
XMax = pow(_xLogBase, xmax_in);
XMin = pow(_xLogBase, xmin_in);
} else {
@@ -804,11 +806,13 @@
bool Kst2DPlot::setLYScale(double ymin_in, double ymax_in) {
if (checkLRange(ymin_in, ymax_in, _yLog, _yLogBase)) {
if (_yLog) {
- if (_yLogBase == 10.0 && ymax_in - ymin_in < 1.1) {
+ // don't do auto scale change... this is the wrong place to do it
+ // and it acts spooky!
+/* if (_yLogBase == 10.0 && ymax_in - ymin_in < 2.0) {
_yLogBase = 2.0;
- } else if (_yLogBase == 2.0 && ymax_in - ymin_in > 3.5) {
+ } else if (_yLogBase == 2.0 && ymax_in - ymin_in > 3.0) {
_yLogBase = 10.0;
- }
+ }*/
YMax = pow(_yLogBase, ymax_in);
YMin = pow(_yLogBase, ymin_in);
} else {
@@ -3061,18 +3065,15 @@
static double b10_ticks[] = {1.0, 2.0, 5.0, 10.0};
static int b10_autominor[]= { 5, 4, 5, 5};
static int n_b10_ticks = sizeof(b10_ticks) / sizeof(double);
+
static double b24_ticks[] = {1.0, 2.0, 4.0, 6.0, 12.0, 24.0};
static int b24_autominor[]= { 5, 4, 4, 6, 6, 6};
static int n_b24_ticks = sizeof(b24_ticks) / sizeof(double);
+
static double b60_ticks[] = {1.0, 2.0, 5.0, 10.0, 15.0, 20.0, 30.0, 60.0};
static int b60_autominor[] = { 5, 4, 5, 5, 3, 4, 6, 6};
-
static int n_b60_ticks = sizeof(b60_ticks) / sizeof(double);
- double *ticks = b10_ticks;
- int nt = n_b10_ticks;
- int *autominor = b10_autominor;
-
// check for hysteresis of y-axis tick spacing...
double St = (max - min) / (double)majorDensity;
if (!isX && is_log == _isLogLast && _stLast != 0.0 &&
@@ -3082,8 +3083,7 @@
tick = _tickYLast;
auto_tick = _autoTickYLast;
} else if (is_log) {
- if (max - min <= (double)majorDensity && ((_xLogBase == 10.0 && max - min > 1.5) ||
- (_xLogBase == 2.0 && max - min > 1.0))) {
+ if (max - min <= (double)majorDensity*1.5) {
// show in logarithmic mode with major ticks nicely labelled and the
// specified number of minor ticks between each major label
if (logBase == 2.0) {
@@ -3094,32 +3094,25 @@
auto_tick = 5;
}
tick = 1.0;
- } else if (max - min >= (double)majorDensity) {
+ } else {
// show in logarithmic mode with major ticks nicely labelled and no minor ticks
auto_tick = 0;
tick = floor((max - min) / (double)majorDensity);
if (tick == 1.0) {
if (logBase == 2.0) {
- auto_tick = 10;
+ auto_tick = 0; // used to be 10... why? what is 1/11 of a log interval?
} else if (logBase == 10.0) {
auto_tick = 9;
} else {
auto_tick = 5;
}
}
- } else {
- // show in "linear" mode with major ticks linearly spaced and no minor ticks
- auto_tick = 0;
- Exp = pow(logBase, floor(log10(St)/log10(logBase)));
-
- tick = ticks[0] * Exp;
- for (int i = 1; i < nt; i++) {
- if (fabs((ticks[i] * Exp) - St) < fabs(tick - St)) {
- tick = ticks[i] * Exp;
- }
- }
}
} else {
+ double *ticks = b10_ticks;
+ int nt = n_b10_ticks;
+ int *autominor = b10_autominor;
+
// determine tick interval
Exp = 0.0;
if (base == 60) {
More information about the Kst
mailing list