25 #define SUPPORT_WRITEDATE
28 #ifdef SUPPORT_WRITEDATE
47 #define WIDTH_NORMAL 1
57 {
"box",
"\"Rectangle\""},
58 {
"ellipse",
"\"Ellipse\""},
59 {
"circle",
"\"Ellipse\""},
60 {
"triangle",
"\"Triangle\""},
61 {
"diamond",
"\"Diamond\""},
62 {
"trapezium",
"\"Trapezoid\""},
63 {
"parallelogram",
"\"Parallelogram\""},
64 {
"hexagon",
"\"Hexagon\""},
73 static int onetime =
TRUE;
86 static void vtx_reset(
void)
92 static void init_vtx(
void)
117 static void vtx_ptarray(
point * A,
int n)
122 fprintf(Output_file,
" (points\n");
123 for (i = 0; i < n; i++) {
124 p.
x = (double) A[i].x;
125 p.
y = (double) A[i].y;
127 fprintf(Output_file,
" (%g %g)\n", p.
x, p.
y);
129 fprintf(Output_file,
" )\n");
132 static void vtx_bzptarray(
point * A,
int start,
int end)
136 int i, j, incr = (start > end) ? -1 : 1;
138 fprintf(Output_file,
" (points\n");
139 for (i = start, j = 1; i != end; i += incr, j++) {
142 p.
x = (double) A[i].x;
143 p.
y = (double) A[i].y;
145 fprintf(Output_file,
" (%g %g)\n", p.
x, p.
y);
152 p.
x = (double) A[i].x;
153 p.
y = (double) A[i].y;
155 fprintf(Output_file,
" (%g %g)\n", p.
x, p.
y);
161 if (A[i].x == qx && A[i].y == qy) {
162 if ((A[i - 2].x == qx && A[i - 2].y == qy)
163 || (A[i + 1].x == qx && A[i + 1].y == qy)) {
164 p.
x = (A[i + 1].
x + A[i - 2].
x) / 2.0;
165 p.
y = (A[i + 1].
y + A[i - 2].
y) / 2.0;
171 p.
x = (A[i].
x + qx) / 2.0;
172 p.
y = (A[i].
y + qy) / 2.0;
175 p.
x = (double) A[i].x;
176 p.
y = (double) A[i].y;
179 fprintf(Output_file,
" (%g %g)\n", p.
x, p.
y);
183 fprintf(Output_file,
" )\n");
199 static void vtx_comment(
char *
str)
201 fprintf(Output_file,
"; %s\n", str);
205 vtx_begin_job(FILE * ofp,
graph_t * g,
const char **lib,
char *
info[],
point pages)
208 #ifdef SUPPORT_WRITEDATE
211 size_t date_length = 200;
214 tm = localtime(&when);
215 date =
N_GNEW(date_length,
char);
216 strftime(date, date_length,
"%a %b %e %H:%M:%S %Z %Y", tm);
222 fprintf(Output_file,
"; Visual Thought 1.0\n"
225 " (program \"%s\")\n"
226 " (version \"%s\")\n"
227 " (buildDate \"%s\")\n"
228 " (writeDate \"%s\")\n"
229 " (documentPath \"\")\n"
230 ")\n" "\n", info[0], info[1], info[2], date);
245 vtx_begin_page(
graph_t * g,
point page,
double scale,
int rot,
253 page_number = page.
x + page.
y * Pages.
x + 1;
256 fprintf(Output_file,
"(document\n"
259 " (page \"Letter\")\n"
260 " (units \"Inches\")\n"
261 " (orientation \"portrait\")\n"
262 " (numberOfPages %d %d)\n"
264 " (margins 18 18 18 18)\n"
270 " (location 269 49)\n"
273 " (documentLocation 0 119)\n"
275 " (gridVisibility F)\n"
278 " (toolVisibility T)\n"
279 " (rulerVisibility T)\n"
282 "\n", page_number, Pages.
x * Pages.
y, scale * 100, scale);
285 static void vtx_begin_nodes(
void)
287 fprintf(Output_file,
"(shapes\n");
290 static void vtx_end_nodes(
void)
292 fprintf(Output_file,
")\n" "\n");
295 static void vtx_begin_edges(
void)
297 fprintf(Output_file,
"(connections\n");
300 static void vtx_end_edges(
void)
302 fprintf(Output_file,
")\n" "\n" "(groups\n" ")\n");
305 static void vtx_begin_node(
node_t * n)
309 for (p = shapemap; p->
shape; p++) {
314 fprintf(Output_file,
" (shape\n"
320 static void vtx_end_node(
void)
322 fprintf(Output_file,
" )\n");
325 static void vtx_begin_edge(
edge_t * e)
327 fprintf(Output_file,
" (connection\n"
331 " (textRotation 0)\n"
338 static void vtx_end_edge(
void)
340 fprintf(Output_file,
" )\n");
343 static void vtx_begin_context(
void)
346 cstk[SP + 1] = cstk[SP];
350 static void vtx_end_context(
void)
358 static void vtx_set_font(
char *name,
double size)
367 if ((q = strchr(p,
'-'))) {
378 static void vtx_style(
void)
383 fprintf(Output_file,
" (style\n"
385 " (fillColor %d %d %d)\n"
387 " (strokeColor %d %d %d)\n"
390 " (shadowColor 39321 39321 39321)\n"
392 cp->
fill ?
"T" :
"F",
397 static void vtx_node_style(
void)
399 fprintf(Output_file,
" (rotation 0)\n" " (locked F)\n");
401 fprintf(Output_file,
" (flipHorizontal F)\n"
402 " (flipVertical F)\n");
405 static void vtx_set_color(
char *name)
417 static void vtx_set_style(
char **
s)
423 while ((line = *s++)) {
424 if (
streq(line,
"solid"))
426 else if (
streq(line,
"dashed"))
428 else if (
streq(line,
"dotted"))
434 else if (
streq(line,
"filled"))
436 else if (
streq(line,
"unfilled"))
440 "vtx_set_style: unsupported style %s - ignoring\n",
447 static char *vtx_string(
char *s)
449 static char *buf =
NULL;
450 static int bufsize = 0;
456 buf =
N_GNEW(bufsize,
char);
461 if (pos > (bufsize - 8)) {
491 static void vtx_textpara(
point p, textpara_t * para)
494 double fontsz = Scale * cstk[SP].
fontsz;
496 if (cstk[SP].pen ==
P_NONE) {
502 mp.
y = (
double) (p.
y - fontsz / 2 + 2);
505 fprintf(Output_file,
" (showText T)\n"
506 " (textDistancePercentage 0.5)\n"
509 " (rtfText{\\rtf1\\ansi\\deff0\n"
510 "{\\fonttbl{\\f0\\fnil helvetica medium;}}\n"
511 "{\\colortbl\\red0\\green0\\blue0;}\n"
512 "\\cf0\\plain\\pard {\\fs%d %s}})\n",
513 (
int) ((fontsz * 2) - 8), vtx_string(para->str));
515 fprintf(Output_file,
" (showText T)\n"
516 " (textVerticalAlignment \"left\")\n"
517 " (rtfText{\\rtf1\\ansi\\deff0\n"
518 "{\\fonttbl{\\f0\\fnil helvetica medium;}}\n"
519 "{\\colortbl\\red0\\green0\\blue0;}\n"
520 "\\cf0\\plain\\pard {\\fs%d %s}})\n",
521 (
int) ((fontsz * 2) - 8), vtx_string(para->str));
525 static void vtx_bezier(
point * A,
int n,
int arrow_at_start,
526 int arrow_at_end,
int filled)
528 if (arrow_at_start) {
529 vtx_bzptarray(A, n - 2, 0);
530 fprintf(Output_file,
" (curved T)\n");
532 fprintf(Output_file,
" (drawStartArrowhead %s)\n"
533 " (drawEndArrowhead %s)\n"
534 " (startArrowhead \"StandardArrow\")\n"
535 " (endArrowhead \"StandardArrow\")\n",
536 arrow_at_end ?
"T" :
"F", arrow_at_start ?
"T" :
"F");
538 vtx_bzptarray(A, 1, n - 1);
539 fprintf(Output_file,
" (curved T)\n");
541 fprintf(Output_file,
" (drawStartArrowhead %s)\n"
542 " (drawEndArrowhead %s)\n"
543 " (startArrowhead \"StandardArrow\")\n"
544 " (endArrowhead \"StandardArrow\")\n",
545 arrow_at_start ?
"T" :
"F", arrow_at_end ?
"T" :
"F");
549 static void vtx_polygon(
point * A,
int n,
int filled)
556 max.
x = min.
x = (double) A[0].x;
557 max.
y = min.
y = (double) A[0].y;
558 for (i = 0; i < n; i++) {
559 mp.
x += (double) A[i].x;
560 mp.
y += (double) A[i].y;
561 max.
x =
MAX(max.
x, (
double) A[i].
x);
562 max.
y =
MAX(max.
y, (
double) A[i].
y);
563 min.
x =
MIN(min.
x, (
double) A[i].
x);
564 min.
y =
MIN(min.
y, (
double) A[i].
y);
571 fprintf(Output_file,
" (location %g %g)\n"
573 mp.
x, mp.
y, max.
x - min.
x, max.
y - min.
y);
577 static void vtx_ellipse(
point p,
int rx,
int ry,
int filled)
584 fprintf(Output_file,
" (location %g %g)\n"
586 mp.
x, mp.
y, (
double) (rx + rx), (
double) (ry + ry));
590 static void vtx_polyline(
point * A,
int n)
593 fprintf(Output_file,
" (curved F)\n");
605 max.
x = min.
x = (double) A[0].x;
606 max.
y = min.
y = (double) A[0].y;
607 for (i = 0; i < n; i++) {
608 mp.
x += (double) A[i].x;
609 mp.
y += (double) A[i].y;
610 max.
x =
MAX(max.
x, (
double) A[i].
x);
611 max.
y =
MAX(max.
y, (
double) A[i].
y);
612 min.
x =
MIN(min.
x, (
double) A[i].
x);
613 min.
y =
MIN(min.
y, (
double) A[i].
y);
620 fprintf(Output_file,
" (location %g %g)\n"
622 mp.
x, mp.
y, max.
x - min.
x, max.
y - min.
y);
633 vtx_begin_nodes, vtx_end_nodes,
634 vtx_begin_edges, vtx_end_edges,
635 vtx_begin_node, vtx_end_node,
636 vtx_begin_edge, vtx_end_edge,
637 vtx_begin_context, vtx_end_context,
639 vtx_set_font, vtx_textpara,
640 vtx_set_color, vtx_set_color, vtx_set_style,
641 vtx_ellipse, vtx_polygon,
642 vtx_bezier, vtx_polyline,
void * grealloc(void *ptr, size_t size)
int agerr(agerrlevel_t level, const char *fmt,...)
CGRAPH_API Agnode_t * agtail(Agedge_t *e)
struct context_t context_t
CGRAPH_API Agnode_t * aghead(Agedge_t *e)
struct shapemap_s shapemap_t
if(aagss+aagstacksize-1<=aagssp)
int colorxlate(char *str, gvcolor_t *color, color_type_t target_type)
int strcasecmp(const char *s1, const char *s2)