Moving files around, starting libtoolization.
[scdataviz] / src / graph.h
diff --git a/src/graph.h b/src/graph.h
new file mode 100644 (file)
index 0000000..31d441f
--- /dev/null
@@ -0,0 +1,107 @@
+/*
+** Graph.h
+** 
+** Made by Johnny Q. Hacker
+** Login   <solarion@johnathan>
+** 
+
+    Copyright (C) 2008 Joseph Pingenot
+
+    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 Affero General Public License for more details.
+
+    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        GRAPHCLASS_H_
+#define        GRAPHCLASS_H_
+
+#include <glib-2.0/glib-object.h>
+
+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;
+};
+
+struct graph_axis {
+  double major_start;
+  double major_step;
+  int major;
+  int minor;
+  int subminor;
+  GString *title;
+};
+
+typedef struct _Graph {
+  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;
+  double miny;
+  graph_symbol symbol;
+  struct graph_axis *xaxis;
+  struct graph_axis *yaxis;
+} Graph;
+
+typedef struct _GraphClass {
+  GObjectClass parent_class;
+} GraphClass;
+
+#define GRAPH_TYPE (graph_get_type())
+#define GRAPH(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GRAPH_TYPE, Graph))
+#define GRAPH_CLASS(obj) (G_TYPE_CHECK_CLASS_CAST ((obj), GRAPH, GraphClass))
+#define IS_GRAPH(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GRAPH_TYPE))
+#define IS_GRAPH_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE ((obj), GRAPH_CLASS_TYPE))
+#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, 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);
+void graph_set_xaxis(Graph *g, struct graph_axis *axis);
+void graph_set_yaxis(Graph *g, struct graph_axis *axis);
+int graph_autoset_xaxis(Graph *g, GString *title);
+int graph_autoset_yaxis(Graph *g, GString *title);
+
+
+
+#endif             /* !GRAPHCLASS_H_ */