[goffice] 2009-08-04 Jean Brefort <jean brefort normalesup org>
- From: Jean Bréfort <jbrefort src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [goffice] 2009-08-04 Jean Brefort <jean brefort normalesup org>
- Date: Tue, 4 Aug 2009 20:24:29 +0000 (UTC)
commit 0b67247fe010ea3543f0ed4590d5a1bd2d7e9c6a
Author: Jean Brefort <jean brefort normalesup org>
Date: Tue Aug 4 22:24:08 2009 +0200
2009-08-04 Jean Brefort <jean brefort normalesup org>
* goffice/graph/gog-series.c (gog_series_get_xy_data): fix tests.
* plugins/plot_distrib/gog-probability-plot.c: implement comparison line
for probability plots. [#590416]
* plugins/plot_distrib/plugin.c (go_plugin_init): ditto.
* plugins/plot_distrib/plugin.xml.in: ditto.
ChangeLog | 8 ++
NEWS | 1 +
goffice/graph/gog-series.c | 13 ++--
plugins/plot_distrib/gog-probability-plot.c | 108 +++++++++++++++++++++++++++
plugins/plot_distrib/plugin.c | 2 +
plugins/plot_distrib/plugin.xml.in | 3 +
6 files changed, 128 insertions(+), 7 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 40bba62..4bd27d0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2009-08-04 Jean Brefort <jean brefort normalesup org>
+
+ * goffice/graph/gog-series.c (gog_series_get_xy_data): fix tests.
+ * plugins/plot_distrib/gog-probability-plot.c: implement comparison line
+ for probability plots. [#590416]
+ * plugins/plot_distrib/plugin.c (go_plugin_init): ditto.
+ * plugins/plot_distrib/plugin.xml.in: ditto.
+
2009-08-02 Andreas J. Guelzow <aguelzow pyrshep ca>
* plugins/plot_distrib/plugin.xml.in: fix spelling
diff --git a/NEWS b/NEWS
index e260f63..a64830f 100644
--- a/NEWS
+++ b/NEWS
@@ -8,6 +8,7 @@ Andreas:
Jean:
* Align surface ticks with grid. [#585298]
* Fixed various contour plots related issues. [#589511, #589512]
+ * Comparison line for probability plots. [#590416]
Morten:
* Fix format localization problem. [#586567]
diff --git a/goffice/graph/gog-series.c b/goffice/graph/gog-series.c
index 3326918..643467c 100644
--- a/goffice/graph/gog-series.c
+++ b/goffice/graph/gog-series.c
@@ -1070,23 +1070,22 @@ gog_series_get_xy_data (GogSeries const *series,
GogSeriesClass *klass = GOG_SERIES_GET_CLASS (series);
double *data[2];
unsigned int n_points;
+ int first, last;
g_return_val_if_fail (klass != NULL, 0);
if (klass->get_xy_data != NULL) {
- int first, last;
-
if (!gog_series_is_valid (GOG_SERIES (series)))
return 0;
- gog_dataset_dims (GOG_DATASET (series), &first, &last);
-
- g_return_val_if_fail (first <= 0, 0);
- g_return_val_if_fail (last >= 1, 0);
-
return (klass->get_xy_data) (series, x, y);
}
+ gog_dataset_dims (GOG_DATASET (series), &first, &last);
+
+ g_return_val_if_fail (first <= 0, 0);
+ g_return_val_if_fail (last >= 1, 0);
+
n_points = gog_series_get_data (series, NULL, data, 2);
*x = data[0];
diff --git a/plugins/plot_distrib/gog-probability-plot.c b/plugins/plot_distrib/gog-probability-plot.c
index a7c96f7..af89f42 100644
--- a/plugins/plot_distrib/gog-probability-plot.c
+++ b/plugins/plot_distrib/gog-probability-plot.c
@@ -359,9 +359,14 @@ gog_probability_plot_view_render (GogView *view, GogViewAllocation const *bbox)
GogProbabilityPlotSeries const *series;
unsigned i, nb;
GOStyle *style;
+ GSList *ptr;
if (model->base.series == NULL)
return;
+
+ for (ptr = view->children ; ptr != NULL ; ptr = ptr->next)
+ gog_view_render (ptr->data, bbox);
+
series = GOG_PROBABILITY_PLOT_SERIES (model->base.series->data);
nb = series->base.num_elements;
style = GOG_STYLED_OBJECT (series)->style;
@@ -393,10 +398,20 @@ gog_probability_plot_view_render (GogView *view, GogViewAllocation const *bbox)
static GogViewClass *probability_plot_view_parent_klass;
static void
+gog_probability_plot_view_size_allocate (GogView *view, GogViewAllocation const *allocation)
+{
+ GSList *ptr;
+ for (ptr = view->children; ptr != NULL; ptr = ptr->next)
+ gog_view_size_allocate (GOG_VIEW (ptr->data), allocation);
+ (probability_plot_view_parent_klass->size_allocate) (view, allocation);
+}
+
+static void
gog_probability_plot_view_class_init (GogViewClass *view_klass)
{
probability_plot_view_parent_klass = (GogViewClass*) g_type_class_peek_parent (view_klass);
view_klass->render = gog_probability_plot_view_render;
+ view_klass->size_allocate = gog_probability_plot_view_size_allocate;
view_klass->clip = FALSE;
}
@@ -404,6 +419,66 @@ GSF_DYNAMIC_CLASS (GogProbabilityPlotView, gog_probability_plot_view,
gog_probability_plot_view_class_init, NULL,
GOG_TYPE_PLOT_VIEW)
+
+/*****************************************************************************/
+
+static gboolean
+regression_curve_can_add (GogObject const *parent)
+{
+ return (gog_object_get_child_by_name (parent, "Regression line") == NULL);
+}
+
+static void
+regression_curve_post_add (GogObject *parent, GogObject *child)
+{
+ gog_object_request_update (child);
+}
+
+static void
+regression_curve_pre_remove (GogObject *parent, GogObject *child)
+{
+}
+
+/*****************************************************************************/
+
+typedef GogView GogProbabilityPlotSeriesView;
+typedef GogViewClass GogProbabilityPlotSeriesViewClass;
+
+#define GOG_TYPE_PROBABILITY_SERIES_VIEW (gog_probability_plot_series_view_get_type ())
+#define GOG__PROBABILITY_SERIES_VIEW(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GOG_TYPE__PROBABILITY_SERIES_VIEW, GogProbabilityPlotSeriesView))
+#define GOG_IS__PROBABILITY_SERIES_VIEW(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GOG_TYPE__PROBABILITY_SERIES_VIEW))
+
+GType gog_probability_plot_series_view_get_type (void);
+
+static void
+gog_probability_plot_series_view_render (GogView *view, GogViewAllocation const *bbox)
+{
+ GSList *ptr;
+ for (ptr = view->children ; ptr != NULL ; ptr = ptr->next)
+ gog_view_render (ptr->data, bbox);
+}
+
+static void
+gog_probability_plot_series_view_size_allocate (GogView *view, GogViewAllocation const *allocation)
+{
+ GSList *ptr;
+
+ for (ptr = view->children; ptr != NULL; ptr = ptr->next)
+ gog_view_size_allocate (GOG_VIEW (ptr->data), allocation);
+}
+
+static void
+gog_probability_plot_series_view_class_init (GogProbabilityPlotSeriesViewClass *gview_klass)
+{
+ GogViewClass *view_klass = GOG_VIEW_CLASS (gview_klass);
+ view_klass->render = gog_probability_plot_series_view_render;
+ view_klass->size_allocate = gog_probability_plot_series_view_size_allocate;
+ view_klass->build_toolkit = NULL;
+}
+
+GSF_DYNAMIC_CLASS (GogProbabilityPlotSeriesView, gog_probability_plot_series_view,
+ gog_probability_plot_series_view_class_init, NULL,
+ GOG_TYPE_VIEW)
/****************************************************************************/
static GogObjectClass *gog_probability_plot_series_parent_klass;
@@ -418,6 +493,7 @@ gog_probability_plot_series_update (GogObject *obj)
double mn, d;
unsigned i;
GODistribution *dist = GO_DISTRIBUTION (((GogProbabilityPlot *) series->base.plot)->dist);
+ GSList *ptr;
g_free (series->x);
series->x = NULL;
@@ -442,6 +518,11 @@ gog_probability_plot_series_update (GogObject *obj)
} else
series->y = NULL;
+ /* update children */
+ for (ptr = obj->children; ptr != NULL; ptr = ptr->next)
+ if (!GOG_IS_SERIES_LINES (ptr->data))
+ gog_object_request_update (GOG_OBJECT (ptr->data));
+
/* queue plot for redraw */
gog_object_request_update (GOG_OBJECT (series->base.plot));
@@ -449,6 +530,17 @@ gog_probability_plot_series_update (GogObject *obj)
gog_probability_plot_series_parent_klass->update (obj);
}
+static unsigned
+gog_probability_plot_series_get_xy_data (GogSeries const *series,
+ double const **x,
+ double const **y)
+{
+ GogProbabilityPlotSeries *ppseries = GOG_PROBABILITY_PLOT_SERIES (series);
+ *x = ppseries->x;
+ *y = ppseries->y;
+ return series->num_elements;
+}
+
static void
gog_probability_plot_series_finalize (GObject *obj)
{
@@ -466,12 +558,28 @@ static void
gog_probability_plot_series_class_init (GogObjectClass *obj_klass)
{
GObjectClass *gobject_klass = (GObjectClass *) obj_klass;
+ GogSeriesClass *series_klass = (GogSeriesClass *) obj_klass;
+
+ static GogObjectRole const roles[] = {
+ { N_("Regression line"), "GogLinRegCurve", 0,
+ GOG_POSITION_SPECIAL, GOG_POSITION_SPECIAL, GOG_OBJECT_NAME_BY_ROLE,
+ regression_curve_can_add,
+ NULL,
+ NULL,
+ regression_curve_post_add,
+ regression_curve_pre_remove,
+ NULL }
+ };
series_parent_klass = g_type_class_peek_parent (obj_klass);
gobject_klass->finalize = gog_probability_plot_series_finalize;
gog_probability_plot_series_parent_klass = g_type_class_peek_parent (obj_klass);
obj_klass->update = gog_probability_plot_series_update;
+ obj_klass->view_type = gog_probability_plot_series_view_get_type ();
+ gog_object_register_roles (obj_klass, roles, G_N_ELEMENTS (roles));
+
+ series_klass->get_xy_data = gog_probability_plot_series_get_xy_data;
}
GSF_DYNAMIC_CLASS (GogProbabilityPlotSeries, gog_probability_plot_series,
diff --git a/plugins/plot_distrib/plugin.c b/plugins/plot_distrib/plugin.c
index 28784c4..829d3b5 100644
--- a/plugins/plot_distrib/plugin.c
+++ b/plugins/plot_distrib/plugin.c
@@ -35,6 +35,7 @@ void gog_histogram_series_view_register_type (GTypeModule *module);
void gog_probability_plot_register_type (GTypeModule *module);
void gog_probability_plot_series_register_type (GTypeModule *module);
void gog_probability_plot_view_register_type (GTypeModule *module);
+void gog_probability_plot_series_view_register_type (GTypeModule *module);
G_MODULE_EXPORT void
go_plugin_init (GOPlugin *plugin, GOCmdContext *cc)
@@ -50,6 +51,7 @@ go_plugin_init (GOPlugin *plugin, GOCmdContext *cc)
gog_probability_plot_register_type (module);
gog_probability_plot_view_register_type (module);
gog_probability_plot_series_register_type (module);
+ gog_probability_plot_series_view_register_type (module);
}
G_MODULE_EXPORT void
diff --git a/plugins/plot_distrib/plugin.xml.in b/plugins/plot_distrib/plugin.xml.in
index 20adf3b..38a3e2f 100644
--- a/plugins/plot_distrib/plugin.xml.in
+++ b/plugins/plot_distrib/plugin.xml.in
@@ -4,6 +4,9 @@
<_name>Charting : distribution related plots</_name>
<_description>box-plots, histograms, and other distribution related plots</_description>
</information>
+ <dependencies>
+ <dep_plugin id="GOffice_reg_linear" force_load="1"/>
+ </dependencies>
<loader type="Gnumeric_Builtin:module">
<attribute name="module_file" value="distrib"/>
</loader>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]