/*{{{}}}*/
...  Authors
/***************************************************************************/
/*                                                                         */
/* $Id: tgif.trm,v 1.53 1995/12/20 21:48:16 drd Exp $                     */
/*                                                                         */
/***************************************************************************/
/* GNUPLOT - tgif.trm                                                      */
/*                                                                         */
/* Copyright (C) 1990, 1991, 1992                                          */
/*                                                                         */
/* Permission to use, copy, and distribute this software and its           */
/* documentation for any purpose with or without fee is hereby granted,    */
/* provided that the above copyright notice appear in all copies and       */
/* that both that copyright notice and this permission notice appear       */
/* in supporting documentation.                                            */
/*                                                                         */
/* Permission to modify the software is granted, but not the right to      */
/* distribute the modified code.  Modifications are to be distributed      */
/* as patches to released version.                                         */
/*                                                                         */
/* This software  is provided "as is" without express or implied warranty. */
/*                                                                         */
/* This file is included by ../term.c.                                     */
/*                                                                         */
/* This terminal driver supports:                                          */
/*     TGIF                                                                */
/*                                                                         */
/* AUTHORS:                                                                */
/*  Werner Geppert and Andreas Kuhlewind                                   */
/*  March, 21st 1995                                                       */
/*                                                                         */
/* send your comments or suggestions to werner@mez.ruhr-uni-bochum.de      */
/***************************************************************************/

/*}}}  */
/***************************************************************************/
#ifndef GOT_DRIVER_H
#include "driver.h"
#endif

#ifdef TERM_REGISTER
register_term(tgif)
#endif           

#ifdef TERM_PROTO
...  PROTOTYPES
TERM_PUBLIC void TGIF_options __P((void));
TERM_PUBLIC void TGIF_init __P((void));
TERM_PUBLIC void TGIF_reset __P((void));
TERM_PUBLIC void TGIF_text __P((void));
TERM_PUBLIC void TGIF_graphics __P((void));
TERM_PUBLIC void TGIF_move __P((unsigned int ux, unsigned int uy));
TERM_PUBLIC void TGIF_vector __P((unsigned int ux, unsigned int uy));
TERM_PUBLIC void TGIF_linetype __P((int linetype));
TERM_PUBLIC void TGIF_put_text __P((unsigned int ux, unsigned int uy, char *str)); /* ref point and text */
TERM_PUBLIC int  TGIF_text_angle __P((int angle));
TERM_PUBLIC int  TGIF_justify_text __P((enum JUSTIFY mode));
TERM_PUBLIC void TGIF_point __P((unsigned int ux, unsigned int uy, int number));
TERM_PUBLIC void TGIF_arrow __P((unsigned int sx, unsigned int sy, unsigned int ex, unsigned int ey, TBOOLEAN head));
TERM_PUBLIC int  TGIF_set_font __P((char *font));
TERM_PUBLIC void TGIF_set_pointsize __P((double size));
/*}}}  */
...  CONSTANTS       
/* standard x/y plot size in portrait mode */
#define TGIF_XMAX 950
#define TGIF_YMAX 634

/* total available plotting area */
#define TGIF_XTOT 950
#define TGIF_YTOT 1400

/* Offset  */
#define TGIF_XOFF 50
#define TGIF_YOFF 50

#define TGIF_XSHIFT 1030 /* 80 points skip */
#define TGIF_YSHIFT 714

#define TGIF_VCHAR 18		/* default is 18 pt	*/
#define TGIF_HCHAR (18*6/10)

#define TGIF_VTIC (TGIF_YMAX/80)
#define TGIF_HTIC (TGIF_YMAX/80)


#define TGIF_MAXPOLY 100
/*}}}  */
#define GOT_TGIF_PROTO
#endif            

#ifndef TERM_PROTO_ONLY

#ifdef TERM_BODY 
/* tgif driver by Werner Geppert, werner@mez.ruhr-uni-bochum.de */
/***************************************************************************/
...  Variables:                                                      
/* Variables:                                                           */
static unsigned int  uLastTgifX, uLastTgifY;      /* last Coordinate           */

