]> granicus.if.org Git - graphviz/commitdiff
implement event processing needed for load/save/export
authorellson <devnull@localhost>
Tue, 18 Oct 2005 18:59:26 +0000 (18:59 +0000)
committerellson <devnull@localhost>
Tue, 18 Oct 2005 18:59:26 +0000 (18:59 +0000)
lib/gvc/gvcjob.h
lib/gvc/gvevent.c

index 663064cac8a267bac001ece509ec4ecd52d23d73..8fdf4fead254e128467a3fe8f28aac5be80120d2 100644 (file)
@@ -119,8 +119,8 @@ extern "C" {
         void (*motion) (GVJ_t * job, pointf pointer);
         void (*modify) (GVJ_t * job, char *name, char *value);
         void (*delete) (GVJ_t * job);
-        void (*read) (GVJ_t * job, char *filename);
-        void (*layout) (GVJ_t * job, char *type);
+        void (*read) (GVJ_t * job, char *filename, char *layout);
+        void (*layout) (GVJ_t * job, char *layout);
         void (*render) (GVJ_t * job, char *format, char *filename);
     } gvdevice_callbacks_t;
 
index 42881e986ed18d8ad3fc78e89dcf1fba72dff091..ebe203007fe86bebe288b2c1eeb6e5d69ba21420 100644 (file)
@@ -27,6 +27,8 @@ extern char *strdup_and_subst_node(char *str, Agnode_t * n);
 extern void emit_graph(GVJ_t * job, graph_t * g);
 extern bool overlap_edge(edge_t *e, boxf b);
 extern bool overlap_node(node_t *n, boxf b);
+extern int gvLayout(GVC_t *gvc, graph_t *g, char *engine);
+extern int gvRenderFilename(GVC_t *gvc, graph_t *g, char *format, char *filename);
 
 #define PANFACTOR 10
 #define ZOOMFACTOR 1.1
@@ -523,19 +525,30 @@ static void gvevent_delete (GVJ_t * job)
     /* FIXME */
 }
 
-static void gvevent_read (GVJ_t * job, char *filename)
+static void gvevent_read (GVJ_t * job, char *filename, char *layout)
 {
-    /* FIXME */
+    FILE *f;
+
+    if (job->gvc->g) {
+        gvFreeLayout(job->gvc, job->gvc->g);
+       agclose(job->gvc->g);
+    }
+    f = fopen(filename, "r");
+    if (!f)
+       return;   /* FIXME - need some error handling */
+    job->gvc->g = agread(f);
+    fclose(f);
+    gvLayout(job->gvc, job->gvc->g, layout);
 }
 
-static void gvevent_layout (GVJ_t * job, char *type)
+static void gvevent_layout (GVJ_t * job, char *layout)
 {
-    /* FIXME */
+    gvLayout(job->gvc, job->gvc->g, layout);
 }
 
 static void gvevent_render (GVJ_t * job, char *format, char *filename)
 {
-    /* FIXME */
+    gvRenderFilename(job->gvc, job->gvc->g, format, filename);
 }