[goffice] Allow for grids above xy and contour plots, partial fix for #632310.



commit 1a25c7ee5b5ef18aa2ed84feaafc6efa311433d5
Author: Jean Brefort <jean brefort normalesup org>
Date:   Sat Oct 23 10:06:46 2010 +0200

    Allow for grids above xy  and contour plots, partial fix for #632310.

 ChangeLog                            |   19 +++++++++++
 goffice/graph/goffice-graph.h        |    6 +++
 goffice/graph/gog-chart.c            |    9 +++--
 goffice/graph/gog-plot-impl.h        |    5 ++-
 goffice/graph/gog-plot.c             |    2 +-
 plugins/plot_barcol/gog-line.c       |    2 +-
 plugins/plot_distrib/gog-histogram.c |    2 +-
 plugins/plot_radar/gog-radar.c       |    2 +-
 plugins/plot_surface/gog-contour.c   |    2 +-
 plugins/plot_surface/gog-surface.c   |    2 +-
 plugins/plot_xy/Makefile.am          |    1 +
 plugins/plot_xy/gog-xy.c             |   59 +++++++++++++++++++++++++++++++++-
 po/ChangeLog                         |    6 +++
 po/POTFILES.in                       |    1 +
 14 files changed, 106 insertions(+), 12 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index a6ad505..2920abe 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,22 @@
+2010-10-23  Jean Brefort  <jean brefort normalesup org>
+
+	* goffice/graph/goffice-graph.h: allow rendering of grids above plots.
+	[#632310]
+	* goffice/graph/gog-chart.c (plot_render), (gog_chart_view_render): ditto.
+	* goffice/graph/gog-plot-impl.h: ditto.
+	* goffice/graph/gog-plot.c (gog_plot_init): ditto.
+	* plugins/plot_barcol/gog-line.c (gog_area_plot_init): ditto.
+	* plugins/plot_distrib/gog-histogram.c (gog_histogram_plot_init): ditto.
+	* plugins/plot_radar/gog-radar.c (gog_radar_area_plot_init): ditto.
+	* plugins/plot_surface/gog-contour.c (gog_contour_plot_init): always show
+	the grids above contour plots.
+	* plugins/plot_surface/gog-surface.c (gog_surface_plot_init): updated
+	according to above changes.
+	* plugins/plot_xy/Makefile.am: add a property box for GogXYPlot.
+	* plugins/plot_xy/gog-xy.c (gog_xy_set_property),
+	(gog_xy_get_property), (display_before_grid_cb),
+	(gog_xy_plot_populate_editor), (gog_xy_plot_class_init): ditto.
+
 2010-10-18  Morten Welinder  <terra gnome org>
 
 	* goffice/utils/go-image.c (go_image_create_cairo_pattern):
diff --git a/goffice/graph/goffice-graph.h b/goffice/graph/goffice-graph.h
index 582a988..cb04021 100644
--- a/goffice/graph/goffice-graph.h
+++ b/goffice/graph/goffice-graph.h
@@ -193,6 +193,12 @@ typedef enum {
 	GOG_POSITION_PADDING	     = 1 << 16
 } GogObjectPosition;
 
+typedef enum {
+	GOG_PLOT_RENDERING_LAST,
+	GOG_PLOT_RENDERING_BEFORE_AXIS,
+	GOG_PLOT_RENDERING_BEFORE_GRID
+} GogPlotRenderingOrder;
+
 #define GOG_POSITION_IS_SPECIAL(pos) (((pos) & GOG_POSITION_SPECIAL)&&(!((pos) & GOG_POSITION_MANUAL)))
 #define GOG_POSITION_IS_PADDING(pos) (((pos) & GOG_POSITION_PADDING)&&(!((pos) & GOG_POSITION_MANUAL)))
 
diff --git a/goffice/graph/gog-chart.c b/goffice/graph/gog-chart.c
index 2cd70ed..e717db9 100644
--- a/goffice/graph/gog-chart.c
+++ b/goffice/graph/gog-chart.c
@@ -1331,7 +1331,7 @@ grid_line_render (GSList *start_ptr, GogViewAllocation const *bbox)
 }
 
 static void
