]> granicus.if.org Git - graphviz/commitdiff
reuse curent job for "New" graph
authorellson <devnull@localhost>
Tue, 18 Oct 2005 19:04:37 +0000 (19:04 +0000)
committerellson <devnull@localhost>
Tue, 18 Oct 2005 19:04:37 +0000 (19:04 +0000)
lib/gvc/gvevent.c

index 6415e42ba0185c5811d36b5e6f0507a3aeffeb8d..5c361fcbacd08735f69c70a51ef0abfbe173c1cc 100644 (file)
 *              AT&T Research, Florham Park NJ             *
 **********************************************************/
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
 #include "gvplugin.h"
 #include "types.h"
 #include "graph.h"
 #include "gvcint.h"
+#include "gvplugin_layout.h"
 #include "gvcproc.h"
 
 #include <string.h>
@@ -29,6 +34,7 @@ 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);
+extern void graph_cleanup(graph_t *g);
 
 #define PANFACTOR 10
 #define ZOOMFACTOR 1.1
@@ -529,14 +535,19 @@ static void gvevent_read (GVJ_t * job, char *filename, char *layout)
 {
     FILE *f;
     GVC_t *gvc;
+    gvlayout_engine_t *gvle;
 
     gvc = job->gvc;
     if (gvc->g) {
-        gvFreeLayout(gvc, gvc->g);
+       gvle = gvc->layout.engine;
+       if (gvle && gvle->cleanup)
+           gvle->cleanup(gvc->g);
+       graph_cleanup(gvc->g);
        agclose(gvc->g);
     }
     if (!filename) {
        gvc->g = agopen("G", AGDIGRAPH);
+       job->output_filename = "new.dot";
     }
     else {
        f = fopen(filename, "r");
@@ -544,8 +555,14 @@ static void gvevent_read (GVJ_t * job, char *filename, char *layout)
                return;   /* FIXME - need some error handling */
        gvc->g = agread(f);
        fclose(f);
+       job->output_filename = filename;
     }
+    GD_gvc(gvc->g) = gvc;
     gvLayout(gvc, gvc->g, layout);
+    job->selected_obj = NULL;
+    job->current_obj = NULL;
+    job->surface = NULL;
+    job->needs_refresh = 1;
 }
 
 static void gvevent_layout (GVJ_t * job, char *layout)