[goffice] GOData/graphs: track date conventions.
- From: Morten Welinder <mortenw src gnome org>
- To: svn-commits-list gnome org
- Subject: [goffice] GOData/graphs: track date conventions.
- Date: Mon, 18 May 2009 15:21:01 -0400 (EDT)
commit d057793cbb3ea79ff59cb1d88cc08434706267ad
Author: Morten Welinder <terra gnome org>
Date: Mon May 18 15:20:31 2009 -0400
GOData/graphs: track date conventions.
---
ChangeLog | 6 ++++++
NEWS | 1 +
goffice/data/go-data-impl.h | 2 ++
goffice/data/go-data.c | 19 ++++++++++++++++++-
goffice/data/go-data.h | 2 ++
goffice/graph/gog-plot.h | 1 -
plugins/plot_barcol/gog-1.5d.c | 6 ++++++
plugins/plot_barcol/gog-1.5d.h | 2 ++
plugins/plot_distrib/gog-histogram.c | 6 ++++++
plugins/plot_distrib/gog-histogram.h | 1 +
plugins/plot_surface/gog-xyz-surface.c | 3 +++
plugins/plot_surface/gog-xyz.c | 8 ++++++++
plugins/plot_surface/gog-xyz.h | 1 +
plugins/plot_xy/gog-xy.c | 10 ++++++++++
plugins/plot_xy/gog-xy.h | 2 ++
15 files changed, 68 insertions(+), 2 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 3fff920..63fded1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2009-05-18 Morten Welinder <terra gnome org>
+
+ * goffice/data/go-data-impl.h (GODataClass): New member date_conv.
+ * goffice/data/go-data.c (go_data_date_conv): New function.
+ * plugins/plot_*/*.c: track date conventions from data as formats.
+
2009-05-16 Morten Welinder <terra gnome org>
* goffice/data/go-data-simple.c (go_data_vector_val_serialize,
diff --git a/NEWS b/NEWS
index a42393e..1779d0e 100644
--- a/NEWS
+++ b/NEWS
@@ -5,6 +5,7 @@ Andreas:
Morten:
* Add "pristine" as GODoc property.
+ * Properly handle date conventions in graphs.
--------------------------------------------------------------------------
goffice 0.7.6:
diff --git a/goffice/data/go-data-impl.h b/goffice/data/go-data-impl.h
index 643f796..d3f60c4 100644
--- a/goffice/data/go-data-impl.h
+++ b/goffice/data/go-data-impl.h
@@ -45,6 +45,8 @@ typedef struct {
GOData * (*dup) (GOData const *src);
gboolean (*eq) (GOData const *a, GOData const *b);
GOFormat * (*preferred_fmt) (GOData const *dat);
+ GODateConventions const*(*date_conv) (GOData const *dat);
+
char * (*serialize) (GOData const *dat, gpointer user);
gboolean (*unserialize) (GOData *dat, char const *str, gpointer user);
void (*emit_changed) (GOData *dat);
diff --git a/goffice/data/go-data.c b/goffice/data/go-data.c
index 6363cc9..2c49716 100644
--- a/goffice/data/go-data.c
+++ b/goffice/data/go-data.c
@@ -151,11 +151,28 @@ go_data_preferred_fmt (GOData const *dat)
GODataClass const *klass = GO_DATA_GET_CLASS (dat);
g_return_val_if_fail (klass != NULL, NULL);
if (klass->preferred_fmt)
- return (*klass->preferred_fmt) (dat);
+ return klass->preferred_fmt (dat);
return NULL;
}
/**
+ * go_data_date_conv :
+ * @dat : #GOData
+ *
+ * Returns: the date conventions used by the data, or NULL if not determined.
+ **/
+GODateConventions const *
+go_data_date_conv (GOData const *dat)
+{
+ GODataClass const *klass = GO_DATA_GET_CLASS (dat);
+ g_return_val_if_fail (klass != NULL, NULL);
+ if (klass->date_conv)
+ return klass->date_conv (dat);
+ return NULL;
+}
+
+
+/**
* go_data_serialize :
* @dat : #GOData
* @user : a gpointer describing the context.
diff --git a/goffice/data/go-data.h b/goffice/data/go-data.h
index 88882f3..884ee32 100644
--- a/goffice/data/go-data.h
+++ b/goffice/data/go-data.h
@@ -36,6 +36,8 @@ GType go_data_get_type (void);
GOData * go_data_dup (GOData const *src);
gboolean go_data_eq (GOData const *a, GOData const *b);
GOFormat * go_data_preferred_fmt (GOData const *dat);
+GODateConventions const *go_data_date_conv (GOData const *dat);
+
char * go_data_serialize (GOData const *dat, gpointer user);
gboolean go_data_unserialize (GOData *dat, char const *str, gpointer user);
void go_data_emit_changed (GOData *dat);
diff --git a/goffice/graph/gog-plot.h b/goffice/graph/gog-plot.h
index abdf9be..5dc4d93 100644
--- a/goffice/graph/gog-plot.h
+++ b/goffice/graph/gog-plot.h
@@ -36,7 +36,6 @@ typedef struct {
gboolean center_on_ticks;
GOFormat *fmt;
- /* Note: apart from NULL, don't expect anything here yet. */
const GODateConventions *date_conv;
} GogPlotBoundInfo;
diff --git a/plugins/plot_barcol/gog-1.5d.c b/plugins/plot_barcol/gog-1.5d.c
index 9472858..ebaefd9 100644
--- a/plugins/plot_barcol/gog-1.5d.c
+++ b/plugins/plot_barcol/gog-1.5d.c
@@ -205,6 +205,7 @@ gog_plot1_5d_update (GogObject *obj)
}
if (model->fmt == NULL)
model->fmt = go_data_preferred_fmt (series->base.values[1].data);
+ model->date_conv = go_data_date_conv (series->base.values[1].data);
index_dim = GOG_SERIES (series)->values[0].data;
}
axis = gog_plot1_5d_get_index_axis (model);
@@ -281,6 +282,10 @@ gog_plot1_5d_axis_get_bounds (GogPlot *plot, GogAxisType axis,
}
} else if (bounds->fmt == NULL && model->fmt != NULL)
bounds->fmt = go_format_ref (model->fmt);
+
+ if (model->date_conv)
+ bounds->date_conv = model->date_conv;
+
return NULL;
} else if (axis == gog_axis_get_atype (gog_plot1_5d_get_index_axis (model))) {
GSList *ptr;
@@ -366,6 +371,7 @@ static void
gog_plot1_5d_init (GogPlot1_5d *plot)
{
plot->fmt = NULL;
+ plot->date_conv = NULL;
plot->in_3d = FALSE;
plot->support_series_lines = FALSE;
plot->support_drop_lines = FALSE;
diff --git a/plugins/plot_barcol/gog-1.5d.h b/plugins/plot_barcol/gog-1.5d.h
index 7bea267..d6982a5 100644
--- a/plugins/plot_barcol/gog-1.5d.h
+++ b/plugins/plot_barcol/gog-1.5d.h
@@ -47,7 +47,9 @@ typedef struct {
unsigned int support_drop_lines : 1;
unsigned int support_lines : 1;
GOFormat *fmt;
+ GODateConventions const *date_conv;
} GogPlot1_5d;
+
typedef struct {
GogPlotClass base;
diff --git a/plugins/plot_distrib/gog-histogram.c b/plugins/plot_distrib/gog-histogram.c
index be7d143..7b9b2cd 100644
--- a/plugins/plot_distrib/gog-histogram.c
+++ b/plugins/plot_distrib/gog-histogram.c
@@ -92,6 +92,7 @@ gog_histogram_plot_update (GogObject *obj)
x_max = x_vals[series->base.num_elements];
if (model->x.fmt == NULL)
model->x.fmt = go_data_preferred_fmt (series->base.values[0].data);
+ model->x.date_conv = go_data_date_conv (series->base.values[0].data);
for (i = 0; i < series->base.num_elements; i++)
series->x[i] = (x_vals[i] + x_vals[i+1]) / 2;
} else {
@@ -125,6 +126,7 @@ gog_histogram_plot_update (GogObject *obj)
go_data_get_bounds (series->base.values[1].data, &y_min, &y_max);
if (model->y.fmt == NULL)
model->y.fmt = go_data_preferred_fmt (series->base.values[1].data);
+ model->y.date_conv = go_data_date_conv (series->base.values[1].data);
}
if (y_min > y_max)
y_min = y_max = go_nan;
@@ -148,11 +150,15 @@ gog_histogram_plot_axis_get_bounds (GogPlot *plot, GogAxisType axis,
bounds->val.maxima = model->x.maxima;
if (bounds->fmt == NULL && model->x.fmt != NULL)
bounds->fmt = go_format_ref (model->x.fmt);
+ if (model->x.date_conv)
+ bounds->date_conv = model->x.date_conv;
} else {
bounds->val.minima = model->y.minima;
bounds->val.maxima = model->y.maxima;
if (bounds->fmt == NULL && model->y.fmt != NULL)
bounds->fmt = go_format_ref (model->y.fmt);
+ if (model->y.date_conv)
+ bounds->date_conv = model->y.date_conv;
}
bounds->is_discrete = FALSE;
return NULL;
diff --git a/plugins/plot_distrib/gog-histogram.h b/plugins/plot_distrib/gog-histogram.h
index 32735ec..43a7a38 100644
--- a/plugins/plot_distrib/gog-histogram.h
+++ b/plugins/plot_distrib/gog-histogram.h
@@ -32,6 +32,7 @@ typedef struct {
struct {
double minima, maxima;
GOFormat *fmt;
+ GODateConventions const *date_conv;
} x, y;
} GogHistogramPlot;
typedef GogPlotClass GogHistogramPlotClass;
diff --git a/plugins/plot_surface/gog-xyz-surface.c b/plugins/plot_surface/gog-xyz-surface.c
index 8f72b03..63ae34f 100644
--- a/plugins/plot_surface/gog-xyz-surface.c
+++ b/plugins/plot_surface/gog-xyz-surface.c
@@ -208,6 +208,7 @@ gog_xyz_surface_plot_update (GogObject *obj)
tmp_max = go_data_get_vector_size (series->base.values[0].data);
} else if (model->x.fmt == NULL)
model->x.fmt = go_data_preferred_fmt (series->base.values[0].data);
+ model->x.date_conv = go_data_date_conv (series->base.values[0].data);
model->x.minima = tmp_min;
model->x.maxima = tmp_max;
gog_axis_bound_changed (model->base.axis[GOG_AXIS_X], GOG_OBJECT (model));
@@ -219,6 +220,7 @@ gog_xyz_surface_plot_update (GogObject *obj)
tmp_max = go_data_get_vector_size (series->base.values[1].data);
} else if (model->y.fmt == NULL)
model->y.fmt = go_data_preferred_fmt (series->base.values[1].data);
+ model->y.date_conv = go_data_date_conv (series->base.values[1].data);
model->y.minima = tmp_min;
model->y.maxima = tmp_max;
gog_axis_bound_changed (model->base.axis[GOG_AXIS_Y], GOG_OBJECT (model));
@@ -230,6 +232,7 @@ gog_xyz_surface_plot_update (GogObject *obj)
tmp_max = go_data_get_vector_size (series->base.values[2].data);
} else if (model->z.fmt == NULL)
model->z.fmt = go_data_preferred_fmt (series->base.values[2].data);
+ model->z.date_conv = go_data_date_conv (series->base.values[2].data);
model->z.minima = tmp_min;
model->z.maxima = tmp_max;
gog_axis_bound_changed (model->base.axis[((GOG_IS_PLOT_CONTOUR (model))? GOG_AXIS_PSEUDO_3D: GOG_AXIS_Z)], GOG_OBJECT (model));
diff --git a/plugins/plot_surface/gog-xyz.c b/plugins/plot_surface/gog-xyz.c
index 69cfead..d8cf0a2 100644
--- a/plugins/plot_surface/gog-xyz.c
+++ b/plugins/plot_surface/gog-xyz.c
@@ -189,6 +189,7 @@ gog_xyz_plot_update (GogObject *obj)
if ((vec = series->base.values[0].data) != NULL) {
if (model->x.fmt == NULL)
model->x.fmt = go_data_preferred_fmt (series->base.values[0].data);
+ model->x.date_conv = go_data_date_conv (series->base.values[0].data);
if (go_data_is_varying_uniformly (vec))
go_data_get_bounds (vec, &tmp_min, &tmp_max);
else
@@ -211,6 +212,7 @@ gog_xyz_plot_update (GogObject *obj)
if ((vec = series->base.values[1].data) != NULL) {
if (model->y.fmt == NULL)
model->y.fmt = go_data_preferred_fmt (series->base.values[1].data);
+ model->y.date_conv = go_data_date_conv (series->base.values[1].data);
if (go_data_is_varying_uniformly (vec))
go_data_get_bounds (vec, &tmp_min, &tmp_max);
else
@@ -267,14 +269,20 @@ gog_xyz_plot_axis_get_bounds (GogPlot *plot, GogAxisType axis,
fmt = xyz->x.fmt;
min = xyz->x.minima;
max = xyz->x.maxima;
+ if (xyz->x.date_conv)
+ bounds->date_conv = xyz->x.date_conv;
} else if (axis == GOG_AXIS_X || axis == GOG_AXIS_Y) {
vec = series->base.values[1].data;
fmt = xyz->y.fmt;
min = xyz->y.minima;
max = xyz->y.maxima;
+ if (xyz->y.date_conv)
+ bounds->date_conv = xyz->y.date_conv;
} else {
if (bounds->fmt == NULL && xyz->z.fmt != NULL)
bounds->fmt = go_format_ref (xyz->z.fmt);
+ if (xyz->z.date_conv)
+ bounds->date_conv = xyz->z.date_conv;
bounds->val.minima = xyz->z.minima;
bounds->val.maxima = xyz->z.maxima;
return NULL;
diff --git a/plugins/plot_surface/gog-xyz.h b/plugins/plot_surface/gog-xyz.h
index 8bd07e6..ad3b09f 100644
--- a/plugins/plot_surface/gog-xyz.h
+++ b/plugins/plot_surface/gog-xyz.h
@@ -42,6 +42,7 @@ typedef struct {
struct {
double minima, maxima;
GOFormat *fmt;
+ GODateConventions const *date_conv;
} x, y, z;
double *plotted_data;
GOData *x_vals, *y_vals;
diff --git a/plugins/plot_xy/gog-xy.c b/plugins/plot_xy/gog-xy.c
index d24897e..4938bb9 100644
--- a/plugins/plot_xy/gog-xy.c
+++ b/plugins/plot_xy/gog-xy.c
@@ -105,6 +105,7 @@ gog_2d_plot_update (GogObject *obj)
if (y_max < tmp_max) y_max = tmp_max;
if (model->y.fmt == NULL)
model->y.fmt = go_data_preferred_fmt (series->base.values[1].data);
+ model->y.date_conv = go_data_date_conv (series->base.values[1].data);
if (series->base.values[0].data != NULL) {
go_data_get_bounds (series->base.values[0].data, &tmp_min, &tmp_max);
@@ -117,6 +118,8 @@ gog_2d_plot_update (GogObject *obj)
is_discrete = TRUE;
} else if (model->x.fmt == NULL)
model->x.fmt = go_data_preferred_fmt (series->base.values[0].data);
+
+ model->x.date_conv = go_data_date_conv (series->base.values[0].data);
} else {
tmp_min = 0;
tmp_max = go_data_get_vector_size (series->base.values[1].data);
@@ -188,6 +191,8 @@ gog_2d_plot_axis_get_bounds (GogPlot *plot, GogAxisType axis,
!go_finite (model->x.maxima);
if (bounds->fmt == NULL && model->x.fmt != NULL)
bounds->fmt = go_format_ref (model->x.fmt);
+ if (model->x.date_conv)
+ bounds->date_conv = model->x.date_conv;
for (ptr = plot->series; ptr != NULL ; ptr = ptr->next)
if (gog_series_is_valid (GOG_SERIES (ptr->data)))
@@ -200,6 +205,8 @@ gog_2d_plot_axis_get_bounds (GogPlot *plot, GogAxisType axis,
bounds->val.maxima = model->y.maxima;
if (bounds->fmt == NULL && model->y.fmt != NULL)
bounds->fmt = go_format_ref (model->y.fmt);
+ if (model->y.date_conv)
+ bounds->date_conv = model->y.date_conv;
}
return NULL;
}
@@ -624,6 +631,7 @@ gog_xy_color_plot_update (GogObject *obj)
if (z_max < tmp_max) z_max = tmp_max;
if (model->z.fmt == NULL)
model->z.fmt = go_data_preferred_fmt (series->base.values[2].data);
+ model->z.date_conv = go_data_date_conv (series->base.values[2].data);
}
if (model->z.minima != z_min || model->z.maxima != z_max) {
model->z.minima = z_min;
@@ -647,6 +655,8 @@ gog_xy_color_plot_axis_get_bounds (GogPlot *plot, GogAxisType axis,
!go_finite (model->z.maxima);
if (bounds->fmt == NULL && model->z.fmt != NULL)
bounds->fmt = go_format_ref (model->z.fmt);
+ if (model->z.date_conv)
+ bounds->date_conv = model->z.date_conv;
return NULL;
}
return GOG_PLOT_CLASS (map_parent_klass)->axis_get_bounds (plot, axis, bounds);
diff --git a/plugins/plot_xy/gog-xy.h b/plugins/plot_xy/gog-xy.h
index b531495..abd1c18 100644
--- a/plugins/plot_xy/gog-xy.h
+++ b/plugins/plot_xy/gog-xy.h
@@ -33,6 +33,7 @@ typedef struct {
struct {
double minima, maxima;
GOFormat *fmt;
+ GODateConventions const *date_conv;
} x, y;
} Gog2DPlot;
@@ -60,6 +61,7 @@ typedef struct {
struct {
double minima, maxima;
GOFormat *fmt;
+ GODateConventions const *date_conv;
} z;
} GogXYColorPlot;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]