From ac9772156cea7cff4d8f1be7fd9396bdb6027505 Mon Sep 17 00:00:00 2001 From: ellson <devnull@localhost> Date: Thu, 30 Dec 2004 00:49:14 +0000 Subject: [PATCH] merging viewport bits of win structure into gvc --- lib/common/emit.c | 78 +++++++++------------- lib/common/gdgen.c | 9 ++- lib/common/mapgen.c | 3 +- lib/common/output.c | 4 +- lib/common/renderprocs.h | 4 +- lib/gvc/gvemit.c | 138 ++++++++++++++++++--------------------- lib/gvc/gvrender.c | 29 +++----- lib/gvc/gvrenderint.h | 10 +-- tclpkg/tcldot/tkgen.c | 3 +- 9 files changed, 121 insertions(+), 157 deletions(-) diff --git a/lib/common/emit.c b/lib/common/emit.c index f4848b3b4..19a7b47af 100644 --- a/lib/common/emit.c +++ b/lib/common/emit.c @@ -48,10 +48,6 @@ static char *Deffontname; static char *Layerdelims; static attrsym_t *G_peripheries; -#ifndef DISABLE_CODEGENS -static char *lang_name(int langID); -#endif - static int write_edge_test(Agraph_t * g, Agedge_t * e) { Agraph_t *sg; @@ -65,7 +61,6 @@ static int write_edge_test(Agraph_t * g, Agedge_t * e) return TRUE; } - static int write_node_test(Agraph_t * g, Agnode_t * n) { Agraph_t *sg; @@ -266,6 +261,18 @@ static void set_pagedir(graph_t * g) } } +static char *lang_name(int langID) +{ +#ifndef DISABLE_CODEGENS + codegen_info_t *p; + for (p = first_codegen(); p->name; p = next_codegen(p)) { + if (p->id == langID) + return p->name; + } +#endif + return "<unknown output format>"; +} + static void setup_layers(GVC_t * gvc, graph_t * g) { char *str; @@ -314,7 +321,8 @@ static void setup_pagination(GVC_t * gvc, graph_t * g) N_pages = Pages.x * Pages.y; /* find the drawable size in device coords */ - tp = gvc->size; + tp.x = gvc->width; + tp.y = gvc->height; if (GD_drawing(g)->landscape) tp = exch_xy(tp); DS.x = MIN(tp.x, PFCLM.x); @@ -328,7 +336,8 @@ static void setup_pagination(GVC_t * gvc, graph_t * g) PFC.y = DEFAULT_PAGEHT; PFCLM.x = PFC.x - 2 * PB.LL.x; PFCLM.y = PFC.y - 2 * PB.LL.y; - DS = gvc->size; + DS.x = gvc->width; + DS.y = gvc->height; if (GD_drawing(g)->landscape) DS = exch_xy(DS); Pages.x = Pages.y = N_pages = 1; @@ -349,19 +358,6 @@ static void setup_pagination(GVC_t * gvc, graph_t * g) PB.UR = add_points(PB.LL, DS); } -/* this isn't a pretty sight... */ -void setup_graph(GVC_t * gvc, graph_t * g) -{ - setup_layers(gvc, g); - - setup_pagination(gvc, g); - - Deffontname = late_nnstring(g->proto->n, N_fontname, DEFAULT_FONTNAME); - Deffontsize = - late_double(g->proto->n, N_fontsize, DEFAULT_FONTSIZE, - MIN_FONTSIZE); -} - void emit_node(GVC_t * gvc, node_t * n) { char *s, *url = NULL, *tooltip = NULL, *target = NULL; @@ -660,12 +656,20 @@ void emit_init(GVC_t * gvc, graph_t * g) sscanf(str, "%lf,%lf,%lf,%lf,%lf", &X, &Y, &Z, &x, &y); G_peripheries = agfindattr(g, "peripheries"); - setup_graph(gvc, g); + + Deffontname = late_nnstring(g->proto->n, N_fontname, DEFAULT_FONTNAME); + Deffontsize = + late_double(g->proto->n, N_fontsize, DEFAULT_FONTSIZE, + MIN_FONTSIZE); + + setup_layers(gvc, g); + gvrender_begin_job(gvc, Lib, Pages, X, Y, Z, x, y, GD_drawing(g)->dpi); } -void emit_deinit(GVC_t * gvc, graph_t * g) +void emit_deinit(GVC_t * gvc) { + gvrender_end_job(gvc); } void emit_graph(GVC_t * gvc, graph_t * g, int flags) @@ -678,8 +682,8 @@ void emit_graph(GVC_t * gvc, graph_t * g, int flags) 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); + /* FIXME - some of setup_pagination should be in emit_init() */ + setup_pagination(gvc, g); gvrender_begin_graph(gvc, g, PB, PFC); if (flags & EMIT_COLORS) { @@ -842,7 +846,7 @@ void emit_graph(GVC_t * gvc, graph_t * g, int flags) void emit_eof(GVC_t * gvc) { if (Page > 0) { - gvrender_end_job(gvc); + emit_deinit(gvc); emit_once_reset(); } } @@ -1093,16 +1097,6 @@ int validpage(point page) && (page.y >= 0) && (page.y < Pages.y)); } -int layerindex(char *tok) -{ - int i; - - for (i = 1; i <= Nlayers; i++) - if (streq(tok, LayerID[i])) - return i; - return -1; -} - int is_natural_number(char *sstr) { unsigned char *str = (unsigned char *) sstr; @@ -1112,7 +1106,7 @@ int is_natural_number(char *sstr) return TRUE; } -int layer_index(char *str, int all) +static int layer_index(char *str, int all) { int i; @@ -1441,18 +1435,6 @@ int lang_select(GVC_t * gvc, char *str, int warn) return rv; } -char *lang_name(int langID) -{ -#ifndef DISABLE_CODEGENS - codegen_info_t *p; - for (p = first_codegen(); p->name; p = next_codegen(p)) { - if (p->id == langID) - return p->name; - } -#endif - return "<unknown output format>"; -} - FILE *file_select(char *str) { FILE *rv; diff --git a/lib/common/gdgen.c b/lib/common/gdgen.c index 77db409f2..19243b382 100644 --- a/lib/common/gdgen.c +++ b/lib/common/gdgen.c @@ -143,17 +143,16 @@ static void init1_gd(GVC_t * gvc, graph_t * g, box bb, point pb) Dpi = DEFAULT_DPI; DevScale = Dpi / POINTS_PER_INCH; - Viewport = gvc->size; + Viewport.x = gvc->width; + Viewport.y = gvc->height; if (Viewport.x) { Zoom = gvc->zoom; GraphFocus = gvc->focus; } else { Viewport.x = - (bb.UR.x - bb.LL.x + 2 * GD_drawing(g)->margin.x) * DevScale + - 2; + (bb.UR.x - bb.LL.x + 2 * GD_drawing(g)->margin.x) * DevScale + 2; Viewport.y = - (bb.UR.y - bb.LL.y + 2 * GD_drawing(g)->margin.y) * DevScale + - 2; + (bb.UR.y - bb.LL.y + 2 * GD_drawing(g)->margin.y) * DevScale + 2; GraphFocus.x = (GD_bb(g).UR.x - GD_bb(g).LL.x) / 2.; GraphFocus.y = (GD_bb(g).UR.y - GD_bb(g).LL.y) / 2.; Zoom = 1.0; diff --git a/lib/common/mapgen.c b/lib/common/mapgen.c index ca07f44a8..c82c9da1c 100644 --- a/lib/common/mapgen.c +++ b/lib/common/mapgen.c @@ -298,7 +298,8 @@ static void map_begin_graph(GVC_t * gvc, graph_t * g, box bb, point pb) Dpi = DEFAULT_DPI; DevScale = Dpi / POINTS_PER_INCH; - Viewport = gvc->size; + Viewport.x = gvc->width; + Viewport.y = gvc->height; if (Viewport.x) { Zoom = gvc->zoom; GraphFocus = gvc->focus; diff --git a/lib/common/output.c b/lib/common/output.c index 51626b3e9..73d1e6127 100644 --- a/lib/common/output.c +++ b/lib/common/output.c @@ -213,7 +213,7 @@ void dotneato_write_one(GVC_t * gvc, graph_t * g) } fflush(gvc->job->output_file); - emit_deinit(gvc, g); + emit_deinit(gvc); } void dotneato_write(GVC_t * gvc, graph_t * g) @@ -493,7 +493,7 @@ void _write_plain(GVC_t * gvc, FILE * f, boolean extend) graph_t *g = gvc->g; char *lbl; - setup_graph(gvc, g); +// setup_graph(gvc, g); setYInvert(g); pt = GD_bb(g).UR; fprintf(f, "graph %.3f %.3f %.3f\n", gvc->zoom, PS2INCH(pt.x), PS2INCH(pt.y)); diff --git a/lib/common/renderprocs.h b/lib/common/renderprocs.h index 8f3aa2cba..7259be7db 100644 --- a/lib/common/renderprocs.h +++ b/lib/common/renderprocs.h @@ -76,7 +76,7 @@ extern "C" { 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_deinit(GVC_t * gvc); 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); @@ -126,8 +126,6 @@ extern "C" { extern int late_int(void *, Agsym_t *, int, int); extern char *late_nnstring(void *, Agsym_t *, char *); extern char *late_string(void *, Agsym_t *, char *); - extern int layer_index(char *, int); - extern int layerindex(char *); extern char *strdup_and_subst_graph(char *str, Agraph_t * g); extern char *strdup_and_subst_node(char *str, Agnode_t * n); extern char *strdup_and_subst_edge(char *str, Agedge_t * e); diff --git a/lib/gvc/gvemit.c b/lib/gvc/gvemit.c index b4162d84a..a28d90a53 100644 --- a/lib/gvc/gvemit.c +++ b/lib/gvc/gvemit.c @@ -58,7 +58,7 @@ typedef struct win { cairo_t *cr; - double tx, ty, zoom, oldx, oldy; + double tx, ty, oldx, oldy; int needs_refresh, fit_mode, click, active; Atom wm_delete_window_atom; @@ -151,10 +151,6 @@ static void win_init(win_t * win, int argb, const char *geometry, win->scr = scr = DefaultScreen(dpy); win->fit_mode = 0; - - win->tx = win->ty = 0.0; - win->zoom = 1.0; - win->needs_refresh = 1; if (argb && (win->visual = find_argb_visual(dpy, scr))) { @@ -178,14 +174,11 @@ static void win_init(win_t * win, int argb, const char *geometry, if (geometry) { int x, y; - XParseGeometry(geometry, &x, &y, &win->width, &win->height); - } else { - win->width = win->gvc->size.x; - win->height = win->gvc->size.y; + XParseGeometry(geometry, &x, &y, &win->gvc->width, &win->gvc->height); } win->win = XCreateWindow(dpy, RootWindow(dpy, scr), - 0, 0, win->width, win->height, 0, win->depth, + 0, 0, win->gvc->width, win->gvc->height, 0, win->depth, InputOutput, win->visual, attributemask, &attributes); @@ -197,8 +190,8 @@ static void win_init(win_t * win, int argb, const char *geometry, normalhints->flags = 0; normalhints->x = 0; normalhints->y = 0; - normalhints->width = win->width; - normalhints->height = win->height; + normalhints->width = win->gvc->width; + normalhints->height = win->gvc->height; classhint = XAllocClassHint(); classhint->res_name = "graphviz"; @@ -216,13 +209,13 @@ static void win_init(win_t * win, int argb, const char *geometry, free(name); win->pix = - XCreatePixmap(dpy, win->win, win->width, win->height, win->depth); + XCreatePixmap(dpy, win->win, win->gvc->width, win->gvc->height, win->depth); if (argb) gcv.foreground = 0; else gcv.foreground = WhitePixel(dpy, scr); win->gc = XCreateGC(dpy, win->pix, GCForeground, &gcv); - XFillRectangle(dpy, win->pix, win->gc, 0, 0, win->width, win->height); + XFillRectangle(dpy, win->pix, win->gc, 0, 0, win->gvc->width, win->gvc->height); for (i = 0; i < ARRAY_SIZE(key_binding); i++) { KeySym keysym; @@ -233,7 +226,6 @@ static void win_init(win_t * win, int argb, const char *geometry, else key_binding[i].keycode = XKeysymToKeycode(dpy, keysym); } -// 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); @@ -245,7 +237,6 @@ static void win_init(win_t * win, int argb, const char *geometry, cairo_surface_destroy(surface); /* XXX: This probably doesn't need to be here (eventually) */ cairo_set_rgb_color(win->cr, 1, 1, 1); -// svg_cairo_set_viewport_dimension(win->svgc, win->width, win->height); win->event_mask = ( ButtonPressMask | ButtonReleaseMask @@ -261,29 +252,31 @@ static void win_init(win_t * win, int argb, const char *geometry, win->click = 0; win->active = 0; + win->tx = 0.0; + win->ty = 0.0; } static void win_deinit(win_t * win) { -// cairo_destroy(win->cr); -// win->cr = NULL; XFreeGC(win->dpy, win->gc); XDestroyWindow(win->dpy, win->win); } static void win_refresh(win_t * win) { - XFillRectangle(win->dpy, win->pix, win->gc, 0, 0, win->width, - win->height); - cairo_save(win->cr); - cairo_translate(win->cr, win->tx, win->ty); - cairo_scale(win->cr, win->zoom, win->zoom); + double Z = (win->gvc->zoom * win->gvc->dpi) / POINTS_PER_INCH; + + XFillRectangle(win->dpy, win->pix, win->gc, 0, 0, + win->gvc->width, win->gvc->height); + + /* FIXME - screen point ==> graph point transforms */ + win->gvc->focus.x = -(win->tx) / Z; + win->gvc->focus.y = (win->ty) / Z; emit_graph(win->gvc, win->g, win->flags); - cairo_restore(win->cr); XCopyArea(win->dpy, win->pix, win->win, win->gc, - 0, 0, win->width, win->height, 0, 0); + 0, 0, win->gvc->width, win->gvc->height, 0, 0); } static void win_grow_pixmap(win_t * win) @@ -291,11 +284,12 @@ static void win_grow_pixmap(win_t * win) Pixmap new; cairo_surface_t *surface; - new = XCreatePixmap(win->dpy, win->win, win->width, win->height, + new = XCreatePixmap(win->dpy, win->win, win->gvc->width, win->gvc->height, win->depth); - XFillRectangle(win->dpy, new, win->gc, 0, 0, win->width, win->height); - XCopyArea(win->dpy, win->pix, new, win->gc, 0, 0, win->width, - win->height, 0, 0); + XFillRectangle(win->dpy, new, win->gc, 0, 0, + win->gvc->width, win->gvc->height); + XCopyArea(win->dpy, win->pix, new, win->gc, 0, 0, + win->gvc->width, win->gvc->height, 0, 0); XFreePixmap(win->dpy, win->pix); win->pix = new; surface = cairo_xlib_surface_create(win->dpy, win->pix, win->visual, @@ -318,24 +312,24 @@ static void win_handle_button_press(win_t *win, XButtonEvent *bev) case 4: /* scrollwheel zoom in at current mouse x,y */ win->fit_mode = 0; - win->tx += bev->x * win->zoom; - win->ty += bev->y * win->zoom; - win->zoom *= ZOOMFACTOR; + win->tx += bev->x * win->gvc->zoom; + win->ty += bev->y * win->gvc->zoom; + win->gvc->zoom *= ZOOMFACTOR; win->tx *= ZOOMFACTOR; win->ty *= ZOOMFACTOR; - win->tx -= bev->x * win->zoom; - win->ty -= bev->y * win->zoom; + win->tx -= bev->x * win->gvc->zoom; + win->ty -= bev->y * win->gvc->zoom; win->needs_refresh = 1; break; case 5: /* scrollwheel zoom out at current mouse x,y */ win->fit_mode = 0; - win->tx += bev->x * win->zoom; - win->ty += bev->y * win->zoom; - win->zoom /= ZOOMFACTOR; + win->tx += bev->x * win->gvc->zoom; + win->ty += bev->y * win->gvc->zoom; + win->gvc->zoom /= ZOOMFACTOR; win->tx /= ZOOMFACTOR; win->ty /= ZOOMFACTOR; - win->tx -= bev->x * win->zoom; - win->ty -= bev->y * win->zoom; + win->tx -= bev->x * win->gvc->zoom; + win->ty -= bev->y * win->gvc->zoom; win->needs_refresh = 1; break; } @@ -352,8 +346,8 @@ static void win_handle_motion(win_t *win, XMotionEvent *mev) case 1: break; case 2: /* pan */ - win->tx += (mev->x - win->oldx) * win->zoom; - win->ty += (mev->y - win->oldy) * win->zoom; + win->tx += (mev->x - win->oldx) * win->gvc->zoom; + win->ty += (mev->y - win->oldy) * win->gvc->zoom; win->needs_refresh = 1; break; case 3: /* unused */ @@ -373,8 +367,6 @@ static int win_handle_key_press(win_t * win, XKeyEvent * kev) { unsigned int i; -// fprintf(stderr,"keycode = %d\n", kev->keycode); - for (i = 0; i < ARRAY_SIZE(key_binding); i++) if (key_binding[i].keycode == kev->keycode) return (key_binding[i].callback) (win); @@ -386,11 +378,10 @@ static void win_reconfigure_normal(win_t * win, unsigned int width, { int has_grown = 0; - if (width > win->width || height > win->height) + if (width > win->gvc->width || height > win->gvc->height) has_grown = 1; - win->width = width; - win->height = height; -// svg_cairo_set_viewport_dimension(win->svgc, win->width, win->height); + win->gvc->width = width; + win->gvc->height = height; if (has_grown) win_grow_pixmap(win); } @@ -402,18 +393,16 @@ win_reconfigure_fit_mode(win_t * win, unsigned int width, int dflt_width, dflt_height; int has_grown = 0; - if (width > win->width || height > win->height) + if (width > win->gvc->width || height > win->gvc->width) has_grown = 1; -// svg_cairo_get_size(win->svgc, &dflt_width, &dflt_height); - dflt_width = win->gvc->size.x; - dflt_height = win->gvc->size.y; - win->zoom = + dflt_width = win->gvc->width; + dflt_height = win->gvc->height; + win->gvc->zoom = MIN((double) width / (double) dflt_width, (double) height / (double) dflt_height); - win->width = width; - win->height = height; -// svg_cairo_set_viewport_dimension(win->svgc, win->width, win->height); + win->gvc->width = width; + win->gvc->height = height; win->needs_refresh = 1; if (has_grown) win_grow_pixmap(win); @@ -489,7 +478,7 @@ static int quit_cb(win_t * win) static int left_cb(win_t * win) { win->fit_mode = 0; - win->tx -= PANFACTOR * win->zoom; + win->tx -= PANFACTOR * win->gvc->zoom; win->needs_refresh = 1; return 0; } @@ -497,7 +486,7 @@ static int left_cb(win_t * win) static int right_cb(win_t * win) { win->fit_mode = 0; - win->tx += PANFACTOR * win->zoom; + win->tx += PANFACTOR * win->gvc->zoom; win->needs_refresh = 1; return 0; } @@ -505,7 +494,7 @@ static int right_cb(win_t * win) static int up_cb(win_t * win) { win->fit_mode = 0; - win->ty -= PANFACTOR * win->zoom; + win->ty -= PANFACTOR * win->gvc->zoom; win->needs_refresh = 1; return 0; } @@ -513,7 +502,7 @@ static int up_cb(win_t * win) static int down_cb(win_t * win) { win->fit_mode = 0; - win->ty += PANFACTOR * win->zoom; + win->ty += PANFACTOR * win->gvc->zoom; win->needs_refresh = 1; return 0; } @@ -521,13 +510,13 @@ static int down_cb(win_t * win) static int zoom_in_cb(win_t * win) { win->fit_mode = 0; - win->tx += win->width * win->zoom; - win->ty += win->height * win->zoom; - win->zoom *= ZOOMFACTOR; + win->tx += win->gvc->width * win->gvc->zoom; + win->ty += win->gvc->height * win->gvc->zoom; + win->gvc->zoom *= ZOOMFACTOR; win->tx *= ZOOMFACTOR; win->ty *= ZOOMFACTOR; - win->tx -= win->width * win->zoom; - win->ty -= win->height * win->zoom; + win->tx -= win->gvc->width * win->gvc->zoom; + win->ty -= win->gvc->height * win->gvc->zoom; win->needs_refresh = 1; return 0; } @@ -535,13 +524,13 @@ static int zoom_in_cb(win_t * win) static int zoom_out_cb(win_t * win) { win->fit_mode = 0; - win->tx += win->width * win->zoom; - win->ty += win->height * win->zoom; - win->zoom /= ZOOMFACTOR; + win->tx += win->gvc->width * win->gvc->zoom; + win->ty += win->gvc->height * win->gvc->zoom; + win->gvc->zoom /= ZOOMFACTOR; win->tx /= ZOOMFACTOR; win->ty /= ZOOMFACTOR; - win->tx -= win->width * win->zoom; - win->ty -= win->height * win->zoom; + win->tx -= win->gvc->width * win->gvc->zoom; + win->ty -= win->gvc->height * win->gvc->zoom; win->needs_refresh = 1; return 0; } @@ -551,11 +540,11 @@ static int toggle_fit_cb(win_t * win) win->fit_mode = !win->fit_mode; if (win->fit_mode) { int dflt_width, dflt_height; - dflt_width = win->gvc->size.x; - dflt_height = win->gvc->size.y; - win->zoom = - MIN((double) win->width / (double) dflt_width, - (double) win->height / (double) dflt_height); + dflt_width = win->gvc->width; + dflt_height = win->gvc->height; + win->gvc->zoom = + MIN((double) win->gvc->width / (double) dflt_width, + (double) win->gvc->height / (double) dflt_height); win->tx = 0.0; win->ty = 0.0; win->needs_refresh = 1; @@ -602,4 +591,5 @@ void gvemit_graph(GVC_t * gvc, graph_t * g, int flags) else { emit_graph(gvc, g, flags); } +fprintf(stderr,"gvemit_graph\n"); } diff --git a/lib/gvc/gvrender.c b/lib/gvc/gvrender.c index 63659e137..56fa9f74d 100644 --- a/lib/gvc/gvrender.c +++ b/lib/gvc/gvrender.c @@ -132,9 +132,8 @@ void gvrender_begin_job(GVC_t * gvc, char **lib, point pages, double X, double Y if (dpi < 1.0) dpi = gvc->render_features->default_dpi; gvc->dpi = dpi; - gvc->size.x = ROUND(X * dpi / POINTS_PER_INCH); - gvc->size.y = ROUND(Y * dpi / POINTS_PER_INCH); - gvc->zoom = Z; /* scaling factor */ + gvc->width = ROUND(X * dpi / POINTS_PER_INCH); + gvc->height = ROUND(Y * dpi / POINTS_PER_INCH); gvc->zoom = Z; /* scaling factor */ gvc->focus.x = x; /* graph coord of focus - points */ gvc->focus.y = y; @@ -180,11 +179,11 @@ static pointf gvrender_ptf(GVC_t * gvc, pointf p) pointf rv; if (gvc->rot == 0) { - rv.x = (p.x - gvc->focus.x) * gvc->compscale.x + gvc->size.x / 2.; - rv.y = (p.y - gvc->focus.y) * gvc->compscale.y + gvc->size.y / 2.; + rv.x = (p.x - gvc->focus.x) * gvc->compscale.x + gvc->width / 2.; + rv.y = (p.y - gvc->focus.y) * gvc->compscale.y + gvc->height / 2.; } else { - rv.x = -(p.y - gvc->focus.y) * gvc->compscale.x + gvc->size.x / 2.; - rv.y = (p.x - gvc->focus.x) * gvc->compscale.y + gvc->size.y / 2.; + rv.x = -(p.y - gvc->focus.y) * gvc->compscale.x + gvc->width / 2.; + rv.y = (p.x - gvc->focus.x) * gvc->compscale.y + gvc->height / 2.; } return rv; } @@ -194,19 +193,11 @@ static pointf gvrender_pt(GVC_t * gvc, point p) pointf rv; if (gvc->rot == 0) { - rv.x = - ((double) p.x - gvc->focus.x) * gvc->compscale.x + - gvc->size.x / 2.; - rv.y = - ((double) p.y - gvc->focus.y) * gvc->compscale.y + - gvc->size.y / 2.; + rv.x = ((double) p.x - gvc->focus.x) * gvc->compscale.x + gvc->width / 2.; + rv.y = ((double) p.y - gvc->focus.y) * gvc->compscale.y + gvc->height / 2.; } else { - rv.x = - -((double) p.y - gvc->focus.y) * gvc->compscale.x + - gvc->size.x / 2.; - rv.y = - ((double) p.x - gvc->focus.x) * gvc->compscale.y + - gvc->size.y / 2.; + rv.x = -((double) p.y - gvc->focus.y) * gvc->compscale.x + gvc->width / 2.; + rv.y = ((double) p.x - gvc->focus.x) * gvc->compscale.y + gvc->height / 2.; } return rv; } diff --git a/lib/gvc/gvrenderint.h b/lib/gvc/gvrenderint.h index 71d3f0fb2..6091d5672 100644 --- a/lib/gvc/gvrenderint.h +++ b/lib/gvc/gvrenderint.h @@ -122,19 +122,21 @@ extern "C" { box bb; /* graph bounding box (what units???) */ point pb; /* page size - including margins (inches) */ point margin; /* page margins (inches) */ - double dpi; /* resolution dots-per-inch */ - color_t bgcolor; /* background color */ gvstyle_t styles[MAXNEST]; /* style stack */ int SP; gvstyle_t *style; /* render defaults set from graph */ - point size; /* viewport size (pixels) */ + color_t bgcolor; /* background color */ + unsigned int width; + unsigned int height; + double dpi; /* resolution dots-per-inch */ + int rot; /* rotation */ + double zoom; /* viewport zoom factor */ pointf focus; /* viewport focus in graph units */ pointf compscale; /* composite device scale incl: scale, zoom, dpi, y_goes_down */ - int rot; /* rotation */ /* gvrender_begin_page() */ point page; diff --git a/tclpkg/tcldot/tkgen.c b/tclpkg/tcldot/tkgen.c index 69e856a10..c3c15fda6 100644 --- a/tclpkg/tcldot/tkgen.c +++ b/tclpkg/tcldot/tkgen.c @@ -195,7 +195,8 @@ static void tk_begin_graph(GVC_t * gvc, graph_t * g, box bb, point pb) dpi = DEFAULT_DPI; DevScale = dpi / POINTS_PER_INCH; - Viewport = gvc->size; + Viewport.x = gvc->width; + Viewport.y = gvc->height; if (Viewport.x) { Zoom = gvc->zoom; GraphFocus = gvc->focus; -- 2.40.0