goffice r2187 - in trunk: . goffice/graph



Author: jbrefort
Date: Sat Aug 23 07:17:20 2008
New Revision: 2187
URL: http://svn.gnome.org/viewvc/goffice?rev=2187&view=rev

Log:
2008-08-23  Jean Brefort  <jean brefort normalesup org>

	* goffice/graph/gog-error-bar.c: (gog_error_bar_init),
	(gog_error_bar_render): use GOPath instead of ArtVpath.
	* goffice/graph/gog-legend.c: (cb_render_elements),
	(gog_legend_view_render): ditto.



Modified:
   trunk/ChangeLog
   trunk/goffice/graph/gog-error-bar.c
   trunk/goffice/graph/gog-legend.c

Modified: trunk/goffice/graph/gog-error-bar.c
==============================================================================
--- trunk/goffice/graph/gog-error-bar.c	(original)
+++ trunk/goffice/graph/gog-error-bar.c	Sat Aug 23 07:17:20 2008
@@ -30,6 +30,7 @@
 #include <goffice/data/go-data-impl.h>
 #include <goffice/data/go-data.h>
 #include <goffice/math/go-math.h>
+#include <goffice/utils/go-path.h>
 #include <goffice/utils/go-persist.h>
 #include <gsf/gsf-impl-utils.h>
 
@@ -336,6 +337,7 @@
 	bar->display = GOG_ERROR_BAR_DISPLAY_BOTH;
 	bar->width = 5.;
 	bar->style = gog_style_new ();
+	bar->style->interesting_fields = GOG_STYLE_LINE;
 	bar->style->line.color = RGBA_BLACK;
 	bar->style->line.width = 1.;
 }
@@ -638,8 +640,7 @@
 			   double plus,
 			   gboolean horizontal)
 {
-	ArtVpath path [7];
-	int n;
+	GOPath *path;
 	double x_start, y_start, x_end, y_end;
 	double line_width, width;
 	gboolean start = plus > .0 && bar ->display & GOG_ERROR_BAR_DISPLAY_POSITIVE,
@@ -679,13 +680,9 @@
 	x = gog_axis_map_to_view (x_map, x);
 	y = gog_axis_map_to_view (y_map, y);
 
-	path[0].code = ART_MOVETO;
-	path[1].code = ART_LINETO;
-	path[0].x = x_start;
-	path[1].x = x_end;
-	path[0].y = path[1].y = y_start;
-	path[0].y = y_start;
-	path[1].y = y_end;
+	path = go_path_new ();
+	go_path_move_to (path, x_start, y_start);
+	go_path_line_to (path, x_end, y_end);
 
 	if (horizontal) {
 		width = gog_renderer_pt2r_y (rend, bar->width) / 2.;
@@ -696,44 +693,31 @@
 	}
 
 	if ((2. * width) > line_width) {
-		if (start && end) {
-			path[2].code = ART_MOVETO;
-			path[3].code = ART_LINETO;
-			n = 4;
-		} else
-			n = 2;
-		path[n].code = ART_MOVETO;
-		path[n + 1].code = ART_LINETO;
-		path[n + 2].code = ART_END;
 		if (horizontal) {
 			if (start) {
-				path[2].x =path[3].x = x_start;
-				path[2].y = y - width;
-				path[3].y = y + width;
+				go_path_move_to (path, x_start, y - width);
+				go_path_line_to (path, x_start, y + width);
 			}
 			if (end) {
-				path[n].x =path[n+1].x = x_end;
-				path[n].y = y - width;
-				path[n+1].y = y + width;
+				go_path_move_to (path, x_end, y - width);
+				go_path_line_to (path, x_end, y + width);
 			}
 		} else {
 			if (start) {
-				path[2].x = x - width;
-				path[3].x = x + width;
-				path[2].y =path[3].y = y_start;
+				go_path_move_to (path, x - width, y_start);
+				go_path_line_to (path, x + width, y_start);
 			}
 			if (end) {
-				path[n].x = x - width;
-				path[n+1].x = x + width;
-				path[n].y =path[n+1].y = y_end;
+				go_path_move_to (path, x - width, y_end);
+				go_path_line_to (path, x + width, y_end);
 			}
 		}
-	} else
-		path[2].code = ART_END;
+	}
 
 	gog_renderer_push_style (rend, bar->style);