static unsigned int  uActNr;                      /* current elementnumber	*/
static unsigned int  uActPage;                    /* current pagenumber	*/
static unsigned int  uActResolution;              /* resolution in percent	*/
static unsigned int  uActZoom;              	   /* zoom factor       	*/
static unsigned int  uActAngle;                   /* current textangle		*/
static unsigned int  uActThick;                   /* actual linethickness       */
static unsigned int  uActPointSize;               /* point size                 */
static unsigned int  uActStyle;                   /* actual linestyle           */
static unsigned int  uActJust;                    /* actual textjustification 	*/
static unsigned int  uXshift;                     /* actual shift x		*/
static unsigned int  uYshift;                     /* actual shift y		*/
static unsigned int  uTgifPlotCount;              /* counts number of plots    */
static unsigned int  uTgifPlotRow,uTgifPlotCol;   /* actual plot row and col   */
static unsigned int  uTgif_win_horiz,             /* number of plots in x and  */  
                     uTgif_win_verti;             /*      y direction [x,y]         */



static char          sActColor[20];               /* current color	 	*/
static unsigned int  uDefaultFontSize;            /* default font size         */
static unsigned int  uActFontSize;                /* current font size         */
static char          sDefaultFont[20];            /* default font 		*/
static char          sActFont[20];                /* current font 		*/
static unsigned int  uActPointSize;
static char          sActPointString[20];

static TBOOLEAN TgifSolid=FALSE;
static TBOOLEAN TgifPortrait=TRUE;

static unsigned int  uTgifPlotsPerPage=1;
static unsigned int  uTextAngle[] = {0, 3};

/*
 * 10 different pointtypes need 10 different linetypes
 */

static unsigned int  uLineThick[] = {3,1,1,1,1,1,1,1,1,1,1,1};
static unsigned int  uLineStyle[] = {0,5,0,1,2,3,4,5,6,7,8,0};
static char*         psColors[] =
	      { "black", "black",     /* border and x/y-zero-axes       */
                "red" , "green" , "blue" , "magenta" , "cyan", "yellow",
                "DarkSeaGreen", "HotPink", "black", "coral" };

static char*         psFonts[] =
              { "Times-Roman", "Courier", "Helvetica", "NewCentury", "Symbol" };

static unsigned int  psFontSizes[] =
              { 8, 10, 11, 12, 14, 17, 18, 20, 24, 25, 34, 40, 45, 50 };


static int      iTgifPolyCount;
static unsigned int    uBuffX[TGIF_MAXPOLY], uBuffY[TGIF_MAXPOLY];

enum  eState { NEWPOLY=100, INPOLY };
static enum eState eTgifState = NEWPOLY;

static void TGIF_flush_poly __P((void));



