#define CHAR_LATIN1 1
#define CHAR_BIG5 2
+/* style flags */
+#define FILLED (1 << 0)
+#define ROUNDED (1 << 1)
+#define DIAGONALS (1 << 2)
+#define AUXLABELS (1 << 3)
+#define INVISIBLE (1 << 4)
+
/* user-specified node position: ND_pinned */
#define P_SET 1 /* position supplied by user */
#define P_FIX 2 /* position fixed during topological layout */
void emit_clusters(GVJ_t * job, Agraph_t * g, int flags)
{
- int i, c, filled;
+ int i, c, istyle, filled;
graph_t *sg;
point A[4];
char *color, *fillcolor, *pencolor, *str, **style;
}
gvrender_begin_context(job);
filled = FALSE;
+ istyle = 0;
xdemitState = EMIT_DRAW;
if (((str = agget(sg, "style")) != 0) && str[0]) {
gvrender_set_style(job, (style = parse_style(str)));
for (i = 0; style[i]; i++)
if (strcmp(style[i], "filled") == 0) {
filled = TRUE;
- break;
+ istyle |= FILLED;
+ }
+ else if (strcmp(style[i], "rounded") == 0) {
+ istyle |= ROUNDED;
}
}
fillcolor = pencolor = 0;
if (((color = agget(sg, "fillcolor")) != 0) && color[0])
fillcolor = color;
}
- if (pencolor)
- gvrender_set_pencolor(job, pencolor);
- if (fillcolor)
- gvrender_set_fillcolor(job, fillcolor);
A[0] = GD_bb(sg).LL;
A[2] = GD_bb(sg).UR;
A[1].x = A[2].x;
A[1].y = A[0].y;
A[3].x = A[0].x;
A[3].y = A[2].y;
- if (late_int(sg, G_peripheries, 1, 0)) {
- gvrender_polygon(job, A, 4, filled);
- } else if (filled) {
- if (fillcolor && fillcolor != pencolor)
- gvrender_set_pencolor(job, fillcolor);
- gvrender_polygon(job, A, 4, filled);
+ if (istyle & ROUNDED) {
+ if (!pencolor) pencolor = DEFAULT_COLOR;
+ if (!fillcolor) fillcolor = DEFAULT_FILL;
+ if (late_int(sg, G_peripheries, 1, 0) || filled)
+ round_corners(job, fillcolor, pencolor, A, 4, istyle);
+ }
+ else {
+ if (pencolor)
+ gvrender_set_pencolor(job, pencolor);
+ if (fillcolor)
+ gvrender_set_fillcolor(job, fillcolor);
+ if (late_int(sg, G_peripheries, 1, 0)) {
+ gvrender_polygon(job, A, 4, filled);
+ }
+ else if (filled) {
+ if (fillcolor && fillcolor != pencolor)
+ gvrender_set_pencolor(job, fillcolor);
+ gvrender_polygon(job, A, 4, filled);
+ }
}
xdemitState = EMIT_DRAW;
if (GD_label(sg))
extern void place_portlabel(edge_t * e, bool head_p);
extern char *ps_string(char *s, int);
extern int rank(graph_t * g, int balance, int maxiter);
+ extern void round_corners(GVJ_t*, char*, char*, point*, int, int);
extern void routesplinesinit(void);
extern point *routesplines(path *, int *);
extern void routesplinesterm(void);
extern codegen_t VRML_CodeGen;
#endif
-#define FILLED (1 << 0)
-#define ROUNDED (1 << 1)
-#define DIAGONALS (1 << 2)
-#define AUXLABELS (1 << 3)
-#define INVISIBLE (1 << 4)
#define RBCONST 12
#define RBCURVE .5
gvrender_set_pencolor(job, DEFAULT_COLOR);
}
+static
+char* findPen(node_t * n)
+{
+ char *color;
+
+ color = late_nnstring(n, N_color, "");
+ if (color[0])
+ return color;
+ else
+ return DEFAULT_COLOR;
+}
+
static
char *findFill(node_t * n)
{
return rv;
}
-static void round_corners(GVJ_t * job, node_t * n, point * A, int sides,
- int style)
+void round_corners(GVJ_t * job, char* fillc, char* penc, point * A,
+ int sides, int style)
{
point *B, C[2], p0, p1;
pointf BF[4];
if (mode == ROUNDED) {
if (style & FILLED) {
int j = 0;
- char* fillc = findFill(n);
point* pts = N_GNEW(2*sides,point);
gvrender_begin_context(job);
gvrender_set_pencolor (job, fillc);
}
gvrender_end_context(job);
}
- pencolor(job, n);
+ gvrender_set_pencolor(job, penc);
for (seg = 0; seg < sides; seg++) {
gvrender_polyline(job, B + 4 * seg + 1, 2);
gvrender_beziercurve(job, BF, 4, FALSE, FALSE, FALSE);
}
} else { /* diagonals are weird. rewrite someday. */
- pencolor(job, n);
+ gvrender_set_pencolor(job, penc);
if (style & FILLED)
- gvrender_set_fillcolor(job, findFill(n)); /* emit fill color */
+ gvrender_set_fillcolor(job, fillc); /* emit fill color */
gvrender_polygon(job, A, sides, style & FILLED);
for (seg = 0; seg < sides; seg++) {
#ifdef NOTDEF
free(B);
}
+static void
+node_round_corners(GVJ_t * job, node_t* n, point * A, int sides, int style)
+{
+ round_corners(job, findFill(n), findPen(n), A, sides, style);
+}
+
/*=============================poly start=========================*/
/* userSize;
Mcircle_hack(job, n);
}
} else if (style & (ROUNDED | DIAGONALS)) {
- round_corners(job, n, A, sides, style);
+ node_round_corners(job, n, A, sides, style);
} else {
gvrender_polygon(job, A, sides, filled);
}
if (streq(ND_shape(n)->name, "Mrecord"))
style |= ROUNDED;
if (style & (ROUNDED | DIAGONALS))
- round_corners(job, n, A, 4, ROUNDED);
+ node_round_corners(job, n, A, 4, ROUNDED);
else
gvrender_polygon(job, A, 4, style & FILLED);
xdemitState = EMIT_LABEL;