r24: Set up include files for conditional INTERACTIVE_GRAPHICS
[ctsim.git] / include / sgp.h
1 /*****************************************************************************
2 **  This is part of the CTSim program
3 **  Copyright (C) 1983-2000 Kevin Rosenberg
4 **
5 **  $Id: sgp.h,v 1.4 2000/04/30 19:17:35 kevin Exp $
6 **  $Log: sgp.h,v $
7 **  Revision 1.4  2000/04/30 19:17:35  kevin
8 **  Set up include files for conditional INTERACTIVE_GRAPHICS
9 **
10 **  Revision 1.3  2000/04/28 18:35:21  kevin
11 **  removed unused files
12 **
13 **  Revision 1.2  2000/04/28 14:14:16  kevin
14 **  *** empty log message ***
15 **
16 **
17 **  This program is free software; you can redistribute it and/or modify
18 **  it under the terms of the GNU General Public License (version 2) as
19 **  published by the Free Software Foundation.
20 **
21 **  This program is distributed in the hope that it will be useful,
22 **  but WITHOUT ANY WARRANTY; without even the implied warranty of
23 **  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24 **  GNU General Public License for more details.
25 **
26 **  You should have received a copy of the GNU General Public License
27 **  along with this program; if not, write to the Free Software
28 **  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
29 ******************************************************************************/
30 /*----------------------------------------------------------------------*/
31 /*                 Standard Graphics Package Header File                */
32 /*----------------------------------------------------------------------*/
33
34 #ifndef __H_SGP
35 #define __H_SGP
36
37 #include "kstddef.h"
38 #include "kmath.h"
39
40 /* device names */
41
42 #define CRTDEV  1
43 #define PRTDEV  2
44 #define MEMDEV  4
45 #define FILEDEV 8
46
47 /* linestyles */
48
49 #define LS_NOLINE 0
50 #define LS_SOLID  0xffff
51 #define LS_DASH1  0xff00
52 #define LS_DASH2  0xf0f0
53 #define LS_DASH3  0xcccc
54 #define LS_DASH4  0xff3e
55 #define LS_DOTTED 0xaaaa
56
57 #define MAXDASH    4
58 #define MAXCOLOR   63
59
60 /* data structures */
61
62 struct device_st {
63         int open;                       /* TRUE if device is open for output */
64         int xsize, ysize;               /* Size of device in pixels */
65         int xmin, ymin;                 /* smallest coordinates */
66         int xmax, ymax;                 /* Maximum coordinates */
67         int colormax;                   /* Maximum color number of device */
68         int style;                      /* Current linestyle of device */
69         int width;                      /* Current width of device */
70         int color;                      /* Current color of device */
71         int icurx, icury;               /* Current position */
72         int icwidth, icheight;          /* Size of characters in pixels */
73         int cfore, cback;               /* Character foregnd & backgnd colors */
74         float asp;                      /* Aspect ratio.  Multipy x coord */
75         int (*dotfunc)(int x1, int y1, int color);              /* Dot function for device */
76         int (*linefunc)(int x1, int y1, int x2, int y2, int color);             /* Line function for device */
77         unsigned int nbytes;            /* Size of buffer in bytes */
78         char *buf;                      /* Pointer to buffer */
79         unsigned int bufseg, bufoff;    /* Buffer memory location */
80         int mode;                       /* Device mode */
81 };
82
83 struct charsp_st {
84         float width, height;            /* size of characters in NDC */
85         float textangle;                /* text angle in radians */
86         float charupangle;              /* character up angle */
87         int font;                       /* font for characters */
88         int updir, textdir;             /* text direct & character orientation */
89         int fore, back;                 /* foreground & background color */
90                                         /* if back = -1, then transparent back */
91 };
92
93 struct state_st {
94         int foregnd, backgnd;           /* current foregound & background colors */
95         int linestyle;                  /* current 16 bit linestyle */
96         int linewidth;                  /* current width of line (in pixels) */
97         int marktype;                   /* current marker type */
98         int markcolor;                  /* current marker color */
99         float xndc, yndc;               /* current position in NDC */
100 };
101
102 typedef struct device_st DEVICE;
103 typedef struct charsp_st CHARSPEC;
104 typedef struct state_st GRFSTATE;
105
106 struct point    {double x, y, z;};
107
108
109 /******************************************************************
110  *                                                                *
111  *   GRAPH.H                                                      *
112  *                                                                *
113  *   Max R. Dursteler     Dec 1983                                *
114  *   12405 Village Square Terrace                                 *
115  *   Rockville Md. 20852                                          *
116  ******************************************************************
117  */
118
119 /* Constants */
120
121 /* Flagcodes for motion directions */
122 #define XPLUS   001     /* right */
123 #define XMINUS  002     /* left */
124 #define YPLUS   004     /* up */
125 #define YMINUS  010     /* down */
126
127 /* Codes for marker symbols */
128 #define POINT    0      /* small dot */
129 #define SQUARE   1      /* empty square */
130 #define FSQUARE  2      /* filled square */
131 #define DIAMOND  3      /* empty diamond */
132 #define FDIAMOND 4      /* filled diamond */
133 #define CROSS    5      /* cross */
134 #define XCROSS   6      /* x */
135 #define CERCLE   7      /* open circle */
136 #define FCERCLE  8      /* filled circle */
137 #define BSQUARE  9      /* big open square */
138 #define BDIAMOND 10     /* big open diamond */
139
140 #define NMARKERS 11     /* Number of available symbol types */
141
142 /*-------------------------------------------------------------------------*/
143
144 #define PSET   0                /* codes for raster merging */
145 #define PRESET 1
146 #define OR     2
147 #define AND    3
148 #define XOR    4
149
150 /*-------------------------------------------------------------------------*/
151
152 #define X_STKMIN  10            /* joystick specific values */
153 #define X_STKMAX 313
154 #define Y_STKMIN  10
155 #define Y_STKMAX 313
156
157 #define X_LOCMAX  (X_STKMAX - X_STKMIN);        /* range from readloc() */
158 #define Y_LOCMAX  (Y_STKMAX - Y_STKMIN);        /*   = 0 to LOCMAX */
159
160 #define JOYSTK1   0             /* device names */
161 #define JOYSTK2   1
162
163 #define BUTT_DONE  2            /* Right joystick button to end a command */
164 #define BUTT_START 1            /* Left joystick button to start a command */
165 #define BUTT_BOTH  3            /* Both buttons pressed */
166
167 #define RL_ERROR  -1            /* readloc() return codes */
168 #define RL_OFF     0
169 #define RL_ON      1
170
171 /*-------------------------------------------------------------------------*/
172
173 struct raster_st {
174     int type;
175     int xmin, ymin;
176     int xmax, ymax;
177 };
178
179 typedef struct raster_st RASTER;
180
181 /*-------------------------------------------------------------------------*/
182
183
184 /* circle.c */
185 void circle(const double r);
186 void drawarc(double start, double stop, const double r);
187 /* ctm.c */
188 int ctm_xlat_pre_2(double x, double y);
189 int ctm_xlat_post_2(double x, double y);
190 int ctm_scale_pre_2(double sx, double sy);
191 int ctm_scale_post_2(double sx, double sy);
192 int ctm_rotate_pre_2(double theta);
193 int ctm_rotate_post_2(double theta);
194 int ctm_shear_pre_2(double shrx, double shry);
195 int ctm_shear_post_2(double shrx, double shry);
196 int xlat_gmtx_2(GRFMTX_2D m, double x, double y);
197 int scale_gmtx_2(GRFMTX_2D m, double sx, double sy);
198 int shear_gmtx_2(GRFMTX_2D m, double shrx, double shry);
199 int rotate_gmtx_2(GRFMTX_2D m, double theta);
200 int ident_gmtx_2(GRFMTX_2D m);
201 int mult_gmtx_2(GRFMTX_2D a, GRFMTX_2D b, GRFMTX_2D c);
202 int invert_gmtx_2(GRFMTX_2D a, GRFMTX_2D b);
203 double determ_gmtx_2(GRFMTX_2D a);
204 /* drawbox.c */
205 int drawbox(double xmin, double ymin, double xmax, double ymax);
206 /* sgp.c */
207 int gp_init_2(void);
208 int window2(double xmin, double ymin, double xmax, double ymax);
209 int window_2(double xmin, double ymin, double xmax, double ymax);
210 int viewprt2(double xmin, double ymin, double xmax, double ymax);
211 int viewport_2(double xmin, double ymin, double xmax, double ymax);
212 int framevpt(void);
213 int calc_wc_to_ndc(void);
214 int calc_ndc_to_mc(void);
215 int wc_to_ndc(double xw, double yw, double *xn, double *yn);
216 int ndc_to_wc(double xn, double yn, double *xw, double *yw);
217 int color(int icol);
218 int linestyle(int style);
219 int line_abs_2(double x, double y);
220 int lineabs2(double x, double y);
221 int move_abs_2(double x, double y);
222 int moveabs2(double x, double y);
223 int line_rel_2(double x, double y);
224 int linerel2(double x, double y);
225 int move_rel_2(double x, double y);
226 int moverel2(double x, double y);
227 int draw_text(char *message);
228 int drawtext(char *message);
229 int polylnabs2(double x[], double y[], int n);
230 int markabs2(double x, double y);
231 int markrel2(double x, double y);
232 int pntabs2(double x, double y);
233 int pntrel2(double x, double y);
234 int ctm_clr_2(void);
235 int ctm_get_2(GRFMTX_2D m);
236 int ctm_set_2(GRFMTX_2D m);
237 int ctm_pre_mult_2(GRFMTX_2D m);
238 int ctm_post_mult_2(GRFMTX_2D m);
239 /* sgpdrive.c */
240 int initgrf2(void);
241 int initdevice(int dev, int mode, int xsize, int ysize);
242 int opendevice(int dev);
243 int closedevice(int dev);
244 int termdevice(int dev);
245 void stylus(double x, double y, int beam);
246 int pntndc(double x, double y);
247 int markndc(double x, double y);
248 GRFSTATE *inqstate(void);
249 int gp_set_aspect(int dev, double asp);
250 void setlinestyle(int style);
251 int setlinewidth(int wid);
252 DEVICE *inqdev(int dev);
253 int settext(double width, double height, double textangle, int font);
254 int settextclr(int fore, int back);
255 int setcolor(int fore);
256 int setbackg(int back);
257 int initmarker(int marker, int color);
258 int settextdir(int direction);
259 int charsize(double wid, double height);
260 int textangle(double angle);
261 int drivtext(char *message);
262 int termgrf2(void);
263 int flushdevice(int dev);
264 /* sgptext.c */
265 void wrtsymbol(int sym, int x, int y, DEVICE *dev);
266 void wrtchar(int ch, int x, int y, CHARSPEC *cspec, DEVICE *dev);
267 void wrttext(char txtstr[], int x, int y, CHARSPEC *cspec, DEVICE *dev);
268 void crtcolor(int mode, int *f, int *b);
269
270
271 #endif