/*}}}  */
/***************************************************************************/
...  static TGIF_flush_poly()
static void TGIF_flush_poly()
{
  int   i;


	if(eTgifState == INPOLY) {
		fprintf(outfile, "poly('%s',%d,[\n\t",sActColor, iTgifPolyCount);

                for (i=0; i < iTgifPolyCount-1; i++) {
                	fprintf(outfile,"%u,%u,",uBuffX[i],uBuffY[i]);
                        if((i+1)%8 == 0) fprintf(outfile,"\n\t");
                }

		fprintf(outfile, "%u,%u],0,%u,1,%u,0,0,%u,0,8,3,0,[\n]).\n",
			uBuffX[iTgifPolyCount-1],uBuffY[iTgifPolyCount-1],uActThick, uActNr, uActStyle);

		uActNr++;

                eTgifState = NEWPOLY;
                iTgifPolyCount=0;
                if(outfile != (FILE *)NULL)
  			fflush(outfile);
        }


} /* TGIF_flush_poly */
/*}}}  */
/***************************************************************************/ 
...  TERM_PUBLIC void TGIF_options()
TERM_PUBLIC void TGIF_options()
{
	extern struct value *const_express();
	extern double real();
        
        struct value a,b;
        double	dscaleH,dscaleV;


...  default settings
        strcpy(sActFont,"Helvetica");
        strcpy(sDefaultFont,"Helvetica");
        uActFontSize=18;
        uDefaultFontSize=18;
	term->v_char = (unsigned int)(uActFontSize);
	term->h_char = (unsigned int)(uActFontSize*6/10);

        TgifPortrait = TRUE;
        uTgifPlotsPerPage = 1;
        uTgifPlotRow = 1;
        uTgifPlotCol = 1;
        uTgif_win_horiz = 1;
        uTgif_win_verti = 1;
        uActResolution=100;

         
/*}}}  */

...  orientation
	if (!END_OF_COMMAND) {
		if (almost_equals(c_token,"p$ortrait")) {
			TgifPortrait=TRUE;
			c_token++;
		}
		else if (almost_equals(c_token,"l$andscape")) {
			TgifPortrait=FALSE;
			uActResolution=140;
			c_token++;
		}
	}

/*}}}  */

...  number of hor/vert. plots
	if (!END_OF_COMMAND) {
		if (equals(c_token,"[")) { /* windows specified */
			c_token++;
			if (END_OF_COMMAND) {
	    			int_error("no. windows: [horizontal,vertical] expected",c_token);
			} else if (!equals(c_token,","))  {
				uTgif_win_horiz = (int)real(const_express(&a));
			}	
			if (!equals(c_token,","))
				int_error("',' expected",c_token);
			c_token++;
			if (!equals(c_token,"]")) {
				uTgif_win_verti = (int)real(const_express(&a));
	 		}
			if (!equals(c_token,"]"))
		  		int_error("expecting ']'",c_token);
			c_token++;  

         		uTgifPlotsPerPage= uTgif_win_verti*uTgif_win_horiz;

       
			}
		} 

/*}}}  */

...  line style
	if (!END_OF_COMMAND) {
		if (almost_equals(c_token,"s$olid")) {
			TgifSolid=TRUE;
			c_token++;
		}
		else if (almost_equals(c_token,"d$ashed")) {
			TgifSolid=FALSE;
			c_token++;
		}
	}
/*}}}  */

...  Font
	if (!END_OF_COMMAND && isstring(c_token)) {
		quote_str(sActFont,c_token,MAX_LINE_LEN);
		strcpy(sDefaultFont,sActFont);
		c_token++;
	}

	if (!END_OF_COMMAND) {
		/* We have font size specified */
		uActFontSize= (unsigned int)real(const_express(&b));
		uDefaultFontSize=uActFontSize;
		term->v_char = (unsigned int)(uActFontSize);
		term->h_char = (unsigned int)(uActFontSize*6/10);
	}

/*}}}  */

...  calculate resolution and zoom
		if(TgifPortrait) { 
			dscaleH=(double)100.0*(TGIF_XTOT)/( xsize*(TGIF_XMAX +(uTgif_win_horiz-1)*TGIF_XSHIFT));
			dscaleV=(double)100.0*(TGIF_YTOT)/( ysize*(TGIF_YMAX +(uTgif_win_verti-1)*TGIF_YSHIFT));
                               uActResolution=(int)min(dscaleH,dscaleV);
                               switch(uTgif_win_verti) {
                               	case 1:
                               		uActZoom = 0;
                               		break;
                                 		
                               	case 2:
                               		uActZoom = 1;
                               		break; 
                               	default:
                               		uActZoom = 2;
                               		break;
                                 		
                               }
		} else {
			dscaleH=(double)100.0*(TGIF_YTOT)/( xsize*(TGIF_XMAX +(uTgif_win_horiz-1)*TGIF_XSHIFT));
			dscaleV=(double)100.0*(TGIF_XTOT)/( ysize*(TGIF_YMAX +(uTgif_win_verti-1)*TGIF_YSHIFT));
                        uActResolution=(unsigned int)min(dscaleH,dscaleV);
                                
                        switch(uTgif_win_verti) {
                               	case 1:
                               		uActZoom = 0;
                               		break;
                                		
                               	case 2:
                               		uActZoom = 1;
                               		break; 
                               	default:
                               		uActZoom = 2;
                               		break;
                                 		
                       }
	      }

/*}}}  */

	sprintf(term_options,"%s [%u,%u] %s \"%s\" %u",
		TgifPortrait ? "portrait" : "landscape",
		uTgif_win_horiz,uTgif_win_verti,
		TgifSolid ? "solid" : "dashed",
		sActFont,uActFontSize);
}
/*}}}  */
/***************************************************************************/
...  TERM_PUBLIC void TGIF_init()
TERM_PUBLIC void TGIF_init()
{

if(multiplot) {                                      
        /* uActResolution= TgifPortrait ? (unsigned int)100 : (unsigned int)145 ;*/
        uActResolution =(unsigned int)100;

        if(uTgifPlotsPerPage > 1) {
         	fprintf(stderr,"warning: using standard multiplot\n");
        	uTgifPlotsPerPage = 1;	
        }
        uActZoom = 1;
}       




fprintf(outfile,"%%TGIF 2.15-p7\n");
fprintf(outfile,"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",
	TgifPortrait ? 0 : 1,uActResolution,uActZoom,sActFont,uActFontSize);
fprintf(outfile,"%%\n%% @(#)$Header: /cvs/gnuplot/term/tgif.trm,v 1.53 1995/12/20 21:48:16 drd Exp $\n%% %%W%%\n%%\n");
fprintf(outfile,"page(1,\"\").\n");
eTgifState = NEWPOLY;
iTgifPolyCount = 0;
uTgifPlotCount = 0;
uActPage = 1;

} /* TGIF_init */
/*}}}  */
/***************************************************************************/
...  TERM_PUBLIC void TGIF_graphics()
TERM_PUBLIC void TGIF_graphics()
{

TGIF_flush_poly();

if(multiplot) {

        term->xmax = (TgifPortrait) ? TGIF_XTOT : TGIF_YTOT;
        term->ymax = (TgifPortrait) ? TGIF_YTOT : TGIF_XTOT;
        uLastTgifX = (TgifPortrait) ? TGIF_XOFF : TGIF_YOFF;
        uLastTgifY = (TgifPortrait) ? TGIF_YTOT + TGIF_YOFF : TGIF_XTOT + TGIF_XOFF;

        uYshift = uLastTgifY;
 	uXshift = uLastTgifX;
 	
} else {
        if(uTgifPlotCount<uTgifPlotsPerPage)
               	uTgifPlotCount++;
        else{
               	fprintf(stderr,"error: number of plots > plots per page\n");
              	return;
        }
        
        uXshift = (unsigned int) TGIF_XOFF * 100/uActResolution + (xsize*(uTgifPlotCol-1)*TGIF_XSHIFT);
        uYshift = (unsigned int) TGIF_YOFF * 100/uActResolution + (ysize*(TGIF_YMAX  + (uTgifPlotRow-1)*TGIF_YSHIFT));
               
        if(uTgifPlotCount%uTgif_win_horiz == 0) {
               	uTgifPlotCol = 1;
               	uTgifPlotRow++;
        }else  {
               	uTgifPlotCol++;
        }

        uLastTgifX = uXshift;
        uLastTgifY = uYshift;
        
}	


      


/* default settings for each plot */
iTgifPolyCount = 0;
uActNr     = 0;
uActAngle  = 0;
uActThick  = 1;
uActStyle  = 0;
uActJust   = LEFT;
strcpy(sActColor, psColors[0]);


} /* TGIF_graphics */
/*}}}  */
/***************************************************************************/
...  TERM_PUBLIC void TGIF_text()
TERM_PUBLIC void TGIF_text()
{
TGIF_flush_poly();


} /* TGIF_text */

