goffice r2110 - in trunk: . goffice/graph goffice/gtk plugins/plot_xy



Author: jbrefort
Date: Fri Jun 20 19:12:17 2008
New Revision: 2110
URL: http://svn.gnome.org/viewvc/goffice?rev=2110&view=rev

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

	* goffice/graph/gog-style.c: (gog_style_create_cairo_pattern): fixed
	gradients coordinates.
	* goffice/gtk/go-gradient-selector.c:
	(go_gradient_swatch_render_func): ditto.
	* plugins/plot_xy/gog-xy.c: (gog_xy_view_render),
	(gog_xy_series_element_init_style),
	(gog_xy_series_element_class_init), (gog_xy_series_class_init),
	(go_plugin_init): add singleton support to scatter plots.



Modified:
   trunk/ChangeLog
   trunk/NEWS
   trunk/goffice/graph/gog-style.c
   trunk/goffice/gtk/go-gradient-selector.c
   trunk/plugins/plot_xy/gog-xy.c

Modified: trunk/NEWS
==============================================================================
--- trunk/NEWS	(original)
+++ trunk/NEWS	Fri Jun 20 19:12:17 2008
@@ -5,6 +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.
 
 Jody:
 	* Fix X axis text clipping on win32. [#442773]

Modified: trunk/goffice/graph/gog-style.c
==============================================================================
--- trunk/goffice/graph/gog-style.c	(original)
+++ trunk/goffice/graph/gog-style.c	Fri Jun 20 19:12:17 2008
@@ -2117,8 +2117,8 @@
 			return go_pattern_create_cairo_pattern (&style->fill.pattern, cr);
 
 		case GOG_FILL_STYLE_GRADIENT:
-			x[2] = (x[1] - x[0]) / 2.0 + x[1];
-			y[2] = (y[1] - y[0]) / 2.0 + y[1];
+			x[2] = (x[1] - x[0]) / 2.0 + x[0];
+			y[2] = (y[1] - y[0]) / 2.0 + y[0];
 			cr_pattern = cairo_pattern_create_linear (
 				x[grad_i[style->fill.gradient.dir].x0i],
 				y[grad_i[style->fill.gradient.dir].y0i],

Modified: trunk/goffice/gtk/go-gradient-selector.c
==============================================================================
--- trunk/goffice/gtk/go-gradient-selector.c	(original)
+++ trunk/goffice/gtk/go-gradient-selector.c	Fri Jun 20 19:12:17 2008
@@ -64,8 +64,8 @@
 	y[0] = area->y;
 	x[1] = area->x + area->width;
 	y[1] = area->y + area->height;
-	x[2] = (x[1] - x[0]) / 2.0 + x[1];
-	y[2] = (y[1] - y[0]) / 2.0 + y[1];
+	x[2] = (x[1] - x[0]) / 2.0 + x[0];
+	y[2] = (y[1] - y[0]) / 2.0 + y[0];
 	cr_pattern = cairo_pattern_create_linear (x[grad_i[index].x0i], 
 						  y[grad_i[index].y0i],
 						  x[grad_i[index].x1i],

Modified: trunk/plugins/plot_xy/gog-xy.c
==============================================================================
--- trunk/plugins/plot_xy/gog-xy.c	(original)
+++ trunk/plugins/plot_xy/gog-xy.c	Fri Jun 20 19:12:17 2008
@@ -882,6 +882,9 @@
 	MarkerData **markers;
 	unsigned *num_markers;
 
+	GogSeriesElement *gse;
+	GList const *overrides;
+
 	for (num_series = 0, ptr = model->base.series ; ptr != NULL ; ptr = ptr->next, num_series++);
 	if (num_series < 1)
 		return;
@@ -1073,6 +1076,7 @@
 		y_margin_min = view->allocation.y - margin;
 		y_margin_max = view->allocation.y + view->allocation.h + margin;
 
+		overrides = gog_series_get_overrides (GOG_SERIES (series));
 		k = 0;
 		for (i = 1 ; i <= n ; i++) {
 			x = x_vals ? *x_vals++ : i;
@@ -1104,13 +1108,23 @@
 						gog_renderer_pop_style (view->renderer);
 					} else continue;
 				} else {
-					if (model->base.vary_style_by_element)
+					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 if (model->base.vary_style_by_element)
 						gog_theme_fillin_style (theme, style, GOG_OBJECT (series),
 									model->base.index_num + i - 1, FALSE);
 					gog_renderer_draw_circle (view->renderer, x_canvas, y_canvas, 
 							    ((size_as_area) ?
 							    sqrt (z / zmax) :
 							    z / zmax) * rmax);
+					if (gse)
+						gog_renderer_pop_style (view->renderer);
 				}
 			}
 
@@ -1166,11 +1180,21 @@
 
 	if (!GOG_IS_BUBBLE_PLOT (model))
 		for (j = 0, ptr = model->base.series ; ptr != NULL ; ptr = ptr->next, j++) {
+			overrides = gog_series_get_overrides (GOG_SERIES (series));
 				if (markers[j] != NULL) {
 					series = ptr->data;
+					overrides = gog_series_get_overrides (GOG_SERIES (series));
 					style = GOG_STYLED_OBJECT (series)->style;
 					gog_renderer_push_style (view->renderer, style);
 					for (k = 0; k < num_markers[j]; k++) {
+						gse = NULL;
+						if ((overrides != NULL) &&
+							(GOG_SERIES_ELEMENT (overrides->data)->index == k)) {
+								gse = GOG_SERIES_ELEMENT (overrides->data);
+								overrides = overrides->next;
+								style = gog_styled_object_get_style (GOG_STYLED_OBJECT (gse));
+								gog_renderer_push_style (view->renderer, style);
+						}
 						if (is_map) {
 							go_marker_set_outline_color
 								(style->marker.mark,markers[j][k].color);
@@ -1183,6 +1207,10 @@
 									  markers[j][k].y);
 						if (is_map)
 							gog_renderer_pop_style (view->renderer);
+						if (gse) {
+							gog_renderer_pop_style (view->renderer);
+							style = GOG_STYLED_OBJECT (series)->style;
+						}
 					}
 					gog_renderer_pop_style (view->renderer);
 					g_free (markers[j]);
@@ -1311,6 +1339,43 @@
 
 /****************************************************************************/
 
+typedef GogSeriesElement GogXYSeriesElement;
+typedef GogSeriesElementClass GogXYSeriesElementClass;
+#define GOG_XY_SERIES_ELEMENT_TYPE	(gog_xy_series_element_get_type ())
+#define GOG_XY_SERIES_ELEMENT(o)	(G_TYPE_CHECK_INSTANCE_CAST ((o), GOG_XY_SERIES_ELEMENT_TYPE, GogXYSeriesElement))
+#define IS_GOG_XY_SERIES_ELEMENT(o)	(G_TYPE_CHECK_INSTANCE_TYPE ((o), GOG_XY_SERIES_ELEMENT_TYPE))
+GType gog_xy_series_element_get_type (void);
+
+static void
+gog_xy_series_element_init_style (GogStyledObject *gso, GogStyle *style)
+{
+	GogSeries const *series = GOG_SERIES (GOG_OBJECT (gso)->parent);
+	GogStyle *parent_style;
+
+	g_return_if_fail (series != NULL);
+
+	parent_style = gog_styled_object_get_style (GOG_STYLED_OBJECT (series));
+	if (parent_style->interesting_fields & GOG_STYLE_MARKER)
+		style->interesting_fields = GOG_STYLE_MARKER;
+	else
+		style->interesting_fields = parent_style->interesting_fields;
+	gog_theme_fillin_style (gog_object_get_theme (GOG_OBJECT (gso)),
+		style, GOG_OBJECT (gso), GOG_SERIES_ELEMENT (gso)->index, FALSE);
+}
+
+static void
+gog_xy_series_element_class_init (GogXYSeriesElementClass *klass)
+{
+	GogStyledObjectClass *style_klass = (GogStyledObjectClass *) klass;
+	style_klass->init_style	    	= gog_xy_series_element_init_style;
+}
+
+GSF_DYNAMIC_CLASS (GogXYSeriesElement, gog_xy_series_element,
+	gog_xy_series_element_class_init, NULL,
+	GOG_SERIES_ELEMENT_TYPE)
+
+/****************************************************************************/
+
 typedef GogSeriesClass GogXYSeriesClass;
 
 enum {
@@ -1587,6 +1652,7 @@
 
 	series_klass->has_interpolation = TRUE;
 	series_klass->has_fill_type	= TRUE;
+	series_klass->series_element_type = GOG_XY_SERIES_ELEMENT_TYPE;
 
 	gog_object_register_roles (gog_klass, roles, G_N_ELEMENTS (roles));
 
@@ -1627,6 +1693,7 @@
 	gog_xy_view_register_type (module);
 	gog_xy_series_view_register_type (module);
 	gog_xy_series_register_type (module);
+	gog_xy_series_element_register_type (module);
 }
 
 G_MODULE_EXPORT void



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