[goffice] Fix minor ticks numbers and other fixes. [#657670][#657694][#657695]
- From: Jean BrÃfort <jbrefort src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [goffice] Fix minor ticks numbers and other fixes. [#657670][#657694][#657695]
- Date: Tue, 30 Aug 2011 16:00:24 +0000 (UTC)
commit 68b01b682b1bb4c6a4cb5f2597db03f1510d7a97
Author: Jean Brefort <jean brefort normalesup org>
Date: Tue Aug 30 18:04:05 2011 +0200
Fix minor ticks numbers and other fixes. [#657670][#657694][#657695]
ChangeLog | 12 ++++++++
NEWS | 5 +++
goffice/canvas/goc-graph.c | 6 +++-
goffice/graph/gog-axis.c | 5 +++-
plugins/plot_surface/gog-contour.c | 2 +-
plugins/plot_surface/gog-xyz-surface.c | 46 ++++++++++++++++++--------------
6 files changed, 53 insertions(+), 23 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 39e3918..477209a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2011-08-30 Jean Brefort <jean brefort normalesup org>
+
+ * goffice/canvas/goc-graph.c (goc_graph_do_tooltip),
+ (goc_graph_motion): appropriately scale the position. [#657694]
+ * goffice/graph/gog-axis.c (map_linear_calc_ticks): always display the
+ correct minor axis ticks. [#657670]
+ * plugins/plot_surface/gog-contour.c
+ (gog_contour_plot_foreach_elem): don't crash when pseudo3d axis has too
+ largemanula ticks spacing. [#657695]
+ * plugins/plot_surface/gog-xyz-surface.c
+ (gog_xyz_surface_plot_build_matrix): ditto.
+
2011-08-30 Andreas J. Guelzow <aguelzow pyrshep ca>
* goffice/utils/go-format.c (go_format_get_logical_rect): change to
diff --git a/NEWS b/NEWS
index ae9f1c4..b296f4d 100644
--- a/NEWS
+++ b/NEWS
@@ -18,6 +18,11 @@ Jean:
* Axes can use only a part of available space. [#654392]
* Add support for smoothed curve renaming. [#656148].
* Fix widgets position inside an RTL canvas.
+ * Fix minor ticks number. [#657670]
+ * Displays correct coordinates when moving the mouse on a zoomed1
+ chart. [#657696]
+ * Don't crash when pseudo3d axis has too large manual ticks
+ spacing. [#657695]
Morten:
* Recognize scientific formats with longer exponents.
diff --git a/goffice/canvas/goc-graph.c b/goffice/canvas/goc-graph.c
index e66ee3a..4ab9ef6 100644
--- a/goffice/canvas/goc-graph.c
+++ b/goffice/canvas/goc-graph.c
@@ -270,6 +270,10 @@ goc_graph_do_tooltip (GocGraph *graph)
goc_group_adjust_coords (item->parent, &xpos, &ypos);
x -= xpos;
y -= ypos;
+ /* multiply by the zoom level, because the graph has been adjusted,
+ * fixes #657694 */
+ x *= item->canvas->pixels_per_unit;
+ y *= item->canvas->pixels_per_unit;
/* get the GogView at the cursor position */
g_object_get (G_OBJECT (graph->renderer), "view", &base_view, NULL);
@@ -399,7 +403,7 @@ goc_graph_motion (GocItem *item, double x, double y)
graph);
}
- /* When the timer first, use the last (x,y) we have. */
+ /* When the timer fires, use the last (x,y) we have. */
graph->coords.x = x;
graph->coords.y = y;
diff --git a/goffice/graph/gog-axis.c b/goffice/graph/gog-axis.c
index 03bfd7b..1506d0b 100644
--- a/goffice/graph/gog-axis.c
+++ b/goffice/graph/gog-axis.c
@@ -755,7 +755,10 @@ map_linear_calc_ticks (GogAxis *axis)
min_step = gog_axis_get_entry (axis, GOG_AXIS_ELEM_MINOR_TICK, NULL);
if (min_step <= 0.) min_step = maj_step;
while (1) {
- double ratio = go_fake_floor (maj_step / min_step);
+ /* add 0.9 there because the ratio might not be an integer
+ * or there might be rounding errors, more than 0.9 would
+ * put a minor tick quite near the next major tick, see #657670) */
+ double ratio = go_fake_floor (maj_step / min_step + 0.9);
double Nd = (maj_N + 2) * ratio;
if (Nd >= 10 * GOG_AXIS_MAX_TICK_NBR)
min_step *= 10;
diff --git a/plugins/plot_surface/gog-contour.c b/plugins/plot_surface/gog-contour.c
index 2f5861c..8a1a3bd 100644
--- a/plugins/plot_surface/gog-contour.c
+++ b/plugins/plot_surface/gog-contour.c
@@ -157,7 +157,7 @@ gog_contour_plot_foreach_elem (GogPlot *plot, gboolean only_visible,
for (; i < nticks; i++)
if (zticks[i].type == GOG_AXIS_TICK_MAJOR)
limits[j++] = zticks[i].position;
- if (maximum > limits[j - 1])
+ if (j == 0 || maximum > limits[j - 1])
limits[j] = maximum;
else
j--;
diff --git a/plugins/plot_surface/gog-xyz-surface.c b/plugins/plot_surface/gog-xyz-surface.c
index f904735..ca3dd06 100644
--- a/plugins/plot_surface/gog-xyz-surface.c
+++ b/plugins/plot_surface/gog-xyz-surface.c
@@ -169,28 +169,34 @@ gog_xyz_surface_plot_build_matrix (GogXYZPlot const *plot, gboolean *cardinality
nticks = gog_axis_get_ticks (axis, &zticks);
map = gog_axis_map_new (axis, 0, 1);
x = g_new (double, nticks);
- for (i = j = 0; i < nticks; i++)
- if (zticks[i].type == GOG_AXIS_TICK_MAJOR) {
- x[j++] = gog_axis_map_to_view (map, zticks[i].position);
- }
- max = --j;
- if (x[1] > x[0]) {
- if (x[0] > EPSILON) {
- offset = 1.;
- max++;
+ if (nticks > 1) {
+ for (i = j = 0; i < nticks; i++)
+ if (zticks[i].type == GOG_AXIS_TICK_MAJOR) {
+ x[j++] = gog_axis_map_to_view (map, zticks[i].position);
+ }
+ max = --j;
+ if (x[1] > x[0]) {
+ if (x[0] > EPSILON) {
+ offset = 1.;
+ max++;
+ }
+ if (x[j] < 1. - EPSILON)
+ max++;
+ slope = 1 / (x[1] - x[0]);
+ } else {
+ offset = j;
+ if (x[0] < 1. - EPSILON)
+ max++;
+ if (x[j] > EPSILON) {
+ max++;
+ offset += 1.;
+ }
+ slope = 1 / (x[0] - x[1]);
}
- if (x[j] < 1. - EPSILON)
- max++;
- slope = 1 / (x[1] - x[0]);
} else {
- offset = j;
- if (x[0] < 1. - EPSILON)
- max++;
- if (x[j] > EPSILON) {
- max++;
- offset += 1.;
- }
- slope = 1 / (x[0] - x[1]);
+ slope = 0.;
+ max = 1;
+ x[0] = 0.; /* is this needed? */
}
for (k = 0; k < n; ++k) {
val = gog_axis_map_to_view (map, data[k]);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]