/*}}}  */
/***************************************************************************/
...  TERM_PUBLIC void TGIF_reset()
TERM_PUBLIC void TGIF_reset()
{
  TGIF_flush_poly();
  iTgifPolyCount=0;
  uTgifPlotCount = 0;
  uTgifPlotRow = 1;
  uTgifPlotCol = 1;


  if(outfile != (FILE *)NULL)
  	fflush(outfile);

} /* TGIF_reset */
/*}}}  */
/***************************************************************************/
...  TERM_PUBLIC void TGIF_linetype(linetype)
TERM_PUBLIC void TGIF_linetype(linetype)
int linetype;
{
unsigned int   ult;


  TGIF_flush_poly();


	if (linetype >= 0)
   		ult = 2+linetype%10;
        else
		ult = linetype + 2;

strcpy(sActColor, psColors[ult]);
uActThick = uLineThick[ult];
if(!TgifSolid)
	uActStyle = uLineStyle[ult];
else {
        if(ult==1)  /* grid */
        	uActStyle = uLineStyle[ult];
        else
                uActStyle = uLineStyle[2];

}

} /* TGIF_linetype */
/*}}}  */
/***************************************************************************/
...  TERM_PUBLIC void TGIF_move(ux, uy)
TERM_PUBLIC void TGIF_move(ux, uy)
unsigned int ux, uy;
{

  uLastTgifX = ux + uXshift;
  uLastTgifY = uYshift-uy;

  if(eTgifState == INPOLY)
  	TGIF_flush_poly();



} /* TGIF_move */
/*}}}  */
/***************************************************************************/
...  TERM_PUBLIC void TGIF_vector(ux, uy)
TERM_PUBLIC void TGIF_vector(ux, uy)
unsigned int ux, uy;
{

ux = ux + uXshift;
uy = uYshift - uy;



        if(eTgifState == NEWPOLY){
                uBuffX[0] = uLastTgifX;
                uBuffY[0] = uLastTgifY;
                iTgifPolyCount=1;
                eTgifState = INPOLY;
        }

        uBuffX[iTgifPolyCount] = ux;
        uBuffY[iTgifPolyCount] = uy;
        uLastTgifX = ux;
        uLastTgifY = uy;
        iTgifPolyCount++;
        eTgifState = INPOLY;

        if(iTgifPolyCount == TGIF_MAXPOLY){
                TGIF_flush_poly();

        }

} /* TGIF_vector */
/*}}}  */
/***************************************************************************/
...  TERM_PUBLIC void TGIF_arrow(sx,sy,ex,ey,head)
TERM_PUBLIC void TGIF_arrow(sx,sy,ex,ey,head)
unsigned int sx,sy,ex,ey;
TBOOLEAN head;
{

TGIF_flush_poly();

sx = sx + uXshift;
ex = ex + uXshift;
sy = uYshift - sy;
ey = uYshift - ey;


if(head) {
fprintf(outfile,"poly('%s',%d,[\n\t%u,%u,%u,%u],1,%u,1,%u,0,0,%u,0,8,3,0,[\n]).\n",
                       sActColor,2,sx,sy,ex,ey,uActThick,uActNr,uActStyle);
} else  {
fprintf(outfile,"poly('%s',%d,[\n\t%u,%u,%u,%u],1,%u,1,%u,0,0,%u,0,8,3,0,[\n]).\n",
                       sActColor,2,sx,sy,ex,ey,uActThick,uActNr,uActStyle);
}

uActNr++;



uLastTgifX = ex;
uLastTgifY = ey;

} /* TGIF_arrow */
/*}}}  */
/***************************************************************************/
...  TERM_PUBLIC void TGIF_put_text(ux, uy, str)
TERM_PUBLIC void TGIF_put_text(ux, uy, str)
unsigned int ux, uy;
char *str;
{

 unsigned int x,y;
 struct termentry *t = term;

TGIF_flush_poly();

  x = ux + uXshift;
  y = uYshift - uy - t->v_char/2;



if(strlen(str)==0) return;


       fprintf(outfile,
       "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",
       sActColor, x, y, sActFont,uActFontSize,uActJust,uActAngle,uActNr, str);

  uActNr+=2;   

  /* reset font size and font, they might have been changed */
  uActFontSize=uDefaultFontSize; 
  strcpy(sActFont,sDefaultFont);

} /* TGIF_put_text */
/*}}}  */
/***************************************************************************/
...  TERM_PUBLIC int TGIF_text_angle(angle)
TERM_PUBLIC int TGIF_text_angle(angle)
int angle;
{
uActAngle = uTextAngle[angle];      /* 0=waag.  1=senkrecht */
return (TRUE);
} /* TGIF_text_angle */

