COPASI API  4.16.103
Public Member Functions | Protected Member Functions | Private Attributes | List of all members
C2DCurveData Class Reference

#include <CopasiPlot.h>

Inheritance diagram for C2DCurveData:
Inheritance graph
[legend]
Collaboration diagram for C2DCurveData:
Collaboration graph
[legend]

Public Member Functions

virtual QwtDoubleRect boundingRect () const
 
 C2DCurveData ()
 
 C2DCurveData (const CVector< double > &x, const CVector< double > &y, size_t size)
 
virtual QwtData * copy () const
 
void reallocated (const CVector< double > *pX, const CVector< double > *pY)
 
void setSize (const size_t &size)
 
virtual size_t size () const
 
virtual double x (size_t i) const
 
virtual double y (size_t i) const
 
virtual ~C2DCurveData ()
 

Protected Member Functions

C2DCurveDataoperator= (const C2DCurveData &rhs)
 

Private Attributes

size_t mLastRectangle
 
size_t mMaxSize
 
double mMaxX
 
double mMaxY
 
double mMinX
 
double mMinY
 
const double * mpX
 
const double * mpY
 
size_t mSize
 

Detailed Description

Definition at line 42 of file CopasiPlot.h.

Constructor & Destructor Documentation

C2DCurveData::C2DCurveData ( )

Definition at line 43 of file CopasiPlot.cpp.

Referenced by copy().

43  :
44  QwtData(),
45  mpX(NULL),
46  mpY(NULL),
47  mSize(0),
48  mMaxSize(0),
49  mLastRectangle(0),
50  mMinX(std::numeric_limits<double>::quiet_NaN()),
51  mMaxX(std::numeric_limits<double>::quiet_NaN()),
52  mMinY(std::numeric_limits<double>::quiet_NaN()),
53  mMaxY(std::numeric_limits<double>::quiet_NaN())
54 {}
double mMinX
Definition: CopasiPlot.h:72
double mMaxY
Definition: CopasiPlot.h:75
size_t mSize
Definition: CopasiPlot.h:68
double mMinY
Definition: CopasiPlot.h:74
const double * mpY
Definition: CopasiPlot.h:67
size_t mLastRectangle
Definition: CopasiPlot.h:71
const double * mpX
Definition: CopasiPlot.h:66
size_t mMaxSize
Definition: CopasiPlot.h:69
double mMaxX
Definition: CopasiPlot.h:73
C2DCurveData::C2DCurveData ( const CVector< double > &  x,
const CVector< double > &  y,
size_t  size 
)
C2DCurveData::~C2DCurveData ( )
virtual

Definition at line 72 of file CopasiPlot.cpp.

73 {}

Member Function Documentation

QwtDoubleRect C2DCurveData::boundingRect ( ) const
virtual

Definition at line 99 of file CopasiPlot.cpp.

References C_FLOAT64, min, mLastRectangle, mMaxX, mMaxY, mMinX, mMinY, mpX, mpY, and mSize.

100 {
101  if (mSize <= 0)
102  return QwtDoubleRect(1.0, 1.0, -2.0, -2.0); // invalid
103 
104  if (mLastRectangle == mSize)
105  return QwtDoubleRect(mMinX, mMinY, mMaxX - mMinX, mMaxY - mMinY);
106 
107  const double *xIt = mpX + mLastRectangle;
108  const double *yIt = mpY + mLastRectangle;
109  const double *end = mpX + mSize;
110 
111  mLastRectangle = mSize;
112 
113  // We have to remember whether we have an initial NaN
114  bool MinXisNaN = isnan(mMinX);
115  bool MaxXisNaN = isnan(mMaxX);
116  bool MinYisNaN = isnan(mMinY);
117  bool MaxYisNaN = isnan(mMaxY);
118 
119  while (xIt < end)
120  {
121  const double xv = *xIt++;
122 
123  if (!isnan(xv))
124  {
125  if ((xv < mMinX || MinXisNaN) && xv > -std::numeric_limits< double >::infinity())
126  {
127  mMinX = xv;
128  MinXisNaN = false;
129  }
130 
131  if ((xv > mMaxX || MaxXisNaN) && xv < std::numeric_limits< double >::infinity())
132  {
133  mMaxX = xv;
134  MaxXisNaN = false;
135  }
136  }
137 
138  const double yv = *yIt++;
139 
140  if (!isnan(yv))
141  {
142  if ((yv < mMinY || MinYisNaN) && yv > -std::numeric_limits< double >::infinity())
143  {
144  mMinY = yv;
145  MinYisNaN = false;
146  }
147 
148  if ((yv > mMaxY || MaxYisNaN) && yv < std::numeric_limits< double >::infinity())
149  {
150  mMaxY = yv;
151  MaxYisNaN = false;
152  }
153  }
154  }
155 
156  if (isnan(mMinX + mMaxX + mMinY + mMaxY))
157  return QwtDoubleRect(1.0, 1.0, -2.0, -2.0); // invalid
158 
159  // We need to avoid very small data ranges (absolute and relative)
160  C_FLOAT64 minRange = fabs(mMinX + mMaxX) * 5.e-5 + std::numeric_limits< C_FLOAT64 >::min() * 100.0;
161 
162  if (mMaxX - mMinX < minRange)
163  {
164  mMinX = mMinX - minRange * 0.5;
165  mMaxX = mMaxX + minRange * 0.5;
166  }
167 
168  minRange = fabs(mMinY + mMaxY) * 5e-5 + std::numeric_limits< C_FLOAT64 >::min() * 100.0;
169 
170  if (mMaxY - mMinY < minRange)
171  {
172  mMinY = mMinY - minRange * 0.5;
173  mMaxY = mMaxY + minRange * 0.5;
174  }
175 
176  return QwtDoubleRect(mMinX, mMinY, mMaxX - mMinX, mMaxY - mMinY);
177 }
double mMinX
Definition: CopasiPlot.h:72
double mMaxY
Definition: CopasiPlot.h:75
size_t mSize
Definition: CopasiPlot.h:68
double mMinY
Definition: CopasiPlot.h:74
const double * mpY
Definition: CopasiPlot.h:67
size_t mLastRectangle
Definition: CopasiPlot.h:71
const double * mpX
Definition: CopasiPlot.h:66
#define C_FLOAT64
Definition: copasi.h:92
double mMaxX
Definition: CopasiPlot.h:73
#define min(a, b)
Definition: f2c.h:175
QwtData * C2DCurveData::copy ( ) const
virtual

