X-Git-Url: http://git.maemo.org/git/?p=scdataviz;a=blobdiff_plain;f=graph.h;h=927935b5bccfe6f11a3566879ed6d1bdfdf2206b;hp=44ec6d7453dae7f6341cf33d4249fd414bdfc15f;hb=f3ddf2cd811f53afd0edaa3b1263035d9faab318;hpb=9e58fff9554349ce00ede966b94275cd9318ed79 diff --git a/graph.h b/graph.h index 44ec6d7..927935b 100644 --- a/graph.h +++ b/graph.h @@ -31,10 +31,33 @@ typedef enum {SQUARE, CIRCLE, STAR, PLUS, MINUS, CROSS} graph_symbol; +struct graph_point { + double x; + double y; + GString *label; +}; + +/*Bezier line*/ +struct graph_line { + /*First point*/ + double p0_x; + double p0_y; + /*Control pts*/ + double p1_x; + double p1_y; + double p2_x; + double p2_y; + /*End point*/ + double p3_x; + double p3_y; +}; + typedef struct _Graph { - GObject parent; + GObject parent_instance; /*Array of n_points sets of x,y coords*/ GPtrArray *points; + /*This draws all of the lines (generally between points)*/ + GPtrArray *lines; double maxx; double minx; double maxy; @@ -43,7 +66,7 @@ typedef struct _Graph { } Graph; typedef struct _GraphClass { - GObject parent; + GObjectClass parent_class; } GraphClass; #define GRAPH_TYPE (graph_get_type()) @@ -54,6 +77,16 @@ typedef struct _GraphClass { #define GRAPH_GET_CLASS (G_TYPE_INSTANCE_GET_CLASS ((obj), GRAPH, GraphClass)) Graph *graph_new(void); -int graph_add_point(Graph* graph, double x, double y); +int graph_add_point(Graph* graph, double x, double y, const GString *label); +int graph_add_graph_point(Graph* graph, struct graph_point *pt); +int graph_add_line(Graph* graph, double p0_x, double p0_y, double p1_x, double p1_y, double p2_x, double p2_y, double p3_x, double p3_y); +int graph_add_graph_line(Graph* graph, struct graph_line *l); +void graph_add_linear_connectors(Graph* graph); +/*Provide x0, x3; x1 and x2 will be set*/ +void graph_bezier_linear_to_cubic(double x0, double x3, double *x1, double *x2); +/*Provide x0, x1, x2. x1 and x2 will be set appropriately.*/ +void graph_bezier_quadratic_to_cubic(double x0, double x3, double *x1, double *x2); + + #endif /* !GRAPHCLASS_H_ */