* Updated files. Now it compiles (though it crashes).
authorJoseph Pingenot <bzrdude@digitasaru.net>
Wed, 23 Jul 2008 01:31:09 +0000 (20:31 -0500)
committerJoseph Pingenot <bzrdude@digitasaru.net>
Wed, 23 Jul 2008 01:31:09 +0000 (20:31 -0500)
Makefile
graph.c
graph.h
graphwidget.c
graphwidget.h
scdataviz.c

index a2e6c9c..ee840ac 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -33,8 +33,7 @@ COMP  = gzip -9v
 UNCOMP = gzip -df
 STRIP  = strip
 
-#CFLAGS  = $(OBJOPT) $(IPATH) `pkg-config --cflags gtk+-2.0` -DAPISTRING=FOO
-CFLAGS  = $(OBJOPT) $(IPATH) `pkg-config --cflags gtk+-2.0` -DAPISTRING=`if [ ! -e api-horkfile ]; then mktemp -u aXXXXXXXXXXXXXX > api-horkfile; fi; head -n1 api-horkfile`
+CFLAGS  = $(OBJOPT) $(IPATH) `pkg-config --cflags gtk+-2.0`
 LDFLAGS = $(EXEOPT) $(LPATH) `pkg-config --libs gtk+-2.0`
 
 .SUFFIXES: .h.Z .c.Z .h.gz .c.gz .c.z .h.z 
@@ -44,7 +43,6 @@ LDFLAGS = $(EXEOPT) $(LPATH) `pkg-config --libs gtk+-2.0`
 ##############################
 
 all:   $(NAME)
-       rm -f api-horkfile
 $(NAME): $(OBJS) $(SRC) $(INCL)  
        $(CC) $(OBJS) $(LDFLAGS) -o $(NAME) 
 #      $(STRIP) ./$(NAME) # if you debug ,don't strip ...
@@ -52,7 +50,7 @@ $(NAME): $(OBJS) $(SRC) $(INCL)
 depend:
        gcc $(IPATH) -MM $(SRC) 
 clean:
-       -$(RM) $(NAME) $(OBJS) api-horkfile *~
+       -$(RM) $(NAME) $(OBJS)
 fclean:
        -$(RM) $(NAME)
 comp: clean
diff --git a/graph.c b/graph.c
index 531f77a..a3a05da 100644 (file)
--- a/graph.c
+++ b/graph.c
@@ -5,20 +5,22 @@
 ** 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 Lesser General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
+    Copyright (C) 2008 Joseph Pingenot
 
-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 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/>.
 
-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/>.
 
 **Many thanks to Davyd Madeley for the excellent Cairo  Tutorial
 **  at http://gnomejournal.org/article/34/writing-a--using-cairo-and-gtk28
@@ -27,7 +29,8 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 ** Last update Sun May 12 01:17:25 2002 Speed Blue
 */
 
-#include "graph.h"
+#include <graph.h>
+#include <stdlib.h>
 
 G_DEFINE_TYPE(Graph, graph, G_TYPE_OBJECT);
 
