1 /*
2 Copyright (c) 1991 - 1994 Heinz W. Werntges.
3 Parts Copyright (c) 1995 Emmanuel Bigler, (c)2002 Michael Rooke,
4 (c) 1999,2001,2002,2003 Martin Kroeker.
5 All rights reserved. Distributed by Free Software Foundation, Inc.
6
7 This file is part of HP2xx.
8
9 HP2xx is distributed in the hope that it will be useful, but
10 WITHOUT ANY WARRANTY. No author or distributor accepts responsibility
11 to anyone for the consequences of using it or for whether it serves any
12 particular purpose or works at all, unless he says so in writing. Refer
13 to the GNU General Public License, Version 2 or later, for full details.
14
15 Everyone is granted permission to copy, modify and redistribute
16 HP2xx, but only under the conditions described in the GNU General Public
17 License. A copy of this license is supposed to have been
18 given to you along with HP2xx so you can know your rights and
19 responsibilities. It should be in a file named COPYING. Among other
20 things, the copyright notice and this notice must be preserved on all
21 copies.
22
23 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
24 */
25
26 /** to_tvec.c: Converter to misc. TeX-oriented vector formats:
27 ** Metafont, several TeX formats, simple HP-GL
28 **
29 ** 91/01/19 V 1.00 HWW Derived from HPtoGF.c
30 ** 91/02/10 V 1.01 HWW "zaehler" removed
31 ** 91/02/15 V 1.02 HWW stdlib.h supported
32 ** 91/02/18 V 1.03 HWW some int's changed to float's
33 ** 91/06/09 V 1.04 HWW New options added; some simplifications done
34 ** 91/10/15 V 1.05 HWW ANSI_C
35 ** 91/11/20 V 1.06 HWW Many changes for "SPn;" support
36 ** 92/01/13 V 1.06a HWW debugged
37 ** 92/02/27 V 1.07b HWW TeX modes added (epic, emTeX specials)
38 ** 92/05/17 V 1.07c HWW Output to stdout if outfile == '-'
39 ** 92/05/19 V 1.07d HWW Warning if color mode
40 ** 92/12/10 V 1.08a HWW CAD (TeXcad) mode added
41 ** 92/12/12 V 1.08b HWW Info line now interprets outfile=='-' as "stdout"
42 ** 93/04/12 V 1.08c HWW Fix for J. Post's report re: \emline
43 ** 93/09/01 V 1.09a HWW Mode 5 (Simple HP-GL) added
44 ** 93/12/30 V 1.09b HWW Mode 5: Pen number preserved
45 ** 94/02/14 V 1.10a HWW Adapted to changes in hp2xx.h
46 ** 95/03/23 V 1.11 E.B. new mode 6 gnuplot ascii format
47 ** 02/.. V 1.12 MK new modes 7, DXF, and 8, Scalable Vector Graphics
48 ** 02/12/20 V 1.13 MJR new mode 9 to generic CNC G Code
49 ** 03/02/26 MK Simple HPGL now writes %f instead of %g -
50 ** HPGL does not tolerate exponent notation
51 ** 03/02/24 GV Added figure limits and pen/color mapping to DXF
52 **/
53
54 #include <stdio.h>
55 #include <stdlib.h>
56
57 #include <math.h>
58 /* needed for floor */
59
60 #ifdef ATARI
61 #include <string.h>
62 #include <ctype.h>
63 #endif
64
65 #include "bresnham.h"
66 #include "pendef.h"
67 #include "lindef.h"
68 #include "hp2xx.h"
69
70
71
72
to_mftex(const GEN_PAR * pg,const OUT_PAR * po,int mode)73 int to_mftex(const GEN_PAR * pg, const OUT_PAR * po, int mode)
74 {
75
76 PlotCmd cmd;
77 HPGL_Pt pt1;
78 float xcoord2mm, ycoord2mm;
79 FILE *md = NULL;
80 PEN_W pensize;
81 int pencolor, pen_no, chars_out = 0, max_chars_out = 210;
82 int mapped_pen_no;
83 PEN_W mapped_pen_size; /* for DXF */
84 int toolz = 0;
85 int np = 1, err = 0;
86 char *ftype = "", *scale_cmd = "", *pen_cmd = "",
87 *poly_start = "", *poly_next = "", *poly_last = "", *poly_end =
88 "", *draw_dot = "", *exit_cmd = "";
89 #ifdef ATARI
90 int i;
91 FILE *csfile;
92 char *csname, *pos1, *pos2, *special_cmd, *tempch;
93 HPGL_Pt old_pt;
94 #endif
95
96
97 switch (mode) {
98 case 0: /* Metafont mode */
99 ftype = "METAFONT";
100 scale_cmd =
101 "mode_setup;\nbeginchar(\"Z\",%4.3fmm#,%4.3fmm#,0);\n";
102 pen_cmd = "pickup pencircle scaled %2.1fmm;\n";
103 poly_start = "draw(%4.3fmm,%4.3fmm)";
104 poly_next = "--(%4.3fmm,%4.3fmm)";
105 poly_last = "--(%4.3fmm,%4.3fmm);\n";
106 poly_end = ";\n";
107 draw_dot = "drawdot(%4.3fmm,%4.3fmm);\n";
108 exit_cmd = "endchar;\nend;\n";
109 break;
110 case 1: /* TeX (em-Specials) mode */
111 ftype = "emTeX-specials";
112 scale_cmd =
113 "\\unitlength1mm\n\\begin{picture}(%4.3f,%4.3f)\n";
114 pen_cmd = "\\special{em:linewidth %2.1fmm}\n";
115 poly_start = "\\put(%4.3f,%4.3f){\\special{em:moveto}}\n";
116 poly_next = "\\put(%4.3f,%4.3f){\\special{em:lineto}}\n";
117 poly_last = poly_next;
118 poly_end = "";
119 draw_dot = "\\put(%4.3f,%4.3f){\\makebox(0,0)[cc]{.}}\n";
120 exit_cmd = "\\end{picture}\n";
121 break;
122 case 2: /* TeX (epic) mode */
123 ftype = "TeX (epic)";
124 scale_cmd =
125 "\\unitlength1mm\n\\begin{picture}(%4.3f,%4.3f)\n";
126 pen_cmd = "\\linethickness{%2.1fmm}\n";
127 poly_start = "\\drawline(%4.3f,%4.3f)";
128 poly_next = "(%4.3f,%4.3f)";
129 poly_last = "(%4.3f,%4.3f)\n";
130 poly_end = "\n";
131 draw_dot = "\\put(%4.3f,%4.3f){\\picsquare}\n";
132 exit_cmd = "\\end{picture}\n";
133 break;
134 case 3: /* TeXcad (\emline-Macros) mode */
135 ftype = "TeXcad compatible";
136 scale_cmd =
137 "\\unitlength=1mm\n\\begin{picture}(%4.3f,%4.3f)\n";
138 pen_cmd =
139 "\\special{em:linewidth %2.1fmm}\n\\linethickness{ %2.1fmm}\n";
140 poly_start = "\\emline{%4.3f}{%4.3f}{%d}";
141 poly_next = "{%4.3f}{%4.3f}{%d}%%\n";
142 /* %% = Fix for John Post's bug report */
143 poly_last = poly_next;
144 poly_end = "";
145 draw_dot = "\\put(%4.3f,%4.3f){\\makebox(0,0)[cc]{.}}\n";
146 exit_cmd = "\\end{picture}\n";
147 break;
148 #ifdef ATARI
149 case 4: /* CS-Graphics specials for ATARI TeX */
150 ftype = "CS-TeX specials";
151 scale_cmd =
152 "\\unitlength1mm\n\\begin{draw}{%4.3f}{%4.3f}{%s}\n";
153 special_cmd = "\\put(0,0){\\special{CS!i %s}}\n";
154 pen_cmd = "w %2.1fmm\n";
155 poly_start = "%4.3f %4.3f l ";
156 poly_next = "%4.3f %4.3f\n";
157 poly_last = poly_next;
158 poly_end = "";
159 draw_dot = "\\put(%4.3f,%4.3f){\\makebox(0,0)[cc]{.}}\n";
160 exit_cmd = "\\end{draw}\n";
161 break;
162 #endif
163 case 5: /* HP-GL mode */
164 ftype = "Simple HP-GL";
165 scale_cmd = "";
166 pen_cmd = "SP%1d;";
167 poly_start = "PA;PU%f,%f;";
168 poly_next = "PD%f,%f;";
169 poly_last = poly_next;
170 poly_end = "";
171 draw_dot = "PU%f,%f;PD%f,%f;PU;";
172 exit_cmd = "";
173 break;
174 case 6: /* gnuplot ascii input from HP-GL mode */
175 ftype = "gnuplot ASCII";
176 scale_cmd = "";
177 pen_cmd = "#SP1\n"; /* Not fully implemented!! */
178 poly_start = "#PA\n\n#PU\n%g %g\n";
179 poly_next = "#PD\n%g %g\n";
180 poly_last = poly_next;
181 poly_end = "";
182 draw_dot = "\n#PU\n%g %g\n#PD\n%g %g\n\n#PU\n\n";
183 exit_cmd = "";
184 break;
185 case 7: /* DXF */
186 ftype = "DXF";
187 scale_cmd =
188 " 0\nSECTION\n 2\nHEADER\n 999\nGenerated by hp2xx\n 9\n$ACADVER\n 1\nAC1009\n 9\n$EXTMIN\n 10\n%g\n 20 \n%g\n 9\n$EXTMAX\n 10\n%g\n 20\n%g\n 0\nENDSEC\n 0\nSECTION\n 2\nBLOCKS\n 0\nENDSEC\n 0\nSECTION\n 2\nENTITIES\n 0\n";
189 pen_cmd = ""; /* linecolor attribute (group 62) does this */
190 poly_start =
191 "LINE\n 8\n0\n 62\n%d\n 39\n%g\n 10\n%g\n 20\n%g\n 30\n0.0\n";
192 poly_next = " 11\n%g\n 21\n%g\n 31\n0.0\n 0\n";
193 poly_last = poly_next;
194 poly_end = "";
195 draw_dot = "";
196 /*FIXME*/ exit_cmd = "ENDSEC\n 0\nEOF\n";
197 break;
198 case 8: /* SVG */
199 ftype = "SVG";
200 scale_cmd =
201 "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\" ?>\n<svg width=\"100%%\" height=\"100%%\" viewBox=\"0 0 %4.3f %4.3f\" xmlns=\"http://www.w3.org/2000/svg\"><g>\n";
202 pen_cmd =
203 "</g><g style=\"stroke:rgb(%d,%d,%d); fill:none; stroke-width:%4.3fmm\" >\n";
204 poly_start = "<path d=\"M %4.3f, %4.3f \n";
205 poly_next = " L %4.3f, %4.3f \n";
206 poly_last = " L %4.3f, %4.3f \n\" />\n";
207 poly_end = "\" />\n";
208 draw_dot = "<path d=\"M %4.3f,%4.3f L %4.3f %4.3f\" />\n";
209 exit_cmd = "</g>\n</svg>\n";
210 break;
211 case 9: /* MJR- Test G Code */
212 ftype = "Test G-Code";
213 scale_cmd = "";
214 pen_cmd = "M06 T%2d\n"; /* pen is tool number ? */
215 poly_start = "; Tool Up\nG01 Z%g\nG00 X %g Y %g\n";
216 poly_next = "G01 X %g Y %g\n"; /* Note tool handling (Z) is done in the writer */
217 poly_last = poly_next;
218 poly_end = ";\n"; /* not sure what to do with this ? */
219 draw_dot = "\nG81 X%g Y%G Z%g R%g ; Drill Hole\nG81\n";
220 exit_cmd = "\nM02\n";
221 break;
222
223 }
224
225 #ifdef ATARI
226 if (mode == 4) {
227 csname =
228 (char *) calloc(strlen(p->outfile) + 5, sizeof(char));
229 tempch =
230 (char *) calloc(strlen(p->outfile) + 5, sizeof(char));
231 strcpy(csname, p->outfile);
232
233 for (i = 0; i < strlen(csname); i++)
234 csname[i] =
235 (isupper(csname[i]) ? tolower(csname[i]) :
236 csname[i]);
237
238 strcpy(tempch, csname);
239 }
240 #endif
241
242
243 if (*po->outfile != '-') {
244
245 #ifdef ATARI
246 if (mode == 4) {
247 pos1 = strrchr(csname, 46);
248 pos2 = strrchr(csname, 92);
249
250 if (pos1 != NULL && pos1 > pos2)
251 pos1[0] = 0;
252
253 strcat(csname, ".tex\0");
254
255 if (!strcmp(csname, tempch)) {
256 pos1 = strrchr(tempch, 46);
257 *pos1 = 0;
258 strcat(tempch, ".csg\0");
259 }
260
261
262 if ((csfile = fopen(csname, "a")) == NULL ||
263 (md = fopen(tempch, "w")) == NULL) {
264 free(csname);
265 free(tempch);
266 PError("hp2xx mf/tex");
267 err = ERROR;
268 goto MF_exit;
269 }
270
271 } else {
272 csfile = stdout;
273
274 #endif
275 if ((md = fopen(po->outfile, "w")) == NULL) {
276 PError("hp2xx (mf/tex)");
277 err = ERROR;
278 goto MF_exit;
279 }
280 #ifdef ATARI
281 }
282 #endif
283
284 } else {
285 md = stdout;
286 #ifdef ATARI
287 csfile = stdout;
288 #endif
289 }
290
291 #ifdef ATARI
292 if (!pg->quiet)
293 if (mode == 4)
294 Eprintf("\n\n- Writing %s code to \"%s\"\n", ftype,
295 *po->outfile == '-' ? "stdout" : tempch);
296 else
297 Eprintf("\n\n- Writing %s code to \"%s\"\n", ftype,
298 *po->outfile ==
299 '-' ? "stdout" : po->outfile);
300 #else
301 if (!pg->quiet) {
302 Eprintf("\n\n- Writing %s code to \"%s\"\n", ftype,
303 *po->outfile == '-' ? "stdout" : po->outfile);
304 if (mode == 9)
305 Eprintf
306 (" using engage depth %f, retract depth %f\n",
307 po->zengage, po->zretract);
308 }
309 #endif
310
311 if (pg->is_color && mode < 5)
312 Eprintf("\nWARNING: MF/TeX modes ignore colors!\n");
313
314 #ifdef ATARI
315 if (mode == 4) {
316 if (!pg->quiet)
317 Eprintf("- TEX-Input file is \"%s\"\n", csname);
318
319 pos1 = strchr(tempch, 92);
320 while (pos1 != NULL) {
321 *pos1 = 47;
322 pos1 = strchr(tempch, 92);
323 }
324
325 fprintf(csfile, "%% %s code in %s, created by hp2xx\n",
326 ftype, tempch);
327 fprintf(csfile, scale_cmd, po->width, po->height, tempch);
328 fprintf(csfile, special_cmd, tempch);
329 fprintf(md, "CS-Graphics V 1\nr\nu 1mm\n");
330 free(csname);
331 free(tempch);
332 } else {
333 #endif
334 if (mode < 5) {
335 fprintf(md, "%% %s code in %s, created by hp2xx\n",
336 ftype, po->outfile);
337 fprintf(md, scale_cmd, po->width, po->height);
338 }
339
340 if (mode == 7)
341 fprintf(md, scale_cmd, po->xoff, po->yoff,
342 po->width + po->xoff,
343 po->height + po->yoff);
344 if (mode == 8)
345 fprintf(md, scale_cmd, po->width * 2.834646,
346 po->height * 2.834646);
347 #ifdef ATARI
348 }
349 #endif
350
351 pen_no = DEFAULT_PEN_NO;
352 pensize = pt.width[pen_no];
353
354 if (pensize != 0)
355 switch (mode) {
356 case 3:
357 fprintf(md, pen_cmd, pensize, pensize);
358 break;
359 case 5:
360 fprintf(md, pen_cmd, pen_no);
361 break;
362 case 7:
363 break;
364 case 8:
365 fprintf(md, pen_cmd, 0, 0, 0, 10 * pensize);
366 break;
367 case 9:
368 Eprintf("\nWARNING: Pensize Ignored!\n");
369 break;
370 default:
371 fprintf(md, pen_cmd, pensize);
372 break;
373 }
374
375 if (mode == 5) {
376 /* xcoord2mm = 1.0;
377 ycoord2mm = 1.0;*/
378 xcoord2mm = po->width / (po->xmax - po->xmin) * 40.;
379 ycoord2mm = po->height / (po->ymax - po->ymin) * 40.;
380 } else {
381 /* Factor transforming the coordinate values into millimeters: */
382 xcoord2mm = po->width / (po->xmax - po->xmin);
383 ycoord2mm = po->height / (po->ymax - po->ymin);
384 }
385
386 if (mode == 8) {
387 xcoord2mm *= 2.834646;
388 ycoord2mm *= 2.834646;
389 }
390
391 while ((cmd = PlotCmd_from_tmpfile()) != CMD_EOF)
392 switch (cmd) {
393 case NOP:
394 break;
395
396 case SET_PEN:
397 if ((pen_no = fgetc(pg->td)) == EOF) {
398 PError("Unexpected end of temp. file: ");
399 err = ERROR;
400 goto MF_exit;
401 }
402 pensize = pt.width[pen_no];
403 if (pensize != 0.) {
404 if (chars_out) { /* Finish up old polygon */
405 fprintf(md, poly_end);
406 chars_out = 0;
407 }
408 switch (mode) {
409 case 3:
410 fprintf(md, pen_cmd, pensize,
411 pensize);
412 break;
413 case 5:
414 fprintf(md, pen_cmd, pen_no);
415 break;
416 case 8:
417 pencolor = (int) pt.color[pen_no];
418 fprintf(md, pen_cmd,
419 pt.clut[pencolor][0],
420 pt.clut[pencolor][1],
421 pt.clut[pencolor][2],
422 pensize);
423 break;
424 case 9:
425 fprintf(md, pen_cmd, pen_no); /* Tool No */
426 break;
427 default:
428 fprintf(md, pen_cmd, pensize);
429 break;
430 }
431 }
432 break;
433
434 case DEF_PW:
435 if (load_pen_width_table(pg->td) < 0) {
436 PError("Unexpected end of temp. file");
437 err = ERROR;
438 goto MF_exit;
439 }
440 pensize = pt.width[pen_no];
441 if (pensize != 0)
442 switch (mode) {
443 case 3:
444 fprintf(md, pen_cmd, pensize,
445 pensize);
446 break;
447 case 5:
448 fprintf(md, pen_cmd, pen_no);
449 break;
450 case 8:
451 break;
452 case 9:
453 break;
454 default:
455 fprintf(md, pen_cmd, pensize);
456 break;
457 }
458 break;
459 case MOVE_TO:
460 HPGL_Pt_from_tmpfile(&pt1);
461 if (pensize == 0 || mode == 3 || mode == 4
462 || mode == 7)
463 break;
464 if (chars_out) /* Finish up old polygon */
465 fprintf(md, poly_end);
466 if (mode == 8)
467 pt1.y = po->ymax - pt1.y;
468
469 if (mode == 9) { /* Special handling for tool depth */
470 chars_out = fprintf(md, poly_start,
471 po->zretract,
472 (pt1.x -
473 po->xmin) * xcoord2mm,
474 (pt1.y -
475 po->ymin) *
476 ycoord2mm);
477 toolz = 0; /* Up */
478 break;
479 }
480
481 chars_out = fprintf(md, poly_start,
482 (pt1.x - po->xmin) * xcoord2mm,
483 (pt1.y -
484 po->ymin) * ycoord2mm);
485
486 break;
487
488 case DRAW_TO:
489 if (mode == 3) { /* Needs special treatment: no polygons! */
490 chars_out = fprintf(md, poly_start,
491 (pt1.x -
492 po->xmin) * xcoord2mm,
493 (pt1.y -
494 po->ymin) * ycoord2mm,
495 np++);
496 HPGL_Pt_from_tmpfile(&pt1);
497 chars_out += fprintf(md, poly_next,
498 (pt1.x -
499 po->xmin) *
500 xcoord2mm,
501 (pt1.y -
502 po->ymin) *
503 ycoord2mm, np++);
504 break;
505 } else if (mode == 7) { /* DXF, mapping pen no. or width to color */
506 switch (po->specials) {
507 case 1: /* pen number is color number */
508 mapped_pen_no = pen_no;
509 mapped_pen_size = pensize;
510 break;
511 case 2: /* pen width translates to color number */
512 mapped_pen_no =
513 (int) floor(pensize * 10.);
514 mapped_pen_size = pensize;
515 if (mapped_pen_no < 1)
516 mapped_pen_no = 1;
517 break;
518 case 3: /* as above, upper limit at 0.4 == 4 */
519 mapped_pen_no =
520 (int) floor(pensize * 10.);
521 if (mapped_pen_no < 1)
522 mapped_pen_no = 1;
523 if (mapped_pen_no > 1)
524 mapped_pen_no = 4;
525 mapped_pen_size = pensize;
526 break;
527 default: /* old behaviour - no mapping */
528 mapped_pen_no = 1;
529 mapped_pen_size = .1;
530 }
531 chars_out = fprintf(md, poly_start,
532 mapped_pen_no,
533 mapped_pen_size,
534 (pt1.x -
535 po->xmin) * xcoord2mm,
536 (pt1.y -
537 po->ymin) * ycoord2mm,
538 np++);
539 HPGL_Pt_from_tmpfile(&pt1);
540 chars_out += fprintf(md, poly_next,
541 (pt1.x -
542 po->xmin) *
543 xcoord2mm,
544 (pt1.y -
545 po->ymin) *
546 ycoord2mm, np++);
547 break;
548 } else if (mode == 9 && toolz == 0) { /* Tool still up! */
549 chars_out =
550 fprintf(md,
551 "; Tool Down\nG01 Z%g\nG01 X %g Y %g\n",
552 po->zengage,
553 (pt1.x - po->xmin) * xcoord2mm,
554 (pt1.y -
555 po->ymin) * ycoord2mm);
556 np++;
557 HPGL_Pt_from_tmpfile(&pt1);
558 chars_out += fprintf(md, poly_next,
559 (pt1.x -
560 po->xmin) *
561 xcoord2mm,
562 (pt1.y -
563 po->ymin) *
564 ycoord2mm, np++);
565 toolz = 1; /* Down */
566 break;
567 } else if (mode == 9 && toolz == 1) { /* Tool already down skip the lower */
568 HPGL_Pt_from_tmpfile(&pt1);
569 chars_out = fprintf(md, poly_next,
570 (pt1.x -
571 po->xmin) * xcoord2mm,
572 (pt1.y -
573 po->ymin) * ycoord2mm,
574 np++);
575
576 break;
577 }
578 #ifdef ATARI
579 else if (mode == 4) {
580 old_pt = pt1;
581 chars_out = fprintf(md, poly_start,
582 (old_pt.x -
583 po->xmin) * xcoord2mm,
584 (old_pt.y -
585 po->ymin) * ycoord2mm,
586 np++);
587 HPGL_Pt_from_tmpfile(&pt1);
588 chars_out += fprintf(md, poly_next,
589 (pt1.x -
590 old_pt.x) *
591 xcoord2mm,
592 (pt1.y -
593 old_pt.y) *
594 ycoord2mm, np++);
595 old_pt = pt1;
596 break;
597 }
598 #endif
599
600 HPGL_Pt_from_tmpfile(&pt1);
601 if (mode == 8)
602 pt1.y = po->ymax - pt1.y;
603
604 if (pensize == 0.)
605 break;
606
607
608 if (chars_out > max_chars_out)
609 /* prevent overlong lines */
610 {
611 fprintf(md, poly_last,
612 (pt1.x - po->xmin) * xcoord2mm,
613 (pt1.y - po->ymin) * ycoord2mm);
614 chars_out = fprintf(md, poly_start,
615 (pt1.x -
616 po->xmin) * xcoord2mm,
617 (pt1.y -
618 po->ymin) *
619 ycoord2mm);
620 } else
621 chars_out += fprintf(md, poly_next,
622 (pt1.x -
623 po->xmin) *
624 xcoord2mm,
625 (pt1.y -
626 po->ymin) *
627 ycoord2mm);
628 break;
629
630 case PLOT_AT:
631 HPGL_Pt_from_tmpfile(&pt1);
632 if (chars_out) { /* Finish up old polygon */
633 fprintf(md, poly_end);
634 chars_out = 0;
635 }
636 if (pensize == 0)
637 break;
638
639 #ifdef ATARI
640 if (mode == 4)
641 fprintf(csfile, draw_dot,
642 (pt1.x - po->xmin) * xcoord2mm,
643 (pt1.y - po->ymin) * ycoord2mm);
644
645 else
646 #endif
647 if (mode == 5 || mode == 8)
648 fprintf(md, draw_dot,
649 (pt1.x - po->xmin) * xcoord2mm,
650 (pt1.y - po->ymin) * ycoord2mm,
651 (pt1.x + 1.0 -
652 po->xmin) * xcoord2mm,
653 (pt1.y - po->ymin) * ycoord2mm);
654 else
655 fprintf(md, draw_dot,
656 (pt1.x - po->xmin) * xcoord2mm,
657 (pt1.y - po->ymin) * ycoord2mm);
658 break;
659
660 case DEF_PC:
661 if (load_pen_color_table(pg->td) < 0) {
662 PError("Unexpected end of temp. file");
663 err = ERROR;
664 goto MF_exit;
665 }
666 Eprintf("Warning, no PC support in vector modes!");
667 break;
668 case DEF_LA:
669 if (load_line_attr(pg->td) < 0) {
670 PError("Unexpected end of temp. file");
671 err = ERROR;
672 goto MF_exit;
673 }
674 break;
675 default:
676 Eprintf("Illegal cmd in temp. file!");
677 err = ERROR;
678 goto MF_exit;
679 }
680
681
682 if (chars_out) { /* Finish up old polygon */
683 fprintf(md, poly_end);
684 chars_out = 0;
685 }
686 #ifdef ATARI
687 if (mode == 4)
688 fprintf(csfile, exit_cmd);
689 else
690 #endif
691 fprintf(md, exit_cmd); /* Add file trailer */
692
693
694 MF_exit:
695
696 if (md != stdout && md != NULL)
697 fclose(md);
698 #ifdef ATARI
699 if (csfile != stdout && csfile != NULL)
700 fclose(csfile);
701 #endif
702
703 if (!pg->quiet)
704 Eprintf("\n");
705 return err;
706 }
707