/*}}}  */
/***************************************************************************/
...  TERM_PUBLIC int TGIF_justify_text(mode)
TERM_PUBLIC int TGIF_justify_text(mode)
enum JUSTIFY mode;
{
uActJust = mode;
return (TRUE);
} /* TGIF_justify_text */

/*}}}  */
/***************************************************************************/
...  TERM_PUBLIC void TGIF_point(ux, uy, number)
TERM_PUBLIC void TGIF_point(ux, uy, number)
unsigned int ux, uy;
int number;
{
double p;      /* all pointtypes fit in a (x +/-p)x(y +/-p) box */
double x,y;   



x = (double)(ux + uXshift);
y = (double)(uYshift - uy);

p=pointsize*4.0;  
if(p==(double)0.0)	
	p=0.1;
	
TGIF_flush_poly();

if (number != -1)
   number = number % 10;
switch (number)
  {
  case -1:
    fprintf(outfile, "poly('%s',2,[\n\t%u,%u,%u,%u],0,1,1,%u,0,0,0,0,8,3,0,[\n]).\n",
            sActColor, x, y, x+1, y+1, uActNr++);
    break;
  case 0:
    ...  x
    /* x */
    /* taking thickness 2 for cross & plus            | */
    fprintf(outfile,"group([\n");
    fprintf(outfile, "poly('%s',2,[\n\t%.1f,%.1f,%.1f,%.1f],0,2,1,%u,0,0,0,0,8,3,0,[\n]).\n",
            sActColor, x-p, y-p, x+p, y+p, uActNr++);
    fprintf(outfile, "poly('%s',2,[\n\t%.1f,%.1f,%.1f,%.1f],0,2,1,%u,0,0,0,0,8,3,0,[\n]).\n",
            sActColor, x-p, y+p, x+p, y-p, uActNr++);
    uActNr += 2;
    fprintf(outfile,"],\n%u,0,[\n]).\n",uActNr++);
    break;
    /*}}}  */
  case 1:
    ...  +
    /* plus */
    /* taking thickness 2 for cross & plus            | */
    fprintf(outfile,"group([\n");
    fprintf(outfile, "poly('%s',2,[\n\t%.1f,%.1f,%.1f,%.1f],0,2,1,%u,0,0,0,0,8,3,0,[\n]),\n",
            sActColor, x, y-p-1, x, y+p+1, uActNr++);
    fprintf(outfile, "poly('%s',2,[\n\t%.1f,%.1f,%.1f,%.1f],0,2,1,%u,0,0,0,0,8,3,0,[\n])\n",
            sActColor, x-p-1, y, x+p+1, y, uActNr++);
    uActNr+=2;
    fprintf(outfile,"],\n%u,0,[\n]).\n",uActNr++);
    break;
    /*}}}  */
  case 2:
    ...  circle
    /* circle */
    fprintf(outfile, "oval('%s',%.1f,%.1f,%.1f,%.1f,0,1,1,%u,0,0,0,[\n]).\n",
            sActColor, x-p, y-p, x+p, y+p, uActNr);
    uActNr++;
    break;
    /*}}}  */
  case 3:
    ...  box
    /* box */
    fprintf(outfile, "box('%s',%.1f,%.1f,%.1f,%.1f,0,1,1,%u,0,0,0,[\n]).\n",
            sActColor, x-p, y-p, x+p, y+p, uActNr);
    uActNr++;
    break;
    /*}}}  */
  case 4:
    ...  diamond
    fprintf(outfile, "poly('%s',5,[\n%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f],0,1,1,%u,0,0,0,0,8,3,0,[\n]).\n",
            sActColor, x, y+p+1, x+p+1, y, x,y-p-1, x-p-1, y, x, y+p+1, uActNr);
    uActNr++;
    break;
    /*}}}  */
  case 5:
    ...  triangle
    /* triangle */
    fprintf(outfile, "poly('%s',4,[\n%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f],0,1,1,%u,0,0,0,0,8,3,0,[\n]).\n",
            sActColor, x-p+1, y, x+p-1, y+p+1, x+p-1,y-p-1, x-p+1, y, uActNr);
    uActNr++;
    break;
    /*}}}  */
  case 6:
    ...  filled circle
    /* filled circle */
    fprintf(outfile, "oval('%s',%.1f,%.1f,%.1f,%.1f,1,1,1,%u,0,0,0,[\n]).\n",
            sActColor, x-p, y-p, x+p, y+p, uActNr);
    uActNr++;
    break;
    /*}}}  */
  case 7:
    ...  filled box
    /* filled box */
    fprintf(outfile, "box('%s',%.1f,%.1f,%.1f,%.1f,1,1,1,%u,0,0,0,[\n]).\n",
            sActColor, x-p, y-p, x+p, y+p, uActNr);
    uActNr++;
    break;
    /*}}}  */
  case 8:
    ...  filled diamond
    /* filled rotated box */
    fprintf(outfile, "poly('%s',5,[\n%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f],0,1,1,%u,0,1,0,0,8,3,0,[\n]).\n",
            sActColor, x, y+p+1, x+p+1, y, x,y-p-1, x-p-1, y, x, y+p+1, uActNr);
    uActNr++;
    break;
    /*}}}  */
  case 9:
    ...  filled triangle
    /* filled dreieck */
    fprintf(outfile, "poly('%s',4,[\n%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f],0,1,1,%u,0,1,0,0,8,3,0,[\n]).\n",
            sActColor, x-p+1, y, x+p-1, y+p+1, x+p-1,y-p-1, x-p+1, y, uActNr);
    uActNr++;
    break;
    /*}}}  */
  } /* switch */
} /* TGIF_point */
    
