projects
/
ctsim.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
r626: no message
[ctsim.git]
/
libctgraphics
/
ezplot.cpp
diff --git
a/libctgraphics/ezplot.cpp
b/libctgraphics/ezplot.cpp
index be1c5d257309c0033e482dd5cfa1d530966035dd..79a4ebbb908c226babb1f72f2e54e03b16d0a328 100644
(file)
--- a/
libctgraphics/ezplot.cpp
+++ b/
libctgraphics/ezplot.cpp
@@
-4,9
+4,9
@@
** EZPLOT
**
** This is part of the CTSim program
** EZPLOT
**
** This is part of the CTSim program
-** Copyright (
C) 1983-2000
Kevin Rosenberg
+** Copyright (
c) 1983-2001
Kevin Rosenberg
**
**
-** $Id: ezplot.cpp,v 1.
29 2001/01/12 16:41:5
6 kevin Exp $
+** $Id: ezplot.cpp,v 1.
32 2001/03/10 23:14:1
6 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
**
** 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
@@
-36,14
+36,12
@@
static const int DEF_CURVE_CLR = C_RED;
EZPlotCurve::EZPlotCurve (const double* xData, const double* yData, int n)
EZPlotCurve::EZPlotCurve (const double* xData, const double* yData, int n)
-: x(
NULL), y(NULL
)
+: x(
new double[n]), y(new double[n]
)
{
{
- x = new double [n];
- y = new double [n];
-
- int copyCount = n * sizeof(double);
- memcpy (x, xData, copyCount);
- memcpy (y, yData, copyCount);
+ for (int i = 0; i < n; i++) {
+ x[i] = xData[i];
+ y[i] = yData[i];
+ }
m_iPointCount = n;
}
m_iPointCount = n;
}
@@
-94,7
+92,7
@@
EZPlot::addCurve (const float x[], const double y[], int num)
}
void
}
void
-EZPlot::addCurve (const double
x[], const float y[]
, int num)
+EZPlot::addCurve (const double
* const x, const float* const y
, int num)
{
double* dy = new double [num];
{
double* dy = new double [num];
@@
-108,7
+106,7
@@
EZPlot::addCurve (const double x[], const float y[], int num)
void
void
-EZPlot::addCurve (const double
x[], const double y[]
, int num)
+EZPlot::addCurve (const double
* const x, const double* const y
, int num)
{
if (num < 1)
return;
{
if (num < 1)
return;
@@
-468,14
+466,11
@@
EZPlot::getLegend (unsigned int iCurve) const
void
EZPlot::plot (SGP* pSGP)
{
void
EZPlot::plot (SGP* pSGP)
{
-
if (m_vecCurves.size() <= 0)
return;
if (m_vecCurves.size() <= 0)
return;
-
m_pSGP = pSGP;
m_pSGP = pSGP;
-
m_pSGP->setWindow (0., 0., 1., 1.);
if (s_textsize == TRUE)
m_pSGP->setWindow (0., 0., 1., 1.);
if (s_textsize == TRUE)
@@
-483,6
+478,8
@@
EZPlot::plot (SGP* pSGP)
charheight = m_pSGP->getCharHeight();
charwidth = m_pSGP->getCharWidth();
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];
const EZPlotCurve& firstCurve = *m_vecCurves[0];
@@
-670,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);
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 * char
height);
+ symbol
(iSymbol, symwidth, sym
height);
}
}
++iLegend; // move to next legend position
}
}
++iLegend; // move to next legend position
@@
-818,10
+815,6
@@
EZPlot::plot (SGP* pSGP)
m_pSGP->setLineStyle (SGP::LS_SOLID);
drawAxes();
m_pSGP->setLineStyle (SGP::LS_SOLID);
drawAxes();
- // size of symbol in NDC
- double symwidth = charwidth;
- double symheight = charheight;
-
double clipRect[4];
double clipRect[4];
@@
-849,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]);
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 x2Clip = x2;
-
double y2Clip = y2;
if (clip_rect (x1, y1, x2Clip, y2Clip, clipRect)) {
double y2Clip = y2;
if (clip_rect (x1, y1, x2Clip, y2Clip, clipRect)) {
-
m_pSGP->moveAbs (x1, y1);
m_pSGP->moveAbs (x1, y1);
-
m_pSGP->lineAbs (x2Clip, y2Clip);
m_pSGP->lineAbs (x2Clip, y2Clip);
-
}
}
-
x1 = x2;
x1 = x2;
-
y1 = y2;
y1 = y2;
-
}
}
if (iSym > 0) {
}
}
if (iSym > 0) {
-
int iSymFreq = getSymbolFreq (iCurve);
m_pSGP->setLineStyle (SGP::LS_SOLID);
double x = convertWorldToNDC_X (pCurve->x[0]);
int iSymFreq = getSymbolFreq (iCurve);
m_pSGP->setLineStyle (SGP::LS_SOLID);
double x = convertWorldToNDC_X (pCurve->x[0]);
@@
-1146,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);
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);
}
}
}
}