[BACK]Return to ggi.trm CVS log [TXT][DIR] Up to [local] / OpenXM_contrib / gnuplot / term

Annotation of OpenXM_contrib/gnuplot/term/ggi.trm, Revision 1.1.1.1

1.1       ohara       1: /*
                      2:  * $Id: ggi.trm,v 1.1.6.1 2000/10/20 18:41:59 lhecking Exp $
                      3:  *
                      4:  */
                      5:
                      6: /* GNUPLOT - ggi.trm */
                      7:
                      8: /*[
                      9:  * Copyright 1986 - 1993, 1998   Thomas Williams, Colin Kelley
                     10:  *
                     11:  * Permission to use, copy, and distribute this software and its
                     12:  * documentation for any purpose with or without fee is hereby granted,
                     13:  * provided that the above copyright notice appear in all copies and
                     14:  * that both that copyright notice and this permission notice appear
                     15:  * in supporting documentation.
                     16:  *
                     17:  * Permission to modify the software is granted, but not the right to
                     18:  * distribute the complete modified source code.  Modifications are to
                     19:  * be distributed as patches to the released version.  Permission to
                     20:  * distribute binaries produced by compiling modified sources is granted,
                     21:  * provided you
                     22:  *   1. distribute the corresponding source modifications from the
                     23:  *    released version in the form of a patch file along with the binaries,
                     24:  *   2. add special version identification to distinguish your version
                     25:  *    in addition to the base release version number,
                     26:  *   3. provide your name and address as the primary contact for the
                     27:  *    support of your modified version, and
                     28:  *   4. retain our contact information in regard to use of the base
                     29:  *    software.
                     30:  * Permission to distribute the released version of the source code along
                     31:  * with corresponding source modifications in the form of a patch file is
                     32:  * granted with same provisions 2 through 4 for binary distributions.
                     33:  *
                     34:  * This software is provided "as is" without express or implied warranty
                     35:  * to the extent permitted by applicable law.
                     36: ]*/
                     37:
                     38: /*
                     39:  * This file is included by ../term.c.
                     40:  *
                     41:  * This terminal driver supports:
                     42:  *   General Graphics Interface
                     43:  *
                     44:  * AUTHOR
                     45:  *  Cesar Crusius <crusius@leland.stanford.edu>
                     46:  *
                     47:  * See also: http://www.ggi-project.org/
                     48:  *
                     49:  * send your comments or suggestions to (info-gnuplot@dartmouth.edu).
                     50:  */
                     51:
                     52: #include "driver.h"
                     53: #ifdef TERM_REGISTER
                     54: register_term(ggi)
                     55: #endif
                     56:
                     57: #ifdef TERM_PROTO
                     58: TERM_PUBLIC void GGI_graphics __PROTO((void));
                     59: TERM_PUBLIC void GGI_init __PROTO((void)); /* Done. */
                     60: TERM_PUBLIC void GGI_linetype __PROTO((int));
                     61: TERM_PUBLIC void GGI_move __PROTO((unsigned int,unsigned int));
                     62: TERM_PUBLIC void GGI_options __PROTO((void)); /* Done. */
                     63: TERM_PUBLIC void GGI_put_text __PROTO((unsigned int,unsigned int,char*));
                     64: TERM_PUBLIC void GGI_reset __PROTO((void)); /* Done. */
                     65: TERM_PUBLIC void GGI_text __PROTO((void));
                     66: TERM_PUBLIC void GGI_vector __PROTO((unsigned int,unsigned int));
                     67: #define GOT_GGI_PROTO
                     68: #endif
                     69:
                     70: #define GGI_XMAX 800
                     71: #define GGI_YMAX 600
                     72: #define GGI_VCHAR 8
                     73: #define GGI_HCHAR 8
                     74: #define GGI_VTIC 8
                     75: #define GGI_HTIC 8
                     76:
                     77: #ifndef TERM_PROTO_ONLY
                     78: #ifdef TERM_BODY
                     79:
                     80: #include <ggi/ggi.h>
                     81: #include <ggi/wmh.h>
                     82:
                     83: /* First to some global variables
                     84:  *
                     85:  * GGIvisual is our 'piece of paper.'
                     86:  * GGIborderColor and axixColor have the obvious meanings.
                     87:  * GGIcolors are the colors for linestyles 0 and up.
                     88:  * GGImap is for initializing colors.
                     89:  * GGIx,GGIy are the current coordinates.
                     90:  * GGIxmax,GGIymax are the maximum coordinates in the visual.
                     91:  */
                     92: static ggi_visual_t GGIvisual=NULL;
                     93: static ggi_pixel GGIborderColor;
                     94: static ggi_pixel GGIaxisColor;
                     95: static ggi_pixel GGIblack;
                     96: static ggi_pixel GGIcolors[6];
                     97: static ggi_color GGImap;
                     98: static unsigned int GGIx,GGIy;
                     99: static unsigned int GGIxmax,GGIymax;
                    100: static unsigned int Xenv;
                    101:
                    102: static void init_ggi_driver()
                    103: {
                    104:     ggi_pixel GGIwhite,GGIred,GGIgreen,GGIblue,GGIcyan,GGImagenta;
                    105:     ggi_pixel GGIyellow;
                    106:     if(GGIvisual==NULL)
                    107:     {
                    108:        if(ggiInit()) {}
                    109:        if(NULL==(GGIvisual=ggiOpen(NULL))) ggiExit();
                    110:        if(ggiSetSimpleMode(GGIvisual,GGI_AUTO,GGI_AUTO,GGI_AUTO,GT_AUTO)) ggiExit();
                    111:     }
                    112:     ggiAddFlags(GGIvisual, GGIFLAG_ASYNC);
                    113:     GGImap.r=0xFFFF; GGImap.g=0xFFFF; GGImap.b=0xFFFF; GGIwhite=ggiMapColor(GGIvisual,&GGImap);
                    114:     GGImap.r=0x0000; GGImap.g=0x0000; GGImap.b=0x0000; GGIblack=ggiMapColor(GGIvisual,&GGImap);
                    115:     GGImap.r=0xFFFF; GGImap.g=0x0000; GGImap.b=0x0000; GGIred=ggiMapColor(GGIvisual,&GGImap);
                    116:     GGImap.r=0x0000; GGImap.g=0xFFFF; GGImap.b=0x0000; GGIgreen=ggiMapColor(GGIvisual,&GGImap);
                    117:     GGImap.r=0x0000; GGImap.g=0x0000; GGImap.b=0xFFFF; GGIblue=ggiMapColor(GGIvisual,&GGImap);
                    118:     GGImap.r=0x0000; GGImap.g=0xFFFF; GGImap.b=0xFFFF; GGIcyan=ggiMapColor(GGIvisual,&GGImap);
                    119:     GGImap.r=0xFFFF; GGImap.g=0x0000; GGImap.b=0xFFFF; GGImagenta=ggiMapColor(GGIvisual,&GGImap);
                    120:     GGImap.r=0xFFFF; GGImap.g=0xFFFF; GGImap.b=0x0000; GGIyellow=ggiMapColor(GGIvisual,&GGImap);
                    121:     GGIborderColor=GGIwhite;
                    122:     GGIaxisColor=GGIwhite;
                    123:     GGIcolors[0]=GGIred;
                    124:     GGIcolors[1]=GGIgreen;
                    125:     GGIcolors[2]=GGIblue;
                    126:     GGIcolors[3]=GGImagenta;
                    127:     GGIcolors[4]=GGIcyan;
                    128:     GGIcolors[5]=GGIyellow;
                    129: }
                    130:
                    131: /* Called begore a graphic is displayed */
                    132: TERM_PUBLIC void GGI_graphics()
                    133: {
                    134:     if(!Xenv)
                    135:     {
                    136:        init_ggi_driver();
                    137:        return;
                    138:     }
                    139:     ggiSetGCForeground(GGIvisual,GGIblack);
                    140:     ggiDrawBox(GGIvisual,0,0,GGIxmax,GGIymax);
                    141: }
                    142:
                    143: /*
                    144:  * init
                    145:  * -----------------------
                    146:  * Called only once, when the terminal is initialized. We have to open the visual here because it
                    147:  * is during 'init' that we have to change the terminal dimensions (xmax, ymax).
                    148:  */
                    149: TERM_PUBLIC void GGI_init()
                    150: {
                    151:     ggi_mode GGImode;
                    152:     if(ggiInit()) { }
                    153:     if(NULL==(GGIvisual=ggiOpen(NULL))) ggiExit();
                    154:     if(ggiSetSimpleMode(GGIvisual,GGI_AUTO,GGI_AUTO,GGI_AUTO,GT_AUTO)) ggiExit();
                    155:     ggiGetMode(GGIvisual,&GGImode);
                    156:     term->xmax=GGImode.virt.x;
                    157:     term->ymax=GGImode.virt.y;
                    158:     GGIxmax=term->xmax-1;
                    159:     GGIymax=term->ymax-1;
                    160:     Xenv=!ggiWmhInit();
                    161:     if(!(Xenv=!ggiWmhAttach(GGIvisual))) ggiWmhDetach(GGIvisual);
                    162:     else Xenv=!ggiWmhSetTitle(GGIvisual,"GGI Gnuplot Driver");
                    163:     if(!Xenv)
                    164:     {
                    165:        ggiWmhDetach(GGIvisual);
                    166:        ggiWmhExit();
                    167:        ggiClose(GGIvisual);
                    168:        GGIvisual=NULL;
                    169:        ggiExit();
                    170:     }
                    171:     else init_ggi_driver();
                    172: }
                    173:
                    174: TERM_PUBLIC void GGI_linetype(linetype)
                    175: int linetype;
                    176: {
                    177:     if(linetype==-2) ggiSetGCForeground(GGIvisual,GGIborderColor);
                    178:     if(linetype==-1) ggiSetGCForeground(GGIvisual,GGIaxisColor);
                    179:     if(linetype<0) return;
                    180:     if(linetype>=6) linetype%=6;
                    181:     ggiSetGCForeground(GGIvisual,GGIcolors[linetype]);
                    182: }
                    183:
                    184: TERM_PUBLIC void GGI_move(x,y)
                    185: unsigned int x,y;
                    186: {
                    187:     GGIx=x;
                    188:     GGIy=y;
                    189: }
                    190:
                    191: TERM_PUBLIC void GGI_options() { }
                    192: /* Called when terminal is terminated */
                    193: TERM_PUBLIC void GGI_reset()
                    194: {
                    195:     if(GGIvisual!=NULL)
                    196:     {
                    197:        if(Xenv)
                    198:        {
                    199:            ggiWmhDetach(GGIvisual);
                    200:            ggiWmhExit();
                    201:        }
                    202:        ggiClose(GGIvisual);
                    203:        ggiExit();
                    204:     }
                    205: }
                    206:
                    207: TERM_PUBLIC void GGI_put_text(x,y,str)
                    208: unsigned int x,y;
                    209: char *str;
                    210: {
                    211:     ggi_pixel current_foreground;
                    212:     ggiGetGCForeground(GGIvisual,&current_foreground);
                    213:     ggiSetGCForeground(GGIvisual,GGIborderColor);
                    214:     ggiPuts(GGIvisual,x,GGIymax-y-4,str);
                    215:     ggiSetGCForeground(GGIvisual,current_foreground);
                    216: }
                    217:
                    218: /* Wait for a key to be pressed and exit graphics mode if running in console mode. */
                    219: TERM_PUBLIC void GGI_text(void)
                    220: {
                    221:     ggiFlush(GGIvisual);
                    222:     if(Xenv) return;
                    223:     ggiGetc(GGIvisual);
                    224:     ggiClose(GGIvisual);
                    225:     ggiExit();
                    226:     GGIvisual=NULL;
                    227: }
                    228:
                    229: TERM_PUBLIC void GGI_vector(x,y)
                    230: unsigned int x,y;
                    231: {
                    232:     ggiDrawLine(GGIvisual,GGIx,GGIymax-GGIy,x,GGIymax-y);
                    233:     GGIx=x;
                    234:     GGIy=y;
                    235: }
                    236:
                    237: #endif /* TERM_BODY */
                    238:
                    239: #ifdef TERM_TABLE
                    240:
                    241: TERM_TABLE_START(ggi_driver)
                    242:     "ggi", "GGI target",
                    243:     GGI_XMAX, GGI_YMAX, GGI_VCHAR, GGI_HCHAR, GGI_VTIC, GGI_HTIC,
                    244:     GGI_options, GGI_init, GGI_reset, GGI_text,
                    245:     null_scale, GGI_graphics, GGI_move, GGI_vector,
                    246:     GGI_linetype, GGI_put_text,
                    247:     0, /* angle */
                    248:     0, /* justify text */
                    249:     0, /* point */
                    250:     0, /* arrow */
                    251:     0, /* set_font */
                    252:     0, /* set_pointsize */
                    253:     0, /* flags */
                    254:     0, /* suspend */
                    255:     0, /* resume */
                    256:     0, /* fillbox */
                    257:     0 /* linewidth */
                    258: TERM_TABLE_END(ggi_driver)
                    259:
                    260: #endif /* TERM_TABLE */
                    261: #endif /* TERM_PROTO_ONLY */
                    262:
                    263: #ifdef TERM_HELP
                    264: START_HELP(ggi)
                    265: "1 ggi",
                    266: "?set terminal ggi",
                    267: "?ggi",
                    268: " The GGI terminal generates output to a GGI target."
                    269: END_HELP(ggi)
                    270: #endif

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>