/*}}}  */
/***************************************************************************/
...  TERM_PUBLIC void TGIF_set_pointsize(size)  
TERM_PUBLIC void  TGIF_set_pointsize(size)
double size;
 {
  	uActPointSize = size;
 }
/*}}}  */
/***************************************************************************/
...  TERM_PUBLIC int TGIF_set_font(font)  
TERM_PUBLIC int TGIF_set_font(font)  /* Entry font as added by DJL in post.trm */
char *font;
{
char name[32];
int  size,sep;

        sep=strcspn(font,",");
        strncpy(name,font,sep); name[sep]='\0';
        size=uActFontSize; sscanf (&(font[sep+1]),"%d",&size);
        uActFontSize=size;
        return TRUE;
}

/*}}}  */
/***************************************************************************/

#endif /* TERM_BODY */

#ifdef TERM_TABLE

TERM_TABLE_START(tgif_driver)

	"tgif",
	"TGIF X11 [mode] [x,y] [dashed] [\042font\042 [fontsize]]",
	TGIF_XMAX, TGIF_YMAX, TGIF_VCHAR, TGIF_HCHAR,
	TGIF_VTIC, TGIF_HTIC, TGIF_options, TGIF_init, TGIF_reset,
	TGIF_text, null_scale, TGIF_graphics, TGIF_move, TGIF_vector,
	TGIF_linetype, TGIF_put_text, TGIF_text_angle,
	TGIF_justify_text, TGIF_point, TGIF_arrow, TGIF_set_font,
	TGIF_set_pointsize,TERM_CAN_MULTIPLOT

