26 static port Center = { {0, 0}, -1, 0, 0, 0, 1, 0, 0, 0 };
28 #define ATTR_SET(a,n) ((a) && (*(agxget(n,a->index)) != '\0'))
30 #define DEF_POINT 0.05
35 #define MIN_POINT 0.0003
39 static char *point_style[3] = {
"invis\0",
"filled\0", 0 };
43 static void poly_init(
node_t * n);
44 static void poly_free(
node_t * n);
45 static port poly_port(
node_t * n,
char *portname,
char *);
47 static int poly_path(
node_t * n,
port * p,
int side,
boxf rv[],
int *kptr);
50 static void record_init(
node_t * n);
51 static void record_free(
node_t * n);
52 static port record_port(
node_t * n,
char *portname,
char *);
56 static void record_gencode(
GVJ_t * job,
node_t * n);
58 static void point_init(
node_t * n);
75 static void cylinder_draw(
GVJ_t * job,
pointf * AF,
int sides,
int style,
int filled);
113 static polygon_t p_doublecircle = {
TRUE, 2, 1, 0., 0., 0. };
152 #define IS_BOX(n) (ND_shape(n)->polygon == &p_box)
153 #define IS_PLAIN(n) (ND_shape(n)->polygon == &p_plain)
156 #define SPECIAL_CORNERS(style) ((style) & (ROUNDED | DIAGONALS | SHAPE_MASK))
234 {
"box", &poly_fns, &p_box},
235 {
"polygon", &poly_fns, &p_polygon},
236 {
"ellipse", &poly_fns, &p_ellipse},
237 {
"oval", &poly_fns, &p_ellipse},
238 {
"circle", &poly_fns, &p_circle},
239 {
"point", &point_fns, &p_circle},
240 {
"egg", &poly_fns, &p_egg},
241 {
"triangle", &poly_fns, &p_triangle},
242 {
"none", &poly_fns, &p_plaintext},
243 {
"plaintext", &poly_fns, &p_plaintext},
244 {
"plain", &poly_fns, &p_plain},
245 {
"diamond", &poly_fns, &p_diamond},
246 {
"trapezium", &poly_fns, &p_trapezium},
247 {
"parallelogram", &poly_fns, &p_parallelogram},
248 {
"house", &poly_fns, &p_house},
249 {
"pentagon", &poly_fns, &p_pentagon},
250 {
"hexagon", &poly_fns, &p_hexagon},
251 {
"septagon", &poly_fns, &p_septagon},
252 {
"octagon", &poly_fns, &p_octagon},
253 {
"note", &poly_fns, &p_note},
254 {
"tab", &poly_fns, &p_tab},
255 {
"folder", &poly_fns, &p_folder},
256 {
"box3d", &poly_fns, &p_box3d},
257 {
"component", &poly_fns, &p_component},
258 {
"cylinder", &cylinder_fns, &p_cylinder},
259 {
"rect", &poly_fns, &p_box},
260 {
"rectangle", &poly_fns, &p_box},
261 {
"square", &poly_fns, &p_square},
262 {
"doublecircle", &poly_fns, &p_doublecircle},
263 {
"doubleoctagon", &poly_fns, &p_doubleoctagon},
264 {
"tripleoctagon", &poly_fns, &p_tripleoctagon},
265 {
"invtriangle", &poly_fns, &p_invtriangle},
266 {
"invtrapezium", &poly_fns, &p_invtrapezium},
267 {
"invhouse", &poly_fns, &p_invhouse},
268 {
"underline", &poly_fns, &p_underline},
269 {
"Mdiamond", &poly_fns, &p_Mdiamond},
270 {
"Msquare", &poly_fns, &p_Msquare},
271 {
"Mcircle", &poly_fns, &p_Mcircle},
274 {
"promoter", &poly_fns, &p_promoter},
275 {
"cds", &poly_fns, &p_cds},
276 {
"terminator", &poly_fns, &p_terminator},
277 {
"utr", &poly_fns, &p_utr},
278 {
"insulator", &poly_fns, &p_insulator},
279 {
"ribosite", &poly_fns, &p_ribosite},
280 {
"rnastab", &poly_fns, &p_rnastab},
281 {
"proteasesite", &poly_fns, &p_proteasesite},
282 {
"proteinstab", &poly_fns, &p_proteinstab},
284 {
"primersite", &poly_fns, &p_primersite},
285 {
"restrictionsite", &poly_fns, &p_restrictionsite},
286 {
"fivepoverhang", &poly_fns, &p_fivepoverhang},
287 {
"threepoverhang", &poly_fns, &p_threepoverhang},
288 {
"noverhang", &poly_fns, &p_noverhang},
289 {
"assembly", &poly_fns, &p_assembly},
290 {
"signature", &poly_fns, &p_signature},
291 {
"rpromoter", &poly_fns, &p_rpromoter},
292 {
"larrow", &poly_fns, &p_larrow},
293 {
"rarrow", &poly_fns, &p_rarrow},
294 {
"lpromoter", &poly_fns, &p_lpromoter},
296 {
"record", &record_fns,
NULL},
297 {
"Mrecord", &record_fns,
NULL},
298 {
"epsf", &epsf_fns,
NULL},
299 {
"star", &star_fns, &p_star},
303 static void unrecognized(
node_t * n,
char *p)
308 static double quant(
double val,
double q)
312 if (i * q + .00001 < val)
326 c = a * L0.
x + b * L0.
y;
328 s0 = (a * p0.
x + b * p0.
y - c >= 0);
329 s1 = (a * p1.
x + b * p1.
y - c >= 0);
346 char *findFillDflt(
node_t * n,
char *dflt)
362 char *findFill(
node_t * n)
370 if(colorattr !=
NULL)
372 else if(dflt !=
NULL && dflt[0])
400 return (p->
sides <= 2);
406 static char **checkStyle(
node_t * n,
int *flagp)
420 if (
streq(p,
"filled")) {
423 }
else if (
streq(p,
"rounded")) {
430 }
else if (
streq(p,
"diagonals")) {
437 }
else if (
streq(p,
"invis")) {
440 }
else if (
streq(p,
"radial")) {
447 }
else if (
streq(p,
"striped") && isBox(n)) {
454 }
else if (
streq(p,
"wedged") && isEllipse(n)) {
478 if ((pstyle = checkStyle(n, &istyle)))
501 AF[1].
x = AF[0].
x - 2 * p.
x;
519 double rbconst, d, dx, dy, t;
520 int i, seg, mode, shape;
526 else if (style & SHAPE_MASK)
531 cylinder_draw (job, AF, sides, style, filled);
541 for (seg = 0; seg < sides; seg++) {
549 d = sqrt(dx * dx + dy * dy);
550 rbconst =
MIN(rbconst, d / 3.0);
552 for (seg = 0; seg < sides; seg++) {
560 d = sqrt(dx * dx + dy * dy);
569 B[i++] = interpolate_pointf(
RBCURVE * t, p0, p1);
570 B[i++] = interpolate_pointf(t, p0, p1);
571 B[i++] = interpolate_pointf(1.0 - t, p0, p1);
573 B[i++] = interpolate_pointf(1.0 -
RBCURVE * t, p0, p1);
583 for (seg = 0; seg < sides; seg++) {
584 pts[i++] = B[4 * seg];
585 pts[i++] = B[4 * seg+1];
586 pts[i++] = B[4 * seg+1];
587 pts[i++] = B[4 * seg+2];
588 pts[i++] = B[4 * seg+2];
589 pts[i++] = B[4 * seg+3];
599 pts[j++] = B[4 * seg + 1];
600 pts[j++] = B[4 * seg + 2];
604 for (seg = 0; seg < sides; seg++) {
608 for (seg = 0; seg < sides; seg++) {
619 for (seg = 0; seg < sides; seg++) {
622 C[1] = B[3 * seg + 3];
625 C[0] = B[3 * seg + 2];
626 C[1] = B[3 * seg + 4];
633 for (seg = 1; seg < sides; seg++)
635 D[0] = B[3 * (sides - 1) + 4];
636 D[sides] = B[3 * (sides - 1) + 2];
642 C[0] = B[3 * seg + 2];
643 C[1] = B[3 * seg + 4];
644 C[2].
x = C[1].
x + (C[0].
x - B[3 * seg + 3].
x);
645 C[2].
y = C[1].
y + (C[0].
y - B[3 * seg + 3].
y);
668 D[2].
x = B[2].
x + (B[3].
x - B[4].
x) / 3;
669 D[2].y = B[2].
y + (B[3].
y - B[4].
y) / 3;
670 D[3].x = B[3].
x + (B[3].
x - B[4].
x) / 3;
671 D[3].y = B[3].
y + (B[3].
y - B[4].
y) / 3;
672 for (seg = 4; seg < sides + 2; seg++)
673 D[seg] = AF[seg - 2];
700 D[1].
x = AF[0].
x - (AF[0].
x - B[1].
x) / 4;
701 D[1].y = AF[0].
y + (B[3].
y - B[4].
y) / 3;
702 D[2].x = AF[0].
x - 2 * (AF[0].
x - B[1].
x);
704 D[3].x = AF[0].
x - 2.25 * (AF[0].
x - B[1].
x);
708 for (seg = 4; seg < sides + 3; seg++)
709 D[seg] = AF[seg - 3];
727 C[0].
x = B[1].
x + (B[11].
x - B[0].
x);
728 C[0].
y = B[1].
y + (B[11].
y - B[0].
y);
757 D[2].
x = B[3].
x + (B[4].
x - B[3].
x);
758 D[2].y = B[3].
y + (B[4].
y - B[3].
y);
759 D[3].x = D[2].x + (B[3].
x - B[2].
x);
760 D[3].y = D[2].y + (B[3].
y - B[2].
y);
761 D[4].x = D[3].x + (B[4].
x - B[3].
x);
762 D[4].y = D[3].y + (B[4].
y - B[3].
y);
763 D[5].x = D[4].x + (D[2].x - D[3].x);
764 D[5].y = D[4].y + (D[2].y - D[3].y);
766 D[9].x = B[6].
x + (B[5].
x - B[6].
x);
767 D[9].y = B[6].
y + (B[5].
y - B[6].
y);
768 D[8].x = D[9].x + (B[6].
x - B[7].
x);
769 D[8].y = D[9].y + (B[6].
y - B[7].
y);
770 D[7].x = D[8].x + (B[5].
x - B[6].
x);
771 D[7].y = D[8].y + (B[5].
y - B[6].
y);
772 D[6].x = D[7].x + (D[9].x - D[8].x);
773 D[6].y = D[7].y + (D[9].y - D[8].y);
781 C[1].
x = D[2].x - (D[3].x - D[2].x);
782 C[1].
y = D[2].y - (D[3].y - D[2].y);
783 C[2].
x = C[1].
x + (D[4].x - D[3].x);
784 C[2].
y = C[1].
y + (D[4].y - D[3].y);
788 C[1].
x = D[6].x - (D[7].x - D[6].x);
789 C[1].
y = D[6].y - (D[7].y - D[6].y);
790 C[2].
x = C[1].
x + (D[8].x - D[7].x);
791 C[2].
y = C[1].
y + (D[8].y - D[7].y);
820 D[0].x = AF[1].
x + (AF[0].
x - AF[1].
x)/2 + (AF[0].x - AF[1].x)/8;
821 D[0].y = AF[2].
y + (AF[1].
y - AF[2].
y)/2 + (B[3].y-B[4].y)*3/2;
822 D[1].x = AF[1].
x + (AF[0].
x - AF[1].
x)/2 - (AF[0].x - AF[1].x)/4;
825 D[2].y = AF[2].
y + (AF[1].
y - AF[2].
y)/2;
826 D[3].x = D[2].x + (B[2].
x - B[3].
x)/2;
827 D[3].y = AF[2].
y + (AF[1].
y - AF[2].
y)/2;
829 D[4].y = AF[2].
y + (AF[1].
y - AF[2].
y)/2 + (B[3].y-B[4].y);
833 D[6].y = D[4].y - (B[3].
y-B[4].
y)/4;
834 D[7].x = D[6].x + (B[2].
x - B[3].
x);
835 D[7].y = D[6].y + (B[3].
y - B[4].
y)/2;
837 D[8].y = D[0].y + (B[3].
y - B[4].
y)/4;
842 C[0].
y = AF[2].
y + (AF[1].
y - AF[2].
y)/2;
844 C[1].
y = AF[2].
y + (AF[0].
y - AF[3].
y)/2;
867 D[0].y = B[1].
y - (B[3].
y - B[4].
y)/2;
869 D[1].y = B[3].
y - (B[3].
y - B[4].
y)/2;
871 D[2].y = AF[2].
y + (B[3].
y - B[4].
y)/2;
873 D[3].y = AF[2].
y + (B[3].
y - B[4].
y)/2;
874 D[4].y = AF[0].
y - (AF[0].
y - AF[3].
y)/2;
901 D[0].x = AF[1].
x + (AF[0].
x-AF[1].
x)/2 + (B[2].x-B[3].x)/4;
902 D[0].y = AF[2].
y + (AF[1].
y - AF[2].
y)/2;
904 D[1].y = D[0].y + (B[3].
y-B[4].
y)/2;
905 D[2].x = D[1].x + (B[2].
x-B[3].
x)/2;
908 D[3].y = D[2].y + (B[3].
y-B[4].
y)/2;
909 D[4].x = AF[1].
x + (AF[0].
x-AF[1].
x)/2 - (B[2].x-B[3].x)*3/4;
913 D[6].x = AF[1].
x + (AF[0].
x-AF[1].
x)/2 - (B[2].x-B[3].x)/4;
921 C[0].
y = AF[2].
y + (AF[1].
y - AF[2].
y)/2;
923 C[1].
y = AF[2].
y + (AF[0].
y - AF[3].
y)/2;
948 D[0].x = AF[1].
x + (AF[0].
x-AF[1].
x)/2 + (B[2].x-B[3].x)*3/4;
949 D[0].y = AF[2].
y + (AF[1].
y - AF[2].
y)/2;
951 D[1].y = D[0].y + (B[3].
y-B[4].
y)/4;
952 D[2].x = AF[1].
x + (AF[0].
x-AF[1].
x)/2 + (B[2].x-B[3].x)/4;
953 D[2].y = D[1].y + (B[3].
y-B[4].
y)/2;
954 D[3].x = AF[1].
x + (AF[0].
x-AF[1].
x)/2 - (B[2].x-B[3].x)/4;
956 D[4].x = AF[1].
x + (AF[0].
x-AF[1].
x)/2 - (B[2].x-B[3].x)*3/4;
964 C[0].
y = AF[2].
y + (AF[1].
y - AF[2].
y)/2;
966 C[1].
y = AF[2].
y + (AF[0].
y - AF[3].
y)/2;
990 D[0].x = AF[1].
x + (AF[0].
x - AF[1].
x)/2 + (B[2].x-B[3].x);
991 D[0].y = AF[2].
y + (AF[1].
y - AF[2].
y)/2 + (B[3].y-B[4].y)/4;
992 D[1].x = D[0].x - (B[2].
x-B[3].
x);
993 D[1].y = D[0].y + (B[3].
y-B[4].
y);
995 D[2].y = D[0].y + (B[3].
y-B[4].
y)/2;
996 D[3].x = AF[1].
x + (AF[0].
x - AF[1].
x)/2 - (AF[0].x - AF[1].x)/4;
1004 C[0].
y = AF[2].
y + (AF[1].
y - AF[2].
y)/2;
1006 C[1].
y = AF[2].
y + (AF[0].
y - AF[3].
y)/2;
1030 D[0].x = AF[1].
x + (AF[0].
x - AF[1].
x)/2 + (AF[0].x - AF[1].x)/8 + (B[2].
x-B[3].
x)/2;
1031 D[0].y = AF[2].
y + (AF[1].
y - AF[2].
y)/2 + (B[3].y-B[4].y)/4;
1032 D[1].x = AF[1].
x + (AF[0].
x - AF[1].
x)/2 - (AF[0].x - AF[1].x)/8;
1035 D[2].y = D[1].y + (B[3].
y-B[4].
y)/2;
1036 D[3].x = D[2].x - (B[2].
x-B[3].
x)/2;
1039 D[4].y = AF[2].
y + (AF[1].
y - AF[2].
y)/2 - (B[3].y-B[4].y)/4;
1040 D[5].x = D[0].x - (B[2].
x-B[3].
x)/2;
1043 D[6].y = D[5].y - (B[3].
y-B[4].
y)/2;
1050 C[0].
y = AF[2].
y + (AF[1].
y - AF[2].
y)/2;
1052 C[1].
y = AF[2].
y + (AF[0].
y - AF[3].
y)/2;
1057 C[0].
y = AF[2].
y + (AF[1].
y - AF[2].
y)/2;
1059 C[1].
y = AF[2].
y + (AF[0].
y - AF[3].
y)/2;
1084 D[0].y = AF[2].
y + (AF[1].
y - AF[2].
y)/2 + (B[3].y-B[4].y)/8;
1085 D[1].x = D[0].x + 2*(B[2].
x-B[3].
x);
1088 D[2].y = D[1].y + (B[3].
y-B[4].
y)/2;
1096 D[0].x = AF[1].
x + (B[2].
x-B[3].
x);
1097 D[0].y = AF[2].
y + (AF[1].
y - AF[2].
y)/2 - (B[3].y-B[4].y)*5/8;
1098 D[1].x = D[0].x + (B[2].
x-B[3].
x);
1101 D[2].y = D[1].y + (B[3].
y-B[4].
y)/2;
1108 C[0].
y = AF[2].
y + (AF[1].
y - AF[2].
y)/2;
1110 C[1].
y = AF[2].
y + (AF[0].
y - AF[3].
y)/2;
1135 D[0].y = AF[2].
y + (AF[1].
y - AF[2].
y)/2 + (B[3].y-B[4].y)/8;
1137 D[1].y = D[0].y + (B[3].
y-B[4].
y)/2;
1138 D[2].x = D[1].x - 2*(B[3].
y-B[4].
y);
1147 D[0].x = AF[0].
x - (B[2].
x-B[3].
x);
1148 D[0].y = AF[2].
y + (AF[1].
y - AF[2].
y)/2 - (B[3].y-B[4].y)*5/8;
1150 D[1].y = D[0].y + (B[3].
y-B[4].
y)/2;
1151 D[2].x = D[1].x - (B[3].
y-B[4].
y);
1159 C[0].
y = AF[2].
y + (AF[1].
y - AF[2].
y)/2;
1161 C[1].
y = AF[2].
y + (AF[0].
y - AF[3].
y)/2;
1187 D[0].x = AF[1].
x + (AF[0].
x - AF[1].
x)/2 - (B[2].x-B[3].x)*9/8;
1188 D[0].y = AF[2].
y + (AF[1].
y - AF[2].
y)/2 + (B[3].y-B[4].y)/8;
1189 D[1].x = D[0].x + (B[2].
x-B[3].
x);
1192 D[2].y = D[1].y + (B[3].
y-B[4].
y)/2;
1200 D[0].x = AF[1].
x + (AF[0].
x - AF[1].
x)/2 - (B[2].x-B[3].x)*9/8;
1201 D[0].y = AF[2].
y + (AF[1].
y - AF[2].
y)/2 - (B[3].y-B[4].y)*5/8;
1202 D[1].x = D[0].x + (B[2].
x-B[3].
x);
1205 D[2].y = D[1].y + (B[3].
y-B[4].
y)/2;
1213 D[0].x = AF[1].
x + (AF[0].
x - AF[1].
x)/2 + (B[2].x-B[3].x)/8;
1214 D[0].y = AF[2].
y + (AF[1].
y - AF[2].
y)/2 - (B[3].y-B[4].y)*5/8;
1215 D[1].x = D[0].x + (B[2].
x-B[3].
x);
1218 D[2].y = D[1].y + (B[3].
y-B[4].
y)/2;
1226 D[0].x = AF[1].
x + (AF[0].
x - AF[1].
x)/2 + (B[2].x-B[3].x)/8;
1227 D[0].y = AF[2].
y + (AF[1].
y - AF[2].
y)/2 + (B[3].y-B[4].y)/8;
1228 D[1].x = D[0].x + (B[2].
x-B[3].
x);
1231 D[2].y = D[1].y + (B[3].
y-B[4].
y)/2;
1238 C[0].
y = AF[2].
y + (AF[1].
y - AF[2].
y)/2;
1240 C[1].
y = AF[2].
y + (AF[0].
y - AF[3].
y)/2;
1244 C[0].
x = AF[1].
x + (AF[0].
x - AF[1].
x)/2 - (B[2].x-B[3].x)*9/8;
1245 C[0].
y = AF[2].
y + (AF[1].
y - AF[2].
y)/2;
1247 C[1].
y = AF[2].
y + (AF[0].
y - AF[3].
y)/2;
1270 D[0].x = AF[1].
x + (AF[0].
x - AF[1].
x)/2 - (B[2].x-B[3].x);
1271 D[0].y = AF[2].
y + (AF[1].
y - AF[2].
y)/2 + (B[3].y-B[4].y)/8;
1272 D[1].x = D[0].x + 2*(B[2].
x-B[3].
x);
1275 D[2].y = D[1].y + (B[3].
y-B[4].
y)/2;
1283 D[0].x = AF[1].
x + (AF[0].
x - AF[1].
x)/2 - (B[2].x-B[3].x);
1284 D[0].y = AF[2].
y + (AF[1].
y - AF[2].
y)/2 - (B[3].y-B[4].y)*5/8;
1285 D[1].x = D[0].x + 2*(B[2].
x-B[3].
x);
1288 D[2].y = D[1].y + (B[3].
y-B[4].
y)/2;
1295 C[0].
y = AF[2].
y + (AF[1].
y - AF[2].
y)/2;
1297 C[1].
y = AF[2].
y + (AF[0].
y - AF[3].
y)/2;
1302 C[0].
y = AF[2].
y + (AF[1].
y - AF[2].
y)/2;
1304 C[1].
y = AF[2].
y + (AF[0].
y - AF[3].
y)/2;
1325 D[0].y = B[1].
y - (B[3].
y - B[4].
y)/2;
1327 D[1].y = B[3].
y - (B[3].
y - B[4].
y)/2;
1329 D[2].y = AF[2].
y + (B[3].
y - B[4].
y)/2;
1331 D[3].y = AF[2].
y + (B[3].
y - B[4].
y)/2;
1335 C[0].
x = AF[1].
x + (B[2].
x-B[3].
x)/4;
1336 C[0].
y = AF[2].
y + (AF[1].
y - AF[2].
y)/2 + (B[3].y-B[4].y)/8;
1337 C[1].
x = C[0].
x + (B[2].
x-B[3].
x)/4;
1338 C[1].
y = C[0].
y - (B[3].
y-B[4].
y)/4;
1342 C[0].
x = AF[1].
x + (B[2].
x-B[3].
x)/4;
1343 C[0].
y = AF[2].
y + (AF[1].
y - AF[2].
y)/2 - (B[3].y-B[4].y)/8;
1344 C[1].
x = C[0].
x + (B[2].
x-B[3].
x)/4;
1345 C[1].
y = C[0].
y + (B[3].
y-B[4].
y)/4;
1349 C[0].
x = AF[1].
x + (B[2].
x-B[3].
x)/4;
1350 C[0].
y = AF[2].
y + (B[3].
y-B[4].
y)*3/4;
1351 C[1].
x = AF[0].
x - (B[2].
x-B[3].
x)/4;
1371 D[0].x = AF[1].
x + (AF[0].
x - AF[1].
x)/2 + (B[2].x-B[3].x)/2;
1372 D[0].y = AF[2].
y + (AF[1].
y - AF[2].
y)/2 + (B[2].x-B[3].x)/2;
1374 D[1].y = AF[2].
y + (AF[1].
y - AF[2].
y)/2 - (B[2].x-B[3].x)/2;
1375 D[2].x = AF[1].
x + (AF[0].
x - AF[1].
x)/2 - (B[2].x-B[3].x)/2;
1383 C[0].
x = AF[1].
x + (AF[0].
x - AF[1].
x)/2 + (B[2].x-B[3].x)*3/4;
1384 C[0].
y = AF[2].
y + (AF[1].
y - AF[2].
y)/2 + (B[2].x-B[3].x)*3/4;
1386 C[1].
y = AF[2].
y + (AF[1].
y - AF[2].
y)/2 - (B[2].x-B[3].x)*3/4;
1387 C[2].
x = AF[1].
x + (AF[0].
x - AF[1].
x)/2 - (B[2].x-B[3].x)*3/4;
1395 C[0].
x = AF[1].
x + (AF[0].
x - AF[1].
x)/2 + (B[2].x-B[3].x)*3/4;
1396 C[0].
y = AF[2].
y + (AF[1].
y - AF[2].
y)/2;
1398 C[1].
y = AF[2].
y + (AF[0].
y - AF[3].
y)/2;
1403 C[0].
y = AF[2].
y + (AF[1].
y - AF[2].
y)/2;
1404 C[1].
x = AF[1].
x + (AF[0].
x - AF[1].
x)/2 - (B[2].x-B[3].x)*3/4;
1405 C[1].
y = AF[2].
y + (AF[0].
y - AF[3].
y)/2;
1423 D[0].x = AF[1].
x + (AF[0].
x-AF[1].
x)/2 + (B[2].x-B[3].x)/4;
1424 D[0].y = AF[2].
y + (AF[1].
y - AF[2].
y)/2 + (B[3].y-B[4].y)/2;
1426 D[1].y = D[0].y + (B[3].
y-B[4].
y)/8;
1427 D[2].x = D[0].x - (B[2].
x-B[3].
x)/8;
1428 D[2].y = D[1].y + (B[3].
y-B[4].
y)/8;
1430 D[3].y = D[2].y + (B[3].
y-B[4].
y)/8;
1432 D[4].y = D[3].y + (B[3].
y-B[4].
y)/8;
1435 D[6].x = AF[1].
x + (AF[0].
x - AF[1].
x)/2;
1437 D[7].x = D[6].x - (B[2].
x-B[3].
x)/8;
1439 D[8].x = D[7].x - (B[2].
x-B[3].
x)/8;
1443 D[10].x = D[8].x + (B[2].
x-B[3].
x)/8;
1461 C[0].
y = AF[2].
y + (AF[1].
y - AF[2].
y)/2;
1463 C[1].
y = C[0].
y + (B[3].
y-B[4].
y)/8;
1468 C[0].
y = AF[2].
y + (AF[1].
y - AF[2].
y)/2 + (B[3].y-B[4].y)/4;
1470 C[1].
y = C[0].
y + (B[3].
y-B[4].
y)/8;
1475 C[0].
y = AF[2].
y + (AF[1].
y - AF[2].
y)/2;
1477 C[1].
y = AF[2].
y + (AF[0].
y - AF[3].
y)/2;
1496 D[0].x = AF[1].
x + (AF[0].
x-AF[1].
x)/2 + (B[2].x-B[3].x)/8;
1497 D[0].y = AF[2].
y + (AF[1].
y - AF[2].
y)/2 + (B[3].y-B[4].y)/2;
1498 D[1].x = D[0].x + (B[2].
x-B[3].
x)/8;
1499 D[1].y = D[0].y + (B[3].
y-B[4].
y)/8;
1501 D[2].y = D[1].y + (B[3].
y-B[4].
y)/4;
1503 D[3].y = D[2].y + (B[3].
y-B[4].
y)/8;
1504 D[4].x = D[3].x - (B[2].
x-B[3].
x)/4;
1506 D[5].x = D[4].x - (B[2].
x-B[3].
x)/8;
1517 C[0].
x = AF[1].
x + (AF[0].
x - AF[1].
x)/2;
1518 C[0].
y = AF[2].
y + (AF[1].
y - AF[2].
y)/2;
1520 C[1].
y = C[0].
y + (B[3].
y-B[4].
y)/8;
1524 C[0].
x = AF[1].
x + (AF[0].
x - AF[1].
x)/2;
1525 C[0].
y = AF[2].
y + (AF[1].
y - AF[2].
y)/2 + (B[3].y-B[4].y)/4;
1527 C[1].
y = C[0].
y + (B[3].
y-B[4].
y)/8;
1534 C[0].
y = AF[2].
y + (AF[1].
y - AF[2].
y)/2;
1536 C[1].
y = AF[2].
y + (AF[0].
y - AF[3].
y)/2;
1554 D[0].x = AF[1].
x + (AF[0].
x-AF[1].
x)/2 + (B[2].x-B[3].x)/4;
1555 D[0].y = AF[2].
y + (AF[1].
y - AF[2].
y)/2 + (B[3].y-B[4].y)/2;
1557 D[1].y = D[0].y + (B[3].
y-B[4].
y)/8;
1558 D[2].x = D[0].x - (B[2].
x-B[3].
x)/8;
1559 D[2].y = D[1].y + (B[3].
y-B[4].
y)/8;
1561 D[3].y = D[2].y + (B[3].
y-B[4].
y)/8;
1563 D[4].y = D[3].y + (B[3].
y-B[4].
y)/8;
1566 D[6].x = AF[1].
x + (AF[0].
x - AF[1].
x)/2;
1568 D[7].x = D[6].x - (B[2].
x-B[3].
x)/8;
1570 D[8].x = D[7].x - (B[2].
x-B[3].
x)/8;
1574 D[10].x = D[8].x + (B[2].
x-B[3].
x)/8;
1592 C[1].
y = AF[2].
y + (AF[1].
y - AF[2].
y)/2;
1597 C[0].
y = AF[2].
y + (AF[1].
y - AF[2].
y)/2;
1599 C[1].
y = AF[2].
y + (AF[0].
y - AF[3].
y)/2;
1618 D[0].x = AF[1].
x + (AF[0].
x-AF[1].
x)/2 + (B[2].x-B[3].x)/8;
1619 D[0].y = AF[2].
y + (AF[1].
y - AF[2].
y)/2 + (B[3].y-B[4].y)/2;
1620 D[1].x = D[0].x + (B[2].
x-B[3].
x)/8;
1621 D[1].y = D[0].y + (B[3].
y-B[4].
y)/8;
1623 D[2].y = D[1].y + (B[3].
y-B[4].
y)/4;
1625 D[3].y = D[2].y + (B[3].
y-B[4].
y)/8;
1626 D[4].x = D[3].x - (B[2].
x-B[3].
x)/4;
1628 D[5].x = D[4].x - (B[2].
x-B[3].
x)/8;
1637 C[0].
x = AF[1].
x + (AF[0].
x - AF[1].
x)/2;
1640 C[1].
y = AF[2].
y + (AF[1].
y - AF[2].
y)/2;
1645 C[0].
y = AF[2].
y + (AF[1].
y - AF[2].
y)/2;
1647 C[1].
y = AF[2].
y + (AF[0].
y - AF[3].
y)/2;
1670 D[0].x = B[1].
x - (B[2].
x - B[3].
x)/2;
1671 D[0].y = B[1].
y - (B[3].
y - B[4].
y)/2;
1673 D[1].y = B[3].
y - (B[3].
y - B[4].
y)/2;
1676 D[3].x = B[2].
x + (B[2].
x - B[3].
x)/2;
1678 D[4].x = B[2].
x + (B[2].
x - B[3].
x)/2;
1679 D[4].y = AF[2].
y + (B[3].
y - B[4].
y)/2;
1680 D[5].x = B[1].
x - (B[2].
x - B[3].
x)/2;
1681 D[5].y = AF[2].
y + (B[3].
y - B[4].
y)/2;
1682 D[6].x = B[1].
x - (B[2].
x - B[3].
x)/2;
1684 D[7].y = AF[0].
y - (AF[0].
y - AF[3].
y)/2;
1687 D[8].x = B[1].
x - (B[2].
x - B[3].
x)/2;
1710 D[0].x = B[1].
x - (B[2].
x - B[3].
x)/2;
1711 D[0].y = B[1].
y - (B[3].
y - B[4].
y)/2;
1713 D[1].y = B[3].
y - (B[3].
y - B[4].
y)/2;
1715 D[2].y = AF[2].
y + (B[3].
y - B[4].
y)/2;
1716 D[3].x = B[1].
x - (B[2].
x - B[3].
x)/2;
1717 D[3].y = AF[2].
y + (B[3].
y - B[4].
y)/2;
1718 D[4].x = B[1].
x - (B[2].
x - B[3].
x)/2;
1720 D[5].y = AF[0].
y - (AF[0].
y - AF[3].
y)/2;
1723 D[6].x = B[1].
x - (B[2].
x - B[3].
x)/2;
1745 D[0].y = AF[0].
y - (B[3].
y-B[4].
y)/2;
1746 D[1].x = B[2].
x + (B[2].
x - B[3].
x)/2;
1747 D[1].y = AF[0].
y - (B[3].
y-B[4].
y)/2;
1748 D[2].x = B[2].
x + (B[2].
x - B[3].
x)/2;
1751 D[3].y = AF[1].
y - (AF[1].
y - AF[2].
y)/2;
1752 D[4].x = B[2].
x + (B[2].
x - B[3].
x)/2;
1754 D[5].y = AF[2].
y + (B[3].
y-B[4].
y)/2;
1755 D[5].x = B[2].
x + (B[2].
x - B[3].
x)/2;
1756 D[6].y = AF[3].
y + (B[3].
y - B[4].
y)/2;
1781 D[0].y = AF[0].
y - (B[3].
y-B[4].
y)/2;
1782 D[1].x = B[2].
x + (B[2].
x - B[3].
x)/2;
1783 D[1].y = AF[0].
y - (B[3].
y-B[4].
y)/2;
1784 D[2].x = B[2].
x + (B[2].
x - B[3].
x)/2;
1787 D[3].y = AF[1].
y - (AF[1].
y - AF[2].
y)/2;
1788 D[4].x = B[2].
x + (B[2].
x - B[3].
x)/2;
1790 D[5].y = AF[2].
y + (B[3].
y-B[4].
y)/2;
1791 D[5].x = B[2].
x + (B[2].
x - B[3].
x)/2;
1792 D[6].y = AF[3].
y + (B[3].
y - B[4].
y)/2;
1793 D[6].x = B[1].
x - (B[2].
x - B[3].
x)/2;
1794 D[7].x = B[1].
x - (B[2].
x - B[3].
x)/2;
1812 static double userSize(
node_t * n)
1828 if (ifn == poly_init)
1830 else if (ifn == record_init)
1832 else if (ifn == point_init)
1845 static void poly_init(
node_t * n)
1847 pointf dimen, min_bb, bb;
1851 char *p, *sfile, *fxd;
1852 double temp,
alpha, beta, gamma;
1853 double orientation, distortion, skew;
1854 double sectorangle, sidelength, skewdist, gdistortion, gskew;
1855 double angle, sinx, cosx,
xmax,
ymax, scalex, scaley;
1856 double width, height, marginx, marginy, spacex;
1857 int regular, peripheries, sides;
1858 int i, j, isBox, outp;
1862 regular =
ND_shape(n)->polygon->regular;
1863 peripheries =
ND_shape(n)->polygon->peripheries;
1864 sides =
ND_shape(n)->polygon->sides;
1865 orientation =
ND_shape(n)->polygon->orientation;
1867 distortion =
ND_shape(n)->polygon->distortion;
1881 double sz = userSize(n);
1883 width = height = sz;
1887 width = height =
POINTS(
MIN(width, height));
1906 if ((dimen.
x > 0) || (dimen.
y > 0)) {
1909 if ((p =
agget(n,
"margin"))) {
1910 marginx = marginy = 0;
1911 i = sscanf(p,
"%lf,%lf", &marginx, &marginy);
1917 dimen.
x += 2 *
POINTS(marginx);
1919 dimen.
y += 2 *
POINTS(marginy);
1921 dimen.
y += 2 *
POINTS(marginx);
1928 spacex = dimen.
x -
ND_label(n)->dimen.x;
1933 dimen.
x = quant(dimen.
x, temp);
1934 dimen.
y = quant(dimen.
y, temp);
1937 imagesize.
x = imagesize.
y = 0;
1944 sfile =
agget(n,
"shapefile");
1946 if ((imagesize.
x == -1) && (imagesize.
y == -1)) {
1948 "No or improper shapefile=\"%s\" for node \"%s\"\n",
1949 (sfile ? sfile :
"<nil>"),
agnameof(n));
1950 imagesize.
x = imagesize.
y = 0;
1957 }
else if ((sfile =
agget(n,
"image")) && (*sfile !=
'\0')) {
1959 if ((imagesize.
x == -1) && (imagesize.
y == -1)) {
1961 "No or improper image=\"%s\" for node \"%s\"\n",
1962 (sfile ? sfile :
"<nil>"),
agnameof(n));
1963 imagesize.
x = imagesize.
y = 0;
1972 bb.
x =
MAX(dimen.
x, imagesize.
x);
1973 bb.
y =
MAX(dimen.
y, imagesize.
y);
1977 if ((sides <= 2) && ((distortion != 0.) || (skew != 0.))) {
1982 p =
agget(n,
"labelloc");
1983 if (p && (p[0] ==
't' || p[0] ==
'b'))
1988 isBox = (sides == 4 && (
ROUND(orientation) % 90) == 0
1989 && distortion == 0. && skew == 0.);
1992 }
else if (
ND_shape(n)->polygon->vertices) {
2001 if (height > temp &&
ND_label(n)->valign ==
'c') {
2005 bb.
x *= sqrt(1. / (1. -
SQR(bb.
y / height)));
2012 temp = cos(
M_PI / sides);
2026 if ((*fxd ==
's') &&
streq(fxd,
"shape")) {
2034 "node '%s', graph '%s' size too small for label\n",
2039 bb.
x = width =
MAX(width, bb.
x);
2040 bb.
y = height =
MAX(height, bb.
y);
2047 width = height = bb.
x = bb.
y =
MAX(bb.
x, bb.
y);
2055 else if (dimen.
y < bb.
y) {
2056 temp = bb.
x * sqrt(1.0 -
SQR(dimen.
y) /
SQR(bb.
y));
2060 ND_label(n)->space.x = dimen.
x - spacex;
2062 ND_label(n)->space.x = dimen.
x - spacex;
2066 temp = bb.
y - min_bb.
y;
2067 if (dimen.
y < imagesize.
y)
2068 temp += imagesize.
y - dimen.
y;
2073 if (peripheries < 1)
2080 vertices[0].
x = -P.
x;
2081 vertices[0].
y = -P.
y;
2083 if (peripheries > 1) {
2084 for (j = 1, i = 2; j < peripheries; j++) {
2087 vertices[i].
x = -P.
x;
2088 vertices[i].
y = -P.
y;
2090 vertices[i].
x = P.
x;
2091 vertices[i].
y = P.
y;
2119 sectorangle = 2. *
M_PI / sides;
2120 sidelength = sin(sectorangle / 2.);
2121 skewdist = hypot(fabs(distortion) + fabs(skew), 1.);
2122 gdistortion = distortion *
SQRT2 / cos(sectorangle / 2.);
2124 angle = (sectorangle -
M_PI) / 2.;
2125 sincos(angle, &sinx, &cosx);
2129 angle += (
M_PI - sectorangle) / 2.;
2130 for (i = 0; i < sides; i++) {
2133 angle += sectorangle;
2134 sincos(angle, &sinx, &cosx);
2135 R.
x += sidelength * cosx;
2136 R.
y += sidelength * sinx;
2139 P.
x = R.
x * (skewdist + R.
y * gdistortion) + R.
y * gskew;
2143 alpha =
RADIANS(orientation) + atan2(P.
y, P.
x);
2144 sincos(alpha, &sinx, &cosx);
2145 P.
x = P.
y = hypot(P.
x, P.
y);
2154 xmax =
MAX(fabs(P.
x), xmax);
2155 ymax =
MAX(fabs(P.
y), ymax);
2160 vertices[1].
x = -P.
x;
2161 vertices[1].
y = P.
y;
2162 vertices[2].
x = -P.
x;
2163 vertices[2].
y = -P.
y;
2164 vertices[3].
x = P.
x;
2165 vertices[3].
y = -P.
y;
2174 bb.
x =
MAX(width, xmax);
2175 bb.
y =
MAX(height, ymax);
2176 scalex = bb.
x /
xmax;
2177 scaley = bb.
y /
ymax;
2179 for (i = 0; i < sides; i++) {
2186 if (peripheries > 1) {
2187 Q = vertices[(sides - 1)];
2189 beta = atan2(R.y - Q.
y, R.x - Q.
x);
2190 for (i = 0; i < sides; i++) {
2195 R = vertices[(i + 1) % sides];
2197 beta = atan2(R.y - Q.
y, R.x - Q.
x);
2198 gamma = (alpha +
M_PI - beta) / 2.;
2202 temp =
GAP / sin(gamma);
2205 sincos((alpha - gamma), &sinx, &cosx);
2211 for (j = 1; j < peripheries; j++) {
2214 vertices[i + j * sides] = Q;
2217 for (i = 0; i < sides; i++) {
2218 P = vertices[i + (peripheries - 1) * sides];
2219 bb.
x =
MAX(2. * fabs(P.
x), bb.
x);
2220 bb.
y =
MAX(2. * fabs(P.
y), bb.
y);
2226 poly->
sides = sides;
2243 static void poly_free(
node_t * n)
2253 #define GET_PORT_BOX(n,e) ((n) == (e)->head ? ED_head_port(e).bp : ED_tail_port(e).bp)
2265 static int last, outp, sides;
2268 static double xsize, ysize, scalex, scaley, box_URx, box_URy;
2275 if (!inside_context) {
2280 bp = inside_context->
s.
bp;
2281 n = inside_context->
s.
n;
2291 double n_width, n_height;
2294 sides = poly->
sides;
2298 n_width = bb.
UR.
x - bb.
LL.
x;
2299 n_height = bb.
UR.
y - bb.
LL.
y;
2326 scalex = n_width / xsize;
2327 scaley = n_height / ysize;
2328 box_URx = n_width / 2.0;
2329 box_URy = n_height / 2.0;
2343 if ((fabs(P.
x) > box_URx) || (fabs(P.
y) > box_URy))
2348 return (hypot(P.
x / box_URx, P.
y / box_URy) < 1.);
2352 i1 = (i + 1) % sides;
2353 Q = vertex[i + outp];
2354 R = vertex[i1 + outp];
2355 if (!(same_side(P, O, Q, R)))
2358 if ((s = same_side(P, Q, R, O)) && (same_side(P, R, O, Q)))
2361 for (j = 1; j < sides; j++) {
2364 i1 = (i + 1) % sides;
2367 i = (i + sides - 1) % sides;
2369 if (!(same_side(P, O, vertex[i + outp], vertex[i1 + outp]))) {
2385 static int poly_path(
node_t * n,
port * p,
int side,
boxf rv[],
int *kptr)
2397 static int invflip_side(
int side,
int rankdir)
2452 static double invflip_angle(
double angle,
int rankdir)
2461 angle -=
M_PI * 0.5;
2465 angle = -0.5 *
M_PI;
2466 else if (angle ==
M_PI * 0.75)
2467 angle = -0.25 *
M_PI;
2468 else if (angle ==
M_PI * 0.5)
2474 else if (angle == 0)
2476 else if (angle ==
M_PI * -0.25)
2477 angle =
M_PI * 0.75;
2478 else if (angle ==
M_PI * -0.5)
2515 curve[0].
x = curve[0].
y = 0;
2516 curve[1] = curve[0];
2517 curve[3] = curve[2] = p;
2551 compassPort(
node_t * n,
boxf * bp,
port * pp,
char *compass,
int sides,
2558 boolean constrain =
FALSE;
2559 boolean dyna =
FALSE;
2561 boolean clip =
TRUE;
2567 p = pointfof((b.
LL.
x + b.
UR.
x) / 2, (b.
LL.
y + b.
UR.
y) / 2);
2587 if (compass && *compass) {
2588 switch (*compass++) {
2594 p = compassPoint(ictxt, ctr.
y, maxv);
2601 side = sides &
RIGHT;
2610 theta = -
M_PI * 0.5;
2613 p = compassPoint(ictxt, -maxv, ctr.
x);
2619 theta = -
M_PI * 0.25;
2622 p = compassPoint(ictxt, -maxv, maxv);
2625 side = sides & (BOTTOM |
RIGHT);
2628 theta = -
M_PI * 0.75;
2631 p = compassPoint(ictxt, -maxv, -maxv);
2634 side = sides & (BOTTOM |
LEFT);
2649 p = compassPoint(ictxt, ctr.
y, -maxv);
2656 side = sides &
LEFT;
2668 p = compassPoint(ictxt, maxv, ctr.
x);
2675 theta =
M_PI * 0.25;
2677 p = compassPoint(ictxt, maxv, maxv);
2680 side = sides & (TOP |
RIGHT);
2684 theta =
M_PI * 0.75;
2686 p = compassPoint(ictxt, maxv, -maxv);
2689 side = sides & (TOP |
LEFT);
2718 if ((p.
x == 0) && (p.
y == 0))
2722 double angle = atan2(p.
y, p.
x) + 1.5 *
M_PI;
2723 if (angle >= 2 *
M_PI)
2734 static port poly_port(
node_t * n,
char *portname,
char *compass)
2740 if (portname[0] ==
'\0')
2743 if (compass ==
NULL)
2747 if (compassPort(n, bp, &rv, compass, sides,
NULL)) {
2749 "node %s, port %s, unrecognized compass point '%s' - ignored\n",
2763 if (compassPort(n,
NULL, &rv, portname, sides, ictxtp))
2764 unrecognized(n, portname);
2771 #define multicolor(f) (strchr(f,':'))
2778 double xsize, ysize;
2779 int i, j, peripheries, sides, style;
2784 boolean usershape_p;
2788 char* fillcolor=
NULL;
2789 char* pencolor=
NULL;
2799 sides = poly->
sides;
2801 if (A_size < sides) {
2812 style = stylenode(job, n);
2850 fillcolor = findFill (n);
2868 fillcolor = findFill (n);
2875 pencolor = penColor(job, n);
2881 if ((peripheries == 0) && filled && pfilled) {
2887 for (j = 0; j < peripheries; j++) {
2888 for (i = 0; i < sides; i++) {
2889 P = vertices[i + j * sides];
2902 Mcircle_hack(job, n);
2925 usershape_p =
FALSE;
2928 if (
streq(name,
"custom")) {
2929 if ((name =
agget(n,
"shapefile")) && name[0])
2933 }
else if ((name =
agget(n,
"image")) && name[0]) {
2938 for (i = 0; i < sides; i++) {
2944 if (filled && pfilled) {
2954 Mcircle_hack(job, n);
2992 static void point_init(
node_t * n)
2995 int sides, outp, peripheries =
ND_shape(n)->polygon->peripheries;
3023 if (peripheries < 1)
3029 P.
y = P.
x = sz / 2.;
3030 vertices[0].
x = -P.
x;
3031 vertices[0].
y = -P.
y;
3033 if (peripheries > 1) {
3034 for (j = 1, i = 2; j < peripheries; j++) {
3037 vertices[i].
x = -P.
x;
3038 vertices[i].
y = -P.
y;
3040 vertices[i].
x = P.
x;
3041 vertices[i].
y = P.
y;
3061 static double radius;
3065 if (!inside_context) {
3070 n = inside_context->
s.
n;
3087 if ((fabs(P.
x) > radius) || (fabs(P.
y) > radius))
3090 return (hypot(P.
x, P.
y) <= radius);
3093 static void point_gencode(
GVJ_t * job,
node_t * n)
3097 int i, j, sides, peripheries, style;
3112 sides = poly->
sides;
3114 if (A_size < sides) {
3119 checkStyle(n, &style);
3156 color = findFillDflt(n,
"black");
3163 if (peripheries == 0) {
3169 for (j = 0; j < peripheries; j++) {
3170 for (i = 0; i < sides; i++) {
3171 P = vertices[i + j * sides];
3197 #define ISCTRL(c) ((c) == '{' || (c) == '}' || (c) == '|' || (c) == '<' || (c) == '>')
3199 static char *reclblp;
3201 static void free_field(
field_t * f)
3205 for (i = 0; i < f->
n_flds; i++) {
3206 free_field(f->
fld[i]);
3226 static field_t *parse_reclbl(
node_t * n,
int LR,
int flag,
char *text)
3229 char *tsp, *psp=
NULL, *hstsp, *hspsp=
NULL, *sp;
3230 char *tmpport =
NULL;
3231 int maxf, cnt, mode, wflag, ishardspace, fi;
3236 for (maxf = 1, cnt = 0, sp = reclblp; *sp; sp++) {
3240 && (*sp ==
'{' || *sp ==
'}' || *sp ==
'|' || *sp ==
'\\'))
3245 else if (*sp ==
'}')
3247 else if (*sp ==
'|' && cnt == 0)
3258 ishardspace =
FALSE;
3260 if ((uc = *(
unsigned char*)reclblp) && (uc <
' ')) {
3267 return parse_error(rv, tmpport);
3278 return parse_error(rv, tmpport);
3279 if (psp > text + 1 && psp - 1 != hspsp && *(psp - 1) ==
' ')
3282 tmpport = strdup(text);
3288 if (mode != 0 || !*reclblp)
3289 return parse_error(rv, tmpport);
3291 if (!(rv->
fld[fi++] = parse_reclbl(n,
NOT(LR),
FALSE, text)))
3292 return parse_error(rv, tmpport);
3297 if ((!*reclblp && !flag) || (mode & INPORT))
3298 return parse_error(rv, tmpport);
3305 if (!(mode & (
HASTEXT | HASTABLE)))
3306 mode |=
HASTEXT, *tsp++ =
' ';
3308 if (tsp > text + 1 &&
3309 tsp - 1 != hstsp && *(tsp - 1) ==
' ')
3321 if (*reclblp ==
'}') {
3332 if (*(reclblp + 1)) {
3333 if (
ISCTRL(*(reclblp + 1)))
3335 else if ((*(reclblp + 1) ==
' ') && !lbl->
html)
3336 ishardspace =
TRUE, reclblp++;
3346 if ((mode & HASTABLE) && *reclblp !=
' ')
3347 return parse_error(rv, tmpport);
3348 if (!(mode & (
INTEXT | INPORT)) && *reclblp !=
' ')
3349 mode |= (
INTEXT | HASTEXT);
3352 (*reclblp ==
' ' && !ishardspace && *(tsp - 1) ==
' '
3357 }
else if (mode & INPORT) {
3358 if (!(*reclblp ==
' ' && !ishardspace &&
3359 (psp == text || *(psp - 1) ==
' ')))
3365 while (*reclblp & 128)
3366 *tsp++ = *reclblp++;
3378 double marginx, marginy;
3386 if ((dimen.
x > 0.0) || (dimen.
y > 0.0)) {
3388 if ((p =
agget(n,
"margin"))) {
3389 i = sscanf(p,
"%lf,%lf", &marginx, &marginy);
3391 dimen.
x += 2 *
POINTS(marginx);
3393 dimen.
y += 2 *
POINTS(marginy);
3395 dimen.
y += 2 *
POINTS(marginx);
3404 for (i = 0; i < f->
n_flds; i++) {
3405 d0 = size_reclbl(n, f->
fld[i]);
3419 static void resize_reclbl(
field_t * f,
pointf sz,
int nojustify_p)
3433 if (f->
lp && !nojustify_p) {
3445 for (i = 0; i < f->
n_flds; i++) {
3447 amt = ((
int) ((i + 1) * inc)) - ((
int) (i * inc));
3449 newsz = pointfof(sf->
size.
x + amt, sz.
y);
3451 newsz = pointfof(sz.
x, sf->
size.
y + amt);
3452 resize_reclbl(sf, newsz, nojustify_p);
3470 for (i = 0; i <= last; i++) {
3478 }
else if (i == last)
3488 }
else if (i == last)
3495 pos_reclbl(f->
fld[i], ul, sides & mask);
3504 static void indent(
int l)
3507 for (i = 0; i < l; i++)
3511 static void prbox(
boxf b)
3513 fprintf(stderr,
"((%.5g,%.5g),(%.5g,%.5g))\n", b.
LL.
x, b.
LL.
y, b.
UR.
x,
3523 fprintf(stderr,
"Label \"%s\" ", info->
lp->
text);
3526 fprintf(stderr,
"Tbl ");
3528 for (i = 0; i < info->
n_flds; i++) {
3529 dumpL(info->
fld[i], level + 1);
3536 static void record_init(
node_t * n)
3547 len = strlen(reclblp);
3552 textbuf =
N_NEW(len + 1,
char);
3553 if (!(info = parse_reclbl(n, flip,
TRUE, textbuf))) {
3556 info = parse_reclbl(n, flip,
TRUE, textbuf);
3559 size_reclbl(n, info);
3573 ul = pointfof(-sz.
x / 2., sz.
y / 2.);
3574 pos_reclbl(info, ul, sides);
3581 static void record_free(
node_t * n)
3597 for (sub = 0; sub < f->
n_flds; sub++)
3598 if ((rv = map_rec_port(f->
fld[sub], str)))
3604 static port record_port(
node_t * n,
char *portname,
char *compass)
3611 if (portname[0] ==
'\0')
3614 if (compass ==
NULL)
3617 if ((subf = map_rec_port(f, portname))) {
3618 if (compassPort(n, &subf->
b, &rv, compass, subf->
sides,
NULL)) {
3620 "node %s, port %s, unrecognized compass point '%s' - ignored\n",
3623 }
else if (compassPort(n, &f->
b, &rv, portname, sides,
NULL)) {
3624 unrecognized(n, portname);
3634 static boolean record_inside(
inside_t * inside_context,
pointf p)
3638 boxf *bp = inside_context->
s.
bp;
3658 static int record_path(
node_t * n, port * prt,
int side,
boxf rv[],
3670 for (i = 0; i < info->
n_flds; i++) {
3707 for (i = 0; i < f->
n_flds; i++) {
3718 AF[0] = add_pointf(AF[0], coord);
3719 AF[1] = add_pointf(AF[1], coord);
3722 gen_fields(job, n, f->
fld[i]);
3726 static void record_gencode(
GVJ_t * job,
node_t * n)
3748 style = stylenode(job, n);
3752 char* fillcolor = findFill (n);
3771 else filled =
FALSE;
3787 gen_fields(job, n, f);
3789 if (clrs[0]) free (clrs[0]);
3801 static int N_UserShape;
3807 for (i = 0; i < N_UserShape; i++) {
3808 if (
streq(UserShape[i]->name, name))
3809 return UserShape[i];
3826 p->
name = strdup(name);
3828 agerr(
AGWARN,
"using %s for unknown shape %s\n", Shapes[0].name,
3844 if (str && !
streq(name,
"epsf"))
3846 if (!
streq(name,
"custom")) {
3847 for (ptr = Shapes; ptr->
name; ptr++) {
3855 rv = user_shape(name);
3867 return ((P.
y >= -x2) && (P.
y <= x2) && (P.
x >= -
ND_lw(n))
3887 "%.5g %.5g translate newpath user_shape_%d\n",
3902 #define alpha (M_PI/10.0)
3903 #define alpha2 (2*alpha)
3904 #define alpha3 (3*alpha)
3905 #define alpha4 (2*alpha2)
3910 double r0, r, rx, ry;
3912 rx = sz0.
x/(2*cos(alpha));
3913 ry = sz0.
y/(sin(alpha) + sin(
alpha3));
3917 sz.
x = 2*r*cos(alpha);
3922 static void star_vertices (
pointf* vertices,
pointf* bb)
3926 double offset, a, aspect = (1 + sin(
alpha3))/(2*cos(alpha));
3927 double r, r0, theta =
alpha;
3934 else if (a < aspect) {
3939 r = sz.
x/(2*cos(alpha));
3943 offset = (r*(1 - sin(
alpha3)))/2;
3945 for (i = 0; i < 10; i += 2) {
3946 vertices[i].
x = r*cos(theta);
3947 vertices[i].
y = r*sin(theta) - offset;
3949 vertices[i+1].
x = r0*cos(theta);
3950 vertices[i+1].
y = r0*sin(theta) - offset;
3961 static int outp, sides;
3965 if (!inside_context) {
3969 boxf *bp = inside_context->
s.
bp;
3985 sides = poly->
sides;
3995 for (i = 0; i < sides; i += 2) {
3996 Q = vertex[i + outp];
3997 R = vertex[((i+4) % sides) + outp];
3998 if (!(same_side(P, O, Q, R))) {
4018 static void cylinder_vertices (
pointf* vertices,
pointf* bb)
4022 double yr = bb->
y/11;
4025 vertices[0].
y = y-yr;
4027 vertices[1].
y = y-(1-0.551784)*yr;
4028 vertices[2].
x = 0.551784*x;
4032 vertices[4].
x = -0.551784*x;
4035 vertices[5].
y = vertices[1].
y;
4037 vertices[6].
y = y-yr;
4038 vertices[7] = vertices[6];
4040 vertices[8].
y = yr-y;
4041 vertices[9] = vertices[8];
4042 vertices[10].
x = -x;
4043 vertices[10].
y = -vertices[1].
y;
4044 vertices[11].
x = vertices[4].
x;
4045 vertices[11].
y = -vertices[4].
y;
4046 vertices[12].
x = vertices[3].
x;
4047 vertices[12].
y = -vertices[3].
y;
4048 vertices[13].
x = vertices[2].
x;
4049 vertices[13].
y = -vertices[2].
y;
4050 vertices[14].
x = vertices[1].
x;
4051 vertices[14].
y = -vertices[1].
y;
4052 vertices[15].
x = vertices[0].
x;
4053 vertices[15].
y = -vertices[0].
y;
4054 vertices[16] = vertices[15];
4055 vertices[18] = vertices[17] = vertices[0];
4058 static void cylinder_draw(
GVJ_t * job,
pointf * AF,
int sides,
int style,
int filled)
4061 double y0 = AF[0].
y;
4064 vertices[0] = AF[0];
4065 vertices[1].
x = AF[1].
x;
4066 vertices[1].
y = y02 - AF[1].
y;
4067 vertices[2].
x = AF[2].
x;
4068 vertices[2].
y = y02 - AF[2].
y;
4069 vertices[3].
x = AF[3].
x;
4070 vertices[3].
y = y02 - AF[3].
y;
4071 vertices[4].
x = AF[4].
x;
4072 vertices[4].
y = y02 - AF[4].
y;
4073 vertices[5].
x = AF[5].
x;
4074 vertices[5].
y = y02 - AF[5].
y;
4075 vertices[6] = AF[6];
4089 static boolean cylinder_inside(
inside_t * inside_context,
pointf p)
4095 static char *side_port[] = {
"s",
"e",
"n",
"w" };
4134 static char *closestSide(
node_t * n,
node_t * other, port * oldport)
4141 int sides = oldport->
side;
4145 if ((sides == 0) || (sides == (
TOP | BOTTOM |
LEFT |
RIGHT)))
4164 for (i = 0; i < 4; i++) {
4165 if ((sides & (1 << i)) == 0)
4188 if (!rv || (d < mind)) {
4199 char *compass = closestSide(n, other, oldport);
4203 compassPort(n, oldport->
bp, &rv, compass, oldport->
side,
NULL);
4221 poly_inside(
NULL, p);
4222 point_inside(
NULL, p);
4223 star_inside(
NULL, p);
void s1(graph_t *, node_t *)
shape_desc * find_user_shape(const char *)
void free_label(textlabel_t *p)
void gvrender_box(GVJ_t *job, boxf BF, int filled)
void gvrender_polygon(GVJ_t *job, pointf *af, int n, int filled)
EXTERN Agsym_t * N_selectedpencolor
#define GUI_STATE_SELECTED
char ** parse_style(char *s)
EXTERN Agsym_t * N_selectedfillcolor
#define DEFAULT_DELETEDFILLCOLOR
EXTERN Agsym_t * N_imagepos
EXTERN Agsym_t * N_activefillcolor
char * late_nnstring(void *obj, attrsym_t *attr, char *def)
pointf cwrotatepf(pointf p, int cwrot)
shape_kind shapeOf(node_t *)
boolean findStopColor(char *colorlist, char *clrs[2], float *frac)
#define ALLOC(size, ptr, type)
#define SPECIAL_CORNERS(style)
EXTERN Agsym_t * N_height
void gvrender_usershape(GVJ_t *job, char *name, pointf *AF, int n, boolean filled, char *imagescale, char *imagepos)
#define GUI_STATE_VISITED
EXTERN Agsym_t * N_peripheries
boxf flip_rec_boxf(boxf b, pointf p)
void gvrender_set_fillcolor(GVJ_t *job, char *name)
void emit_label(GVJ_t *job, emit_state_t emit_state, textlabel_t *lp)
#define DEFAULT_SELECTEDFILLCOLOR
EXTERN Agsym_t * N_gradientangle
int agerr(agerrlevel_t level, const char *fmt,...)
int html_path(node_t *n, port *p, int side, boxf *rv, int *k)
EXTERN Agsym_t * N_visitedfillcolor
#define PS2INCH(a_points)
char * agget(void *obj, char *name)
CGRAPH_API Agraph_t * agraphof(void *obj)
CGRAPH_API Agnode_t * agtail(Agedge_t *e)
point gvusershape_size(graph_t *g, char *name)
pointf ccwrotatepf(pointf p, int ccwrot)
#define DEFAULT_DELETEDPENCOLOR
void epsf_init(node_t *n)
#define DEFAULT_VISITEDFILLCOLOR
EXTERN Agsym_t * N_imagescale
CGRAPH_API Agnode_t * aghead(Agedge_t *e)
#define DEFAULT_VISITEDPENCOLOR
EXTERN Agsym_t * N_deletedfillcolor
CGRAPH_API char * agnameof(void *)
void gvrender_begin_anchor(GVJ_t *job, char *href, char *tooltip, char *target, char *id)
char * findAttrColor(void *obj, attrsym_t *colorattr, char *dflt)
int stripedBox(GVJ_t *job, pointf *AF, char *clrs, int rotate)
void gvrender_set_pencolor(GVJ_t *job, char *name)
void epsf_free(node_t *n)
EXTERN Agsym_t * N_activepencolor
void gvrender_set_style(GVJ_t *job, char **s)
EXTERN Agsym_t * N_orientation
int late_int(void *obj, attrsym_t *attr, int def, int low)
EXTERN Agsym_t * N_penwidth
void gvrender_set_gradient_vals(GVJ_t *job, char *stopcolor, int angle, float frac)
void gvrender_set_penwidth(GVJ_t *job, double penwidth)
#define GUI_STATE_DELETED
const char * safefile(const char *filename)
int wedgedEllipse(GVJ_t *job, pointf *pf, char *clrs)
#define DEFAULT_SELECTEDPENCOLOR
EXTERN Agsym_t * N_nojustify
double late_double(void *obj, attrsym_t *attr, double def, double low)
void round_corners(GVJ_t *job, pointf *AF, int sides, int style, int filled)
#define DEFAULT_ACTIVEPENCOLOR
#define DEFAULT_ACTIVEFILLCOLOR
port resolvePort(node_t *n, node_t *other, port *oldport)
boxf * html_port(node_t *n, char *pname, int *sides)
void(* vertex_gen)(pointf *, pointf *)
pointf(* size_gen)(pointf)
void gvrender_ellipse(GVJ_t *job, pointf *AF, int n, int filled)
char * late_string(void *obj, attrsym_t *attr, char *def)
EXTERN Agsym_t * N_deletedpencolor
EXTERN Agsym_t * N_visitedpencolor
void gvrender_beziercurve(GVJ_t *job, pointf *AF, int n, int arrow_at_start, int arrow_at_end, boolean filled)
boxf polyBB(polygon_t *poly)
void resolvePorts(edge_t *e)
boolean isPolygon(node_t *)
char * agxget(void *obj, Agsym_t *sym)
#define EMIT_CLUSTERS_LAST
void gvrender_end_anchor(GVJ_t *job)
shape_desc * bind_shape(char *name, node_t *)
EXTERN Agsym_t * N_fillcolor
void bezier_clip(inside_t *inside_context, boolean(*insidefn)(inside_t *inside_context, pointf p), pointf *sp, boolean left_inside)
EXTERN Agsym_t * N_distortion
textlabel_t * make_label(void *obj, char *str, int kind, double fontsize, char *fontname, char *fontcolor)
void gvrender_polyline(GVJ_t *job, pointf *AF, int n)