[goffice] Fix #663356 and #669257.



commit abfd45508c6fc167aca9fba85c06a283c02c2e3f
Author: Jean Brefort <jean brefort normalesup org>
Date:   Sun Feb 5 17:21:55 2012 +0100

    Fix #663356 and #669257.

 ChangeLog                     |   11 +++++++++
 NEWS                          |    2 +
 goffice/graph/gog-axis-line.c |   10 +++++---
 goffice/graph/gog-axis.c      |   51 +++++++++++++++++++++++++++++++++--------
 goffice/graph/gog-chart-map.c |    6 +++++
 goffice/utils/go-line.c       |    3 ++
 goffice/utils/goffice-utils.h |    1 +
 7 files changed, 70 insertions(+), 14 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 01956f7..8b0afba 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2012-02-05  Jean Brefort  <jean brefort normalesup org>
+	* goffice/graph/gog-axis-line.c (axis_line_render): limit the axis line
+	to its actual span.
+	* goffice/graph/gog-axis.c (gog_axis_map_get_extents),
+	(gog_axis_map_get_bounds): fix bounds for logarithmic axes using only
+	a partial range. [#669257]
+	* goffice/graph/gog-chart-map.c (xy_make_path): add ODF like Bezier cubic
+	spline interpolation. [#663356]
+	* goffice/utils/go-line.c: ditto.
+	* goffice/utils/goffice-utils.h: ditto.
+
 2012-01-26  Morten Welinder  <terra gnome org>
 
 	* goffice/app/go-doc.c (go_doc_set_dirty_time)
diff --git a/NEWS b/NEWS
index 8e5dea4..7a4a637 100644
--- a/NEWS
+++ b/NEWS
@@ -13,7 +13,9 @@ Jean:
 	* Support wrapped charts labels, partially fixes #643873.
 	* Fixed GdkPixbuf usage. [#667005]
 	* Don't truncate images when exporting a chart. [#645938]
+	* Add automatic Bezier spline interpolation. [663356]
 	* Fixed graph type selector position. [#667793]
+	* Fix bounds for partial range logarithmic axes. [#669257]
 
 Morten:
 	* Embed library ui files into library.
diff --git a/goffice/graph/gog-axis-line.c b/goffice/graph/gog-axis-line.c
index f5853cb..d4b23a5 100644
--- a/goffice/graph/gog-axis-line.c
+++ b/goffice/graph/gog-axis-line.c
@@ -1131,12 +1131,14 @@ axis_line_render (GogAxisBase *axis_base,
 	is_line_visible = go_style_is_line_visible (style);
 	line_width = gog_renderer_line_size (renderer, style->line.width) / 2;
 
-	if (is_line_visible)
-	{
+	if (is_line_visible) {
+		/* draw the line only in the effective range */
+		double s, e;
+		gog_axis_get_effective_span (axis_base->axis, &s, &e);
 		path = go_path_new ();
 		go_path_set_options (path, sharp ? GO_PATH_OPTIONS_SHARP : 0);
-		go_path_move_to (path, x, y);
-		go_path_line_to (path, x + w, y + h);
+		go_path_move_to (path, x + w * s , y + h * s);
+		go_path_line_to (path, x + w * e, y + h * e);
 	}
 
 	map = gog_axis_map_new (axis_base->axis, 0., axis_length);
diff --git a/goffice/graph/gog-axis.c b/goffice/graph/gog-axis.c
index bd22bcd..a6d4802 100644
--- a/goffice/graph/gog-axis.c
+++ b/goffice/graph/gog-axis.c
@@ -1724,17 +1724,31 @@ gog_axis_map_get_baseline (GogAxisMap *map)
 void
 gog_axis_map_get_extents (GogAxisMap *map, double *start, double *stop)
 {
+	double x0, x1;
 	g_return_if_fail (map != NULL);
 
-	if (map->axis->inverted)
-		map->desc->map_bounds (map, stop, start);
+	if (gog_axis_is_inverted (map->axis))
+		map->desc->map_bounds (map, &x1, &x0);
 	else
-		map->desc->map_bounds (map, start, stop);
+		map->desc->map_bounds (map, &x0, &x1);
 	if (map->axis->type != GOG_AXIS_CIRCULAR) {
-		double buf = (*stop - *start) / (map->axis->span_end - map->axis->span_start);
-		*start -= map->axis->span_start * buf;
-		*stop = *start + buf;
+		if (gog_axis_is_discrete (map->axis)) {
+			double buf = (x1 - x0) / (map->axis->span_end - map->axis->span_start);
+			x0 -= map->axis->span_start * buf;
+			x1 = x0 + buf;
+		} else {
+			double t, buf;
+			t = gog_axis_map_to_view (map, x0);
+			buf = (gog_axis_map_to_view (map, x1) - t) / (map->axis->span_end - map->axis->span_start);
+			t -= map->axis->span_start * buf;
+			x0 = gog_axis_map_from_view (map, t);
+			x1 = gog_axis_map_from_view (map, t + buf);
+		}
 	}
+	if (start)
+		*start = x0;
+	if (stop)
+		*stop = x1;
 }
 
 /**
@@ -1752,14 +1766,31 @@ gog_axis_map_get_extents (GogAxisMap *map, double *start, double *stop)
 void
 gog_axis_map_get_bounds (GogAxisMap *map, double *minimum, double *maximum)
 {
+	double x0, x1;
 	g_return_if_fail (map != NULL);
 
-	map->desc->map_bounds (map, minimum, maximum);
+	if (gog_axis_is_inverted (map->axis))
+		map->desc->map_bounds (map, &x1, &x0);
+	else
+		map->desc->map_bounds (map, &x0, &x1);
 	if (map->axis->type != GOG_AXIS_CIRCULAR) {
-		double buf = (*minimum - *maximum) / (map->axis->span_end - map->axis->span_start);
-		*maximum -= map->axis->span_start * buf;
-		*minimum = *maximum + buf;
+		if (gog_axis_is_discrete (map->axis)) {
+			double buf = (x1 - x0) / (map->axis->span_end - map->axis->span_start);
+			x0 -= map->axis->span_start * buf;
+			x1 = x0 + buf;
+		} else {
+			double t, buf;
+			t = gog_axis_map_to_view (map, x0);
+			buf = (gog_axis_map_to_view (map, x1) - t) / (map->axis->span_end - map->axis->span_start);
+			t -= map->axis->span_start * buf;
+			x0 = gog_axis_map_from_view (map, t);
+			x1 = gog_axis_map_from_view (map, t + buf);
+		}
 	}
+	if (minimum)
+		*minimum = (map->axis->inverted)? x1: x0;
+	if (maximum)
+		*maximum = (map->axis->inverted)? x0: x1;
 }
 
 /**
diff --git a/goffice/graph/gog-chart-map.c b/goffice/graph/gog-chart-map.c
index 170a6ee..8530853 100644
--- a/goffice/graph/gog-chart-map.c
+++ b/goffice/graph/gog-chart-map.c
@@ -521,6 +521,12 @@ xy_make_path (GogChartMap *map, double const *x, double const *y,
 		case GO_LINE_INTERPOLATION_STEP_CENTER_Y:
 			path = xy_make_path_step (map, x, y, n_points, interpolation, skip_invalid);
 			break;
+		case GO_LINE_INTERPOLATION_ODF_SPLINE:
+			if (x[0] == x[n_points - 1] && y[0] == y[n_points - 1])
+				path = make_path_spline (map, x, y, n_points - 1, TRUE, TRUE, skip_invalid);
+			else
+				path = make_path_spline (map, x, y, n_points, FALSE, FALSE, skip_invalid);
+			break;
 		default:
 			g_assert_not_reached ();
 	}
diff --git a/goffice/utils/go-line.c b/goffice/utils/go-line.c
index 39d6088..4261721 100644
--- a/goffice/utils/go-line.c
+++ b/goffice/utils/go-line.c
@@ -56,6 +56,7 @@
  * @GO_LINE_INTERPOLATION_STEP_CENTER_X: Steps centered around each point.
  * @GO_LINE_INTERPOLATION_STEP_CENTER_Y: Steps using mean y value.
  * @GO_LINE_INTERPOLATION_MAX: First invalid value.
+ * @GO_LINE_INTERPOLATION_ODF_SPLINE: ODF compatible Bezier cubic spline interpolation, cyclic if first and last points are identical.
  **/
 
 typedef struct {
@@ -121,6 +122,8 @@ static struct {
 		"spline",		TRUE,  FALSE },
 	{ GO_LINE_INTERPOLATION_CLOSED_SPLINE,		N_("Closed Bezier cubic spline"),
 		"closed-spline",	TRUE,  TRUE },
+	{ GO_LINE_INTERPOLATION_ODF_SPLINE,		N_("ODF compatible Bezier cubic spline"),
+		"odf-spline",		TRUE,  FALSE },
 	{ GO_LINE_INTERPOLATION_CUBIC_SPLINE,		N_("Natural cubic spline"),
 		"cspline",		FALSE, FALSE },
 	{ GO_LINE_INTERPOLATION_PARABOLIC_CUBIC_SPLINE,	N_("Cubic spline with parabolic extrapolation"),
diff --git a/goffice/utils/goffice-utils.h b/goffice/utils/goffice-utils.h
index 043f342..d9940df 100644
--- a/goffice/utils/goffice-utils.h
+++ b/goffice/utils/goffice-utils.h
@@ -77,6 +77,7 @@ typedef enum {
 	GO_LINE_INTERPOLATION_STEP_END,
 	GO_LINE_INTERPOLATION_STEP_CENTER_X,
 	GO_LINE_INTERPOLATION_STEP_CENTER_Y,
+	GO_LINE_INTERPOLATION_ODF_SPLINE,
 	GO_LINE_INTERPOLATION_MAX
 } GOLineInterpolation;
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]