r7061: initial property settings
[ctsim.git] / libctgraphics / ezplot.cpp
index ed1ca233d26ef8e8c02e967e78717935a77b64bd..267ad1509d2f3e8b4b0108088a730280b5f07ec9 100644 (file)
@@ -6,7 +6,7 @@
 **  This is part of the CTSim program
 **  Copyright (c) 1983-2001 Kevin Rosenberg
 **
-**  $Id: ezplot.cpp,v 1.31 2001/02/20 04:48:45 kevin Exp $
+**  $Id$
 **
 **  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
@@ -466,14 +466,11 @@ EZPlot::getLegend (unsigned int iCurve) const
 void
 EZPlot::plot (SGP* pSGP)
 {
-
   if (m_vecCurves.size() <= 0)
     return;
   
-
   m_pSGP = pSGP;
 
-
   m_pSGP->setWindow (0., 0., 1., 1.);
   
   if (s_textsize == TRUE)
@@ -481,6 +478,8 @@ EZPlot::plot (SGP* pSGP)
 
   charheight = m_pSGP->getCharHeight();
   charwidth = m_pSGP->getCharWidth();
+  double symheight = charheight * 0.3;       // size of symbol in NDC 
+  double symwidth = symheight;
  
   const EZPlotCurve& firstCurve = *m_vecCurves[0];
 
@@ -668,7 +667,7 @@ EZPlot::plot (SGP* pSGP)
         m_pSGP->setLineStyle (SGP::LS_SOLID);
         for (int j = 0; j < 5; j++) {
           m_pSGP->moveAbs (xmin + j * xinc, y);
-          symbol(iSymbol, 0.5 * charwidth, 0.5 * charheight);
+          symbol (iSymbol, symwidth, symheight);
         }
       }
       ++iLegend;       // move to next legend position 
@@ -816,10 +815,6 @@ EZPlot::plot (SGP* pSGP)
   m_pSGP->setLineStyle (SGP::LS_SOLID);
   drawAxes();
   
-  // size of symbol in NDC 
-  double symwidth = charwidth;
-  double symheight = charheight;
-  
 
   double clipRect[4];
 
@@ -847,27 +842,18 @@ EZPlot::plot (SGP* pSGP)
       for (int i = 1; i < pCurve->m_iPointCount; i++) {
         double x2 = convertWorldToNDC_X (pCurve->x[i]);
         double y2 = convertWorldToNDC_Y (pCurve->y[i]);
-
         double x2Clip = x2;
-
         double y2Clip = y2;
 
         if (clip_rect (x1, y1, x2Clip, y2Clip, clipRect)) {
-
           m_pSGP->moveAbs (x1, y1);
-
           m_pSGP->lineAbs (x2Clip, y2Clip);
-
         }
-
         x1 = x2;
-
         y1 = y2;
-
       } 
     }
     if (iSym > 0) {
-
       int iSymFreq = getSymbolFreq (iCurve);
       m_pSGP->setLineStyle (SGP::LS_SOLID);
       double x = convertWorldToNDC_X (pCurve->x[0]);
@@ -882,7 +868,6 @@ EZPlot::plot (SGP* pSGP)
           if (y >= ygn_min && y <= ygn_max) {
             m_pSGP->moveAbs (x, y);
             symbol (iSym, symwidth, symheight);
-
           }
         }
     }
@@ -1116,11 +1101,12 @@ EZPlot::symbol (int sym, double symwidth, double symheight)
     return;
   
   if (sym == SB_CROSS) {
-    m_pSGP->moveRel (-0.5 * symwidth, -0.5 * symheight);
-    m_pSGP->lineRel (symwidth, symheight);
-    m_pSGP->moveRel (-symwidth, 0.0);
-    m_pSGP->lineRel (symwidth, -symheight);
-    m_pSGP->moveRel (-0.5 * symwidth, 0.5 * symheight);
+    m_pSGP->markerRel (0, 0);
+//    m_pSGP->moveRel (-0.5 * symwidth, -0.5 * symheight);
+//    m_pSGP->lineRel (symwidth, symheight);
+//    m_pSGP->moveRel (-symwidth, 0.0);
+//    m_pSGP->lineRel (symwidth, -symheight);
+//    m_pSGP->moveRel (-0.5 * symwidth, 0.5 * symheight);
   } else if (sym == SB_PLUS) {
     m_pSGP->moveRel (-0.5 * symwidth, 0.0);
     m_pSGP->lineRel (symwidth, 0.0);
@@ -1144,6 +1130,8 @@ EZPlot::symbol (int sym, double symwidth, double symheight)
     m_pSGP->moveRel (-0.5 * symwidth, 0.0);
     m_pSGP->lineRel (symwidth, 0.0);
     m_pSGP->moveRel (-0.5 * symwidth, 0.5 * symheight);
+  } else if (sym == SB_POINT) {
+    m_pSGP->pointRel (0, 0);
   }
 }
 
@@ -1246,7 +1234,7 @@ loop:
 */
 
 static inline double 
-trunc (double x)
+my_trunc (double x)
 {
   double integer;
   
@@ -1277,7 +1265,7 @@ EZPlot::make_numfmt (char *fmtstr, int *fldwid, int *nfrac, double minval, doubl
     
     if (*nfrac < 0) {          // calculate frac 
       delta /= pow (10., floor(logt)); // scale delta 
-      frac = static_cast<int>(fabs(trunc(log10(delta)))) + 1;
+      frac = static_cast<int>(fabs(my_trunc(log10(delta)))) + 1;
       if (frac < 1)
         frac = 1;              // to be safe, add decimal pt 
     } else                     // use users' frac 
@@ -1288,7 +1276,7 @@ EZPlot::make_numfmt (char *fmtstr, int *fldwid, int *nfrac, double minval, doubl
       ++wid;
     sprintf (fmtstr, "%s%d%s%d%s", "%", wid, ".", frac, "g");
   } else {                     // use fixed format 
-    wid = static_cast<int>(trunc(logt)) + 1;
+    wid = static_cast<int>(my_trunc(logt)) + 1;
     if (wid < 1)
       wid = 1;
     if (minval < 0. || maxval < 0.)
@@ -1298,7 +1286,7 @@ EZPlot::make_numfmt (char *fmtstr, int *fldwid, int *nfrac, double minval, doubl
       if (delta >= 0.999999)
         frac = 1;              // add a decimal pt to be safe 
       else
-        frac = static_cast<int>(fabs(trunc(log10(delta)))) + 1;
+        frac = static_cast<int>(fabs(my_trunc(log10(delta)))) + 1;
     } else                     // use users' frac 
       frac = *nfrac;