X-Git-Url: http://git.kpe.io/?p=ctsim.git;a=blobdiff_plain;f=libctgraphics%2Fsgp.cpp;h=bc789cf0fea2f685eed345e84b778d4b58741177;hp=4d70f8cfe965f265f99f06d723542bd7d8603883;hb=08a5cd04c3994d5ea24713b9b000791bd2e406fe;hpb=c85a5b31119b4e0903144c55441717a7ad1e0b8b diff --git a/libctgraphics/sgp.cpp b/libctgraphics/sgp.cpp index 4d70f8c..bc789cf 100644 --- a/libctgraphics/sgp.cpp +++ b/libctgraphics/sgp.cpp @@ -7,7 +7,7 @@ ** This is part of the CTSim program ** Copyright (C) 1983-2000 Kevin Rosenberg ** -** $Id: sgp.cpp,v 1.6 2000/07/28 10:51:31 kevin Exp $ +** $Id: sgp.cpp,v 1.7 2000/07/29 19:50:08 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 @@ -29,6 +29,27 @@ #include "sgp.h" +RGBColor SGP::s_aRGBColor[] = +{ + RGBColor (0, 0, 0), + RGBColor (0, 0, 128), + RGBColor (0, 128, 0), + RGBColor (0, 128, 128), + RGBColor (128, 0, 0), + RGBColor (128, 0, 128), + RGBColor (128, 128, 0), + RGBColor (80, 80, 80), + RGBColor (160, 160, 160), + RGBColor (0, 0, 255), + RGBColor (0, 255, 0), + RGBColor (0, 255, 255), + RGBColor (255, 0, 0), + RGBColor (255, 0, 255), + RGBColor (255, 255, 0), + RGBColor (255, 255, 255), +}; + +int SGP::s_iRGBColorCount = sizeof(s_aRGBColor) / sizeof(class RGBColor); #ifdef HAVE_WXWINDOWS SGPDriver::SGPDriver (wxDC* pDC, const char* szWinTitle = "", int xsize = 640, int ysize = 480) @@ -72,11 +93,11 @@ SGP::SGP (const SGPDriver& driver) setWindow (0., 0., 1., 1.); setViewport (0., 0., 1., 1.); moveAbs (0., 0.); - m_iCurrentPhysicalX = 0; - m_iCurrentPhysicalY = 0; + stylusNDC (0., 0., false); setTextAngle (0.); setTextSize (1. / 25.); + setColor (C_BLACK); } @@ -89,10 +110,14 @@ SGP::stylusNDC (double x, double y, bool beam) yp = m_iPhysicalYSize - yp; if (beam) { +#if HAVE_WXWINDOWS if (m_driver.isWX()) m_driver.idWX()->DrawLine (m_iCurrentPhysicalX, m_iCurrentPhysicalY, xp, yp); +#endif +#if HAVE_G2_H if (m_driver.isG2()) g2_line (m_driver.idG2(), m_iCurrentPhysicalX, m_iCurrentPhysicalY, xp, yp); +#endif } m_iCurrentPhysicalX = xp; m_iCurrentPhysicalY = yp; @@ -115,10 +140,14 @@ SGP::pointNDC (double x, double y) void SGP::eraseWindow () { +#if HAVE_G2_H if (m_driver.isG2()) g2_clear (m_driver.idG2()); +#endif +#if HAVE_WXWINDOWS if (m_driver.isWX()) m_driver.idWX()->Clear(); +#endif } // NAME @@ -186,6 +215,21 @@ SGP::setTextColor (int iFGcolor, int iBGcolor) void SGP::setColor (int icol) { + if (icol >= 0 && icol < s_iRGBColorCount) { +#if HAVE_G2_H + if (m_driver.isG2()) { + int iInk = g2_ink (m_driver.idG2(), s_aRGBColor[icol].getRed() / 255., s_aRGBColor[icol].getGreen() / 255., s_aRGBColor[icol].getBlue() / 255.); + g2_pen (m_driver.idG2(), iInk); + } +#endif +#if HAVE_WXWINDOWS + if (m_driver.isWX()) { + wxColor colour (s_aRGBColor[icol].getRed(), s_aRGBColor[icol].getGreen(), s_aRGBColor[icol].getBlue()); + wxPen pen (colour, 1, wxSOLID); + m_driver.idWX()->SetPen (pen); + } +#endif + } } void @@ -355,12 +399,17 @@ SGP::drawText (const char *pszMessage) stylusNDC (xndc, yndc, false); // move to location +#if HAVE_G2_H if (m_driver.isG2()) { - if (m_dTextAngle == 0.) - g2_string (m_driver.idG2(), m_iCurrentPhysicalX, m_iCurrentPhysicalY, const_cast(pszMessage)); + g2_string (m_driver.idG2(), m_iCurrentPhysicalX, m_iCurrentPhysicalY, const_cast(pszMessage)); } +#endif +#if HAVE_WXWINDOWS if (m_driver.isWX()) { + wxString str (pszMessage); + m_driver.idWX()->DrawRotatedText (str, m_iCurrentPhysicalX, m_iCurrentPhysicalY, m_dTextAngle); } +#endif }