From: trelane@digitasaru.net Date: Fri, 25 Jul 2008 21:10:13 +0000 (-0500) Subject: * Bowing params are working better. X-Git-Url: http://git.maemo.org/git/?p=scdataviz;a=commitdiff_plain;h=152331cb46d5b28d1586ce0fd0aaea3d53b440e0 * Bowing params are working better. * Adding in axis infrastructure. --- diff --git a/graph.c b/graph.c index 1af3cb8..507e557 100644 --- a/graph.c +++ b/graph.c @@ -44,6 +44,7 @@ static void graph_init(Graph *graph) { graph->symbol = CIRCLE; graph->points = g_ptr_array_new(); graph->lines = NULL; + graph->xaxis = graph->yaxis = NULL; } Graph *graph_new(void) { @@ -82,6 +83,7 @@ int graph_add_point(Graph* graph, double x, double y, const GString *label) { } int graph_add_graph_line(Graph* graph, struct graph_line *l) { + if(l == NULL) return 1; if(graph->lines == NULL) { if((graph->lines = g_ptr_array_new()) == NULL) return 1; } @@ -159,3 +161,32 @@ void graph_bezier_quadratic_to_cubic(double x0, double x3, double *x1, double *x *x2 = (x3-2.0*(*x1))/3.0; *x1 = (x0-2.0*(*x1))/3.0; } + +void graph_set_xaxis(Graph *g, struct graph_axis *axis) { + if(g->xaxis != NULL) { + free(g->xaxis); + } + g->xaxis=axis; +} +void graph_set_yaxis(Graph *g, struct graph_axis *axis) { + if(g->yaxis != NULL) { + free(g->yaxis); + } + g->yaxis=axis; +} + +void graph_autoset_xaxis(Graph *g) { + struct graph_axis *axis; + if((axis=(struct graph_axis *)malloc(sizeof(struct graph_axis))) == NULL) { + return 1; + } + graph_set_xaxis(g, axis); +} + +void graph_autoset_yaxis(Graph *g) { + struct graph_axis *axis; + if((axis=(struct graph_axis *)malloc(sizeof(struct graph_axis))) == NULL) { + return 1; + } + graph_set_xaxis(g, axis); +} diff --git a/graph.h b/graph.h index 927935b..cbdfe5d 100644 --- a/graph.h +++ b/graph.h @@ -52,6 +52,14 @@ struct graph_line { double p3_y; }; +struct graph_axis { + double start; + double step; + int xminor; + int subminor; + GString title; +}; + typedef struct _Graph { GObject parent_instance; /*Array of n_points sets of x,y coords*/ @@ -63,6 +71,8 @@ typedef struct _Graph { double maxy; double miny; graph_symbol symbol; + struct graph_axis *xaxis; + struct graph_axis *yaxis; } Graph; typedef struct _GraphClass { diff --git a/scdataviz.c b/scdataviz.c index bfed526..4c0851d 100644 --- a/scdataviz.c +++ b/scdataviz.c @@ -100,13 +100,13 @@ static void inner_link_materials(gpointer key, gpointer value, gpointer user_dat } if(bow != NULL) { if((p1_x = g_hash_table_lookup(bow->properties, propmap->xprop->str)) != NULL) { - l->p1_x = *p1_x; + l->p1_x = *p1_x/2.0; graph_bezier_quadratic_to_cubic(l->p0_x, l->p3_x, &(l->p1_x), &(l->p2_x)); }else{ graph_bezier_linear_to_cubic(l->p0_x, l->p3_x, &(l->p1_x), &(l->p2_x)); } if((p1_y = g_hash_table_lookup(bow->properties, propmap->yprop->str)) != NULL) { - l->p1_y = *p1_y; + l->p1_y = *p1_y/2.0; graph_bezier_quadratic_to_cubic(l->p0_y, l->p3_y, &(l->p1_y), &(l->p2_y)); }else{ graph_bezier_linear_to_cubic(l->p0_y, l->p3_y, &(l->p1_y), &(l->p2_y));