1 /*****************************************************************************
5 ** Purpose: Header file for Simple Graphics Package
6 ** Author: Kevin Rosenberg
9 ** This is part of the CTSim program
10 ** Copyright (C) 1983-2000 Kevin Rosenberg
12 ** $Id: sgp.h,v 1.11 2000/07/28 08:28:08 kevin Exp $
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.
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.
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 ******************************************************************************/
35 #include "transformmatrix.h"
55 string m_sWindowTitle;
65 SGPDRIVER_WXWINDOWS = 1,
71 SGPDriver (wxDC* pDC, const char* szWinTitle = "", int xsize = 640, int ysize = 480);
74 SGPDriver (const char* szWinTitle = "", int xsize = 640, int ysize = 480);
78 int getPhysicalXSize () const
79 { return m_iPhysicalXSize; }
81 int getPhysicalYSize () const
82 { return m_iPhysicalYSize; }
84 const string& getWindowTitle () const
85 { return m_sWindowTitle; }
88 { return (m_idDriver & SGPDRIVER_WXWINDOWS); }
91 { return (m_idDriver & SGPDRIVER_G2); }
105 int m_iPhysicalXSize; // Physical Window size
106 int m_iPhysicalYSize;
107 const SGPDriver m_driver;
109 double xw_min; // Window extents
113 double xv_min; // Viewport extents
117 double viewNDC[4]; // Viewport array for clip_rect()
119 int m_iCurrentPhysicalX;
120 int m_iCurrentPhysicalY;
121 double m_dCurrentWorldX;
122 double m_dCurrentWorldY;
124 bool m_bRecalcTransform;
126 // Master coordinates are coordinates before CTM transformation
127 // World coordinates are coordinates defined by setWindow()
128 // Normalized device coordinates range from 0. to 1. in both axes
129 TransformationMatrix2D wc_to_ndc; // World coord to NDC matrix
130 TransformationMatrix2D mc_to_ndc; // Master to NDC
131 TransformationMatrix2D ndc_to_mc; // NDC to Master
132 TransformationMatrix2D m_ctm; // Current transfromation matrix
134 void calc_transform ();
147 enum { // Codes for marker symbols
148 MARK_POINT = 0, // small dot
149 MARK_SQUARE = 1, // empty square
150 MARK_FSQUARE = 2, // filled square
151 MARK_DIAMOND = 3, // empty diamond
152 MARK_FDIAMOND = 4, // filled diamond
153 MARK_CROSS = 5, // cross
154 MARK_XCROSS = 6, // x
155 MARK_CIRCLE = 7, // open circle
156 MARK_FCIRCLE = 8, // filled circle
157 MARK_BSQUARE = 9, // big open square
158 MARK_BDIAMOND = 10, // big open diamond
160 static const int MARK_COUNT = 11;
161 static const unsigned char MARKER_BITMAP[MARK_COUNT][5];
163 SGP (const SGPDriver& driver);
165 void drawCircle (const double r);
166 void drawArc (double start, double stop, const double r);
167 void drawRect (double xmin, double ymin, double xmax, double ymax);
168 void lineAbs(double x, double y);
169 void moveAbs(double x, double y);
170 void lineRel(double x, double y);
171 void moveRel(double x, double y);
172 void drawText(const char *szMessage);
173 void drawText(const string& rsMessage);
174 void polylineAbs(double x[], double y[], int n);
175 void markerAbs (double x, double y);
176 void markerRel(double x, double y);
177 void pointAbs(double x, double y);
178 void pointRel(double x, double y);
181 void setWindow (double xmin, double ymin, double xmax, double ymax);
182 void setViewport (double xmin, double ymin, double xmax, double ymax);
183 void frameViewport();
185 void setColor (int icol);
186 void setLineStyle (int style);
187 void setTextSize (double height);
188 void setTextAngle (double angle);
189 void setTextColor (int iFGcolor, int iBGcolor);
190 void setMarker (int idMarker, int color);
193 void ctmSet (const TransformationMatrix2D& m);
194 void preTranslate (double x, double y);
195 void postTranslate (double x, double y);
196 void preScale (double sx, double sy);
197 void postScale (double sx, double sy);
198 void preRotate (double theta);
199 void postRotate (double theta);
200 void preShear (double shrx, double shry);
201 void postShear (double shrx, double shry);
202 void transformNDCtoMC (double* x, double* y);
203 void transformMCtoNDC (double* x, double* y);
204 void transformMCtoNDC (double xIn, double yIn, double* xOut, double* yOut);
206 void stylusNDC (double x, double y, bool beam);
207 void pointNDC (double x, double y);
208 void markerNDC (double x, double y);