@@ -38,11 +41,11 @@ static void graph_class_init(GraphClass *klass) {
 
 static void graph_init(Graph *graph) {
   graph->symbol = CIRCLE;
-  GPtrArray = g_ptr_array_new();
+  graph->points = g_ptr_array_new();
 }
 
 Graph *graph_new(void) {
-  return g_object_new(G_GRAPH_TYPE);
+  return g_object_new(GRAPH_TYPE, NULL);
 }
 
 int graph_add_point(Graph* graph, double x, double y) {
@@ -51,14 +54,14 @@ int graph_add_point(Graph* graph, double x, double y) {
   point[0] = x;
   point[1] = y;
   g_ptr_array_add(graph->points, (gpointer)point);
-  if(points->len == 1) {
-    maxx = minx = x;
-    maxy = miny = x;
+  if(graph->points->len == 1) {
+    graph->maxx = graph->minx = x;
+    graph->maxy = graph->miny = x;
   }else{
-    if(x > maxx) maxx = x;
-    if(x < minx) minx = x;
-    if(y > mayy) maxy = y;
-    if(y < miny) miny = y;
+    if(x > graph->maxx) graph->maxx = x;
+    if(x < graph->minx) graph->minx = x;
+    if(y > graph->maxy) graph->maxy = y;
+    if(y < graph->miny) graph->miny = y;
   }
   return 0;
 }
diff --git a/graph.h b/graph.h
index e66e685..44ec6d7 100644 (file)
--- a/graph.h
+++ b/graph.h
@@ -5,38 +5,31 @@
 ** 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;
 
 typedef struct _Graph {
   GObject parent;
@@ -63,4 +56,4 @@ typedef struct _GraphClass {
 Graph *graph_new(void);
 int graph_add_point(Graph* graph, double x, double y);
 
-#endif             /* !GRAPH_H_ */
+#endif             /* !GRAPHCLASS_H_ */
index 6be20f7..ed9cf4b 100644 (file)
@@ -5,20 +5,22 @@
 ** 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 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 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.
+    Copyright (C) 2008 Joseph Pingenot
 
-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/>.
+    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/>.
 
 **Many thanks to Davyd Madeley for the excellent Cairo Widget Tutorial
 **  at http://gnomejournal.org/article/34/writing-a-widget-using-cairo-and-gtk28
@@ -27,7 +29,8 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 ** Last update Sun May 12 01:17:25 2002 Speed Blue
 */
 
-#include "graphwidget.h"
+#include <graphwidget.h>
+#include <math.h>
 
 G_DEFINE_TYPE(GraphWidget, graph_widget, GTK_TYPE_DRAWING_AREA);
 
@@ -39,7 +42,8 @@ struct drawing_context {
 
 static void draw_point(gpointer data, gpointer user_data) {
   struct drawing_context *cxt = (struct drawing_context *) user_data;
-  cairo_arc(cxt->cr, ((*double)data)[0], ((*double)data)[1], cxt->radius, 0, 2*M_PI);
+  double *d = (double*)data;
+  cairo_arc(cxt->cr, d[0], d[1], cxt->radius, 0, 2*M_PI);
 }
 
 static void draw(GtkWidget *graph, cairo_t *cr) {
@@ -88,10 +92,10 @@ static void graph_widget_init(GraphWidget *graph) {
   graph->graph = graph_new();
 }
 
-GtkWidget *graph_widget_new() {
-  return = g_object_new(GRAPH_WIDGET_TYPE, NULL);
+GtkWidget *graph_widget_new(void) {
+  return g_object_new(GRAPH_WIDGET_TYPE, NULL);
 }
 
-Graph* get_graph(GraphWidget* gw) {
+Graph* graph_widget_get_graph(GraphWidget* gw) {
   return gw->graph;
 }
index d580adf..be1ebaa 100644 (file)
@@ -5,27 +5,29 @@
 ** 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 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 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.
+    Copyright (C) 2008 Joseph Pingenot
 
-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/>.
+    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        GRAPH_H_
-# define       GRAPH_H_
+#ifndef        GRAPHWIDGET_H_
+#define GRAPHWIDGET_H_
 
 #include <gtk/gtkdrawingarea.h>
 #include <graph.h>
@@ -47,8 +49,8 @@ typedef struct _GraphWidgetClass {
 #define IS_GRAPH_WIDGET_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE ((obj), GRAPH_WIDGET_CLASS_TYPE))
 #define GRAPH_WIDGET_GET_CLASS (G_TYPE_INSTANCE_GET_CLASS ((obj), GRAPH_WIDGET, GraphWidgetClass))
 
-GtkWidget* graph_widget_new(Graph* graph);
+GtkWidget* graph_widget_new(void);
 
-Graph* get_graph(GraphWidget* gw);
+Graph* graph_widget_get_graph(GraphWidget* gw);
 
-#endif             /* !GRAPH_H_ */
+#endif             /* !GRAPHWIDGET_H_ */
index 1024a12..0ca4468 100644 (file)
@@ -6,20 +6,22 @@
 ** 
 ** Holds the SC graphing widget.
 
-Copyright (C) 2008 Joseph Pingenot
 
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU 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 General Public License for more details.
+    Copyright (C) 2008 Joseph Pingenot
 
-You should have received a copy of the GNU General Public License
-along with this program.  If not, see <http://www.gnu.org/licenses/>.
+    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 11:03:27 2008 Johnny Q. Hacker
 ** Last update Sun May 12 01:17:25 2002 Speed Blue
@@ -44,6 +46,9 @@ int main(int   argc, char *argv[])
     g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(gtk_main_quit), NULL);
 
     gtk_container_add(GTK_CONTAINER(window), graph);
+    graph_add_point(graph_widget_get_graph(graph), 5, 3);
+    graph_add_point(graph_widget_get_graph(graph), 8, 12);
+    graph_add_point(graph_widget_get_graph(graph), 11, 48);
     
     gtk_widget_show_all  (window);