-plot_render (GogView *view, GogViewAllocation const *bbox)
+plot_render (GogView *view, GogViewAllocation const *bbox, GogPlotRenderingOrder order)
 {
 	GSList *ptr;
 	GogView *child_view;
@@ -1340,7 +1340,7 @@ plot_render (GogView *view, GogViewAllocation const *bbox)
 	for (ptr = view->children ; ptr != NULL ; ptr = ptr->next) {
 		child_view = ptr->data;
 		if (GOG_IS_PLOT (child_view->model) &&
-		    GOG_PLOT (child_view->model)->render_before_axes)
+		    GOG_PLOT (child_view->model)->rendering_order == order)
 			gog_view_render	(ptr->data, bbox);
 	}
 }
@@ -1380,12 +1380,13 @@ gog_chart_view_render (GogView *view, GogViewAllocation const *bbox)
 		for (ptr = view->children ; ptr != NULL ; ptr = ptr->next) {
 			child_view = ptr->data;
 			if (!grid_line_rendered && GOG_IS_AXIS (child_view->model)) {
+				plot_render (view, bbox, GOG_PLOT_RENDERING_BEFORE_GRID);
 				grid_line_render (ptr, bbox);
-				plot_render (view, bbox);
+				plot_render (view, bbox, GOG_PLOT_RENDERING_BEFORE_AXIS);
 				grid_line_rendered = TRUE;
 			}
 			if (GOG_IS_PLOT (child_view->model)) {
-			    if (!GOG_PLOT (child_view->model)->render_before_axes)
+			    if (!GOG_PLOT (child_view->model)->rendering_order)
 				gog_view_render	(ptr->data, bbox);
 			} else if (!GOG_IS_LABEL (child_view->model))
 				gog_view_render	(ptr->data, bbox);
diff --git a/goffice/graph/gog-plot-impl.h b/goffice/graph/gog-plot-impl.h
index 4f17222..540df00 100644
--- a/goffice/graph/gog-plot-impl.h
+++ b/goffice/graph/gog-plot-impl.h
@@ -40,7 +40,10 @@ struct _GogPlot {
 	gboolean	 cardinality_valid;
 	unsigned	 index_num;
 	gboolean	 vary_style_by_element;
-	gboolean	 render_before_axes;
+	union {
+		GogPlotRenderingOrder rendering_order;
+		gboolean render_before_axes; /* Deprecated */
+	};
 	gchar		*plot_group;
 	char		*guru_hints;
 
diff --git a/goffice/graph/gog-plot.c b/goffice/graph/gog-plot.c
index 1613c5e..546b022 100644
--- a/goffice/graph/gog-plot.c
+++ b/goffice/graph/gog-plot.c
@@ -415,7 +415,7 @@ gog_plot_init (GogPlot *plot, GogPlotClass const *derived_plot_klass)
 	plot->desc = derived_plot_klass->desc;
 	/* start as true so that we can queue an update when it changes */
 	plot->cardinality_valid = TRUE;
-	plot->render_before_axes = FALSE;
+	plot->rendering_order = GOG_PLOT_RENDERING_LAST;
 	plot->plot_group = NULL;
 	plot->guru_hints = NULL;
 	plot->interpolation = GO_LINE_INTERPOLATION_LINEAR;
diff --git a/plugins/plot_barcol/gog-line.c b/plugins/plot_barcol/gog-line.c
index f817bb9..6542717 100644
--- a/plugins/plot_barcol/gog-line.c
+++ b/plugins/plot_barcol/gog-line.c
@@ -377,7 +377,7 @@ gog_area_plot_class_init (GogObjectClass *gog_klass)
 static void
 gog_area_plot_init (GogPlot *plot)
 {
-	plot->render_before_axes = TRUE;
+	plot->rendering_order = GOG_PLOT_RENDERING_BEFORE_AXIS;
 	GOG_PLOT1_5D (plot)->support_drop_lines = TRUE;
 }
 
diff --git a/plugins/plot_distrib/gog-histogram.c b/plugins/plot_distrib/gog-histogram.c
index 3ea7378..8330399 100644
--- a/plugins/plot_distrib/gog-histogram.c
+++ b/plugins/plot_distrib/gog-histogram.c
@@ -379,7 +379,7 @@ gog_histogram_plot_init (GogHistogramPlot *hist)
 {
 	GogPlot *plot = GOG_PLOT (hist);
 
-	plot->render_before_axes = TRUE;
+	plot->rendering_order = GOG_PLOT_RENDERING_BEFORE_AXIS;
 	hist->vertical = TRUE;
 }
 
diff --git a/plugins/plot_radar/gog-radar.c b/plugins/plot_radar/gog-radar.c
index e3d7315..ad15804 100644
--- a/plugins/plot_radar/gog-radar.c
+++ b/plugins/plot_radar/gog-radar.c
@@ -371,7 +371,7 @@ static void
 gog_radar_area_plot_init (GogPlot *plot)
 {
 	GOG_RT_PLOT(plot)->default_style_has_fill = TRUE;
-	plot->render_before_axes = TRUE;
+	plot->rendering_order = GOG_PLOT_RENDERING_BEFORE_AXIS;
 }
 
 GSF_DYNAMIC_CLASS (GogRadarAreaPlot, gog_radar_area_plot,
diff --git a/plugins/plot_surface/gog-contour.c b/plugins/plot_surface/gog-contour.c
index 7f9ba57..ed6ce2f 100644
--- a/plugins/plot_surface/gog-contour.c
+++ b/plugins/plot_surface/gog-contour.c
@@ -239,7 +239,7 @@ gog_contour_plot_init (GogContourPlot *contour)
 {
 	GogPlot *plot = GOG_PLOT (contour);
 
-	plot->render_before_axes = TRUE;
+	plot->rendering_order = GOG_PLOT_RENDERING_BEFORE_GRID;
 	plot->vary_style_by_element = TRUE;
 }
 
diff --git a/plugins/plot_surface/gog-surface.c b/plugins/plot_surface/gog-surface.c
index d3e55e2..548778c 100644
--- a/plugins/plot_surface/gog-surface.c
+++ b/plugins/plot_surface/gog-surface.c
@@ -91,7 +91,7 @@ gog_surface_plot_init (GogSurfacePlot *surface)
 {
 	GogPlot *plot = GOG_PLOT (surface);
 
-	plot->render_before_axes = FALSE;
+	plot->rendering_order = GOG_PLOT_RENDERING_LAST;
 }
 
 GSF_DYNAMIC_CLASS (GogSurfacePlot, gog_surface_plot,
diff --git a/plugins/plot_xy/Makefile.am b/plugins/plot_xy/Makefile.am
index 1ca8960..2060745 100644
--- a/plugins/plot_xy/Makefile.am
+++ b/plugins/plot_xy/Makefile.am
@@ -19,6 +19,7 @@ if WITH_GTK
 xy_la_SOURCES  += gog-bubble-prefs.c
 dist_ui_DATA = \
 	gog-bubble-prefs.ui	\
+	gog-xy-prefs.ui	\
 	gog-xy-color-prefs.ui	\
 	gog-xy-series-prefs.ui
 endif
diff --git a/plugins/plot_xy/gog-xy.c b/plugins/plot_xy/gog-xy.c
index a8db7dd..fb3c432 100644
--- a/plugins/plot_xy/gog-xy.c
+++ b/plugins/plot_xy/gog-xy.c
@@ -256,7 +256,8 @@ enum {
 	GOG_XY_PROP_DEFAULT_STYLE_HAS_MARKERS,
 	GOG_XY_PROP_DEFAULT_STYLE_HAS_LINES,
 	GOG_XY_PROP_DEFAULT_STYLE_HAS_FILL,
-	GOG_XY_PROP_USE_SPLINES
+	GOG_XY_PROP_USE_SPLINES,
+	GOG_XY_PROP_DISLAY_BEFORE_GRID
 };
 
 static GogObjectClass *xy_parent_klass;
@@ -290,6 +291,12 @@ gog_xy_set_property (GObject *obj, guint param_id,
 	case GOG_XY_PROP_USE_SPLINES:
 		xy->use_splines = g_value_get_boolean (value);
 		break;
+	case GOG_XY_PROP_DISLAY_BEFORE_GRID:
+		GOG_PLOT (obj)->rendering_order = (g_value_get_boolean (value))?
+						GOG_PLOT_RENDERING_BEFORE_GRID:
+						GOG_PLOT_RENDERING_LAST;
+		gog_object_emit_changed (GOG_OBJECT (obj), FALSE);
+		break;
 	default: G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, param_id, pspec);
 		 break;
 	}
@@ -323,11 +330,54 @@ gog_xy_get_property (GObject *obj, guint param_id,
 		}
 		g_value_set_boolean (value, use_splines);
 		break;
+	case GOG_XY_PROP_DISLAY_BEFORE_GRID:
+		g_value_set_boolean (value, GOG_PLOT (obj)->rendering_order == GOG_PLOT_RENDERING_BEFORE_GRID);
+		break;
 	default: G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, param_id, pspec);
 		 break;
 	}
 }
 
