summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 0f61bce)
raw | patch | inline | side by side (parent: 0f61bce)
author | dvlierop2 <dvlierop2@users.sourceforge.net> | |
Fri, 1 Feb 2008 21:59:48 +0000 (21:59 +0000) | ||
committer | dvlierop2 <dvlierop2@users.sourceforge.net> | |
Fri, 1 Feb 2008 21:59:48 +0000 (21:59 +0000) |
src/widgets/ruler.cpp | patch | blob | history |
diff --git a/src/widgets/ruler.cpp b/src/widgets/ruler.cpp
index abc8cddfec3934dad16642de7556c3bb38c85c58..597034faf92e8f480c395e6d0bb25243cc6092d8 100644 (file)
--- a/src/widgets/ruler.cpp
+++ b/src/widgets/ruler.cpp
if ((upper - lower) == 0)
return;
increment = (double) (width + 2*UNUSED_PIXELS) / (upper - lower);
-
- /* determine the scale
+
+ /* determine the scale
* We calculate the text size as for the vruler instead of using
* text_width = gdk_string_width(font, unit_str), so that the result
* for the scale looks consistent with an accompanying vruler
subd_incr = ruler->metric->ruler_scale[scale] /
ruler->metric->subdivide[i];
if (subd_incr * fabs(increment) <= MINIMUM_INCR)
- continue;
+ continue;
/* Calculate the length of the tickmarks. Make sure that
* this length increases for each set of ticks
while (cur <= end)
{
- pos = int(Inkscape::round ((cur - lower) * increment) - UNUSED_PIXELS);
-
+ // due to the typical values for cur, lower and increment, pos will often end up to
+ // be e.g. 641.50000000000; rounding behaviour is not defined in such a case (see round.h)
+ // and jitter will be apparent (upon redrawing some of the lines on the ruler might jump a
+ // by a pixel, and jump back on the next redraw). This is suppressed by adding 1e-12
+ pos = int(Inkscape::round((cur - lower) * increment + 1e-12)) - UNUSED_PIXELS;
+
gdk_draw_line (ruler->backing_store, gc,
pos, height + ythickness,
pos, height - length + ythickness);
* errors in subd_incr.
*/
++tick_index;
- cur = start + (((double)tick_index) * (double)ruler->metric->ruler_scale[scale])/ ruler->metric->subdivide[i];
+ cur = start + tick_index * subd_incr;
}
}
}
cur = start;
while (cur < end) {
- pos = int(Inkscape::round ((cur - lower) * increment) - UNUSED_PIXELS);
+ // due to the typical values for cur, lower and increment, pos will often end up to
+ // be e.g. 641.50000000000; rounding behaviour is not defined in such a case (see round.h)
+ // and jitter will be apparent (upon redrawing some of the lines on the ruler might jump a
+ // by a pixel, and jump back on the next redraw). This is suppressed by adding 1e-12
+ pos = int(Inkscape::round((cur - lower) * increment + 1e-12)) - UNUSED_PIXELS;
gdk_draw_line (ruler->backing_store, gc,
height + xthickness - length, pos,
* errors in subd_incr.
*/
++tick_index;
- cur = start + (((double)tick_index) * (double)ruler->metric->ruler_scale[scale])/ ruler->metric->subdivide[i];
+ cur = start + tick_index * subd_incr;
}
}
}