r59: First functional version of SDF library for X-window
[ctsim.git] / include / sgp.h
index d913ede25d3f2ed589f39fdd3021104585d80e46..32671396ac548bc61ca6690255fea66cfcaa0c68 100644 (file)
@@ -2,8 +2,11 @@
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
-**  $Id: sgp.h,v 1.6 2000/05/11 14:07:00 kevin Exp $
+**  $Id: sgp.h,v 1.7 2000/05/24 22:48:17 kevin Exp $
 **  $Log: sgp.h,v $
+**  Revision 1.7  2000/05/24 22:48:17  kevin
+**  First functional version of SDF library for X-window
+**
 **  Revision 1.6  2000/05/11 14:07:00  kevin
 **  Added support for Windows NT
 **
@@ -33,6 +36,7 @@
 **  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                */
 /*----------------------------------------------------------------------*/
 #include "kstddef.h"
 #include "kmath.h"
 
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#if HAVE_G2_H
+#include "g2.h"
+#include "g2_X11.h"
+#endif
+
 #ifdef __cplusplus
 extern "C" {
 #endif /* __cplusplus */
@@ -70,6 +83,36 @@ extern "C" {
 
 /* 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 */
@@ -117,16 +160,6 @@ typedef struct state_st GRFSTATE;
 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 */
@@ -160,41 +193,10 @@ struct point      {double x, y, z;};
 
 /*-------------------------------------------------------------------------*/
 
-#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;
-
-/*-------------------------------------------------------------------------*/
-
-
 /* circle.c */
-void circle(const double r);
-void drawarc(double start, double stop, const double r);
+void sgp2_draw_circle(const double r);
+void sgp2_draw_arc(double start, double stop, const double r);
+
 /* ctm.c */
 void ctm_xlat_pre_2(double x, double y);
 void ctm_xlat_post_2(double x, double y);
@@ -212,66 +214,67 @@ 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 */
-void drawbox(double xmin, double ymin, double xmax, double ymax);
+void sgp2_draw_rect (double xmin, double ymin, double xmax, double ymax);
+
 /* sgp.c */
-void gp_init_2(void);
-void window2(double xmin, double ymin, double xmax, double ymax);
-void window_2(double xmin, double ymin, double xmax, double ymax);
-void viewprt2(double xmin, double ymin, double xmax, double ymax);
-void viewport_2(double xmin, double ymin, double xmax, double ymax);
-void framevpt(void);
+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 color(int icol);
-void linestyle(int style);
-void line_abs_2(double x, double y);
-void lineabs2(double x, double y);
-void move_abs_2(double x, double y);
-void moveabs2(double x, double y);
-void line_rel_2(double x, double y);
-void linerel2(double x, double y);
-void move_rel_2(double x, double y);
-void moverel2(double x, double y);
-void draw_text(char *message);
-void drawtext(char *message);
-void polylnabs2(double x[], double y[], int n);
-void markabs2(double x, double y);
-void markrel2(double x, double y);
-void pntabs2(double x, double y);
-void pntrel2(double x, double y);
+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.c */
-int initgrf2(void);
+int _sgp2_init_dev(SGP_ID gid);
 int initdevice(int dev, int mode, int xsize, int ysize);
 int opendevice(int dev);
 void closedevice(int dev);
 void termdevice(int dev);
-void stylus(double x, double y, int beam);
-void pntndc(double x, double y);
-void markndc(double x, double y);
+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);
 void gp_set_aspect(int dev, double asp);
 void setlinestyle(int style);
 void setlinewidth(int wid);
 DEVICE *inqdev(int dev);
-void settext(double width, double height, double textangle, int font);
+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);
-void charsize(double wid, double height);
-void textangle(double angle);
-void drivtext(char *message);
+void _sgp2_dev_text(SGP_ID gid, char *message);
 void termgrf2(void);
 void flushdevice(int dev);
+
 /* sgptext.c */
 void wrtsymbol(int sym, int x, int y, DEVICE *dev);
 void wrtchar(int ch, int x, int y, CHARSPEC *cspec, DEVICE *dev);