* Added bezier routines.
[scdataviz] / graph.h
diff --git a/graph.h b/graph.h
index e66e685..68aa97b 100644 (file)
--- a/graph.h
+++ b/graph.h
@@ -5,43 +5,59 @@
 ** Login   <solarion@johnathan>
 ** 
 
-Copyright (C) 2008 Joseph Pingenot
+    Copyright (C) 2008 Joseph Pingenot
 
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU Lesser General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
+    This program is free software: you can redistribute it and/or modify
+    it under the terms of the GNU Affero General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
 
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU Lesser General Public License for more details.
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU Affero General Public License for more details.
 
-You should have received a copy of the GNU Lesser General Public License
-along with this program.  If not, see <http://www.gnu.org/licenses/>.
+    You should have received a copy of the GNU Affero General Public License
+    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 ** Started on  Thu Jul 17 10:51:32 2008 Johnny Q. Hacker
 ** Last update Thu Jul 17 10:51:32 2008 Johnny Q. Hacker
 */
 
-#ifndef        GRAPH_H_
-# define       GRAPH_H_
+#ifndef        GRAPHCLASS_H_
+#define        GRAPHCLASS_H_
 
 #include <glib-2.0/glib-object.h>
 
-enum graph_symbol {
-     SQUARE,
-     CIRCLE,
-     STAR,
-     PLUS,
-     MINUX,
-     CROSS
-   };
+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;
@@ -50,7 +66,7 @@ typedef struct _Graph {
 } Graph;
 
 typedef struct _GraphClass {
-  GObject parent;
+  GObjectClass parent_class;
 } GraphClass;
 
 #define GRAPH_TYPE (graph_get_type())
@@ -61,6 +77,15 @@ 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);
+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_qudratic_to_cubic(double x0, double x3, double *x1, double *x2);
+
+
 
-#endif             /* !GRAPH_H_ */
+#endif             /* !GRAPHCLASS_H_ */