Definition at line 75 of file CopasiPlot.cpp.

References C2DCurveData().

76 {
77  C2DCurveData * pCopy = new C2DCurveData();
78 
79  *pCopy = *this;
80 
81  return pCopy;
82 }
C2DCurveData & C2DCurveData::operator= ( const C2DCurveData rhs)
protected

Definition at line 194 of file CopasiPlot.cpp.

References mLastRectangle, mMaxSize, mMaxX, mMaxY, mMinX, mMinY, mpX, mpY, and mSize.

195 {
196  mpX = rhs.mpX;
197  mpY = rhs.mpY;
198  mSize = rhs.mSize;
199  mMaxSize = rhs.mMaxSize;
201  mMinX = rhs.mMinX;
202  mMaxX = rhs.mMaxX;
203  mMinY = rhs.mMinY;
204  mMaxY = rhs.mMaxY;
205 
206  return * this;
207 }
double mMinX
Definition: CopasiPlot.h:72
double mMaxY
Definition: CopasiPlot.h:75
size_t mSize
Definition: CopasiPlot.h:68
double mMinY
Definition: CopasiPlot.h:74
const double * mpY
Definition: CopasiPlot.h:67
size_t mLastRectangle
Definition: CopasiPlot.h:71
const double * mpX
Definition: CopasiPlot.h:66
size_t mMaxSize
Definition: CopasiPlot.h:69
double mMaxX
Definition: CopasiPlot.h:73
void C2DCurveData::reallocated ( const CVector< double > *  pX,
const CVector< double > *  pY 
)

Definition at line 185 of file CopasiPlot.cpp.

References CVectorCore< CType >::array(), mMaxSize, mpX, mpY, mSize, and CVectorCore< CType >::size().

186 {
187  mpX = pX->array();
188  mpY = pY->array();
189  mMaxSize = pX->size();
190 
191  assert(mSize <= mMaxSize);
192 }
size_t mSize
Definition: CopasiPlot.h:68
const double * mpY
Definition: CopasiPlot.h:67
const double * mpX
Definition: CopasiPlot.h:66
size_t size() const
Definition: CVector.h:100
CType * array()
Definition: CVector.h:139
size_t mMaxSize
Definition: CopasiPlot.h:69
void C2DCurveData::setSize ( const size_t &  size)

Definition at line 179 of file CopasiPlot.cpp.

References mMaxSize, mSize, and size().

180 {
181  mSize = size;
182  assert(mSize <= mMaxSize);
183 }
virtual size_t size() const
Definition: CopasiPlot.cpp:84
size_t mSize
Definition: CopasiPlot.h:68
size_t mMaxSize
Definition: CopasiPlot.h:69
size_t C2DCurveData::size ( ) const
virtual

Definition at line 84 of file CopasiPlot.cpp.

References mSize.

Referenced by setSize().

85 {
86  return mSize;
87 }
size_t mSize
Definition: CopasiPlot.h:68
double C2DCurveData::x ( size_t  i) const
virtual

Definition at line 89 of file CopasiPlot.cpp.

References mpX.

90 {
91  return *(mpX + i);
92 }
const double * mpX
Definition: CopasiPlot.h:66
double C2DCurveData::y ( size_t  i) const
virtual

Definition at line 94 of file CopasiPlot.cpp.

References mpY.

95 {
96  return *(mpY + i);
97 }
const double * mpY
Definition: CopasiPlot.h:67

Member Data Documentation

size_t C2DCurveData::mLastRectangle
mutableprivate

Definition at line 71 of file CopasiPlot.h.

Referenced by boundingRect(), and operator=().

size_t C2DCurveData::mMaxSize
private

Definition at line 69 of file CopasiPlot.h.

Referenced by operator=(), reallocated(), and setSize().

double C2DCurveData::mMaxX
mutableprivate

Definition at line 73 of file CopasiPlot.h.

Referenced by boundingRect(), and operator=().

double C2DCurveData::mMaxY
mutableprivate

Definition at line 75 of file CopasiPlot.h.

Referenced by boundingRect(), and operator=().

double C2DCurveData::mMinX
mutableprivate

Definition at line 72 of file CopasiPlot.h.

Referenced by boundingRect(), and operator=().

double C2DCurveData::mMinY
mutableprivate

Definition at line 74 of file CopasiPlot.h.

Referenced by boundingRect(), and operator=().

const double* C2DCurveData::mpX
private

Definition at line 66 of file CopasiPlot.h.

Referenced by boundingRect(), operator=(), reallocated(), and x().

const double* C2DCurveData::mpY
private

Definition at line 67 of file CopasiPlot.h.

Referenced by boundingRect(), operator=(), reallocated(), and y().

size_t C2DCurveData::mSize
private

Definition at line 68 of file CopasiPlot.h.

Referenced by boundingRect(), operator=(), reallocated(), setSize(), and size().


The documentation for this class was generated from the following files: