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