/* push empty graphic state for current object */
static obj_state_t* push_obj_state(GVJ_t *job)
{
- obj_state_t *obj;
+ obj_state_t *obj, *parent;
if (! (obj = zmalloc(sizeof(obj_state_t))))
agerr(AGERR, "no memory from zmalloc()\n");
- obj->parent = job->obj;
+ parent = obj->parent = job->obj;
job->obj = obj;
-
+ if (parent) {
+ obj->pencolor = parent->pencolor; /* default styles to parent's style */
+ obj->fillcolor = parent->fillcolor;
+ obj->pen = parent->pen;
+ obj->fill = parent->fill;
+ obj->penwidth = parent->penwidth;
+ }
+ else {
+ /* obj->pencolor = NULL */
+ /* obj->fillcolor = NULL */
+ obj->pen = PEN_SOLID;
+ obj->fill = FILL_NONE;
+ obj->penwidth = PENWIDTH_NORMAL;
+ }
return obj;
}
GVC_t *gvc = job->gvc;
char *s;
- if (ND_shape(n) == NULL)
- return;
-
- if (node_in_layer(job, n->graph, n)
- && node_in_box(n, job->pageBoxClip)
- && (ND_state(n) != gvc->common.viewNum)) {
+ if (ND_shape(n) /* node has a shape */
+ && node_in_layer(job, n->graph, n) /* and is in layer */
+ && node_in_box(n, job->pageBoxClip) /* and is in page */
+ && (ND_state(n) != gvc->common.viewNum)) /* and not already drawn */
+ {
+ ND_state(n) = gvc->common.viewNum; /* mark node as drawn */
gvrender_comment(job, n->name);
s = late_string(n, N_comment, "");
emit_begin_node(job, n);
ND_shape(n)->fns->codefn(job, n);
- ND_state(n) = gvc->common.viewNum;
emit_end_node(job);
}
}
{
char *s;
- if (! edge_in_box(e, job->pageBoxClip) || ! edge_in_layer(job, e->head->graph, e))
- return;
+ if (edge_in_box(e, job->pageBoxClip) && edge_in_layer(job, e->head->graph, e)) {
- s = malloc(strlen(e->tail->name) + 2 + strlen(e->head->name) + 1);
- strcpy(s,e->tail->name);
- if (AG_IS_DIRECTED(e->tail->graph))
- strcat(s,"->");
- else
- strcat(s,"--");
- strcat(s,e->head->name);
- gvrender_comment(job, s);
- free(s);
+ s = malloc(strlen(e->tail->name) + 2 + strlen(e->head->name) + 1);
+ strcpy(s,e->tail->name);
+ if (AG_IS_DIRECTED(e->tail->graph))
+ strcat(s,"->");
+ else
+ strcat(s,"--");
+ strcat(s,e->head->name);
+ gvrender_comment(job, s);
+ free(s);
- s = late_string(e, E_comment, "");
- if (s[0])
- gvrender_comment(job, s);
+ s = late_string(e, E_comment, "");
+ if (s[0])
+ gvrender_comment(job, s);
- emit_begin_edge(job, e);
- emit_edge_graphics (job, e);
- emit_end_edge(job);
+ emit_begin_edge(job, e);
+ emit_edge_graphics (job, e);
+ emit_end_edge(job);
+ }
}
static void init_gvc(GVC_t * gvc, graph_t * g)
static void emit_begin_graph(GVJ_t * job, graph_t * g)
{
- GVC_t *gvc = job->gvc;
int flags = job->flags;
obj_state_t *obj;
textlabel_t *lab;
obj->target = strdup_and_subst_graph(s, g);
}
- /* init stack */
- gvc->SP = 0;
- job->style = &(gvc->styles[0]);
- job->style->pen = PEN_SOLID;
- job->style->fill = FILL_NONE;
- job->style->penwidth = PENWIDTH_NORMAL;
-
#ifdef WITH_CODEGENS
Obj = NONE;
#endif
/* default line style */
char **defaultlinestyle;
- gvstyle_t styles[MAXNEST]; /* style stack - reused by each job */
- int SP;
-
/* render defaults set from graph */
gvcolor_t bgcolor; /* background color */
};
#define PENWIDTH_BOLD 2.
typedef enum { GVATTR_STRING, GVATTR_BOOL, GVATTR_COLOR } gvattr_t;
- typedef struct {
- gvcolor_t pencolor, fillcolor;
- pen_type pen;
- fill_type fill;
- double penwidth;
- char **rawstyle;
- } gvstyle_t;
-
#define EMIT_SORTED (1<<0)
#define EMIT_COLORS (1<<1)
#define EMIT_CLUSTERS_LAST (1<<2)
int oldstate; /* FIXME - used by one of those other state stacks */
+ gvcolor_t pencolor, fillcolor;
+ pen_type pen;
+ fill_type fill;
+ double penwidth;
+ char **rawstyle;
+
double z, tail_z, head_z; /* z depths for 2.5D renderers such as vrml */
/* fully substituted text strings */
void *surface; /* gd or cairo surface */
bool external_surface; /* surface belongs to caller */
- gvstyle_t *style; /* active style from gvc->styles[] */
-
int flags; /* emit_graph flags */
int numLayers; /* number of layers */
void gvrender_begin_context(GVJ_t * job)
{
- GVC_t *gvc = job->gvc;
- gvrender_engine_t *gvre = job->render.engine;
-
- if (gvre) {
- (gvc->SP)++;
- assert((gvc->SP) < MAXNEST);
- gvc->styles[gvc->SP] = gvc->styles[(gvc->SP) - 1];
- job->style = &(gvc->styles[gvc->SP]);
- }
#ifdef WITH_CODEGENS
- else {
- codegen_t *cg = job->codegen;
+ codegen_t *cg = job->codegen;
- if (cg && cg->begin_context)
- cg->begin_context();
- }
+ if (cg && cg->begin_context)
+ cg->begin_context();
#endif
}
void gvrender_end_context(GVJ_t * job)
{
- GVC_t *gvc = job->gvc;
- gvrender_engine_t *gvre = job->render.engine;
-
- if (gvre) {
- gvc->SP--;
- assert(gvc->SP >= 0);
- job->style = &(gvc->styles[gvc->SP]);
- }
#ifdef WITH_CODEGENS
- else {
- codegen_t *cg = job->codegen;
+ codegen_t *cg = job->codegen;
- if (cg && cg->end_context)
- cg->end_context();
- }
+ if (cg && cg->end_context)
+ cg->end_context();
#endif
}
pointf PF;
if (para->str && para->str[0]
- && ( ! job->style /* because of xdgen non-conformity */
- || job->style->pen != PEN_NONE)) {
+ && ( ! job->obj /* because of xdgen non-conformity */
+ || job->obj->pen != PEN_NONE)) {
if (job->flags & GVRENDER_DOES_TRANSFORM)
PF = p;
else
void gvrender_set_pencolor(GVJ_t * job, char *name)
{
gvrender_engine_t *gvre = job->render.engine;
- gvcolor_t *color = &(job->style->pencolor);
+ gvcolor_t *color = &(job->obj->pencolor);
if (gvre) {
gvrender_resolve_color(job->render.features, name, color);
void gvrender_set_fillcolor(GVJ_t * job, char *name)
{
gvrender_engine_t *gvre = job->render.engine;
- gvcolor_t *color = &(job->style->fillcolor);
+ gvcolor_t *color = &(job->obj->fillcolor);
if (gvre) {
gvrender_resolve_color(job->render.features, name, color);
void gvrender_set_style(GVJ_t * job, char **s)
{
gvrender_engine_t *gvre = job->render.engine;
+ obj_state_t *obj = job->obj;
char *line, *p;
- gvstyle_t *style = job->style;
- job->style->rawstyle = s;
+ obj->rawstyle = s;
if (gvre) {
while ((p = line = *s++)) {
if (streq(line, "solid"))
- style->pen = PEN_SOLID;
+ obj->pen = PEN_SOLID;
else if (streq(line, "dashed"))
- style->pen = PEN_DASHED;
+ obj->pen = PEN_DASHED;
else if (streq(line, "dotted"))
- style->pen = PEN_DOTTED;
+ obj->pen = PEN_DOTTED;
else if (streq(line, "invis") || streq(line, "invisible"))
- style->pen = PEN_NONE;
+ obj->pen = PEN_NONE;
else if (streq(line, "bold"))
- style->penwidth = PENWIDTH_BOLD;
+ obj->penwidth = PENWIDTH_BOLD;
else if (streq(line, "setlinewidth")) {
while (*p)
p++;
p++;
- style->penwidth = atof(p);
+ obj->penwidth = atof(p);
} else if (streq(line, "filled"))
- style->fill = FILL_SOLID;
+ obj->fill = FILL_SOLID;
else if (streq(line, "unfilled"))
- style->fill = FILL_NONE;
+ obj->fill = FILL_NONE;
else {
agerr(AGWARN,
"gvrender_set_style: unsupported style %s - ignoring\n",
gvrender_engine_t *gvre = job->render.engine;
if (gvre) {
- if (gvre->ellipse && job->style->pen != PEN_NONE) {
+ if (gvre->ellipse && job->obj->pen != PEN_NONE) {
pointf af[2];
/* center */
gvrender_engine_t *gvre = job->render.engine;
if (gvre) {
- if (gvre->polygon && job->style->pen != PEN_NONE) {
+ if (gvre->polygon && job->obj->pen != PEN_NONE) {
if (job->flags & GVRENDER_DOES_TRANSFORM)
gvre->polygon(job, af, n, filled);
else {
gvrender_engine_t *gvre = job->render.engine;
if (gvre) {
- if (gvre->beziercurve && job->style->pen != PEN_NONE) {
+ if (gvre->beziercurve && job->obj->pen != PEN_NONE) {
if (job->flags & GVRENDER_DOES_TRANSFORM)
gvre->beziercurve(job, af, n, arrow_at_start, arrow_at_end,filled);
else {
gvrender_engine_t *gvre = job->render.engine;
if (gvre) {
- if (gvre->polyline && job->style->pen != PEN_NONE) {
+ if (gvre->polyline && job->obj->pen != PEN_NONE) {
if (job->flags & GVRENDER_DOES_TRANSFORM)
gvre->polyline(job, af, n);
else {
color->type = COLOR_INDEX;
}
-static void figgen_line_style(gvstyle_t *style, int *line_style, double *style_val)
+static void figgen_line_style(obj_state_t *obj, int *line_style, double *style_val)
{
- switch (style->pen) {
+ switch (obj->pen) {
case PEN_DASHED:
*line_style = 1;
*style_val = 10.;
static void figgen_textpara(GVJ_t * job, pointf p, textpara_t * para)
{
- gvstyle_t *style = job->style;
+ obj_state_t *obj = job->obj;
int object_code = 4; /* always 4 for text */
int sub_type = 0; /* text justification */
- int color = style->pencolor.u.index;
+ int color = obj->pencolor.u.index;
int depth = Depth;
int pen_style = 0; /* not used */
int font = -1; /* init to xfig's default font */
static void figgen_ellipse(GVJ_t * job, pointf * A, int filled)
{
- gvstyle_t *style = job->style;
+ obj_state_t *obj = job->obj;
int object_code = 1; /* always 1 for ellipse */
int sub_type = 1; /* ellipse defined by radii */
int line_style; /* solid, dotted, dashed */
- int thickness = style->penwidth;
- int pen_color = style->pencolor.u.index;
- int fill_color = style->fillcolor.u.index;
+ int thickness = obj->penwidth;
+ int pen_color = obj->pencolor.u.index;
+ int fill_color = obj->fillcolor.u.index;
int depth = Depth;
int pen_style = 0; /* not used */
int area_fill = filled ? 20 : -1;
int center_x, center_y, radius_x, radius_y;
int start_x, start_y, end_x, end_y;
- figgen_line_style(style, &line_style, &style_val);
+ figgen_line_style(obj, &line_style, &style_val);
start_x = center_x = ROUND(A[0].x);
start_y = center_y = ROUND(A[0].y);
start_y, end_x, end_y);
}
-static void
-figgen_bezier(GVJ_t * job, pointf * A, int n, int arrow_at_start,
+static void figgen_bezier(GVJ_t * job, pointf * A, int n, int arrow_at_start,
int arrow_at_end, int filled)
{
- gvstyle_t *style = job->style;
+ obj_state_t *obj = job->obj;
int object_code = 3; /* always 3 for spline */
int sub_type;
int line_style; /* solid, dotted, dashed */
- int thickness = style->penwidth;
- int pen_color = style->pencolor.u.index;
- int fill_color = style->fillcolor.u.index;
+ int thickness = obj->penwidth;
+ int pen_color = obj->pencolor.u.index;
+ int fill_color = obj->fillcolor.u.index;
int depth = Depth;
int pen_style = 0; /* not used */
int area_fill;
1) * 20 * sizeof(char));
buf = buffer;
- figgen_line_style(style, &line_style, &style_val);
+ figgen_line_style(obj, &line_style, &style_val);
if (filled) {
sub_type = 5; /* closed X-spline */
area_fill = 20; /* fully saturated color */
- fill_color = job->style->fillcolor.u.index;
+ fill_color = job->obj->fillcolor.u.index;
}
else {
sub_type = 4; /* opened X-spline */
static void figgen_polygon(GVJ_t * job, pointf * A, int n, int filled)
{
- gvstyle_t *style = job->style;
+ obj_state_t *obj = job->obj;
int object_code = 2; /* always 2 for polyline */
int sub_type = 3; /* always 3 for polygon */
int line_style; /* solid, dotted, dashed */
- int thickness = style->penwidth;
- int pen_color = style->pencolor.u.index;
- int fill_color = style->fillcolor.u.index;
+ int thickness = obj->penwidth;
+ int pen_color = obj->pencolor.u.index;
+ int fill_color = obj->fillcolor.u.index;
int depth = Depth;
int pen_style = 0; /* not used */
int area_fill = filled ? 20 : -1;
int backward_arrow = 0;
int npoints = n + 1;
- figgen_line_style(style, &line_style, &style_val);
+ figgen_line_style(obj, &line_style, &style_val);
figgen_printf(job,
"%d %d %d %d %d %d %d %d %d %.1f %d %d %d %d %d %d\n",
static void figgen_polyline(GVJ_t * job, pointf * A, int n)
{
- gvstyle_t *style = job->style;
+ obj_state_t *obj = job->obj;
int object_code = 2; /* always 2 for polyline */
int sub_type = 1; /* always 1 for polyline */
int line_style; /* solid, dotted, dashed */
- int thickness = style->penwidth;
- int pen_color = style->pencolor.u.index;
+ int thickness = obj->penwidth;
+ int pen_color = obj->pencolor.u.index;
int fill_color = 0;
int depth = Depth;
int pen_style = 0; /* not used */
int backward_arrow = 0;
int npoints = n;
- figgen_line_style(style, &line_style, &style_val);
+ figgen_line_style(obj, &line_style, &style_val);
figgen_printf(job,
"%d %d %d %d %d %d %d %d %d %.1f %d %d %d %d %d %d\n",
static void
ps_set_pen_style(GVJ_t *job)
{
- double penwidth = job->style->penwidth * job->zoom;
- char *p, *line, **s = job->style->rawstyle;
+ double penwidth = job->obj->penwidth * job->zoom;
+ char *p, *line, **s = job->obj->rawstyle;
FILE *out = job->output_file;
fprintf(out,"%g setlinewidth\n", penwidth);
p++;
}
if (strcmp(line, "invis") == 0)
- job->style->penwidth = 0;
+ job->obj->penwidth = 0;
fprintf(out, "%s\n", line);
}
}
double adj, sz;
char *str;
- if (job->style->pencolor.u.HSVA[3] < .5)
+ if (job->obj->pencolor.u.HSVA[3] < .5)
return; /* skip transparent text */
- ps_set_color(job, &(job->style->pencolor));
+ ps_set_color(job, &(job->obj->pencolor));
if (para->fontname) {
sz = para->fontsize;
if (sz != last_fontsize
{
/* A[] contains 2 points: the center and corner. */
- if (filled && job->style->fillcolor.u.HSVA[3] > .5) {
- ps_set_color(job, &(job->style->fillcolor));
+ if (filled && job->obj->fillcolor.u.HSVA[3] > .5) {
+ ps_set_color(job, &(job->obj->fillcolor));
fprintf(job->output_file, "%g %g %g %g ellipse_path fill\n",
A[0].x, A[0].y, fabs(A[1].x - A[0].x), fabs(A[1].y - A[0].y));
}
- if (job->style->pencolor.u.HSVA[3] > .5) {
+ if (job->obj->pencolor.u.HSVA[3] > .5) {
ps_set_pen_style(job);
- ps_set_color(job, &(job->style->pencolor));
+ ps_set_color(job, &(job->obj->pencolor));
fprintf(job->output_file, "%g %g %g %g ellipse_path stroke\n",
A[0].x, A[0].y, fabs(A[1].x - A[0].x), fabs(A[1].y - A[0].y));
}
{
int j;
- if (filled && job->style->fillcolor.u.HSVA[3] > .5) {
- ps_set_color(job, &(job->style->fillcolor));
+ if (filled && job->obj->fillcolor.u.HSVA[3] > .5) {
+ ps_set_color(job, &(job->obj->fillcolor));
fprintf(job->output_file, "newpath %g %g moveto\n", A[0].x, A[0].y);
for (j = 1; j < n; j += 3)
fprintf(job->output_file, "%g %g %g %g %g %g curveto\n",
A[j + 2].y);
fprintf(job->output_file, "closepath fill\n");
}
- if (job->style->pencolor.u.HSVA[3] > .5) {
+ if (job->obj->pencolor.u.HSVA[3] > .5) {
ps_set_pen_style(job);
- ps_set_color(job, &(job->style->pencolor));
+ ps_set_color(job, &(job->obj->pencolor));
fprintf(job->output_file, "newpath %g %g moveto\n", A[0].x, A[0].y);
for (j = 1; j < n; j += 3)
fprintf(job->output_file, "%g %g %g %g %g %g curveto\n",
{
int j;
- if (filled && job->style->fillcolor.u.HSVA[3] > .5) {
- ps_set_color(job, &(job->style->fillcolor));
+ if (filled && job->obj->fillcolor.u.HSVA[3] > .5) {
+ ps_set_color(job, &(job->obj->fillcolor));
fprintf(job->output_file, "newpath %g %g moveto\n", A[0].x, A[0].y);
for (j = 1; j < n; j++)
fprintf(job->output_file, "%g %g lineto\n", A[j].x, A[j].y);
fprintf(job->output_file, "closepath fill\n");
}
- if (job->style->pencolor.u.HSVA[3] > .5) {
+ if (job->obj->pencolor.u.HSVA[3] > .5) {
ps_set_pen_style(job);
- ps_set_color(job, &(job->style->pencolor));
+ ps_set_color(job, &(job->obj->pencolor));
fprintf(job->output_file, "newpath %g %g moveto\n", A[0].x, A[0].y);
for (j = 1; j < n; j++)
fprintf(job->output_file, "%g %g lineto\n", A[j].x, A[j].y);
{
int j;
- if (job->style->pencolor.u.HSVA[3] > .5) {
+ if (job->obj->pencolor.u.HSVA[3] > .5) {
ps_set_pen_style(job);
- ps_set_color(job, &(job->style->pencolor));
+ ps_set_color(job, &(job->obj->pencolor));
fprintf(job->output_file, "newpath %g %g moveto\n", A[0].x, A[0].y);
for (j = 1; j < n; j++)
fprintf(job->output_file, "%g %g lineto\n", A[j].x, A[j].y);
static void svggen_grstyle(GVJ_t * job, int filled)
{
- gvstyle_t *style = job->style;
+ obj_state_t *obj = job->obj;
svggen_fputs(job, " style=\"fill:");
if (filled)
- svggen_print_color(job, style->fillcolor);
+ svggen_print_color(job, obj->fillcolor);
else
svggen_fputs(job, "none");
svggen_fputs(job, ";stroke:");
- svggen_print_color(job, style->pencolor);
- if (style->penwidth != PENWIDTH_NORMAL)
- svggen_printf(job, ";stroke-width:%g", style->penwidth);
- if (style->pen == PEN_DASHED) {
+ svggen_print_color(job, obj->pencolor);
+ if (obj->penwidth != PENWIDTH_NORMAL)
+ svggen_printf(job, ";stroke-width:%g", obj->penwidth);
+ if (obj->pen == PEN_DASHED) {
svggen_printf(job, ";stroke-dasharray:%s", sdarray);
- } else if (style->pen == PEN_DOTTED) {
+ } else if (obj->pen == PEN_DOTTED) {
svggen_printf(job, ";stroke-dasharray:%s", sdotarray);
}
svggen_fputs(job, ";\"");
static void svggen_textpara(GVJ_t * job, pointf p, textpara_t * para)
{
- gvstyle_t *penstyle = job->style;
+ obj_state_t *obj = job->obj;
svggen_fputs(job, "<text");
switch (para->just) {
svggen_printf(job, "font:%s;", para->fontname);
}
svggen_printf(job, "font-size:%.2fpx;", para->fontsize);
- switch (penstyle->pencolor.type) {
+ switch (obj->pencolor.type) {
case COLOR_STRING:
- if (strcasecmp(penstyle->pencolor.u.string, "black"))
- svggen_printf(job, "fill:%s;", penstyle->pencolor.u.string);
+ if (strcasecmp(obj->pencolor.u.string, "black"))
+ svggen_printf(job, "fill:%s;", obj->pencolor.u.string);
break;
case RGBA_BYTE:
svggen_printf(job, "fill:#%02x%02x%02x;",
- penstyle->pencolor.u.rgba[0],
- penstyle->pencolor.u.rgba[1], penstyle->pencolor.u.rgba[2]);
+ obj->pencolor.u.rgba[0], obj->pencolor.u.rgba[1], obj->pencolor.u.rgba[2]);
break;
default:
assert(0); /* internal error */
/* draw para in place of text */
gdImageLine(im, ROUND(mp.x), ROUND(mp.y),
ROUND(ep.x), ROUND(ep.y),
- job->style->pencolor.u.index);
+ job->obj->pencolor.u.index);
} else {
#if defined(HAVE_LIBFREETYPE) && defined(HAVE_GD_FREETYPE)
- err = gdImageStringFTEx(im, brect, job->style->pencolor.u.index,
+ err = gdImageStringFTEx(im, brect, job->obj->pencolor.u.index,
para->fontname, para->fontsize, job->rotation ? (PI / 2) : 0,
ROUND(mp.x), ROUND(mp.y), (char *)(para->str), &strex);
#if 0
gdImagePolygon(im, (gdPointPtr) brect, 4,
- job->style->pencolor.u.index);
+ job->obj->pencolor.u.index);
#endif
#if 0
fprintf(stderr,
gdImageString(im, gdFontTiny,
ROUND(mp.x), ROUND(mp.y - 9.),
(unsigned char *)para->str,
- job->style->pencolor.u.index);
+ job->obj->pencolor.u.index);
} else if (para->fontsize <= 9.5) {
gdImageString(im, gdFontSmall,
ROUND(mp.x), ROUND(mp.y - 12.),
(unsigned char *)para->str,
- job->style->pencolor.u.index);
+ job->obj->pencolor.u.index);
} else if (para->fontsize <= 10.5) {
gdImageString(im, gdFontMediumBold,
ROUND(mp.x), ROUND(mp.y - 13.),
(unsigned char *)para->str,
- job->style->pencolor.u.index);
+ job->obj->pencolor.u.index);
} else if (para->fontsize <= 11.5) {
gdImageString(im, gdFontLarge,
ROUND(mp.x), ROUND(mp.y - 14.),
(unsigned char *)para->str,
- job->style->pencolor.u.index);
+ job->obj->pencolor.u.index);
} else {
gdImageString(im, gdFontGiant,
ROUND(mp.x), ROUND(mp.y - 15.),
(unsigned char *)para->str,
- job->style->pencolor.u.index);
+ job->obj->pencolor.u.index);
}
#if defined(HAVE_LIBFREETYPE) && defined(HAVE_GD_FREETYPE)
}
static int gdgen_set_penstyle(GVJ_t * job, gdImagePtr im, gdImagePtr brush)
{
- gvstyle_t *style = job->style;
+ obj_state_t *obj = job->obj;
int i, pen, width, dashstyle[40];
- if (style->pen == PEN_DASHED) {
+ if (obj->pen == PEN_DASHED) {
for (i = 0; i < 10; i++)
- dashstyle[i] = style->pencolor.u.index;
+ dashstyle[i] = obj->pencolor.u.index;
for (; i < 20; i++)
dashstyle[i] = transparent;
gdImageSetStyle(im, dashstyle, 20);
pen = gdStyled;
- } else if (style->pen == PEN_DOTTED) {
+ } else if (obj->pen == PEN_DOTTED) {
for (i = 0; i < 2; i++)
- dashstyle[i] = style->pencolor.u.index;
+ dashstyle[i] = obj->pencolor.u.index;
for (; i < 14; i++)
dashstyle[i] = transparent;
gdImageSetStyle(im, dashstyle, 12);
pen = gdStyled;
} else {
- pen = style->pencolor.u.index;
+ pen = obj->pencolor.u.index;
}
- width = style->penwidth * job->scale.x;
+ width = obj->penwidth * job->scale.x;
if (width < PENWIDTH_NORMAL)
width = PENWIDTH_NORMAL; /* gd can't do thin lines */
gdImageSetThickness(im, width);
brush = gdImageCreate(width, width);
gdImagePaletteCopy(brush, im);
gdImageFilledRectangle(brush, 0, 0, width - 1, width - 1,
- style->pencolor.u.index);
+ obj->pencolor.u.index);
gdImageSetBrush(im, brush);
if (pen == gdStyled)
pen = gdStyledBrushed;
gdgen_bezier(GVJ_t * job, pointf * A, int n, int arrow_at_start,
int arrow_at_end, int filled)
{
- gvstyle_t *style = job->style;
+ obj_state_t *obj = job->obj;
gdImagePtr im = (gdImagePtr) job->surface;
pointf p0, p1, V[4];
int i, j, step, pen;
PF2P(p1, F[2]);
gdImageLine(im, F[1].x, F[1].y, F[2].x, F[2].y, pen);
if (filled)
- gdImageFilledPolygon(im, F, 4, style->fillcolor.u.index);
+ gdImageFilledPolygon(im, F, 4, obj->fillcolor.u.index);
p0 = p1;
}
}
static void gdgen_polygon(GVJ_t * job, pointf * A, int n, int filled)
{
- gvstyle_t *style = job->style;
+ obj_state_t *obj = job->obj;
gdImagePtr im = (gdImagePtr) job->surface;
gdImagePtr brush = NULL;
int i;
points[i].y = ROUND(A[i].y);
}
if (filled)
- gdImageFilledPolygon(im, points, n, style->fillcolor.u.index);
+ gdImageFilledPolygon(im, points, n, obj->fillcolor.u.index);
gdImagePolygon(im, points, n, pen);
free(points);
static void gdgen_ellipse(GVJ_t * job, pointf * A, int filled)
{
- gvstyle_t *style = job->style;
+ obj_state_t *obj = job->obj;
gdImagePtr im = (gdImagePtr) job->surface;
double dx, dy;
int pen;
if (filled)
gdImageFilledEllipse(im, ROUND(A[0].x), ROUND(A[0].y),
ROUND(dx), ROUND(dy),
- style->fillcolor.u.index);
+ obj->fillcolor.u.index);
gdImageArc(im, ROUND(A[0].x), ROUND(A[0].y), ROUND(dx), ROUND(dy),
0, 360, pen);
if (brush)
static int set_penstyle(GVJ_t * job, gdImagePtr im, gdImagePtr brush)
{
- gvstyle_t *style = job->style;
+ obj_state_t *obj = job->obj;
int i, pen, pencolor, transparent, width, dashstyle[40];
- pen = pencolor = color_index(im, style->pencolor);
+ pen = pencolor = color_index(im, obj->pencolor);
transparent = gdImageGetTransparent(im);
- if (style->pen == PEN_DASHED) {
+ if (obj->pen == PEN_DASHED) {
for (i = 0; i < 20; i++)
dashstyle[i] = pencolor;
for (; i < 40; i++)
dashstyle[i] = transparent;
gdImageSetStyle(im, dashstyle, 20);
pen = gdStyled;
- } else if (style->pen == PEN_DOTTED) {
+ } else if (obj->pen == PEN_DOTTED) {
for (i = 0; i < 2; i++)
dashstyle[i] = pencolor;
for (; i < 24; i++)
gdImageSetStyle(im, dashstyle, 24);
pen = gdStyled;
}
- width = style->penwidth * job->scale.x;
+ width = obj->penwidth * job->scale.x;
if (width < PENWIDTH_NORMAL)
width = PENWIDTH_NORMAL; /* gd can't do thin lines */
gdImageSetThickness(im, width);
mp = vrml_node_point(job, obj->u.n, p);
err = gdImageStringFT(im, brect,
- color_index(im, job->style->pencolor),
+ color_index(im, obj->pencolor),
para->fontname, para->fontsize, job->rotation ? PI/2 : 0,
ROUND(mp.x), ROUND(mp.y), (char*)para->str);
if (err) {
gdImageString(im,
gdFontSmall, ROUND(mp.x), ROUND(mp.y),
(unsigned char *) para->str,
- color_index(im, job->style->pencolor));
+ color_index(im, obj->pencolor));
}
}
doSegment (GVJ_t *job, pointf* A, point p0, double z0, point p1, double z1)
{
FILE *out = job->output_file;
- gvstyle_t *style = job->style;
+ obj_state_t *obj = job->obj;
double d1, d0;
double delx, dely, delz;
fprintf(out, " Shape {\n");
fprintf(out, " geometry Cylinder {\n");
fprintf(out, " bottom FALSE top FALSE\n");
- fprintf(out, " height %.3f radius %.3f }\n", CylHt, style->penwidth);
+ fprintf(out, " height %.3f radius %.3f }\n", CylHt, obj->penwidth);
fprintf(out, " appearance Appearance {\n");
fprintf(out, " material Material {\n");
fprintf(out, " ambientIntensity 0.33\n");
fprintf(out, " diffuseColor %.3f %.3f %.3f\n",
- style->pencolor.u.rgba[0] / 255.,
- style->pencolor.u.rgba[1] / 255.,
- style->pencolor.u.rgba[2] / 255.);
+ obj->pencolor.u.rgba[0] / 255.,
+ obj->pencolor.u.rgba[1] / 255.,
+ obj->pencolor.u.rgba[2] / 255.);
fprintf(out, " }\n");
fprintf(out, " }\n");
fprintf(out, " }\n");
vrml_bezier(GVJ_t *job, pointf * A, int n, int arrow_at_start, int arrow_at_end, int filled)
{
FILE *out = job->output_file;
- gvstyle_t *style = job->style;
obj_state_t *obj = job->obj;
edge_t *e = obj->u.e;
double fstz = obj->tail_z, sndz = obj->head_z;
}
fprintf(out, " ]\n");
fprintf(out, " crossSection [ %.3f %.3f, %.3f %.3f, %.3f %.3f, %.3f %.3f ]\n",
- (style->penwidth), (style->penwidth), -(style->penwidth),
- (style->penwidth), -(style->penwidth), -(style->penwidth),
- (style->penwidth), -(style->penwidth));
+ (obj->penwidth), (obj->penwidth), -(obj->penwidth),
+ (obj->penwidth), -(obj->penwidth), -(obj->penwidth),
+ (obj->penwidth), -(obj->penwidth));
fprintf(out, "}\n");
fprintf(out, " appearance DEF E%d Appearance {\n", e->id);
fprintf(out, " material Material {\n");
fprintf(out, " ambientIntensity 0.33\n");
fprintf(out, " diffuseColor %.3f %.3f %.3f\n",
- style->pencolor.u.rgba[0] / 255.,
- style->pencolor.u.rgba[1] / 255.,
- style->pencolor.u.rgba[2] / 255.);
+ obj->pencolor.u.rgba[0] / 255.,
+ obj->pencolor.u.rgba[1] / 255.,
+ obj->pencolor.u.rgba[2] / 255.);
fprintf(out, " }\n");
fprintf(out, " }\n");
fprintf(out, "}\n");
static void doArrowhead (GVJ_t *job, pointf * A)
{
FILE *out = job->output_file;
- gvstyle_t *style = job->style;
obj_state_t *obj = job->obj;
edge_t *e = obj->u.e;
double rad, ht, y;
fprintf(out, " material Material {\n");
fprintf(out, " ambientIntensity 0.33\n");
fprintf(out, " diffuseColor %.3f %.3f %.3f\n",
- style->pencolor.u.rgba[0] / 255.,
- style->pencolor.u.rgba[1] / 255.,
- style->pencolor.u.rgba[2] / 255.);
+ obj->pencolor.u.rgba[0] / 255.,
+ obj->pencolor.u.rgba[1] / 255.,
+ obj->pencolor.u.rgba[2] / 255.);
fprintf(out, " }\n");
fprintf(out, " }\n");
fprintf(out, " }\n");
static void vrml_polygon(GVJ_t *job, pointf * A, int np, int filled)
{
FILE *out = job->output_file;
- gvstyle_t *style = job->style;
obj_state_t *obj = job->obj;
node_t *n;
edge_t *e;
switch (obj->type) {
case ROOTGRAPH_OBJTYPE:
fprintf(out, " Background { skyColor %.3f %.3f %.3f }\n",
- style->fillcolor.u.rgba[0] / 255.,
- style->fillcolor.u.rgba[1] / 255.,
- style->fillcolor.u.rgba[2] / 255.);
+ obj->fillcolor.u.rgba[0] / 255.,
+ obj->fillcolor.u.rgba[1] / 255.,
+ obj->fillcolor.u.rgba[2] / 255.);
Saw_skycolor = TRUE;
break;
case CLUSTER_OBJTYPE:
points[i].y = ROUND(mp.y);
}
if (filled)
- gdImageFilledPolygon(im, points, np, color_index(im, job->style->fillcolor));
+ gdImageFilledPolygon(im, points, np, color_index(im, obj->fillcolor));
gdImagePolygon(im, points, np, pen);
free(points);
if (brush)
fprintf(out, " children [\n");
fprintf(out, " Shape {\n");
fprintf(out, " geometry Cone {bottomRadius %.3f height %.3f }\n",
- style->penwidth * 2.5, style->penwidth * 10.0);
+ obj->penwidth * 2.5, obj->penwidth * 10.0);
fprintf(out, " appearance USE E%d\n", e->id);
fprintf(out, " }\n");
fprintf(out, " ]\n");
doSphere (GVJ_t *job, node_t *n, pointf p, double z, double rx, double ry)
{
FILE *out = job->output_file;
- gvstyle_t *style = job->style;
+ obj_state_t *obj = job->obj;
// if (!(strcmp(cstk[SP].fillcolor, "transparent"))) {
// return;
fprintf(out, " material Material {\n");
fprintf(out, " ambientIntensity 0.33\n");
fprintf(out, " diffuseColor %.3f %.3f %.3f\n",
- style->pencolor.u.rgba[0] / 255.,
- style->pencolor.u.rgba[1] / 255.,
- style->pencolor.u.rgba[2] / 255.);
+ obj->pencolor.u.rgba[0] / 255.,
+ obj->pencolor.u.rgba[1] / 255.,
+ obj->pencolor.u.rgba[2] / 255.);
fprintf(out, " }\n");
fprintf(out, " }\n");
fprintf(out, " }\n");
static void vrml_ellipse(GVJ_t * job, pointf * A, int filled)
{
FILE *out = job->output_file;
- gvstyle_t *style = job->style;
obj_state_t *obj = job->obj;
node_t *n;
edge_t *e;
PF2P(npf, np);
if (filled)
- gdImageFilledEllipse(im, np.x, np.y, dx, dy, color_index(im, style->fillcolor));
+ gdImageFilledEllipse(im, np.x, np.y, dx, dy, color_index(im, obj->fillcolor));
gdImageArc(im, np.x, np.y, dx, dy, 0, 360, pen);
if (brush)
static void cairogen_textpara(GVJ_t * job, pointf p, textpara_t * para)
{
- gvstyle_t *style = job->style;
+ obj_state_t *obj = job->obj;
cairo_t *cr = (cairo_t *) job->surface;
pointf offset;
PangoLayout *layout = (PangoLayout*)(para->layout);
PangoLayoutIter* iter;
cairo_set_dash (cr, dashed, 0, 0.0); /* clear any dashing */
- cairogen_set_color(cr, &(style->pencolor));
+ cairogen_set_color(cr, &(obj->pencolor));
switch (para->just) {
case 'r':
static void cairogen_set_penstyle(GVJ_t *job, cairo_t *cr)
{
- gvstyle_t *style = job->style;
+ obj_state_t *obj = job->obj;
- if (style->pen == PEN_DASHED) {
+ if (obj->pen == PEN_DASHED) {
cairo_set_dash (cr, dashed, dashed_len, 0.0);
- } else if (style->pen == PEN_DOTTED) {
+ } else if (obj->pen == PEN_DOTTED) {
cairo_set_dash (cr, dotted, dotted_len, 0.0);
} else {
cairo_set_dash (cr, dashed, 0, 0.0);
}
- cairo_set_line_width (cr, style->penwidth * job->scale.x);
+ cairo_set_line_width (cr, obj->penwidth * job->scale.x);
}
static void cairogen_ellipse(GVJ_t * job, pointf * A, int filled)
{
- gvstyle_t *style = job->style;
+ obj_state_t *obj = job->obj;
cairo_t *cr = (cairo_t *) job->surface;
cairo_matrix_t matrix;
double rx, ry;
cairo_set_matrix(cr, &matrix);
if (filled) {
- cairogen_set_color(cr, &(style->fillcolor));
+ cairogen_set_color(cr, &(obj->fillcolor));
cairo_fill_preserve(cr);
}
- cairogen_set_color(cr, &(style->pencolor));
+ cairogen_set_color(cr, &(obj->pencolor));
cairo_stroke(cr);
}
static void
cairogen_polygon(GVJ_t * job, pointf * A, int n, int filled)
{
- gvstyle_t *style = job->style;
+ obj_state_t *obj = job->obj;
cairo_t *cr = (cairo_t *) job->surface;
int i;
cairo_line_to(cr, A[i].x, -A[i].y);
cairo_close_path(cr);
if (filled) {
- cairogen_set_color(cr, &(style->fillcolor));
+ cairogen_set_color(cr, &(obj->fillcolor));
cairo_fill_preserve(cr);
}
- cairogen_set_color(cr, &(style->pencolor));
+ cairogen_set_color(cr, &(obj->pencolor));
cairo_stroke(cr);
}
cairogen_bezier(GVJ_t * job, pointf * A, int n, int arrow_at_start,
int arrow_at_end, int filled)
{
- gvstyle_t *style = job->style;
+ obj_state_t *obj = job->obj;
cairo_t *cr = (cairo_t *) job->surface;
int i;
for (i = 1; i < n; i += 3)
cairo_curve_to(cr, A[i].x, -A[i].y, A[i + 1].x, -A[i + 1].y,
A[i + 2].x, -A[i + 2].y);
- cairogen_set_color(cr, &(style->pencolor));
+ cairogen_set_color(cr, &(obj->pencolor));
cairo_stroke(cr);
}
static void
cairogen_polyline(GVJ_t * job, pointf * A, int n)
{
- gvstyle_t *style = job->style;
+ obj_state_t *obj = job->obj;
cairo_t *cr = (cairo_t *) job->surface;
int i;
cairogen_set_penstyle(job, cr);
- cairo_set_line_width (cr, style->penwidth * job->scale.x);
+ cairo_set_line_width (cr, obj->penwidth * job->scale.x);
cairo_move_to(cr, A[0].x, -A[0].y);
for (i = 1; i < n; i++)
cairo_line_to(cr, A[i].x, -A[i].y);
- cairogen_set_color(cr, &(style->pencolor));
+ cairogen_set_color(cr, &(obj->pencolor));
cairo_stroke(cr);
}