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;
return TRUE;
}
-
static int write_node_test(Agraph_t * g, Agnode_t * n)
{
Agraph_t *sg;
}
}
+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;
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);
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;
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;
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)
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) {
void emit_eof(GVC_t * gvc)
{
if (Page > 0) {
- gvrender_end_job(gvc);
+ emit_deinit(gvc);
emit_once_reset();
}
}
&& (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;
return TRUE;
}
-int layer_index(char *str, int all)
+static int layer_index(char *str, int all)
{
int i;
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;
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;
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))) {
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);
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";
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;
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);
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
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)
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,
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;
}
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 */
{
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);
{
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);
}
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);
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
else {
emit_graph(gvc, g, flags);
}
+fprintf(stderr,"gvemit_graph\n");
}