goffice r2255 - in trunk: . pixmaps plugins/plot_surface
- From: jbrefort svn gnome org
- To: svn-commits-list gnome org
- Subject: goffice r2255 - in trunk: . pixmaps plugins/plot_surface
- Date: Fri, 31 Oct 2008 10:23:59 +0000 (UTC)
Author: jbrefort
Date: Fri Oct 31 10:23:59 2008
New Revision: 2255
URL: http://svn.gnome.org/viewvc/goffice?rev=2255&view=rev
Log:
2008-10-31 Jean Brefort <jean brefort normalesup org>
* pixmaps/Makefile.am: add new icon for GogXYZContourPlot.
* pixmaps/chart_contour_2_1.png: new icon.
* pixmaps/chart_contour_2_1.svg: ditto.
* plugins/plot_surface/gog-contour.c: fixed various regressions.
* plugins/plot_surface/gog-xyz-surface.c: add GogXYZContourPlot.
* plugins/plot_surface/gog-xyz-surface.h: ditto.
* plugins/plot_surface/gog-xyz.c: ditto.
* plugins/plot_surface/plot-types.xml.in: ditto.
Added:
trunk/pixmaps/chart_contour_2_1.png (contents, props changed)
trunk/pixmaps/chart_contour_2_1.svg
Modified:
trunk/ChangeLog
trunk/NEWS
trunk/pixmaps/Makefile.am
trunk/plugins/plot_surface/gog-contour.c
trunk/plugins/plot_surface/gog-xyz-surface.c
trunk/plugins/plot_surface/gog-xyz-surface.h
trunk/plugins/plot_surface/gog-xyz.c
trunk/plugins/plot_surface/plot-types.xml.in
Modified: trunk/NEWS
==============================================================================
--- trunk/NEWS (original)
+++ trunk/NEWS Fri Oct 31 10:23:59 2008
@@ -1,3 +1,13 @@
+goffice 0.7.3:
+
+Jean:
+ * Fixed various regressions in contour plots.
+ * Add XYZ series based contour plots.
+
+Morten:
+ * Plug leaks.
+
+--------------------------------------------------------------------------
goffice 0.7.2:
Hib Eris:
@@ -17,7 +27,6 @@
Morten:
* Fix go_url_resolve_relative. [#550898]
- * Plug leaks.
--------------------------------------------------------------------------
goffice 0.7.1:
Modified: trunk/pixmaps/Makefile.am
==============================================================================
--- trunk/pixmaps/Makefile.am (original)
+++ trunk/pixmaps/Makefile.am Fri Oct 31 10:23:59 2008
@@ -33,7 +33,7 @@
chart_scatter_4_4.png \
chart_bubble_1_1.png \
chart_colored_1_1.png \
- chart_contour_1_1.png \
+ chart_contour_1_1.png chart_contour_2_1.png \
chart_boxplot_1_1.png chart_boxplot_1_2.png \
chart_boxplot_2_1.png chart_boxplot_2_2.png \
chart_dropbar_1_1.png chart_dropbar_1_2.png \
Added: trunk/pixmaps/chart_contour_2_1.png
==============================================================================
Binary file. No diff available.
Added: trunk/pixmaps/chart_contour_2_1.svg
==============================================================================
--- (empty file)
+++ trunk/pixmaps/chart_contour_2_1.svg Fri Oct 31 10:23:59 2008
@@ -0,0 +1,238 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:xlink="http://www.w3.org/1999/xlink"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ id="svg1"
+ sodipodi:version="0.32"
+ inkscape:version="0.46"
+ width="64.000000mm"
+ height="60.000000mm"
+ sodipodi:docbase="/home/manu/Desktop"
+ sodipodi:docname="chart_contour_2_1.svg"
+ inkscape:export-filename="/home/jean/devel/goffice/pixmaps/chart_contour_2_1.png"
+ inkscape:export-xdpi="25.4"
+ inkscape:export-ydpi="25.4"
+ inkscape:output_extension="org.inkscape.output.svg.inkscape">
+ <defs
+ id="defs3">
+ <inkscape:perspective
+ sodipodi:type="inkscape:persp3d"
+ inkscape:vp_x="0 : 106.29921 : 1"
+ inkscape:vp_y="0 : 1000 : 0"
+ inkscape:vp_z="226.77165 : 106.29921 : 1"
+ inkscape:persp3d-origin="113.38583 : 70.86614 : 1"
+ id="perspective3158" />
+ <linearGradient
+ id="linearGradient4044">
+ <stop
+ style="stop-color:#ffffff;stop-opacity:0.0000000;"
+ offset="0.0000000"
+ id="stop4045" />
+ <stop
+ style="stop-color:#363636;stop-opacity:0.18750000;"
+ offset="1.0000000"
+ id="stop4046" />
+ </linearGradient>
+ <linearGradient
+ id="linearGradient3418">
+ <stop
+ style="stop-color:#f7f7f7;stop-opacity:1.0000000;"
+ offset="0.0000000"
+ id="stop3419" />
+ <stop
+ style="stop-color:#dedede;stop-opacity:1.0000000;"
+ offset="1.0000000"
+ id="stop3420" />
+ </linearGradient>
+ <linearGradient
+ id="linearGradient2791">
+ <stop
+ style="stop-color:#fbfbfb;stop-opacity:1.0000000;"
+ offset="0.0000000"
+ id="stop2792" />
+ <stop
+ style="stop-color:#e9e9e9;stop-opacity:1.0000000;"
+ offset="1.0000000"
+ id="stop2793" />
+ </linearGradient>
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient2791"
+ id="linearGradient2794"
+ x1="0.49693251"
+ y1="0.058441557"
+ x2="0.49079755"
+ y2="0.96103895" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient3418"
+ id="linearGradient3417"
+ x1="0.53846157"
+ y1="0.012987013"
+ x2="0.53254437"
+ y2="0.98051947" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient4044"
+ id="linearGradient4043"
+ x1="0.49689442"
+ y1="0.012987013"
+ x2="0.49689442"
+ y2="0.99350649" />
+ </defs>
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageopacity="0.0000000"
+ inkscape:pageshadow="2"
+ inkscape:zoom="2.5352964"
+ inkscape:cx="113.38583"
+ inkscape:cy="106.29921"
+ inkscape:window-width="727"
+ inkscape:window-height="719"
+ showborder="true"
+ showgrid="true"
+ inkscape:grid-points="true"
+ inkscape:grid-bbox="true"
+ gridtolerance="1.0000000px"
+ inkscape:guide-bbox="true"
+ inkscape:guide-points="true"
+ guidetolerance="1.0000000mm"
+ inkscape:window-x="666"
+ inkscape:window-y="25"
+ showguides="true"
+ inkscape:current-layer="svg1">
+ <sodipodi:guide
+ orientation="vertical"
+ position="23.994627"
+ id="guide5924" />
+ <sodipodi:guide
+ orientation="vertical"
+ position="58.080453"
+ id="guide5925" />
+ <sodipodi:guide
+ orientation="vertical"
+ position="92.166278"
+ id="guide5926" />
+ <sodipodi:guide
+ orientation="vertical"
+ position="126.25210"
+ id="guide5927" />
+ <inkscape:grid
+ id="GridFromPre046Settings"
+ type="xygrid"
+ originx="0px"
+ originy="0.50000000mm"
+ spacingx="1.0000000mm"
+ spacingy="1.0000000mm"
+ color="#0000ff"
+ empcolor="#0000ff"
+ opacity="0.2"
+ empopacity="0.4"
+ empspacing="5" />
+ </sodipodi:namedview>
+ <metadata
+ id="metadata4">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <rect
+ style="fill:url(#linearGradient4043);fill-opacity:1.0;fill-rule:evenodd;stroke:none;stroke-width:3.0000000pt;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1.0000000;"
+ id="rect4047"
+ width="184.25197"
+ height="177.15660"
+ x="23.031496"
+ y="23.040251"
+ rx="17.594519"
+ ry="14.164467" />
+ <rect
+ style="fill:url(#linearGradient4043);fill-opacity:1.0;fill-rule:evenodd;stroke:none;stroke-width:3.0000000pt;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1.0000000;"
+ id="rect3421"
+ width="177.16536"
+ height="173.62204"
+ x="26.574802"
+ y="23.031490"
+ rx="17.594519"
+ ry="14.164467" />
+ <rect
+ style="fill:url(#linearGradient2794);fill-opacity:1.0;fill-rule:evenodd;stroke:none;stroke-width:3.5262673;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4.0000000;stroke-opacity:1.0000000;"
+ id="rect2169"
+ width="170.38249"
+ height="159.80026"
+ x="30.118111"
+ y="26.554472"
+ rx="17.594519"
+ ry="14.164467" />
+ <rect
+ style="fill:url(#linearGradient3417);fill-opacity:1.0;fill-rule:evenodd;stroke:none;stroke-width:3.0000000pt;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1.0000000;"
+ id="rect3416"
+ width="163.39728"
+ height="149.19994"
+ x="31.955462"
+ y="31.699234"
+ rx="17.594519"
+ ry="14.164467" />
+ <rect
+ style="fill:#c5d2c8;fill-opacity:1.0000000;fill-rule:evenodd;stroke:#000000;stroke-width:3.5262673;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4.0000000;stroke-opacity:1.0000000;"
+ id="rect386"
+ width="170.38249"
+ height="159.80026"
+ x="29.993284"
+ y="26.574797"
+ rx="17.594519"
+ ry="14.164467" />
+ <path
+ style="fill:#83a67f;fill-opacity:1.0000000;fill-rule:evenodd;stroke:#000000;stroke-width:1.7750000;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1.0000000;stroke-miterlimit:4.0000000;stroke-dasharray:none;"
+ d="M 47.593750,26.562500 C 37.846387,26.562500 30.000000,32.902883 30.000000,40.750000 L 30.000000,157.31250 C 30.006008,157.31920 30.121170,157.68750 30.125000,157.68750 L 65.562500,148.31250 L 120.31250,93.906250 L 114.00000,28.000000 C 114.00000,28.000000 111.27000,26.882252 110.56250,26.562500 L 47.593750,26.562500 z "
+ id="path13"
+ sodipodi:nodetypes="ccccccccc" />
+ <path
+ style="fill:#d1940c;fill-opacity:1.0000000;fill-rule:evenodd;stroke:#000000;stroke-width:1.7750000;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1.0000000;stroke-miterlimit:4.0000000;stroke-dasharray:none;"
+ d="M 47.593750,26.562500 C 37.846387,26.562500 30.000000,32.902883 30.000000,40.750000 L 30.000000,95.031250 C 30.005058,95.045916 30.125000,95.437500 30.125000,95.437500 L 76.187500,83.281250 L 80.187500,26.562500 L 47.593750,26.562500 z "
+ id="path12"
+ sodipodi:nodetypes="ccccccc" />
+ <path
+ style="fill:#83a67f;fill-opacity:1.0000000;fill-rule:evenodd;stroke:#000000;stroke-width:1.7750000;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1.0000000;stroke-miterlimit:4.0000000;stroke-dasharray:none;"
+ d="M 180.40625,26.562500 C 180.26064,26.680328 179.46875,27.218750 179.46875,27.218750 L 149.50000,122.25000 L 69.093750,186.03125 C 68.976443,186.05329 70.037845,186.29787 70.187500,186.37500 L 182.78125,186.37500 C 192.52861,186.37500 200.37500,180.06587 200.37500,172.21875 L 200.37500,40.750000 C 200.37500,32.902885 192.52862,26.562500 182.78125,26.562500 L 180.40625,26.562500 z "
+ id="path15"
+ sodipodi:nodetypes="cccccccccc" />
+ <path
+ style="fill:#d1940c;fill-opacity:1.0000000;fill-rule:evenodd;stroke:#000000;stroke-width:1.7750000;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1.0000000;stroke-miterlimit:4.0000000;stroke-dasharray:none;"
+ d="M 200.18750,123.84375 L 155.81250,145.93750 L 143.96875,185.78125 C 143.96875,185.78125 145.28255,186.27152 145.53125,186.37500 L 182.78125,186.37500 C 192.52861,186.37500 200.37500,180.06587 200.37500,172.21875 L 200.37500,123.96875 C 200.32000,123.94859 200.23799,123.84375 200.18750,123.84375 z "
+ id="path14"
+ sodipodi:nodetypes="cccccccc" />
+ <rect
+ style="fill:none;fill-opacity:1.0;fill-rule:evenodd;stroke:#000000;stroke-width:3.5262673;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4.0000000;stroke-opacity:1.0000000;"
+ id="rect5928"
+ width="170.38249"
+ height="159.80026"
+ x="29.993284"
+ y="26.574797"
+ rx="17.594519"
+ ry="14.164467" />
+ <text
+ xml:space="preserve"
+ style="font-size:32px;font-style:normal;font-weight:normal;text-align:center;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Liberation Serif"
+ x="79.500122"
+ y="165.17741"
+ id="text2350"><tspan
+ sodipodi:role="line"
+ id="tspan2352"
+ x="79.500122"
+ y="165.17741">XYZ</tspan></text>
+</svg>
Modified: trunk/plugins/plot_surface/gog-contour.c
==============================================================================
--- trunk/plugins/plot_surface/gog-contour.c (original)
+++ trunk/plugins/plot_surface/gog-contour.c Fri Oct 31 10:23:59 2008
@@ -112,6 +112,11 @@
}
gog_axis_map_free (map);
g_free (x);
+ if (max < 2) { /* this might happen with bad 3d axis configuration */
+ g_free (data);
+ return NULL;
+ }
+
return data;
}
@@ -129,7 +134,6 @@
{
unsigned i, j, nticks;
char *label;
- static char separator = 0;
GogStyle *style = gog_style_new ();
GogTheme *theme = gog_object_get_theme (GOG_OBJECT (plot));
GogAxis *axis = plot->axis[GOG_AXIS_PSEUDO_3D];
@@ -137,13 +141,10 @@
GogAxisTick *zticks;
double *limits;
double minimum, maximum;
+ char const *separator = go_locale_get_decimal ()->str;
gog_axis_get_bounds (axis, &minimum, &maximum);
- if (separator == 0) {
- struct lconv *lc = localeconv ();
- separator = (strcmp (lc->decimal_point, ","))? ',': ';';
- }
nticks = gog_axis_get_ticks (axis, &zticks);
limits = g_new (double, nticks + 1);
for (i = j = 0; i < nticks; i++)
@@ -171,14 +172,14 @@
if (gog_axis_is_inverted (axis)) {
for (i = 0; i < j; i++) {
style->fill.pattern.back = color[i];
- label = g_strdup_printf ("[%g%c %g%c", limits[j - i - 1], separator,
+ label = g_strdup_printf ("[%g%s %g%c", limits[j - i - 1], separator,
limits[j - i], (limits[i - j] > minimum)? '[':']');
(func) (i, style, label, data);
g_free (label);
}
if (limits[i - j] > minimum) {
gog_theme_fillin_style (theme, style, GOG_OBJECT (plot->series->data), i, FALSE);
- label = g_strdup_printf ("[%g%c %g]", minimum, separator,
+ label = g_strdup_printf ("[%g%s %g]", minimum, separator,
limits[i - j]);
(func) (i, style, label, data);
g_free (label);
@@ -186,7 +187,7 @@
} else {
if (minimum < limits[0]) {
style->fill.pattern.back = color[0];
- label = g_strdup_printf ("[%g%c %g]", minimum, separator,
+ label = g_strdup_printf ("[%g%s %g]", minimum, separator,
limits[0]);
(func) (0, style, label, data);
g_free (label);
@@ -196,7 +197,7 @@
i = 0;
for (; i < j; i++) {
style->fill.pattern.back = color[i];
- label = g_strdup_printf ("[%g%c %g%c", limits[i], separator,
+ label = g_strdup_printf ("[%g%s %g%c", limits[i], separator,
limits[i + 1], (i == j - 1)? ']':'[');
(func) (i, style, label, data);
g_free (label);
@@ -231,6 +232,7 @@
GogPlot *plot = GOG_PLOT (contour);
plot->render_before_axes = TRUE;
+ plot->vary_style_by_element = TRUE;
}
GSF_DYNAMIC_CLASS (GogContourPlot, gog_contour_plot,
@@ -307,8 +309,8 @@
if (xdiscrete) {
x0 = gog_axis_map_to_view (x_map, 0.);
x1 = gog_axis_map_to_view (x_map, 1.);
- }else {
- x_vec = GO_DATA_VECTOR (series->values[(plot->transposed)? 1: 0].data);
+ } else {
+ x_vec = gog_xyz_plot_get_x_vals (GOG_XYZ_PLOT (plot));
x0 = gog_axis_map_to_view (x_map, go_data_vector_get_value (x_vec, 0));
x1 = gog_axis_map_to_view (x_map, go_data_vector_get_value (x_vec, 1));
}
@@ -317,8 +319,8 @@
if (ydiscrete) {
y0 = gog_axis_map_to_view (y_map, 0.);
y1 = gog_axis_map_to_view (y_map, 1.);
- }else {
- y_vec = GO_DATA_VECTOR (series->values[(plot->transposed)? 0: 1].data);
+ } else {
+ y_vec = gog_xyz_plot_get_y_vals (GOG_XYZ_PLOT (plot));
y0 = gog_axis_map_to_view (y_map, go_data_vector_get_value (y_vec, 0));
y1 = gog_axis_map_to_view (y_map, go_data_vector_get_value (y_vec, 1));
}
@@ -326,6 +328,7 @@
style = gog_style_new ();
path = go_path_new ();
+ go_path_set_options (path, GO_PATH_OPTIONS_SHARP);
/* build the colors table */
color = g_new0 (GOColor, max);
if (max < 2)
@@ -345,14 +348,9 @@
style->disable_theming = GOG_STYLE_ALL;
style->fill.type = GOG_FILL_STYLE_PATTERN;
style->fill.pattern.pattern = GO_PATTERN_SOLID;
- style->outline.dash_type = GO_LINE_SOLID;
- style->outline.auto_dash = FALSE;
- style->outline.auto_color = FALSE;
- style->outline.width = 1.; /* seems a lower value shows grid effects */
- style->outline.color = RGBA_BLACK;
lines = go_path_new ();
-
+
for (j = 1; j < jmax; j++) {
if (xdiscrete) {
x0 = gog_axis_map_to_view (x_map, j);
@@ -478,7 +476,7 @@
for (k = 1; k < s; k++)
go_path_line_to (path, x[k], y[k]);
/* narrow parameter is TRUE below to avoid border effects */
- gog_renderer_draw_shape (rend, path);
+ gog_renderer_fill_shape (rend, path);
go_path_clear (path);
gog_renderer_pop_style (rend);
} else {
@@ -533,10 +531,11 @@
go_path_line_to (path, xl[0], yl[0]);
go_path_line_to (lines, xl[0], yl[0]);
gog_renderer_push_style (rend, style);
- gog_renderer_draw_shape (rend, path);
+ gog_renderer_fill_shape (rend, path);
go_path_clear (path);
gog_renderer_pop_style (rend);
while (k < zn) {
+
style->outline.color = color[k];
style->fill.pattern.back = color[k];
k++;
@@ -551,11 +550,11 @@
t = (k - zval[0]) / (zval[1] - zval[0]);
xl[0] = x[0] + t * (x[1] - x[0]);
yl[0] =y[0] + t * (y[1] - y[0]);
- go_path_line_to (path, xl[7], yl[7]);
- go_path_line_to (lines, xl[7], yl[7]);
+ go_path_line_to (path, xl[0], yl[0]);
+ go_path_line_to (lines, xl[0], yl[0]);
go_path_line_to (path, xc, yc);
gog_renderer_push_style (rend, style);
- gog_renderer_draw_shape (rend, path);
+ gog_renderer_fill_shape (rend, path);
go_path_clear (path);
gog_renderer_pop_style (rend);
}
@@ -578,7 +577,7 @@
go_path_line_to (path, xl[4], yl[4]);
go_path_line_to (lines, xl[4], yl[4]);
gog_renderer_push_style (rend, style);
- gog_renderer_draw_shape (rend, path);
+ gog_renderer_fill_shape (rend, path);
go_path_clear (path);
gog_renderer_pop_style (rend);
while (k < zn) {
@@ -600,7 +599,7 @@
go_path_line_to (lines, xl[4], yl[4]);
go_path_line_to (path, xc, yc);
gog_renderer_push_style (rend, style);
- gog_renderer_draw_shape (rend, path);
+ gog_renderer_fill_shape (rend, path);
go_path_clear (path);
gog_renderer_pop_style (rend);
}
@@ -625,7 +624,7 @@
style->outline.color = color[k];
style->fill.pattern.back = color[k];
gog_renderer_push_style (rend, style);
- gog_renderer_draw_shape (rend, path);
+ gog_renderer_fill_shape (rend, path);
go_path_clear (path);
gog_renderer_pop_style (rend);
k--;
@@ -647,7 +646,7 @@
style->outline.color = color[k];
style->fill.pattern.back = color[k];
gog_renderer_push_style (rend, style);
- gog_renderer_draw_shape (rend, path);
+ gog_renderer_fill_shape (rend, path);
go_path_clear (path);
gog_renderer_pop_style (rend);
k--;
@@ -672,7 +671,7 @@
style->outline.color = color[k];
style->fill.pattern.back = color[k];
gog_renderer_push_style (rend, style);
- gog_renderer_draw_shape (rend, path);
+ gog_renderer_fill_shape (rend, path);
go_path_clear (path);
gog_renderer_pop_style (rend);
k--;
@@ -694,7 +693,7 @@
style->outline.color = color[k];
style->fill.pattern.back = color[k];
gog_renderer_push_style (rend, style);
- gog_renderer_draw_shape (rend, path);
+ gog_renderer_fill_shape (rend, path);
go_path_clear (path);
gog_renderer_pop_style (rend);
k--;
@@ -735,7 +734,7 @@
style->outline.color = color[zn];
style->fill.pattern.back = color[zn];
gog_renderer_push_style (rend, style);
- gog_renderer_draw_shape (rend, path);
+ gog_renderer_fill_shape (rend, path);
go_path_clear (path);
if (xl[4] < 0.)
go_path_move_to (path, x[2], y[2]);
@@ -746,7 +745,7 @@
go_path_line_to (path, xb[2], yb[2]);
if (xl[4] >= 0.)
go_path_line_to (path, xl[4], yl[4]);
- gog_renderer_draw_shape (rend, path);
+ gog_renderer_fill_shape (rend, path);
go_path_clear (path);
gog_renderer_pop_style (rend);
if (xl[2] < 0.)
@@ -761,7 +760,7 @@
style->outline.color = color[zx];
style->fill.pattern.back = color[zx];
gog_renderer_push_style (rend, style);
- gog_renderer_draw_shape (rend, path);
+ gog_renderer_fill_shape (rend, path);
go_path_clear (path);
if (xl[6] < 0.)
go_path_move_to (path, x[3], y[3]);
@@ -772,19 +771,20 @@
go_path_line_to (path, xb[3], yb[3]);
if (xl[6] >= 0.)
go_path_line_to (path, xl[6], yl[6]);
- gog_renderer_draw_shape (rend, path);
+ gog_renderer_fill_shape (rend, path);
go_path_clear (path);
gog_renderer_pop_style (rend);
} else {
if (up) {
/* saddle point is in the lower slice */
/* draw the upper slices */
- if (xl[1] < 0.)
+ if (xl[1] < 0.) {
go_path_move_to (path, x[1], y[1]);
- else {
+ xc = -1;
+ } else {
go_path_move_to (path, xl[1], yl[1]);
xc = xl[2];
- xc = yl[2];
+ yc = yl[2];
}
t = (zx - zval[1]) / (zval[0] - zval[1]);
xl[1] = x[1] + t * (x[0] - x[1]);
@@ -796,19 +796,20 @@
yl[2] = y[1] + t * (y[2] - y[1]);
go_path_line_to (lines, xl[2], yl[2]);
go_path_line_to (path, xl[2], yl[2]);
- if (xl[1] >= 0.)
+ if (xc >= 0.)
go_path_line_to (path, xc, yc);
style->outline.color = color[zx];
style->fill.pattern.back = color[zx];
gog_renderer_push_style (rend, style);
- gog_renderer_draw_shape (rend, path);
+ gog_renderer_fill_shape (rend, path);
go_path_clear (path);
- if (xl[5] < 0.)
+ if (xl[5] < 0.) {
go_path_move_to (path, x[3], y[3]);
- else {
+ xc = -1;
+ } else {
go_path_move_to (path, xl[5], yl[5]);
xc = xl[6];
- xc = yl[6];
+ yc = yl[6];
}
t = (zx - zval[3]) / (zval[2] - zval[3]);
xl[5] = x[3] + t * (x[2] - x[3]);
@@ -820,19 +821,20 @@
yl[6] = y[3] + t * (y[0] - y[3]);
go_path_line_to (lines, xl[6], yl[6]);
go_path_line_to (path, xl[6], yl[6]);
- if (xl[1] >= 0.)
+ if (xc >= 0.)
go_path_line_to (path, xc, yc);
- gog_renderer_draw_shape (rend, path);
+ gog_renderer_fill_shape (rend, path);
go_path_clear (path);
gog_renderer_pop_style (rend);
} else {
/* saddle point is in the upper slice */
- if (xl[0] < 0.)
+ if (xl[0] < 0.) {
go_path_move_to (path, x[0], y[0]);
- else {
+ xc = -1.;
+ } else {
go_path_move_to (path, xl[7], yl[7]);
xc = xl[0];
- xc = yl[0];
+ yc = yl[0];
}
t = (k - zval[0]) / (zval[3] - zval[0]);
xl[7] = x[0] + t * (x[3] - x[0]);
@@ -844,19 +846,20 @@
yl[0] = y[0] + t * (y[1] - y[0]);
go_path_line_to (lines, xl[0], yl[0]);
go_path_line_to (path, xl[0], yl[0]);
- if (xl[1] >= 0.)
+ if (xc >= 0.)
go_path_line_to (path, xc, yc);
style->outline.color = color[zn];
style->fill.pattern.back = color[zn];
gog_renderer_push_style (rend, style);
- gog_renderer_draw_shape (rend, path);
+ gog_renderer_fill_shape (rend, path);
go_path_clear (path);
- if (xl[4] < 0.)
+ if (xl[4] < 0.) {
go_path_move_to (path, x[2], y[2]);
- else {
+ xc = -1.;
+ } else {
go_path_move_to (path, xl[3], yl[3]);
xc = xl[4];
- xc = yl[4];
+ yc = yl[4];
}
t = (k - zval[2]) / (zval[1] - zval[2]);
xl[3] = x[2] + t * (x[1] - x[2]);
@@ -868,9 +871,9 @@
yl[4] = y[2] + t * (y[3] - y[2]);
go_path_line_to (lines, xl[4], yl[4]);
go_path_line_to (path, xl[4], yl[4]);
- if (xl[1] >= 0.)
+ if (xc >= 0.)
go_path_line_to (path, xc, yc);
- gog_renderer_draw_shape (rend, path);
+ gog_renderer_fill_shape (rend, path);
go_path_clear (path);
gog_renderer_pop_style (rend);
zn = zx;
@@ -891,7 +894,7 @@
style->outline.color = color[zn];
style->fill.pattern.back = color[zn];
gog_renderer_push_style (rend, style);
- gog_renderer_draw_shape (rend, path);
+ gog_renderer_fill_shape (rend, path);
go_path_clear (path);
gog_renderer_pop_style (rend);
}
@@ -911,7 +914,7 @@
style->outline.color = color[zx];
style->fill.pattern.back = color[zx];
gog_renderer_push_style (rend, style);
- gog_renderer_draw_shape (rend, path);
+ gog_renderer_fill_shape (rend, path);
go_path_clear (path);
gog_renderer_pop_style (rend);
}
@@ -987,7 +990,7 @@
}
}
s = r + 1;
- gog_renderer_draw_shape (rend, path);
+ gog_renderer_fill_shape (rend, path);
go_path_clear (path);
gog_renderer_pop_style (rend);
go_path_move_to (path, x1, y1);
@@ -1011,13 +1014,14 @@
style->outline.color = color[zmin];
style->fill.pattern.back = color[zmin];
gog_renderer_push_style (rend, style);
- gog_renderer_draw_shape (rend, path);
+ gog_renderer_fill_shape (rend, path);
go_path_clear (path);
gog_renderer_pop_style (rend);
}
}
}
}
+
gog_renderer_push_style (rend, GOG_STYLED_OBJECT (series)->style);
gog_renderer_stroke_serie (rend, lines);
gog_renderer_pop_style (rend);
@@ -1038,4 +1042,3 @@
GSF_DYNAMIC_CLASS (GogContourView, gog_contour_view,
gog_contour_view_class_init, NULL,
GOG_PLOT_VIEW_TYPE)
-
Modified: trunk/plugins/plot_surface/gog-xyz-surface.c
==============================================================================
--- trunk/plugins/plot_surface/gog-xyz-surface.c (original)
+++ trunk/plugins/plot_surface/gog-xyz-surface.c Fri Oct 31 10:23:59 2008
@@ -41,8 +41,11 @@
XYZ_SURFACE_PROP_COLUMNS
};
+static GogObjectClass *plot_xyz_contour_parent_klass;
static GogObjectClass *plot_xyz_surface_parent_klass;
+#define EPSILON 1e-13
+
static double *
gog_xyz_surface_plot_build_matrix (GogXYZPlot const *plot, gboolean *cardinality_changed)
{
@@ -80,12 +83,81 @@
if (grid[k] != 0)
data[k] /= grid[k];
- *cardinality_changed = FALSE;
+ if (GOG_IS_PLOT_CONTOUR (plot)) {
+ GogAxisMap *map;
+ GogAxisTick *zticks;
+ GogAxis *axis = plot->base.axis[GOG_AXIS_PSEUDO_3D];
+ unsigned nticks;
+ double *x, val, minimum, maximum, slope, offset = 0.;
+ unsigned max;
+
+ if (!gog_axis_get_bounds (axis, &minimum, &maximum)) {
+ g_free (grid);
+ g_free (data);
+ return NULL;
+ }
+ nticks = gog_axis_get_ticks (axis, &zticks);
+ map = gog_axis_map_new (axis, 0, 1);
+ x = g_new (double, nticks);
+ for (i = j = 0; i < nticks; i++)
+ if (zticks[i].type == GOG_AXIS_TICK_MAJOR) {
+ x[j++] = gog_axis_map_to_view (map, zticks[i].position);
+ }
+ max = --j;
+ if (x[1] > x[0]) {
+ if (x[0] > EPSILON) {
+ offset = 1.;
+ max++;
+ }
+ if (x[j] < 1. - EPSILON)
+ max++;
+ slope = 1 / (x[1] - x[0]);
+ } else {
+ offset = j;
+ if (x[0] < 1. - EPSILON)
+ max++;
+ if (x[j] > EPSILON) {
+ max++;
+ offset += 1.;
+ }
+ slope = 1 / (x[0] - x[1]);
+ }
+ for (k = 0; k < n; ++k) {
+ val = gog_axis_map_to_view (map, data[k]);
+ if (fabs (val) == DBL_MAX)
+ val = go_nan;
+ else {
+ val = offset + slope * (val - x[0]);
+ if (val < 0)
+ val = (val < -EPSILON)? go_nan: 0.;
+ }
+ data[k] = val;
+ }
+ if (series->num_elements != max) {
+ series->num_elements = max;
+ *cardinality_changed = TRUE;
+ }
+ gog_axis_map_free (map);
+ g_free (x);
+ if (max < 2) { /* this might happen with bad 3d axis configuration */
+ g_free (data);
+ data = NULL;
+ }
+ } else
+ *cardinality_changed = FALSE;
g_free (grid);
return data;
}
static char const *
+gog_xyz_contour_plot_type_name (G_GNUC_UNUSED GogObject const *item)
+{
+ /* xgettext : the base for how to name surface plot objects
+ */
+ return N_("PlotXYZContour");
+}
+
+static char const *
gog_xyz_surface_plot_type_name (G_GNUC_UNUSED GogObject const *item)
{
/* xgettext : the base for how to name surface plot objects
@@ -93,20 +165,22 @@
return N_("PlotXYZSurface");
}
-
#ifdef GOFFICE_WITH_GTK
-extern gpointer gog_xyz_surface_plot_pref (GogXYZSurfacePlot *plot, GOCmdContext *cc);
+extern gpointer gog_xyz_surface_plot_pref (GogXYZPlot *plot, GOCmdContext *cc);
static void
gog_xyz_surface_plot_populate_editor (GogObject *item,
GogEditor *editor,
G_GNUC_UNUSED GogDataAllocator *dalloc,
GOCmdContext *cc)
{
+ GogObjectClass *klass = (GOG_IS_PLOT_CONTOUR (item))?
+ plot_xyz_contour_parent_klass:
+ plot_xyz_surface_parent_klass;
+
gog_editor_add_page (editor,
- gog_xyz_surface_plot_pref (GOG_XYZ_SURFACE_PLOT (item), cc),
+ gog_xyz_surface_plot_pref (GOG_XYZ_PLOT (item), cc),
_("Properties"));
-
- (GOG_OBJECT_CLASS (plot_xyz_surface_parent_klass)->populate_editor) (item, editor, dalloc, cc);
+ (GOG_OBJECT_CLASS (klass)->populate_editor) (item, editor, dalloc, cc);
}
#endif
@@ -116,6 +190,9 @@
GogXYZPlot *model = GOG_XYZ_PLOT(obj);
GogXYZSeries *series;
double tmp_min, tmp_max;
+ GogObjectClass *klass = (GOG_IS_PLOT_CONTOUR (obj))?
+ plot_xyz_contour_parent_klass:
+ plot_xyz_surface_parent_klass;
if (model->base.series == NULL)
return;
@@ -158,11 +235,11 @@
model->z.fmt = go_data_preferred_fmt (series->base.values[2].data);
model->z.minima = tmp_min;
model->z.maxima = tmp_max;
- gog_axis_bound_changed (model->base.axis[GOG_AXIS_Z], GOG_OBJECT (model));
+ gog_axis_bound_changed (model->base.axis[((GOG_IS_PLOT_CONTOUR (model))? GOG_AXIS_PSEUDO_3D: GOG_AXIS_Z)], GOG_OBJECT (model));
gog_object_emit_changed (GOG_OBJECT (obj), FALSE);
- if (plot_xyz_surface_parent_klass->update)
- plot_xyz_surface_parent_klass->update (obj);
+ if (klass->update)
+ klass->update (obj);
}
static void
@@ -221,14 +298,12 @@
}
static void
-gog_xyz_surface_plot_class_init (GogXYZPlotClass *klass)
+common_init_class (GogXYZPlotClass *klass)
{
GogPlotClass *gog_plot_klass = (GogPlotClass*) klass;
GObjectClass *gobject_klass = (GObjectClass *) klass;
GogObjectClass *gog_object_klass = (GogObjectClass *) klass;
- plot_xyz_surface_parent_klass = g_type_class_peek_parent (klass);
-
gobject_klass->set_property = gog_xyz_surface_plot_set_property;
gobject_klass->get_property = gog_xyz_surface_plot_get_property;
g_object_class_install_property (gobject_klass, XYZ_SURFACE_PROP_ROWS,
@@ -244,7 +319,6 @@
2, 1000, 10,
GSF_PARAM_STATIC | G_PARAM_READWRITE | GO_PARAM_PERSISTENT));
- gog_object_klass->type_name = gog_xyz_surface_plot_type_name;
gog_object_klass->update = gog_xyz_surface_plot_update;
#ifdef GOFFICE_WITH_GTK
@@ -268,16 +342,33 @@
}
static void
-gog_xyz_surface_plot_init (GogXYZSurfacePlot *surface)
+gog_xyz_contour_plot_class_init (GogXYZPlotClass *klass)
+{
+ plot_xyz_contour_parent_klass = g_type_class_peek_parent (klass);
+ GOG_OBJECT_CLASS (klass)->type_name = gog_xyz_contour_plot_type_name;
+ common_init_class (klass);
+}
+
+static void
+gog_xyz_surface_plot_class_init (GogXYZPlotClass *klass)
{
- GogXYZPlot *xyz = GOG_XYZ_PLOT (surface);
+ plot_xyz_surface_parent_klass = g_type_class_peek_parent (klass);
+ GOG_OBJECT_CLASS (klass)->type_name = gog_xyz_surface_plot_type_name;
+ common_init_class (klass);
+}
+static void
+gog_xyz_surface_plot_init (GogXYZPlot *xyz)
+{
xyz->data_xyz = TRUE;
xyz->rows = 10;
xyz->columns = 10;
}
+GSF_DYNAMIC_CLASS (GogXYZContourPlot, gog_xyz_contour_plot,
+ gog_xyz_contour_plot_class_init, gog_xyz_surface_plot_init,
+ GOG_CONTOUR_PLOT_TYPE)
+
GSF_DYNAMIC_CLASS (GogXYZSurfacePlot, gog_xyz_surface_plot,
gog_xyz_surface_plot_class_init, gog_xyz_surface_plot_init,
GOG_SURFACE_PLOT_TYPE)
-
Modified: trunk/plugins/plot_surface/gog-xyz-surface.h
==============================================================================
--- trunk/plugins/plot_surface/gog-xyz-surface.h (original)
+++ trunk/plugins/plot_surface/gog-xyz-surface.h Fri Oct 31 10:23:59 2008
@@ -22,12 +22,31 @@
#ifndef GOG_XYZ_SURFACE_H
#define GOG_XYZ_SURFACE_H
+#include "gog-contour.h"
#include "gog-surface.h"
G_BEGIN_DECLS
/*-----------------------------------------------------------------------------
*
+ * GogXYZContourPlot
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+typedef GogContourPlot GogXYZContourPlot;
+typedef GogContourPlotClass GogXYZContourPlotClass;
+
+#define GOG_XYZ_CONTOUR_PLOT_TYPE (gog_xyz_contour_plot_get_type ())
+#define GOG_XYZ_CONTOUR_PLOT(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GOG_XYZ_CONTOUR_PLOT_TYPE, GogXYZContourPlot))
+#define GOG_IS_XYZ_CONTOUR_PLOT(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GOG_XYZ_CONTOUR_PLOT_TYPE))
+
+GType gog_xyz_contour_plot_get_type (void);
+
+void gog_xyz_contour_plot_register_type (GTypeModule *module);
+
+/*-----------------------------------------------------------------------------
+ *
* GogXYZSurfacePlot
*
*-----------------------------------------------------------------------------
Modified: trunk/plugins/plot_surface/gog-xyz.c
==============================================================================
--- trunk/plugins/plot_surface/gog-xyz.c (original)
+++ trunk/plugins/plot_surface/gog-xyz.c Fri Oct 31 10:23:59 2008
@@ -240,7 +240,7 @@
go_data_matrix_get_minmax (mat, &tmp_min, &tmp_max);
if ((tmp_min != model->z.minima)
|| (tmp_max != model->z.maxima)) {
- model->z.minima = tmp_min - 0.5 * fabs (tmp_max - tmp_min);
+ model->z.minima = tmp_min;
model->z.maxima = tmp_max;
gog_axis_bound_changed (
model->base.axis[GOG_XYZ_PLOT_GET_CLASS (model)->third_axis],
@@ -513,6 +513,7 @@
gog_contour_view_register_type (module);
gog_surface_plot_register_type (module);
gog_surface_view_register_type (module);
+ gog_xyz_contour_plot_register_type (module);
gog_xyz_surface_plot_register_type (module);
gog_xyz_series_register_type (module);
xl_xyz_series_register_type (module);
Modified: trunk/plugins/plot_surface/plot-types.xml.in
==============================================================================
--- trunk/plugins/plot_surface/plot-types.xml.in (original)
+++ trunk/plugins/plot_surface/plot-types.xml.in Fri Oct 31 10:23:59 2008
@@ -8,6 +8,11 @@
_description="Contour plot."
sample_image_file="chart_contour_1_1.png">
</Type>
+ <Type _name="XYZSurface" row="1" col="2"
+ engine="GogXYZContourPlot" family="Contour"
+ _description="Builds a contour from a set of points with three coordinates"
+ sample_image_file="chart_contour_2_1.png">
+ </Type>
<Type _name="Surface" row="1" col="1"
engine="GogSurfacePlot" family="Surface"
_description="Surface plot."
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]