Initial release of Maemo 5 port of gnuplot
[gnuplot] / term / tgif.trm
1 /* Hello, Emacs, this is -*-C-*- */
2 /* $Id: tgif.trm,v 1.41.2.2 2009/03/02 23:57:54 sfeam Exp $ */
3
4 /* GNUPLOT - tgif.trm */
5
6 /*[
7  * Copyright 1990 - 1993, 1998, 2004
8  *
9  * Permission to use, copy, and distribute this software and its
10  * documentation for any purpose with or without fee is hereby granted,
11  * provided that the above copyright notice appear in all copies and
12  * that both that copyright notice and this permission notice appear
13  * in supporting documentation.
14  *
15  * Permission to modify the software is granted, but not the right to
16  * distribute the complete modified source code.  Modifications are to
17  * be distributed as patches to the released version.  Permission to
18  * distribute binaries produced by compiling modified sources is granted,
19  * provided you
20  *   1. distribute the corresponding source modifications from the
21  *    released version in the form of a patch file along with the binaries,
22  *   2. add special version identification to distinguish your version
23  *    in addition to the base release version number,
24  *   3. provide your name and address as the primary contact for the
25  *    support of your modified version, and
26  *   4. retain our contact information in regard to use of the base
27  *    software.
28  * Permission to distribute the released version of the source code along
29  * with corresponding source modifications in the form of a patch file is
30  * granted with same provisions 2 through 4 for binary distributions.
31  *
32  * This software is provided "as is" without express or implied warranty
33  * to the extent permitted by applicable law.
34 ]*/
35
36 /*                                       */
37 /* This file is included by ../term.c.                                     */
38 /*                                                                         */
39 /* This terminal driver supports:                                          */
40 /*     TGIF                                                                */
41 /*                                                                         */
42 /* AUTHORS:                                                                */
43 /*  Werner Geppert and Andreas Kuhlewind                                   */
44 /*  March, 21st 1995                                                       */
45 /*                                                                         */
46 /* send your comments or suggestions to werner@mez.ruhr-uni-bochum.de      */
47 /*                                                                         */
48 /*                                                                         */
49 /* MODIFIED May, 11st 1997 by NOVÁK Levente (novakl@tigris.klte.hu):       */
50 /*                                                                         */
51 /*          - Modified the default linewidth for borders from 3 to 2       */
52 /*          - Modified the default size of markers' bounding box           */
53 /*            to allow nicer shapes                                        */
54 /*          - Slightly modified the markers and added several new ones,    */
55 /*            now we have 64 different pointtypes, the same as for the     */
56 /*            PostScript terminal                                          */
57 /*          - I left the %.1f format for pixel positions, but I think      */
58 /*            Tgif does only calculate with integer positions              */
59 /*                                                                         */
60 /* Modified  07 July 2000 by Ian MacPhedran                                */
61 /*          - added PM3D support                                           */
62 /*                                                                         */
63 /* Modified  04 February 2002 by Levente Novák                             */
64 /*          - break long "polygon()" directives into lines, as it made     */
65 /*            Tgif fail polygons had >8 sides                              */
66 /*            (e.g. when using "filledcurves")                             */
67 /*                                                                         */
68 /* Modified  29 November 2004  Shigeharu TAKENO <shige@iee.niit.ac.jp>     */
69 /*          - add linewidth and monochrome options                         */
70 /*            update option parsing to be order-independent                */
71 /*                                                                         */
72 /***************************************************************************/
73
74 /*}}}  */
75 /***************************************************************************/
76 #include "driver.h"
77
78 #ifdef TERM_REGISTER
79 register_term(tgif)
80 #endif
81
82 #define USE_LINEWIDTH
83 #define USE_MONO_MODE
84
85 #ifdef TERM_PROTO
86 TERM_PUBLIC void TGIF_options __PROTO((void));
87 TERM_PUBLIC void TGIF_init __PROTO((void));
88 TERM_PUBLIC void TGIF_reset __PROTO((void));
89 TERM_PUBLIC void TGIF_text __PROTO((void));
90 TERM_PUBLIC void TGIF_graphics __PROTO((void));
91 TERM_PUBLIC void TGIF_move __PROTO((unsigned int ux, unsigned int uy));
92 TERM_PUBLIC void TGIF_vector __PROTO((unsigned int ux, unsigned int uy));
93 TERM_PUBLIC void TGIF_linetype __PROTO((int linetype));
94 TERM_PUBLIC void TGIF_put_text __PROTO((unsigned int ux, unsigned int uy, const char *str));    /* ref point and text */
95 TERM_PUBLIC int TGIF_text_angle __PROTO((int ang));
96 TERM_PUBLIC int TGIF_justify_text __PROTO((enum JUSTIFY mode));
97 TERM_PUBLIC void TGIF_point __PROTO((unsigned int ux, unsigned int uy, int number));
98 TERM_PUBLIC void TGIF_arrow __PROTO((unsigned int sx, unsigned int sy, unsigned int ex, unsigned int ey, int head));
99 TERM_PUBLIC int TGIF_set_font __PROTO((const char *font));
100 TERM_PUBLIC void TGIF_set_pointsize __PROTO((double size));
101 #ifdef USE_LINEWIDTH
102 TERM_PUBLIC void TGIF_set_linewidth __PROTO((double size));
103 #endif
104 TERM_PUBLIC int TGIF_make_palette (t_sm_palette *);
105 /* TERM_PUBLIC void TGIF_previous_palette (void); */
106 TERM_PUBLIC void TGIF_set_color (t_colorspec *);
107 TERM_PUBLIC void TGIF_filled_polygon (int, gpiPoint *);
108 /*}}}  */
109 /* default length for static strings */
110 #define TGIF_STRLEN_MAX 255
111
112 /* standard x/y plot size in portrait mode */
113 #define TGIF_XMAX 950
114 #define TGIF_YMAX 634
115
116 /* total available plotting area */
117 #define TGIF_XTOT 950
118 #define TGIF_YTOT 1400
119
120 /* Offset  */
121 #define TGIF_XOFF 50
122 #define TGIF_YOFF 50
123
124 #define TGIF_XSHIFT 1030        /* 80 points skip */
125 #define TGIF_YSHIFT 714
126
127 #define TGIF_VCHAR 18           /* default is 18 pt       */
128 #define TGIF_HCHAR (18*6/10)
129
130 #define TGIF_VTIC (TGIF_YMAX/80)
131 #define TGIF_HTIC (TGIF_YMAX/80)
132
133 static int TGIF_palette_set = FALSE;    /* PM3D Palette Set ? */
134 static int TGIF_palette_size = 128;     /* Number of colours in palette */
135 /* unused (joze) */
136 #if 0
137 static int TGIF_palette_offst = 32;     /* Offset from zero for user colours */
138 #endif
139 static char TGIF_colours[128][8];       /* Colours */
140
141
142 #define TGIF_MAXPOLY 100
143 /*}}}  */
144 #define GOT_TGIF_PROTO
145 #endif
146
147 #ifndef TERM_PROTO_ONLY
148
149 #ifdef TERM_BODY
150 /* tgif driver by Werner Geppert, werner@mez.ruhr-uni-bochum.de */
151 /***************************************************************************/
152 /* Variables:                                                              */
153 static unsigned int uLastTgifX, uLastTgifY;     /* last Coordinate         */
154
155 static unsigned int uActNr;     /* current elementnumber                   */
156 static unsigned int uActPage;   /* current pagenumber                      */
157 static unsigned int uActResolution=100; /* resolution in percent           */
158 static unsigned int uActZoom;   /* zoom factor                             */
159 static unsigned int uActAngle;  /* current textangle                       */
160 static unsigned int uActThick;  /* actual linethickness                    */
161 static unsigned int uActPointSize;      /* point size                      */
162 static unsigned int uActStyle;  /* actual linestyle                        */
163 static unsigned int uActJust;   /* actual textjustification                */
164 static unsigned int uXshift;    /* actual shift x                          */
165 static unsigned int uYshift;    /* actual shift y                          */
166 static unsigned int uTgifPlotCount;     /* counts number of plots          */
167 static unsigned int uTgifPlotRow=1, uTgifPlotCol=1;             /* actual plot row and col   */
168 static unsigned int uTgif_win_horiz=1, /* number of plots in x and  */
169     uTgif_win_verti=1;  /*      y direction [x,y]         */
170
171
172 #ifdef USE_LINEWIDTH
173 static double uActThick_factor=1.0;
174 static double uActThick_default=1.0;
175 #endif
176 #ifdef USE_MONO_MODE
177 static TBOOLEAN TgifUseColor = TRUE;
178 #endif
179
180 static char sActColor[TGIF_STRLEN_MAX];         /* current color         */
181 static unsigned int uDefaultFontSize = 18;      /* default font size         */
182 static unsigned int uActFontSize = 18;  /* current font size         */
183 static char sDefaultFont[TGIF_STRLEN_MAX] = "Helvetica";        /* default font          */
184 static char sActFont[TGIF_STRLEN_MAX] = "Helvetica";    /* current font          */
185 /* static char          sActPointString[TGIF_STRLEN_MAX]; HBB: unused */
186
187 static TBOOLEAN TgifSolid = FALSE;
188 static TBOOLEAN TgifPortrait = TRUE;
189
190 static unsigned int uTgifPlotsPerPage = 1;
191
192 /*
193  * 10 different pointtypes need 10 different linetypes
194  */
195
196 /* NL: Modified first value to 2 from 3 */
197 static unsigned int uLineThick[] = { 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 };
198 static unsigned int uLineStyle[] = { 0, 5, 0, 1, 2, 3, 4, 5, 6, 7, 8, 0 };
199 static const char *psColors[] = {
200     "black", "black",           /* border and x/y-zero-axes       */
201     "red", "green", "blue", "magenta", "cyan", "yellow",
202     "DarkSeaGreen", "HotPink", "black", "coral"
203 };
204
205 #if 0                           /* HBB: unused */
206 static const char *psFonts[] = {
207     "Times-Roman", "Courier", "Helvetica", "NewCenturySchlbk-Roman",
208     "Symbol", NULL
209 };
210
211 static unsigned int psFontSizes[] = {
212     8, 10, 11, 12, 14, 17, 18, 20, 24, 25, 34, 40, 45, 50
213 };
214 #endif
215
216 static int iTgifPolyCount;
217 static unsigned int uBuffX[TGIF_MAXPOLY], uBuffY[TGIF_MAXPOLY];
218
219 enum eState {
220     NEWPOLY = 100, INPOLY
221 };
222 static enum eState eTgifState = NEWPOLY;
223
224 static void TGIF_flush_poly __PROTO((void));
225
226
227
228 /*}}}  */
229 /***************************************************************************/
230 static void
231 TGIF_flush_poly()
232 {
233     int i;
234
235
236     if (eTgifState == INPOLY) {
237         fprintf(gpoutfile, "poly('%s',%d,[\n\t", sActColor, iTgifPolyCount);
238
239         for (i = 0; i < iTgifPolyCount - 1; i++) {
240             fprintf(gpoutfile, "%u,%u,", uBuffX[i], uBuffY[i]);
241             if ((i + 1) % 8 == 0)
242                 fputs("\n\t", gpoutfile);
243         }
244
245         fprintf(gpoutfile, "%u,%u],0,%u,1,%u,0,0,%u,0,8,3,0,[\n]).\n",
246                 uBuffX[iTgifPolyCount - 1], uBuffY[iTgifPolyCount - 1],
247                 uActThick, uActNr, uActStyle);
248
249         uActNr++;
250
251         eTgifState = NEWPOLY;
252         iTgifPolyCount = 0;
253         if (gpoutfile != (FILE *) NULL)
254             fflush(gpoutfile);
255     }
256 }                               /* TGIF_flush_poly */
257 /*}}}  */
258 /***************************************************************************/
259
260 enum TGIF_id {
261     TGIF_MONOCHROME, TGIF_COLOR,
262     TGIF_LINEWIDTH,
263     TGIF_PORTRAIT, TGIF_LANDSCAPE,
264     TGIF_GRAPHS,
265     TGIF_SOLID, TGIF_DASHED,
266     TGIF_FONT,
267     TGIF_OTHER,
268     TGIF_DEFAULT
269 };
270
271 static struct gen_table TGIF_opts[] =
272 {
273     {"mo$nochrome", TGIF_MONOCHROME},
274     {"c$olor", TGIF_COLOR},
275     {"c$olour", TGIF_COLOR},
276     {"linew$idth", TGIF_LINEWIDTH},
277     {"lw", TGIF_LINEWIDTH},
278     {"p$ortrait", TGIF_PORTRAIT},
279     {"l$andscape", TGIF_LANDSCAPE},
280     {"[", TGIF_GRAPHS},
281     {"s$olid", TGIF_SOLID},
282     {"d$ashed", TGIF_DASHED},
283     {"font", TGIF_FONT},
284     {"default", TGIF_DEFAULT},
285     {NULL, TGIF_OTHER}
286 };
287
288 TERM_PUBLIC void
289 TGIF_options()
290 {
291
292     struct value a, b;
293     double dscaleH, dscaleV;
294     int option;
295
296     while (!END_OF_COMMAND) {
297         option = lookup_table(&TGIF_opts[0],c_token);
298         switch(option) {
299         case TGIF_DEFAULT:
300             strcpy(sActFont, "Helvetica");
301             strcpy(sDefaultFont, "Helvetica");
302             uActFontSize = 18;
303             uDefaultFontSize = 18;
304             term->v_char = (unsigned int) (uActFontSize);
305             term->h_char = (unsigned int) (uActFontSize * 6 / 10);
306
307             TgifPortrait = TRUE;
308 #ifdef USE_MONO_MODE
309             TgifUseColor = TRUE;
310 #endif
311             TgifSolid = FALSE;
312             uTgifPlotsPerPage = 1;
313             uTgifPlotRow = 1;
314             uTgifPlotCol = 1;
315             uTgif_win_horiz = 1;
316             uTgif_win_verti = 1;
317             uActResolution = 100;
318 #ifdef USE_LINEWIDTH
319             uActThick_factor = 1.0;
320             uActThick_default = 1.0;
321 #endif
322             c_token++;
323             break;
324 #ifdef USE_MONO_MODE
325         case TGIF_MONOCHROME:
326             TgifUseColor = FALSE;
327             c_token++;
328             break;
329         case TGIF_COLOR:
330             TgifUseColor = TRUE;
331             c_token++;
332             break;
333 #endif
334 #ifdef USE_LINEWIDTH
335         case TGIF_LINEWIDTH:
336             c_token++;
337             if (END_OF_COMMAND) {
338                 int_error(c_token, "linewidth: width is not specified.");
339             } else {
340                 if((uActThick_default = real(const_express(&a)))<=0.0){
341                     int_error(c_token-1,"linewidth: out of range");
342                     uActThick_default = 1.0;
343                 }
344             }
345             break;
346 #endif
347         case TGIF_PORTRAIT:
348             TgifPortrait = TRUE;
349             c_token++;
350             break;
351         case TGIF_LANDSCAPE:
352             TgifPortrait = FALSE;
353             /* uActResolution = 140;
354             */
355             c_token++;
356             break;
357         case TGIF_GRAPHS:
358             c_token++;
359             if (END_OF_COMMAND) {
360                 int_error(c_token, "no. windows: [horizontal,vertical] expected");
361             } else if (!equals(c_token, ",")) {
362                 uTgif_win_horiz = (int) real(const_express(&a));
363             }
364             if (!equals(c_token, ","))
365                 int_error(c_token, "',' expected");
366             c_token++;
367             if (!equals(c_token, "]")) {
368                 uTgif_win_verti = (int) real(const_express(&a));
369             }
370             if (!equals(c_token, "]"))
371                 int_error(c_token, "expecting ']'");
372             c_token++;
373             uTgifPlotsPerPage = uTgif_win_verti * uTgif_win_horiz;
374             break;
375         case TGIF_SOLID:
376             TgifSolid = TRUE;
377             c_token++;
378             break;
379         case TGIF_DASHED:
380             TgifSolid = FALSE;
381             c_token++;
382             break;
383         case TGIF_FONT:
384             c_token++;
385             /* Fall through */
386         case TGIF_OTHER:
387         default:
388         {
389             char *s;
390             if ((s = try_to_get_string())) {
391                 double fontsize;
392                 char *comma = strrchr(s,',');
393                 if (comma && (1 == sscanf(comma+1,"%lf",&fontsize))) {
394                     *comma = '\0';
395                     uActFontSize =  (int)(fontsize+0.5);
396                 }
397                 strncpy(sActFont, s, sizeof(sActFont));
398                 strcpy(sDefaultFont, sActFont);
399                 free(s);
400             } else if (option == TGIF_FONT) {
401                 int_error(c_token,"Expecting font name ");
402             } else {
403                 /* We have font size specified */
404                 uActFontSize = (unsigned int) real(const_express(&b));
405                 uDefaultFontSize = uActFontSize;
406                 term->v_char = (unsigned int) (uActFontSize);
407                 term->h_char = (unsigned int) (uActFontSize * 6 / 10);
408             }
409             break;
410         }
411         }
412     }
413     if (TgifPortrait) {
414         dscaleH = (double) 100.0 *(TGIF_XTOT) / (xsize * (TGIF_XMAX + (uTgif_win_horiz - 1) * TGIF_XSHIFT));
415         dscaleV = (double) 100.0 *(TGIF_YTOT) / (ysize * (TGIF_YMAX + (uTgif_win_verti - 1) * TGIF_YSHIFT));
416         uActResolution = (int) GPMIN(dscaleH, dscaleV);
417         switch (uTgif_win_verti) {
418         case 1:
419             uActZoom = 0;
420             break;
421
422         case 2:
423             uActZoom = 1;
424             break;
425         default:
426             uActZoom = 2;
427             break;
428
429         }
430     } else {
431         dscaleH = (double) 100.0 *(TGIF_YTOT) / (xsize * (TGIF_XMAX + (uTgif_win_horiz - 1) * TGIF_XSHIFT));
432         dscaleV = (double) 100.0 *(TGIF_XTOT) / (ysize * (TGIF_YMAX + (uTgif_win_verti - 1) * TGIF_YSHIFT));
433         uActResolution = (unsigned int) GPMIN(dscaleH, dscaleV);
434
435         switch (uTgif_win_verti) {
436         case 1:
437             uActZoom = 0;
438             break;
439
440         case 2:
441             uActZoom = 1;
442             break;
443         default:
444             uActZoom = 2;
445             break;
446
447         }
448     }
449
450     sprintf(&(term_options[strlen(term_options)]), "%s [%u,%u]",
451             TgifPortrait ? "portrait" : "landscape",
452             uTgif_win_horiz, uTgif_win_verti);
453
454 #ifdef USE_MONO_MODE
455     strcat(term_options, TgifUseColor ? " color" : " monochrome");
456 #endif
457 #ifdef USE_LINEWIDTH
458     sprintf(&(term_options[strlen(term_options)]), " linewidth %f", uActThick_default);
459 #endif
460     sprintf(&(term_options[strlen(term_options)]), " %s \"%s\" %u",
461             TgifSolid ? "solid" : "dashed",
462             sActFont, uActFontSize);
463 }
464 /*}}}  */
465 /***************************************************************************/
466 TERM_PUBLIC void
467 TGIF_init()
468 {
469
470     if (multiplot) {
471         /* uActResolution= TgifPortrait ? (unsigned int)100 : (unsigned int)145 ; */
472         uActResolution = (unsigned int) 100;
473
474         if (uTgifPlotsPerPage > 1) {
475             fputs("warning: using standard multiplot\n", stderr);
476             uTgifPlotsPerPage = 1;
477         }
478         uActZoom = 1;
479     }
480     fprintf(gpoutfile, "\
481 %%TGIF 2.15-p7\n\
482 state(%d,30,%u,0,0,%u,16,1,9,1,1,0,0,0,0,1,0,'%s',0,%u,0,0,1,10,0,0,1,1,0,16,0,0,1,1,1).\n\
483 %%\n\
484 %% @(#)Creator: gnuplot %s patchlevel %s\n\
485 %% %%W%%\n\
486 %%\n\
487 page(1,\"\").\n",
488             TgifPortrait ? 0 : 1, uActResolution, uActZoom, sActFont, uActFontSize,
489             gnuplot_version, gnuplot_patchlevel);
490     eTgifState = NEWPOLY;
491     iTgifPolyCount = 0;
492     uTgifPlotCount = 0;
493     uActPage = 1;
494     TGIF_palette_set = FALSE;    /* PM3D Palette Set ? */
495 }                               /* TGIF_init */
496 /*}}}  */
497
498 /***************************************************************************/
499 TERM_PUBLIC void
500 TGIF_graphics()
501 {
502
503     TGIF_flush_poly();
504
505     if (multiplot) {
506
507         term->xmax = (TgifPortrait) ? TGIF_XTOT : TGIF_YTOT;
508         term->ymax = (TgifPortrait) ? TGIF_YTOT : TGIF_XTOT;
509         uLastTgifX = (TgifPortrait) ? TGIF_XOFF : TGIF_YOFF;
510         uLastTgifY = (TgifPortrait) ? TGIF_YTOT + TGIF_YOFF : TGIF_XTOT + TGIF_XOFF;
511
512         uYshift = uLastTgifY;
513         uXshift = uLastTgifX;
514
515     } else {
516         if (uTgifPlotCount < uTgifPlotsPerPage)
517             uTgifPlotCount++;
518         else {
519             fputs("error: number of plots > plots per page\n", stderr);
520             return;
521         }
522
523         uXshift = (unsigned int) TGIF_XOFF *100 / uActResolution + (xsize * (uTgifPlotCol - 1) * TGIF_XSHIFT);
524         uYshift = (unsigned int) TGIF_YOFF *100 / uActResolution + (ysize * (TGIF_YMAX +
525                                                                              (uTgifPlotRow - 1) * TGIF_YSHIFT));
526
527         if (uTgifPlotCount % uTgif_win_horiz == 0) {
528             uTgifPlotCol = 1;
529             uTgifPlotRow++;
530         } else {
531             uTgifPlotCol++;
532         }
533
534         uLastTgifX = uXshift;
535         uLastTgifY = uYshift;
536
537     }
538
539
540
541
542
543 /* default settings for each plot */
544     iTgifPolyCount = 0;
545     uActNr = 0;
546     uActAngle = 0;
547     uActThick = 1;
548     uActStyle = 0;
549     uActJust = LEFT;
550 #ifndef USE_MONO_MODE
551     strcpy(sActColor, psColors[0]);
552 #else
553     if(TgifUseColor == FALSE) strcpy(sActColor,"black");
554     else strcpy(sActColor, psColors[0]);
555 #endif
556
557 }                               /* TGIF_graphics */
558 /*}}}  */
559 /***************************************************************************/
560 TERM_PUBLIC void
561 TGIF_text()
562 {
563     TGIF_flush_poly();
564
565
566 }                               /* TGIF_text */
567
568 /*}}}  */
569 /***************************************************************************/
570 TERM_PUBLIC void
571 TGIF_reset()
572 {
573     TGIF_flush_poly();
574     iTgifPolyCount = 0;
575     uTgifPlotCount = 0;
576     uTgifPlotRow = 1;
577     uTgifPlotCol = 1;
578
579
580     if (gpoutfile != (FILE *) NULL)
581         fflush(gpoutfile);
582
583 }                               /* TGIF_reset */
584 /*}}}  */
585 /***************************************************************************/
586 TERM_PUBLIC void
587 TGIF_linetype(int linetype)
588 {
589     unsigned int ult;
590
591
592     TGIF_flush_poly();
593
594
595     if (linetype >= 0)
596         ult = 2 + linetype % 10;
597     else if (linetype < -2)
598         ult = 0;
599     else
600         ult = linetype + 2;
601
602 #ifndef USE_MONO_MODE
603     strcpy(sActColor, psColors[ult]);
604 #else
605     if(TgifUseColor == FALSE) strcpy(sActColor,"black");
606     else strcpy(sActColor, psColors[ult]);
607 #endif
608 #ifndef USE_LINEWIDTH
609     uActThick = uLineThick[ult];
610 #else
611     uActThick = uActThick_factor * uActThick_default * uLineThick[ult]+0.5;
612 #endif
613     if (!TgifSolid)
614         uActStyle = uLineStyle[ult];
615     else {
616         if (ult == 1)           /* grid */
617             uActStyle = uLineStyle[ult];
618         else
619             uActStyle = uLineStyle[2];
620
621     }
622
623 }                               /* TGIF_linetype */
624 /*}}}  */
625 /***************************************************************************/
626 TERM_PUBLIC void
627 TGIF_move(unsigned int ux, unsigned int uy)
628 {
629
630     uLastTgifX = ux + uXshift;
631     uLastTgifY = uYshift - uy;
632
633     if (eTgifState == INPOLY)
634         TGIF_flush_poly();
635
636
637
638 }                               /* TGIF_move */
639 /*}}}  */
640 /***************************************************************************/
641 TERM_PUBLIC void
642 TGIF_vector(unsigned int ux, unsigned int uy)
643 {
644
645     ux = ux + uXshift;
646     uy = uYshift - uy;
647
648
649
650     if (eTgifState == NEWPOLY) {
651         uBuffX[0] = uLastTgifX;
652         uBuffY[0] = uLastTgifY;
653         iTgifPolyCount = 1;
654         eTgifState = INPOLY;
655     }
656     uBuffX[iTgifPolyCount] = ux;
657     uBuffY[iTgifPolyCount] = uy;
658     uLastTgifX = ux;
659     uLastTgifY = uy;
660     iTgifPolyCount++;
661     eTgifState = INPOLY;
662
663     if (iTgifPolyCount == TGIF_MAXPOLY) {
664         TGIF_flush_poly();
665
666     }
667 }                               /* TGIF_vector */
668 /*}}}  */
669 /***************************************************************************/
670 TERM_PUBLIC void
671 TGIF_arrow(
672     unsigned int sx, unsigned int sy,
673     unsigned int ex, unsigned int ey,
674     int head)
675 {
676
677     TGIF_flush_poly();
678
679     sx = sx + uXshift;
680     ex = ex + uXshift;
681     sy = uYshift - sy;
682     ey = uYshift - ey;
683
684
685     if (head) {
686         fprintf(gpoutfile, "\
687 poly('%s',%d,[\n\
688 \t%u,%u,%u,%u],1,%u,1,%u,0,0,%u,0,8,3,0,[\n]).\n",
689                 sActColor, 2, sx, sy, ex, ey, uActThick, uActNr, uActStyle);
690     } else {
691         fprintf(gpoutfile, "\
692 poly('%s',%d,[\n\
693 \t%u,%u,%u,%u],1,%u,1,%u,0,0,%u,0,8,3,0,[\n]).\n",
694                 sActColor, 2, sx, sy, ex, ey, uActThick, uActNr, uActStyle);
695     }
696
697     uActNr++;
698
699
700
701     uLastTgifX = ex;
702     uLastTgifY = ey;
703
704 }                               /* TGIF_arrow */
705 /*}}}  */
706 /***************************************************************************/
707 TERM_PUBLIC void
708 TGIF_put_text(unsigned int ux, unsigned int uy, const char *str)
709 {
710
711     unsigned int x, y;
712     struct termentry *t = term;
713
714     TGIF_flush_poly();
715
716     x = ux + uXshift;
717     y = uYshift - uy - t->v_char / 2;
718
719     if (strlen(str) == 0)
720         return;
721
722     fprintf(gpoutfile, "\
723 text('%s',%u,%u,'%s',0,%u,1,%u,%u,1,55,119,%u,0,15,4,0,0,0,0,[\n\t\"%s\"]).\n",
724             sActColor, x, y, sActFont, uActFontSize,
725             (uActAngle ? CENTRE : uActJust), uActAngle,
726             uActNr, str);
727
728     uActNr += 2;
729
730 #if 0
731     /* reset font size and font, they might have been changed */
732     uActFontSize = uDefaultFontSize;
733     strcpy(sActFont, sDefaultFont);
734 #endif
735
736 }                               /* TGIF_put_text */
737 /*}}}  */
738 /***************************************************************************/
739 TERM_PUBLIC int
740 TGIF_text_angle(int ang)
741 {
742     switch (ang) {
743         case   90:      uActAngle = 3; break;
744         case  180:
745         case -180:      uActAngle = 2; break;
746         case  -90:
747         case  270:      uActAngle = 1; break;
748         default:        uActAngle = 0; break;
749     }
750     return (TRUE);
751 }                               /* TGIF_text_angle */
752
753 /*}}}  */
754 /***************************************************************************/
755 TERM_PUBLIC int
756 TGIF_justify_text(enum JUSTIFY mode)
757 {
758     uActJust = mode;
759     return (TRUE);
760 }                               /* TGIF_justify_text */
761
762 /*}}}  */
763 /***************************************************************************/
764 TERM_PUBLIC void
765 TGIF_point(unsigned int ux, unsigned int uy, int number)
766 {
767     double p;           /* all pointtypes fit in a (x +/-p)x(y +/-p) box */
768
769     double x, y;
770
771
772
773     x = (double) (ux + uXshift);
774     y = (double) (uYshift - uy);
775
776     p = pointsize * 8.0;        /* NL: Increased the bounding box (p value) from 4.0 to 8.0 */
777     if (p == (double) 0.0)
778         p = 0.1;
779
780     TGIF_flush_poly();
781
782     if (number != -1)
783         number = number % 63;
784     switch (number) {
785     case -1:
786         /* HBB: corrected format string, shuts up gcc -Wall */
787         fprintf(gpoutfile, "\
788 poly('%s',2,[\n\t%.1f,%.1f,%.1f,%.1f],0,1,1,%u,0,0,0,0,8,3,0,[\n]).\n",
789                 sActColor, x, y, x + 1, y + 1, uActNr++);
790         break;
791     case 0:
792         /* cross */
793         /* taking thickness 2 for cross & plus & star */
794         fprintf(gpoutfile, "\
795 group([\n\
796 poly('%s',2,[\n\t%.1f,%.1f,%.1f,%.1f],0,2,1,%u,0,0,0,0,8,3,0,[\n]).\n\
797 poly('%s',2,[\n\t%.1f,%.1f,%.1f,%.1f],0,2,1,%u,0,0,0,0,8,3,0,[\n]).\n",
798                 sActColor, x - p, y - p, x + p, y + p, uActNr+1,
799                 sActColor, x - p, y + p, x + p, y - p, uActNr+2);
800         uActNr += 4;
801         fprintf(gpoutfile, "],\n%u,0,[\n]).\n", uActNr++);
802         break;
803         /*}}}  */
804     case 1:
805         /* plus */
806         /* taking thickness 2 for cross & plus & star */
807         fprintf(gpoutfile, "\
808 group([\n\
809 poly('%s',2,[\n\t%.1f,%.1f,%.1f,%.1f],0,2,1,%u,0,0,0,0,8,3,0,[\n]),\n\
810 poly('%s',2,[\n\t%.1f,%.1f,%.1f,%.1f],0,2,1,%u,0,0,0,0,8,3,0,[\n])\n",
811                 sActColor, x, y - p - 1, x, y + p + 1, uActNr+1,
812                 sActColor, x - p - 1, y, x + p + 1, y, uActNr+2);
813         uActNr += 4;
814         fprintf(gpoutfile, "],\n%u,0,[\n]).\n", uActNr++);
815         break;
816         /*}}}  */
817     case 2:
818         /* star */
819         /* taking thickness 2 for cross & plus & star */
820         fputs("group([\n", gpoutfile);
821         fprintf(gpoutfile, "\
822 poly('%s',2,[\n\t%.1f,%.1f,%.1f,%.1f],0,2,1,%u,0,0,0,0,8,3,0,[\n]),\n",
823                 sActColor, x, y - p - 1, x, y + p + 1, uActNr++);
824         fprintf(gpoutfile, "\
825 poly('%s',2,[\n\t%.1f,%.1f,%.1f,%.1f],0,2,1,%u,0,0,0,0,8,3,0,[\n])\n",
826                 sActColor, x - p - 1, y, x + p + 1, y, uActNr++);
827         fprintf(gpoutfile, "\
828 poly('%s',2,[\n\t%.1f,%.1f,%.1f,%.1f],0,2,1,%u,0,0,0,0,8,3,0,[\n]).\n",
829                 sActColor, x - p, y - p, x + p, y + p, uActNr++);
830         fprintf(gpoutfile, "\
831 poly('%s',2,[\n\t%.1f,%.1f,%.1f,%.1f],0,2,1,%u,0,0,0,0,8,3,0,[\n]).\n",
832                 sActColor, x - p, y + p, x + p, y - p, uActNr++);
833         uActNr += 4;
834         fprintf(gpoutfile, "],\n%u,0,[\n]).\n", uActNr++);
835         break;
836         /*}}}  */
837     case 3:
838         /* box */
839         fprintf(gpoutfile, "\
840 box('%s',%.1f,%.1f,%.1f,%.1f,2,1,1,%u,0,0,0,[\n]).\n",
841                 sActColor, x - p, y - p, x + p, y + p, uActNr);
842         uActNr++;
843         break;
844         /*}}}  */
845     case 4:
846         /* filled box */
847         fprintf(gpoutfile, "\
848 box('%s',%.1f,%.1f,%.1f,%.1f,1,1,1,%u,0,0,0,[\n]).\n",
849                 sActColor, x - p, y - p, x + p, y + p, uActNr);
850         uActNr++;
851         break;
852         /*}}}  */
853     case 5:
854         /* circle */
855         fprintf(gpoutfile, "\
856 oval('%s',%.1f,%.1f,%.1f,%.1f,2,1,1,%u,0,0,0,[\n]).\n",
857                 sActColor, x - p, y - p, x + p, y + p, uActNr);
858         uActNr++;
859         break;
860         /*}}}  */
861     case 6:
862         /* filled circle */
863         fprintf(gpoutfile, "\
864 oval('%s',%.1f,%.1f,%.1f,%.1f,1,1,1,%u,0,0,0,[\n]).\n",
865                 sActColor, x - p, y - p, x + p, y + p, uActNr);
866         uActNr++;
867         break;
868         /*}}}  */
869     case 7:
870         /* triangle up */
871         fprintf(gpoutfile, "\
872 polygon('%s',4,[\n\
873 %.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f],0,1,1,0,%u,0,0,0,0,0,[\n]).\n",
874                 sActColor, x, y - p, x + p, y + 0.75 * p, x - p, y + 0.75 * p,
875                 x, y - p, uActNr);
876         uActNr++;
877         break;
878         /*}}}  */
879     case 8:
880         /* filled triangle up */
881         fprintf(gpoutfile, "\
882 polygon('%s',4,[\n\
883 %.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f],1,1,1,0,%u,0,0,0,0,0,[\n]).\n",
884                 sActColor, x, y - p, x + p, y + 0.75 * p, x - p, y + 0.75 * p,
885                 x, y - p, uActNr);
886         uActNr++;
887         break;
888         /*}}}  */
889     case 9:
890         /* triangle down */
891         fprintf(gpoutfile, "\
892 polygon('%s',4,[\n\
893 %.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f],0,1,1,0,%u,0,0,0,0,0,[\n]).\n",
894                 sActColor, x, y + p, x - p, y - 0.75 * p, x + p, y - 0.75 * p,
895                 x, y + p, uActNr);
896         uActNr++;
897         break;
898         /*}}}  */
899     case 10:
900         /* filled triangle down */
901         fprintf(gpoutfile, "\
902 polygon('%s',4,[\n\
903 %.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f],1,1,1,0,%u,0,0,0,0,0,[\n]).\n",
904                 sActColor, x, y + p, x - p, y - 0.75 * p, x + p, y - 0.75 * p,
905                 x, y + p, uActNr);
906         uActNr++;
907         break;
908         /*}}}  */
909     case 11:
910         /* diamond */
911         fprintf(gpoutfile, "\
912 polygon('%s',5,[\n\
913 %.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f],0,1,1,0,%u,0,0,0,0,0,[\n\
914 ]).\n",
915                 sActColor, x, y + p, x + p, y, x, y - p, x - p, y, x, y + p,
916                 uActNr);
917         uActNr++;
918         break;
919         /*}}}  */
920     case 12:
921         /* filled diamond */
922         fprintf(gpoutfile, "\
923 polygon('%s',5,[\n\
924 %.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f],1,1,1,0,%u,0,0,0,0,0,[\n\
925 ]).\n",
926                 sActColor, x, y + p, x + p, y, x, y - p, x - p, y, x, y + p,
927                 uActNr);
928         uActNr++;
929         break;
930         /*}}}  */
931     case 13:
932         /* pentagon */
933         fprintf(gpoutfile, "\
934 polygon('%s',6,[\n\
935 %.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f],0,1,1,0,%u,0,0,0,0,0,[\n]).\n",
936                 sActColor, x, y - p, x + p, y - p / 4, x + 0.625 * p, y + p,
937                 x - 0.625 * p, y + p, x - p, y - p / 4, x, y - p, uActNr);
938         uActNr++;
939         break;
940         /*}}}  */
941     case 14:
942         /* filled pentagon */
943         fprintf(gpoutfile, "\
944 polygon('%s',6,[\n\
945 %.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f],1,1,1,0,%u,0,0,0,0,0,[\n]).\n",
946                 sActColor, x, y - p, x + p, y - p / 4, x + 0.625 * p, y + p,
947                 x - 0.625 * p, y + p, x - p, y - p / 4, x, y - p, uActNr);
948         uActNr++;
949         break;
950         /*}}}  */
951     case 15:
952         /* circle1 */
953         fputs("group([\n", gpoutfile);
954         fprintf(gpoutfile, "\
955 oval('%s',%.1f,%.1f,%.1f,%.1f,2,1,1,%u,0,0,0,[\n\
956 ]).\n",
957                 sActColor, x - p, y - p, x + p, y + p, uActNr++);
958         fprintf(gpoutfile, "\
959 arc('%s',1,1,1,0,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,0,%.1f,%.1f,4480,2560,%u,0,0,8,3,0,[\n]).\n",
960                 sActColor, x - p, y - p, x, y, x + p * 0.342, y - p * 0.94,
961                 x - p * 0.342, y - p * 0.94, 2 * p, 2 * p, uActNr++);
962         uActNr += 2;
963         fprintf(gpoutfile, "],\n%u,0,[\n]).\n", uActNr++);
964         break;
965         /*}}}  */
966     case 16:
967         /* circle2 */
968         fputs("group([\n", gpoutfile);
969         fprintf(gpoutfile, "\
970 oval('%s',%.1f,%.1f,%.1f,%.1f,2,1,1,%u,0,0,0,[\n]).\n",
971                 sActColor, x - p, y - p, x + p, y + p, uActNr++);
972         fprintf(gpoutfile, "\
973 arc('%s',1,1,1,0,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,0,%.1f,%.1f,0,5760,%u,0,0,8,3,0,[\n]).\n",
974                 sActColor, x - p, y - p, x, y, x + p, y, x, y - p, 2 * p,
975                 2 * p, uActNr++);
976         uActNr += 2;
977         fprintf(gpoutfile, "],\n%u,0,[\n]).\n", uActNr++);
978         break;
979         /*}}}  */
980     case 17:
981         /* circle3 */
982         fputs("group([\n", gpoutfile);
983         fprintf(gpoutfile, "\
984 oval('%s',%.1f,%.1f,%.1f,%.1f,2,1,1,%u,0,0,0,[\n]).\n",
985                 sActColor, x - p, y - p, x + p, y + p, uActNr++);
986         fprintf(gpoutfile, "\
987 arc('%s',1,1,1,0,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,0,%.1f,%.1f,5760,5760,%u,0,0,8,3,0,[\n]).\n",
988                 sActColor, x - p, y - p, x, y, x, y - p, x - p, y, 2 * p,
989                 2 * p, uActNr++);
990         uActNr += 2;
991         fprintf(gpoutfile, "],\n%u,0,[\n]).\n", uActNr++);
992         break;
993         /*}}}  */
994     case 18:
995         /* circle4 */
996         fputs("group([\n", gpoutfile);
997         fprintf(gpoutfile, "\
998 oval('%s',%.1f,%.1f,%.1f,%.1f,2,1,1,%u,0,0,0,[\n]).\n",
999                 sActColor, x - p, y - p, x + p, y + p, uActNr++);
1000         fprintf(gpoutfile, "\
1001 arc('%s',1,1,1,0,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,0,%.1f,%.1f,0,11520,%u,0,0,8,3,0,[\n]).\n",
1002                 sActColor, x - p, y - p, x, y, x + p, y, x - p, y, 2 * p,
1003                 2 * p, uActNr++);
1004         uActNr += 2;
1005         fprintf(gpoutfile, "],\n%u,0,[\n]).\n", uActNr++);
1006         break;
1007         /*}}}  */
1008     case 19:
1009         /* circle5 */
1010         fputs("group([\n", gpoutfile);
1011         fprintf(gpoutfile, "\
1012 oval('%s',%.1f,%.1f,%.1f,%.1f,2,1,1,%u,0,0,0,[\n]).\n",
1013                 sActColor, x - p, y - p, x + p, y + p, uActNr++);
1014         fprintf(gpoutfile, "\
1015 arc('%s',1,1,1,0,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,0,%.1f,%.1f,11520,5760,%u,0,0,8,3,0,[\n]).\n",
1016                 sActColor, x - p, y - p, x, y, x - p, y, x, y + p, 2 * p,
1017                 2 * p, uActNr++);
1018         uActNr += 2;
1019         fprintf(gpoutfile, "],\n%u,0,[\n]).\n", uActNr++);
1020         break;
1021         /*}}}  */
1022     case 20:
1023         /* circle6 */
1024         fputs("group([\n", gpoutfile);
1025         fprintf(gpoutfile, "\
1026 oval('%s',%.1f,%.1f,%.1f,%.1f,2,1,1,%u,0,0,0,[\n]).\n",
1027                 sActColor, x - p, y - p, x + p, y + p, uActNr++);
1028         fprintf(gpoutfile, "\
1029 arc('%s',1,1,1,0,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,0,%.1f,%.1f,0,5760,%u,0,0,8,3,0,[\n]).\n",
1030                 sActColor, x - p, y - p, x, y, x + p, y, x, y - p, 2 * p,
1031                 2 * p, uActNr++);
1032         fprintf(gpoutfile, "\
1033 arc('%s',1,1,1,0,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,0,%.1f,%.1f,11520,5760,%u,0,0,8,3,0,[\n]).\n",
1034                 sActColor, x - p, y - p, x, y, x - p, y, x, y + p, 2 * p,
1035                 2 * p, uActNr++);
1036         uActNr += 3;
1037         fprintf(gpoutfile, "],\n%u,0,[\n]).\n", uActNr++);
1038         break;
1039         /*}}}  */
1040     case 21:
1041         /* circle7 */
1042         fputs("group([\n", gpoutfile);
1043         fprintf(gpoutfile, "\
1044 oval('%s',%.1f,%.1f,%.1f,%.1f,2,1,1,%u,0,0,0,[\n]).\n",
1045                 sActColor, x - p, y - p, x + p, y + p, uActNr++);
1046         fprintf(gpoutfile, "\
1047 arc('%s',1,1,1,0,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,0,%.1f,%.1f,5760,11520,%u,0,0,8,3,0,[\n]).\n",
1048                 sActColor, x - p, y - p, x, y, x, y - p, x, y + p, 2 * p,
1049                 2 * p, uActNr++);
1050         uActNr += 2;
1051         fprintf(gpoutfile, "],\n%u,0,[\n]).\n", uActNr++);
1052         break;
1053         /*}}}  */
1054     case 22:
1055         /* circle8 */
1056         fputs("group([\n", gpoutfile);
1057         fprintf(gpoutfile, "\
1058 oval('%s',%.1f,%.1f,%.1f,%.1f,2,1,1,%u,0,0,0,[\n]).\n",
1059                 sActColor, x - p, y - p, x + p, y + p, uActNr++);
1060         fprintf(gpoutfile, "\
1061 arc('%s',1,1,1,0,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,0,%.1f,%.1f,0,17280,%u,0,0,8,3,0,[\n]).\n",
1062                 sActColor, x - p, y - p, x, y, x + p, y, x, y + p, 2 * p,
1063                 2 * p, uActNr++);
1064         uActNr += 2;
1065         fprintf(gpoutfile, "],\n%u,0,[\n]).\n", uActNr++);
1066         break;
1067         /*}}}  */
1068     case 23:
1069         /* circle9 */
1070         fputs("group([\n", gpoutfile);
1071         fprintf(gpoutfile, "\
1072 oval('%s',%.1f,%.1f,%.1f,%.1f,2,1,1,%u,0,0,0,[\n]).\n",
1073                 sActColor, x - p, y - p, x + p, y + p, uActNr++);
1074         fprintf(gpoutfile, "\
1075 arc('%s',1,1,1,0,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,0,%.1f,%.1f,17280,5760,%u,0,0,8,3,0,[\n]).\n",
1076                 sActColor, x - p, y - p, x, y, x, y + p, x + p, y, 2 * p,
1077                 2 * p, uActNr++);
1078         uActNr += 2;
1079         fprintf(gpoutfile, "],\n%u,0,[\n]).\n", uActNr++);
1080         break;
1081         /*}}}  */
1082     case 24:
1083         /* circle10 */
1084         fputs("group([\n", gpoutfile);
1085         fprintf(gpoutfile, "\
1086 oval('%s',%.1f,%.1f,%.1f,%.1f,2,1,1,%u,0,0,0,[\n]).\n",
1087                 sActColor, x - p, y - p, x + p, y + p, uActNr++);
1088         fprintf(gpoutfile, "\
1089 arc('%s',1,1,1,0,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,0,%.1f,%.1f,17280,11520,%u,0,0,8,3,0,[\n]).\n",
1090                 sActColor, x - p, y - p, x, y, x, y + p, x, y - p, 2 * p,
1091                 2 * p, uActNr++);
1092         uActNr += 2;
1093         fprintf(gpoutfile, "],\n%u,0,[\n]).\n", uActNr++);
1094         break;
1095         /*}}}  */
1096     case 25:
1097         /* circle11 */
1098         fputs("group([\n", gpoutfile);
1099         fprintf(gpoutfile, "\
1100 oval('%s',%.1f,%.1f,%.1f,%.1f,2,1,1,%u,0,0,0,[\n]).\n",
1101                 sActColor, x - p, y - p, x + p, y + p, uActNr++);
1102         fprintf(gpoutfile, "\
1103 arc('%s',1,1,1,0,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,0,%.1f,%.1f,5760,5760,%u,0,0,8,3,0,[\n]).\n",
1104                 sActColor, x - p, y - p, x, y, x, y - p, x - p, y, 2 * p,
1105                 2 * p, uActNr++);
1106         fprintf(gpoutfile, "\
1107 arc('%s',1,1,1,0,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,0,%.1f,%.1f,17280,5760,%u,0,0,8,3,0,[\n]).\n",
1108                 sActColor, x - p, y - p, x, y, x, y + p, x + p, y, 2 * p,
1109                 2 * p, uActNr++);
1110         uActNr += 3;
1111         fprintf(gpoutfile, "],\n%u,0,[\n]).\n", uActNr++);
1112         break;
1113         /*}}}  */
1114     case 26:
1115         /* circle12 */
1116         fprintf(gpoutfile, "group([\n");
1117         fprintf(gpoutfile, "oval('%s',%.1f,%.1f,%.1f,%.1f,2,1,1,%u,0,0,0,[\n]).\n",
1118                 sActColor, x - p, y - p, x + p, y + p, uActNr++);
1119         fprintf(gpoutfile,
1120                 "arc('%s',1,1,1,0,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,0,%.1f,%.1f,17280,17280,%u,0,0,8,3,0,[\n]).\n",
1121                 sActColor, x - p, y - p, x, y, x, y + p, x - p, y, 2 * p, 2 * p, uActNr++);
1122         uActNr += 2;
1123         fprintf(gpoutfile, "],\n%u,0,[\n]).\n", uActNr++);
1124         break;
1125         /*}}}  */
1126     case 27:
1127         /* circle13 */
1128         fprintf(gpoutfile, "group([\n");
1129         fprintf(gpoutfile, "oval('%s',%.1f,%.1f,%.1f,%.1f,2,1,1,%u,0,0,0,[\n]).\n",
1130                 sActColor, x - p, y - p, x + p, y + p, uActNr++);
1131         fprintf(gpoutfile,
1132                 "arc('%s',1,1,1,0,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,0,%.1f,%.1f,11520,11520,%u,0,0,8,3,0,[\n]).\n",
1133                 sActColor, x - p, y - p, x, y, x - p, y, x + p, y, 2 * p, 2 * p, uActNr++);
1134         uActNr += 2;
1135         fprintf(gpoutfile, "],\n%u,0,[\n]).\n", uActNr++);
1136         break;
1137         /*}}}  */
1138     case 28:
1139         /* circle14 */
1140         fprintf(gpoutfile, "group([\n");
1141         fprintf(gpoutfile, "oval('%s',%.1f,%.1f,%.1f,%.1f,2,1,1,%u,0,0,0,[\n]).\n",
1142                 sActColor, x - p, y - p, x + p, y + p, uActNr++);
1143         fprintf(gpoutfile,
1144                 "arc('%s',1,1,1,0,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,0,%.1f,%.1f,11520,17280,%u,0,0,8,3,0,[\n]).\n",
1145                 sActColor, x - p, y - p, x, y, x - p, y, x, y - p, 2 * p, 2 * p, uActNr++);
1146         uActNr += 2;
1147         fprintf(gpoutfile, "],\n%u,0,[\n]).\n", uActNr++);
1148         break;
1149         /*}}}  */
1150     case 29:
1151         /* circle15 */
1152         fprintf(gpoutfile, "group([\n");
1153         fprintf(gpoutfile, "oval('%s',%.1f,%.1f,%.1f,%.1f,2,1,1,%u,0,0,0,[\n]).\n",
1154                 sActColor, x - p, y - p, x + p, y + p, uActNr++);
1155         fprintf(gpoutfile,
1156                 "arc('%s',1,1,1,0,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,0,%.1f,%.1f,5760,17280,%u,0,0,8,3,0,[\n]).\n",
1157                 sActColor, x - p, y - p, x, y, x, y - p, x + p, y, 2 * p, 2 * p, uActNr++);
1158         uActNr += 2;
1159         fprintf(gpoutfile, "],\n%u,0,[\n]).\n", uActNr++);
1160         break;
1161         /*}}}  */
1162     case 30:
1163         /* circle16 */
1164         fprintf(gpoutfile, "oval('%s',%.1f,%.1f,%.1f,%.1f,1,1,1,%u,0,0,0,[\n]).\n",
1165                 sActColor, x - p, y - p, x + p, y + p, uActNr);
1166         uActNr++;
1167         break;
1168         /*}}}  */
1169     case 31:
1170         /* box1 */
1171         fprintf(gpoutfile, "group([\n");
1172         fprintf(gpoutfile, "box('%s',%.1f,%.1f,%.1f,%.1f,2,1,1,%u,0,0,0,[\n]).\n",
1173                 sActColor, x - p, y - p, x + p, y + p, uActNr++);
1174         fprintf(gpoutfile, "box('%s',%.1f,%.1f,%.1f,%.1f,1,1,1,%u,0,0,0,[\n]).\n",
1175                 sActColor, x - p / 4, y - p, x + p / 4, y, uActNr++);
1176         uActNr += 2;
1177         fprintf(gpoutfile, "],\n%u,0,[\n]).\n", uActNr++);
1178         break;
1179         /*}}}  */
1180     case 32:
1181         /* box2 */
1182         fprintf(gpoutfile, "group([\n");
1183         fprintf(gpoutfile, "box('%s',%.1f,%.1f,%.1f,%.1f,2,1,1,%u,0,0,0,[\n]).\n",
1184                 sActColor, x - p, y - p, x + p, y + p, uActNr++);
1185         fprintf(gpoutfile, "box('%s',%.1f,%.1f,%.1f,%.1f,1,1,1,%u,0,0,0,[\n]).\n",
1186                 sActColor, x, y - p, x + p, y, uActNr++);
1187         uActNr += 2;
1188         fprintf(gpoutfile, "],\n%u,0,[\n]).\n", uActNr++);
1189         break;
1190         /*}}}  */
1191     case 33:
1192         /* box3 */
1193         fprintf(gpoutfile, "group([\n");
1194         fprintf(gpoutfile, "box('%s',%.1f,%.1f,%.1f,%.1f,2,1,1,%u,0,0,0,[\n]).\n",
1195                 sActColor, x - p, y - p, x + p, y + p, uActNr++);
1196         fprintf(gpoutfile, "box('%s',%.1f,%.1f,%.1f,%.1f,1,1,1,%u,0,0,0,[\n]).\n",
1197                 sActColor, x - p, y - p, x, y, uActNr++);
1198         uActNr += 2;
1199         fprintf(gpoutfile, "],\n%u,0,[\n]).\n", uActNr++);
1200         break;
1201         /*}}}  */
1202     case 34:
1203         /* box4 */
1204         fprintf(gpoutfile, "group([\n");
1205         fprintf(gpoutfile, "box('%s',%.1f,%.1f,%.1f,%.1f,2,1,1,%u,0,0,0,[\n]).\n",
1206                 sActColor, x - p, y - p, x + p, y + p, uActNr++);
1207         fprintf(gpoutfile, "box('%s',%.1f,%.1f,%.1f,%.1f,1,1,1,%u,0,0,0,[\n]).\n",
1208                 sActColor, x - p, y - p, x + p, y, uActNr++);
1209         uActNr += 2;
1210         fprintf(gpoutfile, "],\n%u,0,[\n]).\n", uActNr++);
1211         break;
1212         /*}}}  */
1213     case 35:
1214         /* box5 */
1215         fprintf(gpoutfile, "group([\n");
1216         fprintf(gpoutfile, "box('%s',%.1f,%.1f,%.1f,%.1f,2,1,1,%u,0,0,0,[\n]).\n",
1217                 sActColor, x - p, y - p, x + p, y + p, uActNr++);
1218         fprintf(gpoutfile, "box('%s',%.1f,%.1f,%.1f,%.1f,1,1,1,%u,0,0,0,[\n]).\n",
1219                 sActColor, x - p, y, x, y + p, uActNr++);
1220         uActNr += 2;
1221         fprintf(gpoutfile, "],\n%u,0,[\n]).\n", uActNr++);
1222         break;
1223         /*}}}  */
1224     case 36:
1225         /* box6 */
1226         fprintf(gpoutfile, "group([\n");
1227         fprintf(gpoutfile, "box('%s',%.1f,%.1f,%.1f,%.1f,2,1,1,%u,0,0,0,[\n]).\n",
1228                 sActColor, x - p, y - p, x + p, y + p, uActNr++);
1229         fprintf(gpoutfile, "box('%s',%.1f,%.1f,%.1f,%.1f,1,1,1,%u,0,0,0,[\n]).\n",
1230                 sActColor, x, y - p, x + p, y, uActNr++);
1231         fprintf(gpoutfile, "box('%s',%.1f,%.1f,%.1f,%.1f,1,1,1,%u,0,0,0,[\n]).\n",
1232                 sActColor, x - p, y, x, y + p, uActNr++);
1233         uActNr += 3;
1234         fprintf(gpoutfile, "],\n%u,0,[\n]).\n", uActNr++);
1235         break;
1236         /*}}}  */
1237     case 37:
1238         /* box7 */
1239         fprintf(gpoutfile, "group([\n");
1240         fprintf(gpoutfile, "box('%s',%.1f,%.1f,%.1f,%.1f,2,1,1,%u,0,0,0,[\n]).\n",
1241                 sActColor, x - p, y - p, x + p, y + p, uActNr++);
1242         fprintf(gpoutfile, "box('%s',%.1f,%.1f,%.1f,%.1f,1,1,1,%u,0,0,0,[\n]).\n",
1243                 sActColor, x - p, y - p, x, y + p, uActNr++);
1244         uActNr += 2;
1245         fprintf(gpoutfile, "],\n%u,0,[\n]).\n", uActNr++);
1246         break;
1247         /*}}}  */
1248     case 38:
1249         /* box8 */
1250         fprintf(gpoutfile, "group([\n");
1251         fprintf(gpoutfile, "box('%s',%.1f,%.1f,%.1f,%.1f,2,1,1,%u,0,0,0,[\n]).\n",
1252                 sActColor, x - p, y - p, x + p, y + p, uActNr++);
1253         fprintf(gpoutfile, "box('%s',%.1f,%.1f,%.1f,%.1f,1,1,1,%u,0,0,0,[\n]).\n",
1254                 sActColor, x - p, y - p, x + p, y, uActNr++);
1255         fprintf(gpoutfile, "box('%s',%.1f,%.1f,%.1f,%.1f,1,1,1,%u,0,0,0,[\n]).\n",
1256                 sActColor, x - p, y, x, y + p, uActNr++);
1257         uActNr += 3;
1258         fprintf(gpoutfile, "],\n%u,0,[\n]).\n", uActNr++);
1259         break;
1260         /*}}}  */
1261     case 39:
1262         /* box9 */
1263         fprintf(gpoutfile, "group([\n");
1264         fprintf(gpoutfile, "box('%s',%.1f,%.1f,%.1f,%.1f,2,1,1,%u,0,0,0,[\n]).\n",
1265                 sActColor, x - p, y - p, x + p, y + p, uActNr++);
1266         fprintf(gpoutfile, "box('%s',%.1f,%.1f,%.1f,%.1f,1,1,1,%u,0,0,0,[\n]).\n",
1267                 sActColor, x, y, x + p, y + p, uActNr++);
1268         uActNr += 2;
1269         fprintf(gpoutfile, "],\n%u,0,[\n]).\n", uActNr++);
1270         break;
1271         /*}}}  */
1272     case 40:
1273         /* box10 */
1274         fprintf(gpoutfile, "group([\n");
1275         fprintf(gpoutfile, "box('%s',%.1f,%.1f,%.1f,%.1f,2,1,1,%u,0,0,0,[\n]).\n",
1276                 sActColor, x - p, y - p, x + p, y + p, uActNr++);
1277         fprintf(gpoutfile, "box('%s',%.1f,%.1f,%.1f,%.1f,1,1,1,%u,0,0,0,[\n]).\n",
1278                 sActColor, x, y - p, x + p, y + p, uActNr++);
1279         uActNr += 2;
1280         fprintf(gpoutfile, "],\n%u,0,[\n]).\n", uActNr++);
1281         break;
1282         /*}}}  */
1283     case 41:
1284         /* box11 */
1285         fprintf(gpoutfile, "group([\n");
1286         fprintf(gpoutfile, "box('%s',%.1f,%.1f,%.1f,%.1f,2,1,1,%u,0,0,0,[\n]).\n",
1287                 sActColor, x - p, y - p, x + p, y + p, uActNr++);
1288         fprintf(gpoutfile, "box('%s',%.1f,%.1f,%.1f,%.1f,1,1,1,%u,0,0,0,[\n]).\n",
1289                 sActColor, x - p, y - p, x, y, uActNr++);
1290         fprintf(gpoutfile, "box('%s',%.1f,%.1f,%.1f,%.1f,1,1,1,%u,0,0,0,[\n]).\n",
1291                 sActColor, x, y, x + p, y + p, uActNr++);
1292         uActNr += 3;
1293         fprintf(gpoutfile, "],\n%u,0,[\n]).\n", uActNr++);
1294         break;
1295         /*}}}  */
1296     case 42:
1297         /* box12 */
1298         fprintf(gpoutfile, "group([\n");
1299         fprintf(gpoutfile, "box('%s',%.1f,%.1f,%.1f,%.1f,2,1,1,%u,0,0,0,[\n]).\n",
1300                 sActColor, x - p, y - p, x + p, y + p, uActNr++);
1301         fprintf(gpoutfile, "box('%s',%.1f,%.1f,%.1f,%.1f,1,1,1,%u,0,0,0,[\n]).\n",
1302                 sActColor, x - p, y - p, x + p, y, uActNr++);
1303         fprintf(gpoutfile, "box('%s',%.1f,%.1f,%.1f,%.1f,1,1,1,%u,0,0,0,[\n]).\n",
1304                 sActColor, x, y, x + p, y + p, uActNr++);
1305         uActNr += 3;
1306         fprintf(gpoutfile, "],\n%u,0,[\n]).\n", uActNr++);
1307         break;
1308         /*}}}  */
1309     case 43:
1310         /* box13 */
1311         fprintf(gpoutfile, "group([\n");
1312         fprintf(gpoutfile, "box('%s',%.1f,%.1f,%.1f,%.1f,2,1,1,%u,0,0,0,[\n]).\n",
1313                 sActColor, x - p, y - p, x + p, y + p, uActNr++);
1314         fprintf(gpoutfile, "box('%s',%.1f,%.1f,%.1f,%.1f,1,1,1,%u,0,0,0,[\n]).\n",
1315                 sActColor, x - p, y, x + p, y + p, uActNr++);
1316         uActNr += 2;
1317         fprintf(gpoutfile, "],\n%u,0,[\n]).\n", uActNr++);
1318         break;
1319         /*}}}  */
1320     case 44:
1321         /* box14 */
1322         fprintf(gpoutfile, "group([\n");
1323         fprintf(gpoutfile, "box('%s',%.1f,%.1f,%.1f,%.1f,2,1,1,%u,0,0,0,[\n]).\n",
1324                 sActColor, x - p, y - p, x + p, y + p, uActNr++);
1325         fprintf(gpoutfile, "box('%s',%.1f,%.1f,%.1f,%.1f,1,1,1,%u,0,0,0,[\n]).\n",
1326                 sActColor, x, y - p, x + p, y, uActNr++);
1327         fprintf(gpoutfile, "box('%s',%.1f,%.1f,%.1f,%.1f,1,1,1,%u,0,0,0,[\n]).\n",
1328                 sActColor, x - p, y, x + p, y + p, uActNr++);
1329         uActNr += 3;
1330         fprintf(gpoutfile, "],\n%u,0,[\n]).\n", uActNr++);
1331         break;
1332         /*}}}  */
1333     case 45:
1334         /* box15 */
1335         fprintf(gpoutfile, "group([\n");
1336         fprintf(gpoutfile, "box('%s',%.1f,%.1f,%.1f,%.1f,2,1,1,%u,0,0,0,[\n]).\n",
1337                 sActColor, x - p, y - p, x + p, y + p, uActNr++);
1338         fprintf(gpoutfile, "box('%s',%.1f,%.1f,%.1f,%.1f,1,1,1,%u,0,0,0,[\n]).\n",
1339                 sActColor, x - p, y - p, x, y, uActNr++);
1340         fprintf(gpoutfile, "box('%s',%.1f,%.1f,%.1f,%.1f,1,1,1,%u,0,0,0,[\n]).\n",
1341                 sActColor, x - p, y, x + p, y + p, uActNr++);
1342         uActNr += 3;
1343         fprintf(gpoutfile, "],\n%u,0,[\n]).\n", uActNr++);
1344         break;
1345         /*}}}  */
1346     case 46:
1347         /* box16 */
1348         fprintf(gpoutfile, "box('%s',%.1f,%.1f,%.1f,%.1f,1,1,1,%u,0,0,0,[\n]).\n",
1349                 sActColor, x - p, y - p, x + p, y + p, uActNr);
1350         uActNr++;
1351         break;
1352         /*}}}  */
1353     case 47:
1354         /* diamond1 */
1355         fprintf(gpoutfile, "group([\n");
1356         fprintf(gpoutfile,
1357                 "polygon('%s',5,[\n%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f],0,1,1,0,%u,0,0,0,0,0,[\n]).\n",
1358                 sActColor, x, y + p, x + p, y, x, y - p, x - p, y, x, y + p, uActNr);
1359         fprintf(gpoutfile,
1360                 "polygon('%s',5,[\n%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f],1,1,1,0,%u,0,0,0,0,0,[\n]).\n",
1361                 sActColor, x - 0.625 * p, y - 0.375 * p, x - 0.375 * p, y - 0.625 * p, x + p / 8,
1362                 y - p / 8, x - p / 8, y + p / 8, x - 0.625 * p, y - 0.375 * p, uActNr);
1363         fprintf(gpoutfile, "],\n%u,0,[\n]).\n", uActNr++);
1364         uActNr += 2;
1365         break;
1366         /*}}}  */
1367     case 48:
1368         /* diamond2 */
1369         fprintf(gpoutfile, "group([\n");
1370         fprintf(gpoutfile,
1371                 "polygon('%s',5,[\n%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f],0,1,1,0,%u,0,0,0,0,0,[\n]).\n",
1372                 sActColor, x, y + p, x + p, y, x, y - p, x - p, y, x, y + p, uActNr);
1373         fprintf(gpoutfile,
1374                 "polygon('%s',5,[\n%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f],1,1,1,0,%u,0,0,0,0,0,[\n]).\n",
1375                 sActColor, x - p / 2, y - p / 2, x, y - p, x + p / 2, y - p / 2, x, y, x - p / 2,
1376                 y - p / 2, uActNr);
1377         uActNr += 2;
1378         fprintf(gpoutfile, "],\n%u,0,[\n]).\n", uActNr++);
1379         break;
1380         /*}}}  */
1381     case 49:
1382         /* diamond3 */
1383         fprintf(gpoutfile, "group([\n");
1384         fprintf(gpoutfile,
1385                 "polygon('%s',5,[\n%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f],0,1,1,0,%u,0,0,0,0,0,[\n]).\n",
1386                 sActColor, x, y + p, x + p, y, x, y - p, x - p, y, x, y + p, uActNr);
1387         fprintf(gpoutfile,
1388                 "polygon('%s',5,[\n%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f],1,1,1,0,%u,0,0,0,0,0,[\n]).\n",
1389                 sActColor, x - p, y, x - p / 2, y - p / 2, x, y, x - p / 2, y + p / 2, x - p, y, uActNr);
1390         uActNr += 2;
1391         fprintf(gpoutfile, "],\n%u,0,[\n]).\n", uActNr++);
1392         break;
1393         /*}}}  */
1394     case 50:
1395         /* diamond4 */
1396         fprintf(gpoutfile, "group([\n");
1397         fprintf(gpoutfile,
1398                 "polygon('%s',5,[\n%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f],0,1,1,0,%u,0,0,0,0,0,[\n]).\n",
1399                 sActColor, x, y + p, x + p, y, x, y - p, x - p, y, x, y + p, uActNr);
1400         fprintf(gpoutfile,
1401                 "polygon('%s',5,[\n%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f],1,1,1,0,%u,0,0,0,0,0,[\n]).\n",
1402                 sActColor, x - p, y, x, y - p, x + p / 2, y - p / 2, x - p / 2, y + p / 2, x - p,
1403                 y, uActNr);
1404         uActNr += 2;
1405         fprintf(gpoutfile, "],\n%u,0,[\n]).\n", uActNr++);
1406         break;
1407         /*}}}  */
1408     case 51:
1409         /* diamond5 */
1410         fprintf(gpoutfile, "group([\n");
1411         fprintf(gpoutfile,
1412                 "polygon('%s',5,[\n%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f],0,1,1,0,%u,0,0,0,0,0,[\n]).\n",
1413                 sActColor, x, y + p, x + p, y, x, y - p, x - p, y, x, y + p, uActNr);
1414         fprintf(gpoutfile,
1415                 "polygon('%s',5,[\n%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f],1,1,1,0,%u,0,0,0,0,0,[\n]).\n",
1416                 sActColor, x - p / 2, y + p / 2, x, y, x + p / 2, y + p / 2, x, y + p, x - p / 2,
1417                 y + p / 2, uActNr);
1418         uActNr += 2;
1419         fprintf(gpoutfile, "],\n%u,0,[\n]).\n", uActNr++);
1420         break;
1421         /*}}}  */
1422     case 52:
1423         /* diamond6 */
1424         fprintf(gpoutfile, "group([\n");
1425         fprintf(gpoutfile,
1426                 "polygon('%s',5,[\n%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f],0,1,1,0,%u,0,0,0,0,0,[\n]).\n",
1427                 sActColor, x, y + p, x + p, y, x, y - p, x - p, y, x, y + p, uActNr);
1428         fprintf(gpoutfile,
1429                 "polygon('%s',5,[\n%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f],1,1,1,0,%u,0,0,0,0,0,[\n]).\n",
1430                 sActColor, x - p / 2, y - p / 2, x, y - p, x + p / 2, y - p / 2, x, y, x - p / 2,
1431                 y - p / 2, uActNr);
1432         fprintf(gpoutfile,
1433                 "polygon('%s',5,[\n%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f],1,1,1,0,%u,0,0,0,0,0,[\n]).\n",
1434                 sActColor, x - p / 2, y + p / 2, x, y, x + p / 2, y + p / 2, x, y + p, x - p / 2,
1435                 y + p / 2, uActNr);
1436         uActNr += 3;
1437         fprintf(gpoutfile, "],\n%u,0,[\n]).\n", uActNr++);
1438         break;
1439         /*}}}  */
1440     case 53:
1441         /* diamond7 */
1442         fprintf(gpoutfile, "group([\n");
1443         fprintf(gpoutfile,
1444                 "polygon('%s',5,[\n%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f],0,1,1,0,%u,0,0,0,0,0,[\n]).\n",
1445                 sActColor, x, y + p, x + p, y, x, y - p, x - p, y, x, y + p, uActNr);
1446         fprintf(gpoutfile,
1447                 "polygon('%s',5,[\n%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f],1,1,1,0,%u,0,0,0,0,0,[\n]).\n",
1448                 sActColor, x - p, y, x - p / 2, y - p / 2, x + p / 2, y + p / 2, x, y + p, x - p,
1449                 y, uActNr);
1450         uActNr += 2;
1451         fprintf(gpoutfile, "],\n%u,0,[\n]).\n", uActNr++);
1452         break;
1453         /*}}}  */
1454     case 54:
1455         /* diamond8 */
1456         fprintf(gpoutfile, "group([\n");
1457         fprintf(gpoutfile,
1458                 "polygon('%s',5,[\n%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f],0,1,1,0,%u,0,0,0,0,0,[\n]).\n",
1459                 sActColor, x, y + p, x + p, y, x, y - p, x - p, y, x, y + p, uActNr);
1460         fprintf(gpoutfile,
1461                 "polygon('%s',7,[\n%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f],1,1,1,0,%u,0,0,0,0,0,[\n]).\n",
1462                 sActColor, x - p, y, x, y - p, x + p / 2, y - p / 2, x, y, x + p / 2, y + p / 2,
1463                 x, y + p, x - p, y, uActNr);
1464         uActNr += 2;
1465         fprintf(gpoutfile, "],\n%u,0,[\n]).\n", uActNr++);
1466         break;
1467         /*}}}  */
1468     case 55:
1469         /* diamond9 */
1470         fprintf(gpoutfile, "group([\n");
1471         fprintf(gpoutfile,
1472                 "polygon('%s',5,[\n%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f],0,1,1,0,%u,0,0,0,0,0,[\n]).\n",
1473                 sActColor, x, y + p, x + p, y, x, y - p, x - p, y, x, y + p, uActNr);
1474         fprintf(gpoutfile,
1475                 "polygon('%s',5,[\n%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f],1,1,1,0,%u,0,0,0,0,0,[\n]).\n",
1476                 sActColor, x, y, x + p / 2, y - p / 2, x + p, y, x + p / 2, y + p / 2, x, y, uActNr);
1477         uActNr += 2;
1478         fprintf(gpoutfile, "],\n%u,0,[\n]).\n", uActNr++);
1479         break;
1480         /*}}}  */
1481     case 56:
1482         /* diamond10 */
1483         fprintf(gpoutfile, "group([\n");
1484         fprintf(gpoutfile,
1485                 "polygon('%s',5,[\n%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f],0,1,1,0,%u,0,0,0,0,0,[\n]).\n",
1486                 sActColor, x, y + p, x + p, y, x, y - p, x - p, y, x, y + p, uActNr);
1487         fprintf(gpoutfile,
1488                 "polygon('%s',5,[\n%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f],1,1,1,0,%u,0,0,0,0,0,[\n]).\n",
1489                 sActColor, x - p / 2, y - p / 2, x, y - p, x + p, y, x + p / 2, y + p / 2, x - p /
1490                 2, y - p / 2, uActNr);
1491         uActNr += 2;
1492         fprintf(gpoutfile, "],\n%u,0,[\n]).\n", uActNr++);
1493         break;
1494         /*}}}  */
1495     case 57:
1496         /* diamond11 */
1497         fprintf(gpoutfile, "group([\n");
1498         fprintf(gpoutfile,
1499                 "polygon('%s',5,[\n%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f],0,1,1,0,%u,0,0,0,0,0,[\n]).\n",
1500                 sActColor, x, y + p, x + p, y, x, y - p, x - p, y, x, y + p, uActNr);
1501         fprintf(gpoutfile,
1502                 "polygon('%s',5,[\n%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f],1,1,1,0,%u,0,0,0,0,0,[\n]).\n",
1503                 sActColor, x - p, y, x - p / 2, y - p / 2, x, y, x - p / 2, y + p / 2, x - p, y, uActNr);
1504         fprintf(gpoutfile,
1505                 "polygon('%s',5,[\n%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f],1,1,1,0,%u,0,0,0,0,0,[\n]).\n",
1506                 sActColor, x, y, x + p / 2, y - p / 2, x + p, y, x + p / 2, y + p / 2, x, y, uActNr);
1507         uActNr += 3;
1508         fprintf(gpoutfile, "],\n%u,0,[\n]).\n", uActNr++);
1509         break;
1510         /*}}}  */
1511     case 58:
1512         /* diamond12 */
1513         fprintf(gpoutfile, "group([\n");
1514         fprintf(gpoutfile,
1515                 "polygon('%s',5,[\n%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f],0,1,1,0,%u,0,0,0,0,0,[\n]).\n",
1516                 sActColor, x, y + p, x + p, y, x, y - p, x - p, y, x, y + p, uActNr);
1517         fprintf(gpoutfile,
1518                 "polygon('%s',7,[\n%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f],1,1,1,0,%u,0,0,0,0,0,[\n]).\n",
1519                 sActColor, x - p, y, x, y - p, x + p, y, x + p / 2, y + p / 2, x, y, x - p / 2, y
1520                 + p / 2, x - p, y, uActNr);
1521         uActNr += 2;
1522         fprintf(gpoutfile, "],\n%u,0,[\n]).\n", uActNr++);
1523         break;
1524         /*}}}  */
1525     case 59:
1526         /* diamond13 */
1527         fprintf(gpoutfile, "group([\n");
1528         fprintf(gpoutfile,
1529                 "polygon('%s',5,[\n%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f],0,1,1,0,%u,0,0,0,0,0,[\n]).\n",
1530                 sActColor, x, y + p, x + p, y, x, y - p, x - p, y, x, y + p, uActNr);
1531         fprintf(gpoutfile,
1532                 "polygon('%s',5,[\n%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f],1,1,1,0,%u,0,0,0,0,0,[\n]).\n",
1533                 sActColor, x - p / 2, y + p / 2, x + p / 2, y - p / 2, x + p, y, x, y + p, x - p /
1534                 2, y + p / 2, uActNr);
1535         uActNr += 2;
1536         fprintf(gpoutfile, "],\n%u,0,[\n]).\n", uActNr++);
1537         break;
1538         /*}}}  */
1539     case 60:
1540         /* diamond14 */
1541         fprintf(gpoutfile, "group([\n");
1542         fprintf(gpoutfile,
1543                 "polygon('%s',5,[\n%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f],0,1,1,0,%u,0,0,0,0,0,[\n]).\n",
1544                 sActColor, x, y + p, x + p, y, x, y - p, x - p, y, x, y + p, uActNr);
1545         fprintf(gpoutfile,
1546                 "polygon('%s',7,[\n%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f],1,1,1,0,%u,0,0,0,0,0,[\n]).\n",
1547                 sActColor, x - p / 2, y - p / 2, x, y - p, x + p, y, x, y + p, x - p / 2, y + p /
1548                 2, x, y, x - p / 2, y - p / 2, uActNr);
1549         uActNr += 2;
1550         fprintf(gpoutfile, "],\n%u,0,[\n]).\n", uActNr++);
1551         break;
1552         /*}}}  */
1553     case 61:
1554         /* diamond15 */
1555         fprintf(gpoutfile, "group([\n");
1556         fprintf(gpoutfile,
1557                 "polygon('%s',5,[\n%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f],0,1,1,0,%u,0,0,0,0,0,[\n]).\n",
1558                 sActColor, x, y + p, x + p, y, x, y - p, x - p, y, x, y + p, uActNr);
1559         fprintf(gpoutfile,
1560                 "polygon('%s',7,[\n%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f],1,1,1,0,%u,0,0,0,0,0,[\n]).\n",
1561                 sActColor, x - p, y, x - p / 2, y - p / 2, x, y, x + p / 2, y - p / 2, x + p, y,
1562                 x, y + p, x - p, y, uActNr);
1563         uActNr += 2;
1564         fprintf(gpoutfile, "],\n%u,0,[\n]).\n", uActNr++);
1565         break;
1566         /*}}}  */
1567     case 62:
1568         /* diamond16 */
1569         fprintf(gpoutfile,
1570                 "polygon('%s',5,[\n%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f],1,1,1,0,%u,0,0,0,0,0,[\n]).\n",
1571                 sActColor, x, y + p, x + p, y, x, y - p, x - p, y, x, y + p, uActNr);
1572         uActNr++;
1573         break;
1574         /*}}}  */
1575
1576     }                           /* switch */
1577 }                               /* TGIF_point */
1578
1579 /*}}}  */
1580 /***************************************************************************/
1581 TERM_PUBLIC void
1582 TGIF_set_pointsize(double size)
1583 {
1584     uActPointSize = size < 0. ? 1. : size;
1585 }
1586
1587 #ifdef USE_LINEWIDTH
1588 TERM_PUBLIC void
1589 TGIF_set_linewidth(double size)
1590 {
1591     uActThick_factor = size < 0. ? 1. : size;
1592 }
1593 #endif
1594
1595 /*}}}  */
1596 /***************************************************************************/
1597 TERM_PUBLIC int
1598 TGIF_set_font(const char *font)
1599 {
1600     int sep;
1601
1602     if (!font || !(*font))
1603         font = sDefaultFont;
1604     sep = strcspn(font, ",");
1605     if (sep > 0) {
1606         strncpy(sActFont, font, sep);
1607         sActFont[sep] = NUL;
1608     }
1609     sscanf(&(font[sep + 1]), "%d", &uActFontSize);
1610     return TRUE;
1611 }
1612
1613 TERM_PUBLIC int
1614 TGIF_make_palette(t_sm_palette *palette)
1615 {
1616     int i;
1617
1618     /* Query to determine palette size */
1619     if (palette==NULL) {
1620         return(TGIF_palette_size); /* How big is palette ? */
1621     }
1622
1623     TGIF_flush_poly(); /* Clean up current data */
1624
1625     if (TGIF_palette_set == FALSE) {
1626 #ifdef USE_MONO_MODE
1627         if (TgifUseColor == FALSE
1628             || sm_palette.colorMode == SMPAL_COLOR_MODE_GRAY) {
1629             /* Gray palette */
1630             if (TgifUseColor == FALSE
1631                 && sm_palette.colorMode == SMPAL_COLOR_MODE_RGB){
1632                 fprintf(stderr, "Monochrome Tgif file: ");
1633                 fprintf(stderr, "using gray palette instead of color\n");
1634             }
1635             for (i = 0; i < sm_palette.colors; i++) {
1636                 int j = (int)(i * 255.0 / (sm_palette.colors-1) + 0.5);
1637                 sprintf(TGIF_colours[i],"#%.2x%.2x%.2x",j,j,j);
1638             }
1639         } else {
1640 #endif
1641         /* Create new palette */
1642         for (i = 0; i < sm_palette.colors; i++) {
1643             sprintf(TGIF_colours[i],"#%.2x%.2x%.2x",
1644                 (int)( palette->color[i].r * 255 + 0.5 ),
1645                 (int)( palette->color[i].g * 255 + 0.5 ),
1646                 (int)( palette->color[i].b * 255 + 0.5 ) );
1647         }
1648 #ifdef USE_MONO_MODE
1649         }
1650 #endif
1651         TGIF_palette_set = TRUE;
1652     } else {
1653         fprintf(stderr, "Attempt to set palette twice\n");
1654     }
1655     return(0);
1656 }
1657
1658 TERM_PUBLIC void
1659 TGIF_set_color(t_colorspec *colorspec)
1660 {
1661     double gray = colorspec->value;
1662     int color;
1663
1664     if (colorspec->type != TC_FRAC)
1665         return;
1666
1667     color = (gray <= 0) ? 0 : (int)(gray * TGIF_palette_size);
1668     if (color >= TGIF_palette_size)
1669         color = TGIF_palette_size - 1;
1670     if (TGIF_palette_set == FALSE) {
1671         fprintf(stderr, "tgif: Palette used before set\n"); /* Error condition */
1672     }
1673     sprintf(sActColor, "%s", TGIF_colours[color]);
1674 }
1675
1676 TERM_PUBLIC void
1677 TGIF_filled_polygon(int points, gpiPoint *corners)
1678 {
1679     int i;
1680
1681     if (eTgifState == INPOLY)
1682         TGIF_flush_poly(); /* Clean up current data */
1683
1684     fprintf(gpoutfile, "polygon('%s',%d,[\n\t",sActColor,points+1);
1685     /* loop through points, do the first one last as well as first */
1686     fprintf(gpoutfile,"%u,%u,", corners[0].x+uXshift, uYshift-corners[0].y);
1687     for (i = 1; i < points; i++) {
1688         fprintf(gpoutfile, "%u,%u,",
1689                 corners[i].x+uXshift, uYshift-corners[i].y);
1690         /* LN: Break long lines as Tgif is rather picky about them */
1691         if ((i + 1) % 8 == 0)
1692             fputs("\n\t", gpoutfile);
1693     }
1694     fprintf(gpoutfile, "%u,%u", corners[0].x+uXshift, uYshift-corners[0].y);
1695     fprintf(gpoutfile, "],1,1,1,0,%u,0,0,0,0,0,[\n]).\n", uActNr);
1696     uActNr++;
1697 }
1698
1699 /*}}}  */
1700 /***************************************************************************/
1701
1702 #endif /* TERM_BODY */
1703
1704 #ifdef TERM_TABLE
1705
1706 TERM_TABLE_START(tgif_driver)
1707     "tgif",
1708     "TGIF X11 [mode] [x,y] [dashed] [\042font\042 [fontsize]]",
1709     TGIF_XMAX, TGIF_YMAX, TGIF_VCHAR, TGIF_HCHAR,
1710     TGIF_VTIC, TGIF_HTIC, TGIF_options, TGIF_init, TGIF_reset,
1711     TGIF_text, null_scale, TGIF_graphics, TGIF_move, TGIF_vector,
1712     TGIF_linetype, TGIF_put_text, TGIF_text_angle,
1713     TGIF_justify_text, TGIF_point, TGIF_arrow, TGIF_set_font,
1714 #ifndef USE_LINEWIDTH
1715     TGIF_set_pointsize, TERM_CAN_MULTIPLOT, 0, 0, 0, 0
1716 #else
1717     TGIF_set_pointsize, TERM_CAN_MULTIPLOT, 0, 0, 0, TGIF_set_linewidth
1718 #endif
1719 #ifdef USE_MOUSE
1720     ,0, 0, 0, 0, 0 /* no mouse support for the tgif terminal */
1721 #endif
1722     , TGIF_make_palette, 0 /*previous_palette*/, TGIF_set_color, TGIF_filled_polygon
1723 TERM_TABLE_END(tgif_driver)
1724
1725 #undef LAST_TERM
1726 #define LAST_TERM tgif_driver
1727
1728 #endif /* TERM_TABLE */
1729
1730 #endif /* TERM_PROTO_ONLY */
1731
1732 #ifdef TERM_HELP
1733 START_HELP(tgif)
1734 "1 tgif",
1735 "?commands set terminal tgif",
1736 "?set terminal tgif",
1737 "?set term tgif",
1738 "?terminal tgif",
1739 "?term tgif",
1740 "?tgif",
1741 " Tgif is an X11-based drawing tool---it has nothing to do with GIF.",
1742 "",
1743 " The `tgif` driver supports different pointsizes (with `set pointsize`),",
1744 " different label fonts and font sizes (e.g. `set label \"Hallo\" at x,y font",
1745 " \"Helvetica,34\"`) and multiple graphs on the page.  The proportions of the",
1746 " axes are not changed.",
1747 "",
1748 " Syntax:",
1749 "       set terminal tgif {portrait | landscape | default} {<[x,y]>}",
1750 "                         {monochrome | color}",
1751 "                         {{linewidth | lw} <LW>}",
1752 "                         {solid | dashed}",
1753 "                         {font \"<fontname>\"} {<fontsize>}",
1754 "",
1755 " where <[x,y]> specifies the number of graphs in the x and y directions on the",
1756 " page, `color` enables color, `linewidth` scales all linewidths by <LW>,",
1757 " \"<fontname>\" is the name of a valid PostScript font, and <fontsize>",
1758 " specifies the size of the PostScript font.",
1759 " `defaults` sets all options to their defaults: `portrait`, `[1,1]`, `color`,",
1760 " `linwidth 1.0`, `dashed`, `\"Helvetica\"`, and `18`.",
1761 "",
1762 " The `solid` option is usually prefered if lines are colored, as they often",
1763 " are in the editor.  Hardcopy will be black-and-white, so `dashed` should be",
1764 " chosen for that.",
1765 "",
1766 " Multiplot is implemented in two different ways.",
1767 "",
1768 " The first multiplot implementation is the standard gnuplot multiplot feature:",
1769 "",
1770 "       set terminal tgif",
1771 "       set output \"file.obj\"",
1772 "       set multiplot",
1773 "       set origin x01,y01",
1774 "       set size  xs,ys",
1775 "       plot ...",
1776 "            ...",
1777 "       set origin x02,y02",
1778 "       plot ...",
1779 "       unset multiplot",
1780 "",
1781 " See `set multiplot` for further information.",
1782 "",
1783 " The second version is the [x,y] option for the driver itself.  The advantage",
1784 " of this implementation is that everything is scaled and placed automatically",
1785 " without the need for setting origins and sizes; the graphs keep their natural",
1786 " x/y proportions of 3/2 (or whatever is fixed by `set size`).",
1787 "",
1788 " If both multiplot methods are selected, the standard method is chosen and a",
1789 " warning message is given.",
1790 "",
1791 " Examples of single plots (or standard multiplot):",
1792 "       set terminal tgif                  # defaults",
1793 "       set terminal tgif \"Times-Roman\" 24",
1794 "       set terminal tgif landscape",
1795 "       set terminal tgif landscape solid",
1796 "",
1797 " Examples using the built-in multiplot mechanism:",
1798 "       set terminal tgif portrait [2,4]  # portrait; 2 plots in the x-",
1799 "                                         # and 4 in the y-direction",
1800 "       set terminal tgif [1,2]           # portrait; 1 plot in the x-",
1801 "                                         # and 2 in the y-direction",
1802 "       set terminal tgif landscape [3,3] # landscape; 3 plots in both",
1803 "                                         # directions"
1804 END_HELP(tgif)
1805 #endif
1806 /*{{{}}}*/