goffice r2113 - in trunk: . plugins/plot_barcol



Author: jbrefort
Date: Sat Jun 21 12:32:19 2008
New Revision: 2113
URL: http://svn.gnome.org/viewvc/goffice?rev=2113&view=rev

Log:
2008-06-21  Jean Brefort  <jean brefort normalesup org>

	* plugins/plot_barcol/gog-1.5d.c: add singleton formatting support to
	bars/columns plots. [#517488]
	* plugins/plot_barcol/gog-barcol.c: ditto.
	* plugins/plot_barcol/gog-barcol.h: ditto.



Modified:
   trunk/ChangeLog
   trunk/NEWS
   trunk/plugins/plot_barcol/gog-1.5d.c
   trunk/plugins/plot_barcol/gog-barcol.c
   trunk/plugins/plot_barcol/gog-barcol.h

Modified: trunk/NEWS
==============================================================================
--- trunk/NEWS	(original)
+++ trunk/NEWS	Sat Jun 21 12:32:19 2008
@@ -5,7 +5,7 @@
 	* Moved GOConf code from gnumeric to goffice.
 	* Fixed plot types activation/deactivation issues.
 	* Always use full lines when drawing markers. [#536276]
-	* Add singleton support to scatter plots.
+	* Add singleton support to scatter and bars/columns plots.
 
 Jody:
 	* Fix X axis text clipping on win32. [#442773]

Modified: trunk/plugins/plot_barcol/gog-1.5d.c
==============================================================================
--- trunk/plugins/plot_barcol/gog-1.5d.c	(original)
+++ trunk/plugins/plot_barcol/gog-1.5d.c	Sat Jun 21 12:32:19 2008
@@ -665,6 +665,8 @@
 	gog_series1_5d_register_type (module);
 	gog_barcol_plot_register_type (module);
 	gog_barcol_view_register_type (module);
+	gog_barcol_series_register_type (module);
+	gog_barcol_series_element_register_type (module);
 	gog_dropbar_plot_register_type (module);
 	gog_dropbar_view_register_type (module);
 	gog_line_series_register_type (module);

Modified: trunk/plugins/plot_barcol/gog-barcol.c
==============================================================================
--- trunk/plugins/plot_barcol/gog-barcol.c	(original)
+++ trunk/plugins/plot_barcol/gog-barcol.c	Sat Jun 21 12:32:19 2008
@@ -35,6 +35,42 @@
 #include <glib/gi18n-lib.h>
 #include <gsf/gsf-impl-utils.h>
 
+/******************************************************************************/
+
+typedef GogSeriesElement GogBarColSeriesElement;
+typedef GogSeriesElementClass GogBarColSeriesElementClass;
+
+#define GOG_BARCOL_SERIES_ELEMENT_TYPE	(gog_barcol_series_element_get_type ())
+#define GOG_BARCOL_SERIES_ELEMENT(o)	(G_TYPE_CHECK_INSTANCE_CAST ((o), GOG_BARCOL_SERIES_ELEMENT_TYPE, GogBarColSeriesElement))
+#define GOG_IS_BARCOL_SERIES_ELEMENT(o)	(G_TYPE_CHECK_INSTANCE_TYPE ((o), GOG_BARCOL_SERIES_ELEMENT_TYPE))
+GType gog_barcol_series_element_get_type (void);
+
+GSF_DYNAMIC_CLASS (GogBarColSeriesElement, gog_barcol_series_element,
+	NULL, NULL,
+	GOG_SERIES_ELEMENT_TYPE)
+
+/******************************************************************************/
+
+typedef GogSeries1_5d GogBarColSeries;
+typedef GogSeries1_5dClass GogBarColSeriesClass;
+
+#define GOG_BARCOL_SERIES_TYPE	(gog_barcol_series_eget_type ())
+#define GOG_BARCOL_SERIES(o)	(G_TYPE_CHECK_INSTANCE_CAST ((o), GOG_BARCOL_SERIES_TYPE, GogBarColSeries))
+#define GOG_IS_BARCOL_SERIEST(o)	(G_TYPE_CHECK_INSTANCE_TYPE ((o), GOG_BARCOL_SERIES_TYPE))
+GType gog_barcol_series_get_type (void);
+
+static void
+gog_barcol_series_class_init (GogSeriesClass *series_klass)
+{
+	series_klass->series_element_type = GOG_BARCOL_SERIES_ELEMENT_TYPE;
+}
+
+GSF_DYNAMIC_CLASS (GogBarColSeries, gog_barcol_series,
+	gog_barcol_series_class_init, NULL,
+	GOG_SERIES1_5D_TYPE)
+
+/******************************************************************************/
+
 enum {
 	BARCOL_PROP_0,
 	BARCOL_PROP_GAP_PERCENTAGE,
@@ -223,6 +259,7 @@
 	gog_object_klass->view_type	= gog_barcol_view_get_type ();
 
 	plot_klass->desc.series.style_fields	= GOG_STYLE_OUTLINE | GOG_STYLE_FILL;
+	plot_klass->series_type = gog_barcol_series_get_type ();
 	plot_klass->axis_get_bounds   		= gog_barcol_axis_get_bounds;
 
 	gog_plot_1_5d_klass->swap_x_and_y = gog_barcol_swap_x_and_y;
@@ -343,6 +380,8 @@
 	unsigned *lengths;
 	double plus, minus;
 	GogObjectRole const *role = NULL;
+	GogSeriesElement *gse;
+	GList const *overrides;
 
 	if (num_elements <= 0 || num_series <= 0)
 		return;
@@ -424,8 +463,9 @@
 		}
 
 		pos_base = neg_base = 0.0;
+		ptr = gog_1_5d_model->base.series;
 		for (j = 0 ; j < num_series ; j++) {
-			
+			overrides = gog_series_get_overrides (GOG_SERIES (ptr->data));
 			work.y = (double) j * col_step + (double) i - offset + 1.0;
 			
 			if (i >= lengths[j])
@@ -451,7 +491,16 @@
 					neg_base += tmp;
 			}
 
-			gog_renderer_push_style (view->renderer, styles[j]);
+			gse = NULL;
+			if ((overrides != NULL) &&
+				(GOG_SERIES_ELEMENT (overrides->data)->index == i - 1)) {
+					gse = GOG_SERIES_ELEMENT (overrides->data);
+					overrides = overrides->next;
+					gog_renderer_push_style (view->renderer,
+						gog_styled_object_get_style (
+							GOG_STYLED_OBJECT (gse)));
+			} else
+				gog_renderer_push_style (view->renderer, styles[j]);
 			barcol_draw_rect (rend, is_vertical, x_map, y_map, &work);
 			gog_renderer_pop_style (view->renderer);
 			
@@ -489,6 +538,7 @@
 							 gog_axis_map_to_view (y_map, work.y + work.h));
 				}
 			}
+			ptr = ptr->next;
 		}
 	}
 	/*Now draw error bars and clean*/

Modified: trunk/plugins/plot_barcol/gog-barcol.h
==============================================================================
--- trunk/plugins/plot_barcol/gog-barcol.h	(original)
+++ trunk/plugins/plot_barcol/gog-barcol.h	Sat Jun 21 12:32:19 2008
@@ -43,6 +43,8 @@
 GType gog_barcol_plot_get_type (void);
 void  gog_barcol_plot_register_type (GTypeModule *module);
 void  gog_barcol_view_register_type (GTypeModule *module);
+void  gog_barcol_series_register_type (GTypeModule *module);
+void  gog_barcol_series_element_register_type (GTypeModule *module);
 
 G_END_DECLS
 



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