+/*****************************************************************************
+** This is part of the CTSim program
+** Copyright (C) 1983-2000 Kevin Rosenberg
+**
+** $Id: sgp.h,v 1.10 2000/06/19 19:04:05 kevin Exp $
+**
+** This program is free software; you can redistribute it and/or modify
+** it under the terms of the GNU General Public License (version 2) as
+** published by the Free Software Foundation.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+******************************************************************************/
+
/*----------------------------------------------------------------------*/
/* Standard Graphics Package Header File */
/*----------------------------------------------------------------------*/
#ifndef __H_SGP
#define __H_SGP
-#include "kstddef.h"
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
-/* Write modes for CPIX_?????() routines */
+#include "ctsupport.h"
-#define CPIX_WRT 0
-#define CPIX_XOR 1
-#define CPIX_AND 2
-#define CPIX_OR 3
+#if HAVE_G2_H
+extern "C" {
+#include "g2.h"
+#include "g2_X11.h"
+}
+#endif
/* device names */
/* data structures */
+struct sgp_window_st {
+ int pw_xsize; /* Physical Window size */
+ int pw_ysize;
+ char title[256];
+ int g2_id;
+ double xw_min; /* Window extents */
+ double yw_min;
+ double xw_max;
+ double yw_max;
+ double xv_min; /* Viewport extents */
+ double yv_min;
+ double xv_max;
+ double yv_max;
+ double view[4]; /* Viewport array for clip_rect() */
+ double curx; /* Current stylus position in world coords */
+ double cury;
+ int recalc_mc_to_ndc;
+ int recalc_ndc_to_mc;
+ GRFMTX_2D wc_to_ndc_x; /* World coord to NDC matrix */
+ GRFMTX_2D mc_to_ndc_x; /* Master to NDC */
+ GRFMTX_2D ndc_to_mc_x; /* NDC to Master */
+ GRFMTX_2D ctm_2_x; /* Current transfromation matrix */
+
+ int phys_curx;
+ int phys_cury;
+};
+
+typedef struct sgp_window_st SGP_WINDOW;
+typedef struct sgp_window_st *SGP_ID;
+
struct device_st {
int open; /* TRUE if device is open for output */
int xsize, ysize; /* Size of device in pixels */
struct point {double x, y, z;};
-/******************************************************************
- * *
- * GRAPH.H *
- * *
- * Max R. Dursteler Dec 1983 *
- * 12405 Village Square Terrace *
- * Rockville Md. 20852 *
- ******************************************************************
- */
-
/* Constants */
/* Flagcodes for motion directions */
/*-------------------------------------------------------------------------*/
-#define X_STKMIN 10 /* joystick specific values */
-#define X_STKMAX 313
-#define Y_STKMIN 10
-#define Y_STKMAX 313
-
-#define X_LOCMAX (X_STKMAX - X_STKMIN); /* range from readloc() */
-#define Y_LOCMAX (Y_STKMAX - Y_STKMIN); /* = 0 to LOCMAX */
-
-#define JOYSTK1 0 /* device names */
-#define JOYSTK2 1
-
-#define BUTT_DONE 2 /* Right joystick button to end a command */
-#define BUTT_START 1 /* Left joystick button to start a command */
-#define BUTT_BOTH 3 /* Both buttons pressed */
-
-#define RL_ERROR -1 /* readloc() return codes */
-#define RL_OFF 0
-#define RL_ON 1
-
-/*-------------------------------------------------------------------------*/
-
-struct raster_st {
- int type;
- int xmin, ymin;
- int xmax, ymax;
-};
-
-typedef struct raster_st RASTER;
-
-/*-------------------------------------------------------------------------*/
-
-typedef double GRFMTX_2D[3][3];
-typedef double GRFMTX_3D[4][4];
-
-
-/* circle.c */
-void circle(const double r);
-void drawarc(double start, double stop, const double r);
-/* cliprect.c */
-int cliprect(double *x1, double *y1, double *x2, double *y2, const double rect[4]);
-/* crt_line.c */
-void crt_line(int x1, int y1, int x2, int y2, int color);
-int prtline(int func, int x1, int y1, int x2, int y2, int arg1, int arg2);
-void crt_line_style(int style);
-/* crt_wdot.c */
-void crt_wdot(int x, int y, int c);
-void ega_wdot(int x, int y, int c);
-void prtdot(int x, int y, int c);
-void prtndc(void);
-void cpix_set(int x, int y, int c);
-void cpix_init(void);
-void cpix_set_wrt_mode(int mode);
-void cpix_calc_addr(void);
-void cpix_set_addr(int addr);
-void cpix_inc_col(void);
-int cpix_get_addr(void);
-void cpix_term(void);
-void cpix_setcolor(int c);
-void cpix_set_at_addr(int addr, int c);
-void cpix_inc_row(void);
-void cpix_set_color(int c);
-/* ctm.c */
-int ctm_xlat_pre_2(double x, double y);
-int ctm_xlat_post_2(double x, double y);
-int ctm_scale_pre_2(double sx, double sy);
-int ctm_scale_post_2(double sx, double sy);
-int ctm_rotate_pre_2(double theta);
-int ctm_rotate_post_2(double theta);
-int ctm_shear_pre_2(double shrx, double shry);
-int ctm_shear_post_2(double shrx, double shry);
-int xlat_gmtx_2(GRFMTX_2D m, double x, double y);
-int scale_gmtx_2(GRFMTX_2D m, double sx, double sy);
-int shear_gmtx_2(GRFMTX_2D m, double shrx, double shry);
-int rotate_gmtx_2(GRFMTX_2D m, double theta);
-int ident_gmtx_2(GRFMTX_2D m);
-int mult_gmtx_2(GRFMTX_2D a, GRFMTX_2D b, GRFMTX_2D c);
-int invert_gmtx_2(GRFMTX_2D a, GRFMTX_2D b);
+/* circle.cpp */
+void sgp2_draw_circle(const double r);
+void sgp2_draw_arc(double start, double stop, const double r);
+
+/* ctm.cpp */
+void ctm_xlat_pre_2(double x, double y);
+void ctm_xlat_post_2(double x, double y);
+void ctm_scale_pre_2(double sx, double sy);
+void ctm_scale_post_2(double sx, double sy);
+void ctm_rotate_pre_2(double theta);
+void ctm_rotate_post_2(double theta);
+void ctm_shear_pre_2(double shrx, double shry);
+void ctm_shear_post_2(double shrx, double shry);
+void xlat_gmtx_2(GRFMTX_2D m, double x, double y);
+void scale_gmtx_2(GRFMTX_2D m, double sx, double sy);
+void shear_gmtx_2(GRFMTX_2D m, double shrx, double shry);
+void rotate_gmtx_2(GRFMTX_2D m, double theta);
+void ident_gmtx_2(GRFMTX_2D m);
+void mult_gmtx_2(GRFMTX_2D a, GRFMTX_2D b, GRFMTX_2D c);
+void invert_gmtx_2(GRFMTX_2D a, GRFMTX_2D b);
double determ_gmtx_2(GRFMTX_2D a);
-/* drawbox.c */
-int drawbox(double xmin, double ymin, double xmax, double ymax);
-/* gp.c */
-int gptrace(int state);
-int viewprt3(double xmin, double ymin, double zmin, double xmax, double ymax, double zmax);
-int window3(double xmin, double ymin, double xmax, double ymax);
-int setproj(int pr, double x, double y, double z);
-int setvrp(double x, double y, double z);
-int setvpn(double x, double y, double z);
-int setvup(double x, double y, double z);
-int viewdepth(double front, double back);
-int gpfrontclip(int on_off);
-int gpbackclip(int on_off);
-int calcnper(void);
-int calcnpar(void);
-int calcrot(double rot[5][5]);
-int calcpertrans(void);
-int calcpartrans(void);
-int matident(double mtx[5][5]);
-int matmult(double premtx[5][5], double postmtx[5][5], double result[5][5]);
-int crossprod(struct point *v, struct point *w, struct point *result);
-int transform(double mtx[5][5], double *x, double *y, double *z);
-int homotrans(double mtx[5][5], double *x, double *y, double *z, double *w);
-int moveabs3(double x, double y, double z);
-int moverel3(double xr, double yr, double zr);
-int lineabs3(double x, double y, double z);
-int linerel3(double xr, double yr, double zr);
-int drawline(double xinput, double yinput, double zinput);
-int mastertondc(double *x, double *y, double *z);
-int checkchange(void);
-int initgrf3(void);
-int termgrf3(void);
-int matwrite(double mtx[5][5]);
-int pyr_edge(double x, double y, double z, int *pos);
-int clippyramid(double *x1, double *y1, double *z1, double *x2, double *y2, double *z2, int *accept);
-int cube_edge(double x, double y, double z, int *pos);
-int clipcube(double *x1, double *y1, double *z1, double *x2, double *y2, double *z2, int *accept);
-/* pickbox.c */
-int pickbox(int dev, int *xmin, int *ymin, int *xmax, int *ymax, int xtab[], int ytab[]);
-/* pickloc.c */
-int pickloc(int dev, int *xloc, int *yloc, int xtab[], int ytab[]);
-/* pixblock.c */
-int readblock(char array[], int x1, int y1, int x2, int y2);
-int writeblock(char array[], int x1, int y1, int mode);
-char *allocblock(int x1, int y1, int x2, int y2);
-/* readloc.c */
-int readloc(int dev, int *x, int *y);
-int loc_to_ndc(int xloc, int yloc, float *xndc, float *yndc);
-int readbutt(int dev);
-/* sgp.c */
-int gp_init_2(void);
-int window2(double xmin, double ymin, double xmax, double ymax);
-int window_2(double xmin, double ymin, double xmax, double ymax);
-int viewprt2(double xmin, double ymin, double xmax, double ymax);
-int viewport_2(double xmin, double ymin, double xmax, double ymax);
-int framevpt(void);
-int calc_wc_to_ndc(void);
-int calc_ndc_to_mc(void);
-int wc_to_ndc(double xw, double yw, double *xn, double *yn);
-int ndc_to_wc(double xn, double yn, double *xw, double *yw);
-int color(int icol);
-int linestyle(int style);
-int line_abs_2(double x, double y);
-int lineabs2(double x, double y);
-int move_abs_2(double x, double y);
-int moveabs2(double x, double y);
-int line_rel_2(double x, double y);
-int linerel2(double x, double y);
-int move_rel_2(double x, double y);
-int moverel2(double x, double y);
-int draw_text(char *message);
-int drawtext(char *message);
-int polylnabs2(double x[], double y[], int n);
-int markabs2(double x, double y);
-int markrel2(double x, double y);
-int pntabs2(double x, double y);
-int pntrel2(double x, double y);
-int ctm_clr_2(void);
-int ctm_get_2(GRFMTX_2D m);
-int ctm_set_2(GRFMTX_2D m);
-int ctm_pre_mult_2(GRFMTX_2D m);
-int ctm_post_mult_2(GRFMTX_2D m);
-/* sgpdrive.c */
-int initgrf2(void);
+
+/* drawbox.cpp */
+void sgp2_draw_rect (double xmin, double ymin, double xmax, double ymax);
+
+/* sgp.cpp */
+SGP_ID sgp2_init (int xsize, int ysize, const char *title);
+void sgp2_close (SGP_ID gid);
+void sgp2_set_active_win (SGP_ID);
+SGP_ID sgp2_get_active_win (void);
+void sgp2_clear (void);
+void sgp2_window(double xmin, double ymin, double xmax, double ymax);
+void sgp2_viewport(double xmin, double ymin, double xmax, double ymax);
+void sgp2_frame_vpt(void);
+void calc_wc_to_ndc(void);
+void calc_ndc_to_mc(void);
+void wc_to_ndc(double xw, double yw, double *xn, double *yn);
+void ndc_to_wc(double xn, double yn, double *xw, double *yw);
+void sgp2_color(int icol);
+void sgp2_line_style(int style);
+void sgp2_line_abs(double x, double y);
+void sgp2_move_abs(double x, double y);
+void sgp2_line_rel(double x, double y);
+void sgp2_move_rel(double x, double y);
+void sgp2_draw_text(char *message);
+void sgp2_polyline_abs(double x[], double y[], int n);
+void sgp2_mark_abs(double x, double y);
+void sgp2_mark_rel(double x, double y);
+void sgp2_point_abs(double x, double y);
+void sgp2_point_rel(double x, double y);
+void charsize(double wid, double height);
+void textangle(double angle);
+void ctm_clr_2(void);
+void ctm_get_2(GRFMTX_2D m);
+void ctm_set_2(GRFMTX_2D m);
+void ctm_pre_mult_2(GRFMTX_2D m);
+void ctm_post_mult_2(GRFMTX_2D m);
+
+/* sgpdrive.cpp */
+int _sgp2_init_dev(SGP_ID gid);
int initdevice(int dev, int mode, int xsize, int ysize);
int opendevice(int dev);
-int closedevice(int dev);
-int termdevice(int dev);
-void stylus(double x, double y, int beam);
-int pntndc(double x, double y);
-int markndc(double x, double y);
+void closedevice(int dev);
+void termdevice(int dev);
+void _sgp2_stylus(SGP_ID gid, double x, double y, int beam);
+void pntndc (SGP_ID gid, double x, double y);
+void markndc (SGP_ID gid, double x, double y);
GRFSTATE *inqstate(void);
-int gp_set_aspect(int dev, double asp);
+void gp_set_aspect(int dev, double asp);
void setlinestyle(int style);
-int setlinewidth(int wid);
+void setlinewidth(int wid);
DEVICE *inqdev(int dev);
-int settext(double width, double height, double textangle, int font);
-int settextclr(int fore, int back);
-int setcolor(int fore);
-int setbackg(int back);
+void _sgp2_set_text(SGP_ID gid, double width, double height, double textangle, int font);
+void settextclr(int fore, int back);
+void setcolor(int fore);
+void setbackg(int back);
int initmarker(int marker, int color);
int settextdir(int direction);
-int charsize(double wid, double height);
-int textangle(double angle);
-int drivtext(char *message);
-int termgrf2(void);
-int flushdevice(int dev);
-/* sgptext.c */
-int wrtsymbol(int sym, int x, int y, DEVICE *dev);
-int wrtchar(int ch, int x, int y, CHARSPEC *cspec, DEVICE *dev);
-int wrttext(char txtstr[], int x, int y, CHARSPEC *cspec, DEVICE *dev);
+void _sgp2_dev_text(SGP_ID gid, char *message);
+void termgrf2(void);
+void flushdevice(int dev);
+
+/* sgptext.cpp */
+void wrtsymbol(int sym, int x, int y, DEVICE *dev);
+void wrtchar(int ch, int x, int y, CHARSPEC *cspec, DEVICE *dev);
+void wrttext(char txtstr[], int x, int y, CHARSPEC *cspec, DEVICE *dev);
void crtcolor(int mode, int *f, int *b);
-/* trackloc.c */
-int trackloc(int dev, int *xloc, int *yloc, int (*loc_on)(int x, int y), int (*loc_off)(int x, int y));
+
#endif