goffice r2192 - in trunk: . goffice/graph plugins/plot_barcol plugins/plot_boxes
- From: jbrefort svn gnome org
- To: svn-commits-list gnome org
- Subject: goffice r2192 - in trunk: . goffice/graph plugins/plot_barcol plugins/plot_boxes
- Date: Tue, 26 Aug 2008 11:27:17 +0000 (UTC)
Author: jbrefort
Date: Tue Aug 26 11:27:17 2008
New Revision: 2192
URL: http://svn.gnome.org/viewvc/goffice?rev=2192&view=rev
Log:
2008-08-26 Jean Brefort <jean brefort normalesup org>
* goffice/graph/gog-series-lines.h: do not include libart.h.
* plugins/plot_barcol/gog-barcol.c: (barcol_draw_rect): fixed snap.
* plugins/plot_boxes/gog-boxplot.c: (gog_box_plot_view_render):
use GOPath instead of ArtVpath.
* plugins/plot_boxes/gog-histogram.c:
(gog_histogram_plot_init): draw before the axis.
(gog_histogram_plot_view_render): use GOPath instead of ArtVpath.
Modified:
trunk/ChangeLog
trunk/goffice/graph/gog-series-lines.h
trunk/plugins/plot_barcol/gog-barcol.c
trunk/plugins/plot_boxes/gog-boxplot.c
trunk/plugins/plot_boxes/gog-histogram.c
Modified: trunk/goffice/graph/gog-series-lines.h
==============================================================================
--- trunk/goffice/graph/gog-series-lines.h (original)
+++ trunk/goffice/graph/gog-series-lines.h Tue Aug 26 11:27:17 2008
@@ -25,7 +25,6 @@
#include <goffice/graph/goffice-graph.h>
#include <goffice/graph/gog-styled-object.h>
#include <goffice/utils/go-path.h>
-#include <libart_lgpl/libart.h>
G_BEGIN_DECLS
Modified: trunk/plugins/plot_barcol/gog-barcol.c
==============================================================================
--- trunk/plugins/plot_barcol/gog-barcol.c (original)
+++ trunk/plugins/plot_barcol/gog-barcol.c Tue Aug 26 11:27:17 2008
@@ -335,9 +335,10 @@
go_path_line_to (path, x1, y1);
go_path_line_to (path, x0, y1);
go_path_close (path);
-
- gog_renderer_fill_serie (rend, path, NULL);
- gog_renderer_stroke_serie (rend, path);
+ go_path_set_options (path, GO_PATH_OPTIONS_SHARP);
+
+ gog_renderer_draw_shape (rend, path);
+ go_path_free (path);
}
typedef struct {
Modified: trunk/plugins/plot_boxes/gog-boxplot.c
==============================================================================
--- trunk/plugins/plot_boxes/gog-boxplot.c (original)
+++ trunk/plugins/plot_boxes/gog-boxplot.c Tue Aug 26 11:27:17 2008
@@ -32,6 +32,7 @@
#include <goffice/math/go-rangefunc.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/app/module-plugin-defs.h>
@@ -433,7 +434,7 @@
GogBoxPlotSeries const *series;
double hrect, hser, y, hbar;
double min, qu1, med, qu3, max;
- ArtVpath path[6];
+ GOPath *path;
GSList *ptr;
GogStyle *style;
int num_ser = 1;
@@ -465,12 +466,9 @@
}
hrect /= 2.;
hbar = hrect / 2.;
- path[0].code = ART_MOVETO;
- path[1].code = ART_LINETO;
- path[3].code = ART_LINETO;
- path[4].code = ART_LINETO;
- path[5].code = ART_END;
+ path = go_path_new ();
+ go_path_set_options (path, GO_PATH_OPTIONS_SHARP);
for (ptr = model->base.series ; ptr != NULL ; ptr = ptr->next) {
series = ptr->data;
if (!gog_series_is_valid (GOG_SERIES (series)) ||
@@ -533,69 +531,51 @@
qu3 = gog_axis_map_to_view (map, series->vals[3]);
max = gog_axis_map_to_view (map, max);
if (model->vertical) {
- path[2].code = ART_LINETO;
- path[0].y = path[3].y = path[4].y = qu1;
- path[1].y = path[2].y = qu3;
- path[0].x = path[1].x = path[4].x = y - hrect;
- path[2].x = path[3].x = y + hrect;
- gog_renderer_draw_sharp_polygon (view->renderer, path, TRUE);
- path[2].code = ART_END;
- path[0].x = y + hbar;
- path[1].x = y - hbar;
- path[0].y = path[1].y = min;
- gog_renderer_draw_sharp_path (view->renderer, path);
- path[0].y = path[1].y = max;
- gog_renderer_draw_sharp_path (view->renderer, path);
- path[0].x = path[1].x = y;
- path[0].y = qu3;
- gog_renderer_draw_sharp_path (view->renderer, path);
- path[0].y = min;
- path[1].y = qu1;
- gog_renderer_draw_sharp_path (view->renderer, path);
- path[0].y = path[1].y = med;
- path[0].x = y + hrect;
- path[1].x = y - hrect;
- gog_renderer_draw_sharp_path (view->renderer, path);
- path[2].code = ART_LINETO;
- path[0].y = path[3].y = path[4].y = qu1;
- path[1].y = path[2].y = qu3;
- path[0].x = path[1].x = path[4].x = y - hrect;
- path[2].x = path[3].x = y + hrect;
+ go_path_move_to (path, y - hrect, qu1);
+ go_path_line_to (path, y - hrect, qu3);
+ go_path_line_to (path, y + hrect, qu3);
+ go_path_line_to (path, y + hrect, qu1);
+ go_path_close (path);
+ gog_renderer_draw_shape (view->renderer, path);
+ go_path_clear (path);
+ go_path_move_to (path, y + hbar, min);
+ go_path_line_to (path, y - hbar, min);
+ go_path_move_to (path, y + hbar, max);
+ go_path_line_to (path, y - hbar, max);
+ go_path_move_to (path, y, max);
+ go_path_line_to (path, y, qu3);
+ go_path_move_to (path, y, min);
+ go_path_line_to (path, y, qu1);
+ go_path_move_to (path, y - hrect, med);
+ go_path_line_to (path, y + hrect, med);
+ gog_renderer_stroke_shape (view->renderer, path);
+ go_path_clear (path);
} else {
- path[2].code = ART_LINETO;
- path[0].x = path[3].x = path[4].x = qu1;
- path[1].x = path[2].x = qu3;
- path[0].y = path[1].y = path[4].y = y - hrect;
- path[2].y = path[3].y = y + hrect;
- gog_renderer_draw_sharp_polygon (view->renderer, path, TRUE);
- path[2].code = ART_END;
- path[0].y = y + hbar;
- path[1].y = y - hbar;
- path[0].x = path[1].x = min;
- gog_renderer_draw_sharp_path (view->renderer, path);
- path[0].x = path[1].x = max;
- gog_renderer_draw_sharp_path (view->renderer, path);
- path[0].y = path[1].y = y;
- path[0].x = qu3;
- gog_renderer_draw_sharp_path (view->renderer, path);
- path[0].x = min;
- path[1].x = qu1;
- gog_renderer_draw_sharp_path (view->renderer, path);
- path[0].x = path[1].x = med;
- path[0].y = y + hrect;
- path[1].y = y - hrect;
- gog_renderer_draw_sharp_path (view->renderer, path);
- path[2].code = ART_LINETO;
- path[0].x = path[3].x = path[4].x = qu1;
- path[1].x = path[2].x = qu3;
- path[0].y = path[1].y = path[4].y = y - hrect;
- path[2].y = path[3].y = y + hrect;
+ go_path_move_to (path, qu1, y - hrect);
+ go_path_line_to (path, qu3, y - hrect);
+ go_path_line_to (path, qu3, y + hrect);
+ go_path_line_to (path, qu1, y + hrect);
+ go_path_close (path);
+ gog_renderer_draw_shape (view->renderer, path);
+ go_path_clear (path);
+ go_path_move_to (path, min, y + hbar);
+ go_path_line_to (path, min, y - hbar);
+ go_path_move_to (path, max, y + hbar);
+ go_path_line_to (path, max, y - hbar);
+ go_path_move_to (path, max, y);
+ go_path_line_to (path, qu3, y);
+ go_path_move_to (path, min, y);
+ go_path_line_to (path, qu1, y);
+ go_path_move_to (path, med, y - hrect);
+ go_path_line_to (path, med, y + hrect);
+ gog_renderer_stroke_shape (view->renderer, path);
+ go_path_clear (path);
}
- gog_renderer_draw_sharp_path (view->renderer, path);
gog_renderer_pop_style (view->renderer);
g_object_unref (style);
num_ser++;
}
+ go_path_free (path);
gog_chart_map_free (chart_map);
}
Modified: trunk/plugins/plot_boxes/gog-histogram.c
==============================================================================
--- trunk/plugins/plot_boxes/gog-histogram.c (original)
+++ trunk/plugins/plot_boxes/gog-histogram.c Tue Aug 26 11:27:17 2008
@@ -29,6 +29,7 @@
#include <goffice/graph/gog-series-lines.h>
#include <goffice/math/go-math.h>
#include <goffice/utils/go-format.h>
+#include <goffice/utils/go-path.h>
#include <glib/gi18n-lib.h>
#include <gsf/gsf-impl-utils.h>
@@ -197,8 +198,16 @@
plot_klass->axis_get_bounds = gog_histogram_plot_axis_get_bounds;
}
+static void
+gog_histogram_plot_init (GogHistogramPlot *hist)
+{
+ GogPlot *plot = GOG_PLOT (hist);
+
+ plot->render_before_axes = TRUE;
+}
+
GSF_DYNAMIC_CLASS (GogHistogramPlot, gog_histogram_plot,
- gog_histogram_plot_class_init, NULL,
+ gog_histogram_plot_class_init, gog_histogram_plot_init,
GOG_PLOT_TYPE)
/*****************************************************************************/
@@ -214,9 +223,9 @@
GogAxisMap *x_map, *y_map;
GogViewAllocation const *area;
GogHistogramPlotSeries const *series;
- double *x_vals = NULL, *y_vals, curx, cury;
+ double *x_vals = NULL, *y_vals, curx, cury, y0;
unsigned i, j, nb;
- ArtVpath *path ;
+ GOPath *path ;
GSList *ptr;
GogStyle *style;
@@ -246,65 +255,50 @@
y_vals = (x_vals)? series->y: go_data_vector_get_values (
GO_DATA_VECTOR (series->base.values[1].data));
- path = art_new (ArtVpath, nb);
- path[0].code = ART_MOVETO;
- curx = path[0].x = gog_axis_map_to_view (x_map, ((x_vals)? x_vals[0]: 0.));
- path[0].y = gog_axis_map_get_baseline (y_map);
+ path = go_path_new ();
+ go_path_set_options (path, GO_PATH_OPTIONS_SHARP);
+ curx = gog_axis_map_to_view (x_map, ((x_vals)? x_vals[0]: 0.));
+ go_path_move_to (path, curx, y0 = gog_axis_map_get_baseline (y_map));
for (i = 0, j = 1; i < series->base.num_elements; i++) {
- path[j].code = ART_LINETO;
- path[j].x = curx;
- cury = path[j++].y = gog_axis_map_to_view (y_map, y_vals[i]);
- path[j].code = ART_LINETO;
- curx = path[j].x = gog_axis_map_to_view (x_map, ((x_vals)? x_vals[i+1]: 0.));
- path[j++].y = cury;
- }
- path[j].code = ART_LINETO;
- path[j].x = curx;
- path[j++].y = path[0].y;
- path[j].code = ART_LINETO;
- path[j].x = path[0].x;
- path[j++].y = path[0].y;
- path[j].code = ART_END;
+ cury = gog_axis_map_to_view (y_map, y_vals[i]);
+ go_path_line_to (path, curx, cury);
+ curx = gog_axis_map_to_view (x_map, ((x_vals)? x_vals[i+1]: 0.));
+ go_path_line_to (path, curx, cury);
+ }
+ go_path_line_to (path, curx, y0);
gog_renderer_push_style (view->renderer, style);
- gog_renderer_draw_sharp_polygon (view->renderer, path, FALSE);
+ gog_renderer_fill_shape (view->renderer, path);
if (series->droplines) {
- ArtVpath droppath[3];
- droppath[0].code = ART_MOVETO;
- droppath[1].code = ART_LINETO;
- droppath[2].code = ART_END;
+ GOPath *drop_path = go_path_new ();
+ go_path_set_options (drop_path, GO_PATH_OPTIONS_SHARP);
gog_renderer_push_style (view->renderer,
gog_styled_object_get_style (GOG_STYLED_OBJECT (series->droplines)));
+ cury = y0;
for (i = 1; i < series->base.num_elements; i++) {
- droppath[0].x = droppath[1].x =
- gog_axis_map_to_view (x_map, ((x_vals)? x_vals[i]: 0.));
+ curx = gog_axis_map_to_view (x_map, ((x_vals)? x_vals[i]: 0.));
if (y_vals[i-1] * y_vals[i] > 0.) {
- droppath[0].y = path[0].y;
+ go_path_move_to (drop_path, curx, y0);
if (y_vals[i] > 0.)
- droppath[1].y = gog_axis_map_to_view (y_map,
+ cury = gog_axis_map_to_view (y_map,
MIN (y_vals[i-1], y_vals[i]));
else
- droppath[1].y = gog_axis_map_to_view (y_map,
+ cury = gog_axis_map_to_view (y_map,
MAX (y_vals[i-1], y_vals[i]));
+
} else {
- droppath[0].y = gog_axis_map_to_view (y_map, y_vals[i-1]);
- droppath[1].y = gog_axis_map_to_view (y_map, y_vals[i]);
+ go_path_move_to (drop_path, curx, cury);
+ cury = gog_axis_map_to_view (y_map, y_vals[i]);
}
- gog_renderer_draw_path (view->renderer, droppath);
+ go_path_line_to (drop_path, curx, cury);
}
+ gog_renderer_stroke_serie (view->renderer, drop_path);
+ go_path_free (drop_path);
gog_renderer_pop_style (view->renderer);
}
-/* int nb = series->base.num_elements - 1;
- x = g_new (double, nb);
- y = g_new (double, nb);
-
- g_free (x);
- g_free (y);*/
- j--;
- path[j].code = ART_END;
- gog_renderer_draw_path (view->renderer, path);
+ gog_renderer_stroke_shape (view->renderer, path);
gog_renderer_pop_style (view->renderer);
- art_free (path);
+ go_path_free (path);
/* Now render children */
for (ptr = view->children ; ptr != NULL ; ptr = ptr->next)
gog_view_render (ptr->data, bbox);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]