+#ifdef GOFFICE_WITH_GTK
+static void
+display_before_grid_cb (GtkToggleButton *btn, GObject *obj)
+{
+	g_object_set (obj, "before-grid", gtk_toggle_button_get_active (btn), NULL);
+}
+#endif
+
+static void
+gog_xy_plot_populate_editor (GogObject *obj,
+			     GOEditor *editor,
+                             GogDataAllocator *dalloc,
+                             GOCmdContext *cc)
+{
+#ifdef GOFFICE_WITH_GTK
+	GtkBuilder *gui;
+	char const *dir;
+	char *path;
+
+	dir = go_plugin_get_dir_name (go_plugins_get_plugin_by_id ("GOffice_plot_xy"));
+	path = g_build_filename (dir, "gog-xy-prefs.ui", NULL);
+	gui = go_gtk_builder_new (path, GETTEXT_PACKAGE, cc);
+	g_free (path);
+
+	if (gui != NULL) {
+		GtkWidget *w = go_gtk_builder_get_widget (gui, "before-grid");
+		gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (w),
+				(GOG_PLOT (obj))->rendering_order == GOG_PLOT_RENDERING_BEFORE_GRID);
+		g_signal_connect (G_OBJECT (w),
+			"toggled",
+			G_CALLBACK (display_before_grid_cb), obj);
+		w = go_gtk_builder_get_widget (gui, "gog-xy-prefs");
+		go_editor_add_page (editor, w, _("Properties"));
+		g_object_unref (gui);
+	}
+
+#endif
+	(GOG_OBJECT_CLASS (xy_parent_klass)->populate_editor) (obj, editor, dalloc, cc);
+};
+
 static void
 gog_xy_plot_class_init (GogPlotClass *plot_klass)
 {
@@ -363,7 +413,14 @@ gog_xy_plot_class_init (GogPlotClass *plot_klass)
 			_("Should the plot use splines instead of linear interpolation"),
 			FALSE,
 			GSF_PARAM_STATIC | G_PARAM_READWRITE | GO_PARAM_PERSISTENT));
