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.18 2000/09/04 09:06:46 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"
56 string m_sWindowTitle;
66 SGPDRIVER_WXWINDOWS = 1,
72 SGPDriver (wxDC* pDC, int xsize = 640, int ysize = 480);
75 SGPDriver (const char* szWinTitle = "", int xsize = 640, int ysize = 480);
79 int getPhysicalXSize () const
80 { return m_iPhysicalXSize; }
82 int getPhysicalYSize () const
83 { return m_iPhysicalYSize; }
85 const string& getWindowTitle () const
86 { return m_sWindowTitle; }
89 { return (m_idDriver & SGPDRIVER_WXWINDOWS); }
92 { return (m_idDriver & SGPDRIVER_G2); }
101 void setDC (wxDC* dc)
110 int m_iPhysicalXSize; // Physical Window size
111 int m_iPhysicalYSize;
114 double xw_min; // Window extents
118 double xv_min; // Viewport extents
122 double viewNDC[4]; // Viewport array for clip_rect()
124 int m_iCurrentPhysicalX;
125 int m_iCurrentPhysicalY;
126 double m_dCurrentWorldX;
127 double m_dCurrentWorldY;
129 bool m_bRecalcTransform;
130 double m_dPointsPerPixel; // points (72pt/in) per screen pixel;
132 // Master coordinates are coordinates before CTM transformation
133 // World coordinates are coordinates defined by setWindow()
134 // Normalized device coordinates range from 0. to 1. in both axes
135 TransformationMatrix2D wc_to_ndc; // World coord to NDC matrix
136 TransformationMatrix2D mc_to_ndc; // Master to NDC
137 TransformationMatrix2D ndc_to_mc; // NDC to Master
138 TransformationMatrix2D m_ctm; // Current transfromation matrix
140 void calc_transform ();
142 static RGBColor s_aRGBColor[];
143 static int s_iRGBColorCount;
161 enum { // Codes for marker symbols
162 MARK_POINT = 0, // small dot
163 MARK_SQUARE = 1, // empty square
164 MARK_FSQUARE = 2, // filled square
165 MARK_DIAMOND = 3, // empty diamond
166 MARK_FDIAMOND = 4, // filled diamond
167 MARK_CROSS = 5, // cross
168 MARK_XCROSS = 6, // x
169 MARK_CIRCLE = 7, // open circle
170 MARK_FCIRCLE = 8, // filled circle
171 MARK_BSQUARE = 9, // big open square
172 MARK_BDIAMOND = 10, // big open diamond
174 static const int MARK_COUNT = 11;
175 static const unsigned char MARKER_BITMAP[MARK_COUNT][5];
177 SGP (const SGPDriver& driver);
179 void drawCircle (const double r);
180 void drawArc (const double r, double start, double stop);
181 void drawRect (double xmin, double ymin, double xmax, double ymax);
182 void lineAbs(double x, double y);
183 void moveAbs(double x, double y);
184 void lineRel(double x, double y);
185 void moveRel(double x, double y);
186 void drawText(const char *szMessage);
187 void drawText(const string& rsMessage);
188 void polylineAbs(double x[], double y[], int n);
189 void markerAbs (double x, double y);
190 void markerRel(double x, double y);
191 void pointAbs(double x, double y);
192 void pointRel(double x, double y);
195 void setWindow (double xmin, double ymin, double xmax, double ymax);
196 void setViewport (double xmin, double ymin, double xmax, double ymax);
197 void frameViewport();
199 void setColor (int icol);
200 void setLineStyle (int style);
201 void setTextSize (double height);
202 void setTextNDCSize (double height);
203 void setTextPointSize (double height);
204 void setTextAngle (double angle);
205 void setTextColor (int iFGcolor, int iBGcolor);
206 void setPenWidth (int width);
207 void setMarker (int idMarker, int color);
208 void setRasterOp (int ro);
210 void getWindow (double& xmin, double& ymin, double& xmax, double& ymax);
211 void getViewport (double& xmin, double& ymin, double& xmax, double& ymax);
212 void getTextExtent (const char *szText, double* x, double* y);
213 double getCharHeight ();
214 double getCharWidth ();
215 SGPDriver& getDriver() {return m_driver;}
216 const SGPDriver& getDriver() const {return m_driver;}
219 void ctmSet (const TransformationMatrix2D& m);
220 void preTranslate (double x, double y);
221 void postTranslate (double x, double y);
222 void preScale (double sx, double sy);
223 void postScale (double sx, double sy);
224 void preRotate (double theta);
225 void postRotate (double theta);
226 void preShear (double shrx, double shry);
227 void postShear (double shrx, double shry);
228 void transformNDCtoMC (double* x, double* y);
229 void transformMCtoNDC (double* x, double* y);
230 void transformMCtoNDC (double xIn, double yIn, double* xOut, double* yOut);
232 void stylusNDC (double x, double y, bool beam);
233 void pointNDC (double x, double y);
234 void markerNDC (double x, double y);
237 void setDC (wxDC* pDC);
243 C_BLACK = 0, // color codes
288 RGBColor (int r, int g, int b)
295 int getGreen () const