From: ellson Date: Tue, 28 Dec 2004 19:02:22 +0000 (+0000) Subject: partially migrate win viewport to use graph viewport data X-Git-Tag: LAST_LIBGRAPH~32^2~8185 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=619ad87ca4bad97ec8bdd6886f72d88c74576243;p=graphviz partially migrate win viewport to use graph viewport data --- diff --git a/cmd/dot/dot.c b/cmd/dot/dot.c index ba8405bc7..69f3fbe1f 100644 --- a/cmd/dot/dot.c +++ b/cmd/dot/dot.c @@ -56,7 +56,7 @@ static GVC_t *gvc; static void intr(int s) { if (gvc->g) - dotneato_write(gvc); + dotneato_write(gvc, gvc->g); dotneato_terminate(gvc); exit(1); } @@ -174,7 +174,7 @@ int main(int argc, char **argv) agclose(prev); } gvlayout_layout(gvc, g); - dotneato_write(gvc); + dotneato_write(gvc, g); prev = g; } } diff --git a/lib/common/emit.c b/lib/common/emit.c index 60aeb4356..2db7b5841 100644 --- a/lib/common/emit.c +++ b/lib/common/emit.c @@ -80,9 +80,8 @@ static int write_node_test(Agraph_t * g, Agnode_t * n) } -void emit_reset(GVC_t * gvc) +void emit_reset(GVC_t * gvc, graph_t * g) { - Agraph_t *g = gvc->g; Agnode_t *n; N_pages = 1; @@ -653,18 +652,13 @@ void emit_edge(GVC_t * gvc, edge_t * e) gvrender_end_edge(gvc); } -void emit_graph(GVC_t * gvc, graph_t * g, int flags) +void emit_init(GVC_t * gvc, graph_t * g) { - point curpage; - graph_t *sg; - node_t *n; - edge_t *e; - int c; - char *str, *colors; - double X, Y, Z, x, y; - char *s, *url = NULL, *tooltip = NULL, *target = NULL; + char *str; + double X = 400.0, Y = 400.0, Z = 0.0, x = 0.0, y = 0.0; + +/* FIXME - init viewport to graph dimensions */ - X = Y = Z = x = y = 0.0; if ((str = agget(g, "viewport"))) sscanf(str, "%lf,%lf,%lf,%lf,%lf", &X, &Y, &Z, &x, &y); gvc->size.x = ROUND(X); @@ -675,8 +669,26 @@ void emit_graph(GVC_t * gvc, graph_t * g, int flags) G_peripheries = agfindattr(g, "peripheries"); setup_graph(gvc, g); - if (Page == 0) - gvrender_begin_job(gvc, Lib, Pages); + gvrender_begin_job(gvc, Lib, Pages); +} + +void emit_deinit(GVC_t * gvc, graph_t * g) +{ +} + +void emit_graph(GVC_t * gvc, graph_t * g, int flags) +{ + point curpage; + graph_t *sg; + node_t *n; + edge_t *e; + int c; + char *str, *colors; + char *s, *url = NULL, *tooltip = NULL, *target = NULL; + + /* FIXME - I don't understand why I need this again */ + setup_graph(gvc, g); + gvrender_begin_graph(gvc, g, PB, PFC); if (flags & EMIT_COLORS) { gvrender_set_fillcolor(gvc, DEFAULT_FILL); diff --git a/lib/common/output.c b/lib/common/output.c index b92b682c2..c8e6e5e32 100644 --- a/lib/common/output.c +++ b/lib/common/output.c @@ -122,6 +122,9 @@ void dotneato_write_one(GVC_t * gvc, graph_t * g) { int flags; + gvc->g = g; + dotneato_set_margins(gvc, g); + emit_init(gvc, g); if (NOT(gvrender_features(gvc) & GVRENDER_DOES_MULTIGRAPH_OUTPUT_FILES) #ifndef DISABLE_CODEGENS /* FIXME - bad hack until feaures supported in codegens */ @@ -131,8 +134,7 @@ void dotneato_write_one(GVC_t * gvc, graph_t * g) #endif #endif ) - emit_reset(gvc); - dotneato_set_margins(gvc, g); + emit_reset(gvc, g); switch (gvc->job->output_lang) { case GVRENDER_PLUGIN: flags = chkOrder(g); @@ -211,11 +213,11 @@ void dotneato_write_one(GVC_t * gvc, graph_t * g) } fflush(gvc->job->output_file); + emit_deinit(gvc, g); } -void dotneato_write(GVC_t * gvc) +void dotneato_write(GVC_t * gvc, graph_t * g) { - graph_t *g = gvc->g; gvrender_job_t *job; for (job = gvrender_first_job(gvc); job; job = gvrender_next_job(gvc)) { diff --git a/lib/common/renderprocs.h b/lib/common/renderprocs.h index 2effe7dbe..8f3aa2cba 100644 --- a/lib/common/renderprocs.h +++ b/lib/common/renderprocs.h @@ -68,13 +68,15 @@ extern "C" { extern void dotneato_set_margins(GVC_t * gvc, Agraph_t *); extern void dotneato_eof(GVC_t * gvc); extern void dotneato_terminate(GVC_t * gvc); - extern void dotneato_write(GVC_t * gvc); - extern void dotneato_write_one(GVC_t * gvc, graph_t * g); + extern void dotneato_write(GVC_t * gvc, graph_t *g); + extern void dotneato_write_one(GVC_t * gvc, graph_t *g); extern int edge_in_CB(Agedge_t *); extern int edge_in_layer(Agraph_t *, Agedge_t *); extern double elapsed_sec(void); extern void enqueue(queue *, Agnode_t *); extern void enqueue_neighbors(queue *, Agnode_t *, int); + extern void emit_init(GVC_t * gvc, graph_t * g); + extern void emit_deinit(GVC_t * gvc, graph_t * g); extern void emit_attachment(GVC_t * gvc, textlabel_t *, splines *); extern void emit_clusters(GVC_t * gvc, Agraph_t * g, int flags); extern void emit_eof(GVC_t * gvc); @@ -84,7 +86,7 @@ extern "C" { extern void emit_label(GVC_t * gvc, textlabel_t *, void *obj); extern int emit_once(char *message); extern void emit_once_reset(); - extern void emit_reset(GVC_t * gvc); + extern void emit_reset(GVC_t * gvc, graph_t * g); extern void endpath(path *, Agedge_t *, int, pathend_t *, boolean); extern void epsf_init(node_t * n); extern void epsf_free(node_t * n); diff --git a/lib/gvc/gvemit.c b/lib/gvc/gvemit.c index 1fef649b1..b4162d84a 100644 --- a/lib/gvc/gvemit.c +++ b/lib/gvc/gvemit.c @@ -52,8 +52,11 @@ typedef struct win { unsigned int width, height; - cairo_t *cr; GVC_t *gvc; + graph_t *g; + int flags; + + cairo_t *cr; double tx, ty, zoom, oldx, oldy; int needs_refresh, fit_mode, click, active; @@ -177,8 +180,6 @@ static void win_init(win_t * win, int argb, const char *geometry, int x, y; XParseGeometry(geometry, &x, &y, &win->width, &win->height); } else { -/* FIXME - gvc->size is 0,0 at this time. need to set viewport and transform earlier */ -// svg_cairo_get_size(win->svgc, &win->width, &win->height); win->width = win->gvc->size.x; win->height = win->gvc->size.y; } @@ -232,7 +233,7 @@ static void win_init(win_t * win, int argb, const char *geometry, else key_binding[i].keycode = XKeysymToKeycode(dpy, keysym); } - win->cr = cairo_create(); +// win->cr = cairo_create(); surface = cairo_xlib_surface_create(dpy, win->pix, win->visual, CAIRO_FORMAT_ARGB32, win->cmap); cairo_set_target_surface(win->cr, surface); @@ -264,8 +265,8 @@ static void win_init(win_t * win, int argb, const char *geometry, static void win_deinit(win_t * win) { - cairo_destroy(win->cr); - win->cr = NULL; +// cairo_destroy(win->cr); +// win->cr = NULL; XFreeGC(win->dpy, win->gc); XDestroyWindow(win->dpy, win->win); } @@ -278,9 +279,7 @@ static void win_refresh(win_t * win) cairo_translate(win->cr, win->tx, win->ty); cairo_scale(win->cr, win->zoom, win->zoom); -// svg_cairo_render(win->svgc, win->cr); -// FIXME: flags = chkOrder(g) | gvc->render_features->flags; - emit_graph(win->gvc, win->gvc->g, win->gvc->render_features->flags); + emit_graph(win->gvc, win->g, win->flags); cairo_restore(win->cr); XCopyArea(win->dpy, win->pix, win->win, win->gc, @@ -552,7 +551,6 @@ static int toggle_fit_cb(win_t * win) win->fit_mode = !win->fit_mode; if (win->fit_mode) { int dflt_width, dflt_height; -// svg_cairo_get_size(win->svgc, &dflt_width, &dflt_height); dflt_width = win->gvc->size.x; dflt_height = win->gvc->size.y; win->zoom = @@ -566,7 +564,6 @@ static int toggle_fit_cb(win_t * win) } #endif /* X_DISPLAY_MISSING */ - void gvemit_graph(GVC_t * gvc, graph_t * g, int flags) { if (flags & GVRENDER_X11_EVENTS) { @@ -574,9 +571,14 @@ void gvemit_graph(GVC_t * gvc, graph_t * g, int flags) win_t win; const char *display=NULL; int argb=0; - const char *geometry="200x200"; + const char *geometry=NULL; win.gvc = gvc; + win.g = g; + win.flags = flags; + + gvc->surface = win.cr = cairo_create();; + gvc->external_surface = TRUE; win.dpy = XOpenDisplay(display); if (win.dpy == NULL) { @@ -589,6 +591,7 @@ void gvemit_graph(GVC_t * gvc, graph_t * g, int flags) win_handle_events(&win); + cairo_destroy(win.cr); win_deinit(&win); XCloseDisplay(win.dpy); diff --git a/lib/gvc/gvrender.c b/lib/gvc/gvrender.c index db76c8b80..9dcaf6685 100644 --- a/lib/gvc/gvrender.c +++ b/lib/gvc/gvrender.c @@ -134,7 +134,7 @@ void gvrender_begin_job(GVC_t * gvc, char **lib, point pages) else { codegen_t *cg = gvc->codegen; - if (cg && cg->begin_job) + if (cg && cg->begin_job && gvc->page_number == 0) cg->begin_job(gvc->job->output_file, gvc->g, lib, gvc->user, gvc->info, pages); } diff --git a/tclpkg/tcldot/tcldot.c b/tclpkg/tcldot/tcldot.c index dbec842b0..6af266cb9 100644 --- a/tclpkg/tcldot/tcldot.c +++ b/tclpkg/tcldot/tcldot.c @@ -1267,7 +1267,7 @@ static int graphcmd(ClientData clientData, Tcl_Interp * interp, return TCL_OK; } else if ((c == 'w') && (strncmp(argv[1], "write", length) == 0)) { - gvc->g = g = g->root; + g = g->root; if (argc < 3) { Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], @@ -1299,7 +1299,7 @@ static int graphcmd(ClientData clientData, Tcl_Interp * interp, tcldot_layout(g, (argc > 4) ? argv[4] : (char *) NULL); } - emit_reset(gvc); /* reset page numbers in postscript */ + emit_reset(gvc, g); /* reset page numbers in postscript */ dotneato_write_one(gvc, g); gvrender_delete_jobs(gvc); return TCL_OK;