TERM_TABLE_END(tgif_driver)

#undef LAST_TERM

#define LAST_TERM tgif_driver

#endif /* TERM_TABLE */

#endif /* TERM_PROTO_ONLY */

#ifdef TERM_HELP
START_HELP(tgif)
"1 tgif",
"?set terminal tgif",
"?tgif",
"The Tgif driver supports different pointsizes (with `set pointsize`),",
"different label fonts  and  font  sizes  (with  e.g.",
"  set  label  \"Hallo\" at x,y  font \"Helvetica,34\".",
"",
"Multiplot is implemented in two different manners:",
"  The first one is the standard gnuplot multiplot feature:",
"  set term tgif",
"  set output \"file.obj\"",
"  set multiplot",
"  set origin x01,y01",
"  set size  xs,ys",
"  plot ...",
"      ...",
"  set origin x02,y02",
"  plot ...",
"  set nomultiplot",
"",
"The second multiplot version is implemented in the driver itself",
"and can be chosen via an option [n,m] where n are the number of",
"plots in x- and m the number of plots in y-direction.",
"The advantage is that everything is scaled and placed automatically",
"without the need of setting origin and size, the plots keep there",
"natural x/y proportions of 3/2. Of cours it is possible to change",
"the size to something different.",
"If methods are selected, the standard method is chosen and a warning",
"message appears",
"",
" Syntax:",
"    set terminal tgif {<mode>} {<[x,y]>} {<dashed>} \\",
"                          {\"<fontname>\"} {<fontsize>}",
" where <mode> is `portrait` or `landscape`,",
"<[x,y]> specify the number of plots in x and y direction on the page,",
"<dashed> is either `solid` or `dashed`,",
""<fontname>" is the name of a valid PostScript font, and",
"<fontsize> specifies the size of the PostScript font.",
"",
"Examples:",
"    set term tgif                     # -> portrait",
"    set term tgif \"Times-Roman\" 24                 # -> portrait",
"    set term tgif landscape           # -> landscape",
"    set term tgif landscape solid     # -> landscape and solid lines. The", 
"                                      #    latter is usefull for color plots",
"all the above examples work with the standard multiplot now ",
"some examples for using the built-in multiplot mechanism:",
"    set term tgif portrait [2,4]      # -> 3 plots in x and 2 in y-direction",
"    set term tgif [1,2]               # -> 1 plot  in x and 2 in y-direction",
"    set term tgif lanfscape [3,3]     # -> landscape",
"                                      #    3 plots  in x and  y-direction"
END_HELP(tgif)
#endif

