** This is part of the CTSim program
** Copyright (C) 1983-2000 Kevin Rosenberg
**
-** $Id: sgp.cpp,v 1.11 2000/08/27 20:32:55 kevin Exp $
+** $Id: sgp.cpp,v 1.12 2000/08/31 08:38:58 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
#ifdef HAVE_WXWINDOWS
SGPDriver::SGPDriver (wxDC* pDC, int xsize = 640, int ysize = 480)
- : m_iPhysicalXSize(xsize), m_iPhysicalYSize(ysize), m_idDriver(0)
+ : m_iPhysicalXSize(xsize), m_iPhysicalYSize(ysize), m_idDriver(0), m_pDC(pDC)
{
- m_pDC = pDC;
m_idDriver |= SGPDRIVER_WXWINDOWS;
}
#endif
setTextAngle (0.);
setTextSize (1. / 25.);
setColor (C_BLACK);
-
}
viewNDC[3] = ymax;
}
+void
+SGP::getViewport (double& xmin, double& ymin, double& xmax, double& ymax)
+{
+ xmin = xv_min;
+ ymin = yv_min;
+ xmax = xv_max;
+ ymax = yv_max;
+}
+
// NAME
// frameViewport draw box around viewport
void
SGP::drawCircle (const double r)
{
- drawArc (r, 0.0, 7.0);
+ drawArc (r, 0.0, TWOPI);
}
-// =============================================================
-// draw arc around current center. pass angles and radius
+//==============================================================
+// draw arc around current center. angles in radius
//==============================================================
void
SGP::drawArc (const double r, double start, double stop)
{
- if ((stop-start) > 2 * PI)
- stop = start + 2 * PI;
- if ((start-stop) > 2 * PI)
- stop = start + 2 * PI;
- while (start >= stop)
- stop += 2*PI;
+ if (start > stop) {
+ double temp = start;
+ start = stop;
+ stop = temp;
+ }
double x = r * cos ((double) start);
double y = r * sin ((double) start);
moveRel (x, y); // move from center to start of arc
- double theta = 5 * PI / 180;
- double c = cos(theta);
- double s = sin(theta);
+ const double thetaIncrement = (5 * (TWOPI / 360));
+ double cosTheta = cos(thetaIncrement);
+ double sinTheta = sin(thetaIncrement);
double angle, xp, yp;
- for (angle = start; angle < stop - theta; angle += theta) {
- xp = c * x - s * y;
- yp = s * x + c * y;
- lineRel (xp - x, yp - y);
+ for (angle = start; angle < stop - thetaIncrement; angle += thetaIncrement) {
+ xp = cosTheta * x - sinTheta * y; // translate point by thetaIncrement
+ yp = sinTheta * x + cosTheta * y;
+ lineAbs (xp, yp);
x = xp; y = yp;
}
- c = cos (stop - angle);
- s = sin (stop - angle);
+ double c = cos (stop - angle);
+ double s = sin (stop - angle);
xp = c * x - s * y;
yp = s * x + c * y;
- lineRel (xp - x, yp - y);
+ lineAbs (xp, yp);
- x = r * cos ((double) stop);
- y = r * sin ((double) stop);
+ x = r * cos (stop);
+ y = r * sin (stop);
moveRel (-x, -y); // move back to center of circle
}
{'\076', '\042', '\042', '\042', '\076'}, // big open square
{'\010', '\024', '\042', '\024', '\010'}, // big open diamond
};
+
+
+#if HAVE_WXWINDOWS
+void
+SGP::setDC (wxDC* pDC)
+{
+ if (m_driver.isWX())
+ m_driver.setDC(pDC);
+}
+#endif