+	g_object_class_install_property (gobject_klass, GOG_XY_PROP_DISLAY_BEFORE_GRID,
+		g_param_spec_boolean ("before-grid",
+			_("Displayed under the grids"),
+			_("Should the plot be displayed before the grids"),
+			FALSE,
+			GSF_PARAM_STATIC | G_PARAM_READWRITE | GO_PARAM_PERSISTENT));
 	gog_klass->type_name	= gog_xy_plot_type_name;
+	gog_klass->populate_editor = gog_xy_plot_populate_editor;
 
 	{
 		static GogSeriesDimDesc dimensions[] = {
diff --git a/po/ChangeLog b/po/ChangeLog
index af31ab2..4827769 100644
--- a/po/ChangeLog
+++ b/po/ChangeLog
@@ -1,3 +1,9 @@
+2010-10-23  Jean Brefort  <jean brefort normalesup org>
+
+	reviewed by: <delete if not using a buddy>
+
+	* POTFILES.in:
+
 2010-10-01  Morten Welinder <terra gnome org>
 
 	* Release 0.8.11
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 92a29b2..7711429 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -304,6 +304,7 @@ plugins/plot_xy/gog-bubble-prefs.c
 [type: gettext/glade]plugins/plot_xy/gog-bubble-prefs.ui
 [type: gettext/glade]plugins/plot_xy/gog-xy-series-prefs.ui
 [type: gettext/glade]plugins/plot_xy/gog-xy-color-prefs.ui
+[type: gettext/glade]plugins/plot_xy/gog-xy-prefs.ui
 plugins/plot_xy/gog-xy.c
 plugins/plot_xy/gog-xy.h
 plugins/plot_xy/plot-types.xml.in



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