-	gog_renderer_draw_sharp_path (rend, path);
+	gog_renderer_stroke_serie (rend, path);
 	gog_renderer_pop_style (rend);
+	go_path_free (path);
 }
 
 gboolean

Modified: trunk/goffice/graph/gog-legend.c
==============================================================================
--- trunk/goffice/graph/gog-legend.c	(original)
+++ trunk/goffice/graph/gog-legend.c	Sat Aug 23 07:17:20 2008
@@ -30,6 +30,7 @@
 #include <goffice/utils/go-color.h>
 #include <goffice/math/go-math.h>
 #include <goffice/utils/go-marker.h>
+#include <goffice/utils/go-path.h>
 #include <goffice/utils/go-persist.h>
 #include <goffice/utils/go-units.h>
 
@@ -417,7 +418,6 @@
 	double element_step_x, element_step_y;
 	double block_step_x, block_step_y;
 	GogViewAllocation swatch;
-	ArtVpath line_path[3];
 	double swatch_scale_a, swatch_scale_b;
 	double line_scale_a, line_scale_b;
 	double hairline_width;
@@ -432,7 +432,8 @@
 	GogRenderer *renderer = view->renderer;
 	GogStyle *style = NULL;
 	GogViewAllocation pos, rectangle;
-	double half_width;
+	double half_width, y;
+	GOPath *line_path;
 
 	if (data->count > 0) {
 		if ((data->count % glv->element_per_blocks) != 0) {
@@ -455,20 +456,20 @@
 
 		gog_renderer_push_style (renderer, style);
 		half_width = 0.5 * gog_renderer_line_size (renderer, style->line.width);
-		data->line_path[0].x = data->x + half_width;
-		data->line_path[1].x = data->x + data->swatch.w * GLV_LINE_LENGTH_EM - half_width;
-		data->line_path[0].y =
-		data->line_path[1].y = data->y + glv->element_height / 2.;
+		line_path = go_path_new ();
+		y = data->y + glv->element_height / 2.;
+		go_path_move_to (line_path, data->x + half_width, y);
+		go_path_line_to (line_path, data->x + data->swatch.w * GLV_LINE_LENGTH_EM - half_width, y);
 		if (style->interesting_fields & GOG_STYLE_FILL) {
 			rectangle.x = data->x - half_width;
-			rectangle.y = data->line_path[0].y;
+			rectangle.y = y;
 			rectangle.w = data->swatch.w * GLV_LINE_LENGTH_EM + 2.0 * half_width;
 			rectangle.h = glv->element_height / 2.0;
 			gog_renderer_fill_rectangle (renderer, &rectangle);
 		}
-		gog_renderer_draw_path (renderer, data->line_path);
-		gog_renderer_draw_marker (renderer, data->x + data->swatch.w  * GLV_LINE_LENGTH_EM * 0.5,
-					  data->line_path[0].y);
+		gog_renderer_stroke_serie (renderer, line_path);
+		go_path_free (line_path);
+		gog_renderer_draw_marker (renderer, data->x + data->swatch.w  * GLV_LINE_LENGTH_EM * 0.5, y);
 	} else {					/* area swatch */
 		style = gog_style_dup (base_style);
 		if (style->outline.width > data->hairline_width)
@@ -547,11 +548,11 @@
 
 	data.hairline_width = hairline_width;
 
-	if (glv->uses_lines) {
+/*	if (glv->uses_lines) {
 		data.line_path[0].code = ART_MOVETO;
 		data.line_path[1].code = ART_LINETO;
 		data.line_path[2].code = ART_END;
-	}
+	}*/
 	
 	data.count = 0;
 	data.view = v;



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