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

#include <CopasiPlot.h>

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

Public Member Functions

virtual QwtDoubleRect boundingRect () const
 
 CBandedGraphData ()
 
 CBandedGraphData (const CVector< double > &x, const CVector< double > &y1, const CVector< double > &y2, size_t size)
 
virtual QwtData * copy () const
 
void reallocated (const CVector< double > *pX, const CVector< double > *pY1, const CVector< double > *pY2)
 
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
 
double y1 (size_t i) const
 
double y2 (size_t i) const
 
virtual ~CBandedGraphData ()
 

Protected Member Functions

CBandedGraphDataoperator= (const CBandedGraphData &rhs)
 

Private Attributes

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

Detailed Description

Definition at line 78 of file CopasiPlot.h.

Constructor & Destructor Documentation

CBandedGraphData::CBandedGraphData ( )

Definition at line 210 of file CopasiPlot.cpp.

Referenced by copy().

210  :
211  QwtData(),
212  mpX(NULL),
213  mpY1(NULL),
214  mpY2(NULL),
215  mSize(0),
216  mMaxSize(0),
217  mLastRectangle(0),
218  mMinX(std::numeric_limits<double>::quiet_NaN()),
219  mMaxX(std::numeric_limits<double>::quiet_NaN()),
220  mMinY(std::numeric_limits<double>::quiet_NaN()),
221  mMaxY(std::numeric_limits<double>::quiet_NaN())
222 {}
const double * mpX
Definition: CopasiPlot.h:107
const double * mpY2
Definition: CopasiPlot.h:109
size_t mLastRectangle
Definition: CopasiPlot.h:114
const double * mpY1
Definition: CopasiPlot.h:108
CBandedGraphData::CBandedGraphData ( const CVector< double > &  x,
const CVector< double > &  y1,
const CVector< double > &  y2,
size_t  size 
)

Definition at line 224 of file CopasiPlot.cpp.

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

227  :
228  QwtData(),
229  mpX(x.array()),
230  mpY1(y1.array()),
231  mpY2(y2.array()),
232  mSize(size),
233  mMaxSize(x.size()),
234  mLastRectangle(0),
235  mMinX(std::numeric_limits<double>::quiet_NaN()),
236  mMaxX(std::numeric_limits<double>::quiet_NaN()),
237  mMinY(std::numeric_limits<double>::quiet_NaN()),
238  mMaxY(std::numeric_limits<double>::quiet_NaN())
239 {
240  assert(x.size() == y1.size());
241  assert(x.size() == y2.size());
242  assert(mSize <= mMaxSize);
243 }
const double * mpX
Definition: CopasiPlot.h:107
size_t size() const
Definition: CVector.h:100
CType * array()
Definition: CVector.h:139
const double * mpY2
Definition: CopasiPlot.h:109
virtual size_t size() const
Definition: CopasiPlot.cpp:259
size_t mLastRectangle
Definition: CopasiPlot.h:114
const double * mpY1
Definition: CopasiPlot.h:108
CBandedGraphData::~CBandedGraphData ( )
virtual

Definition at line 245 of file CopasiPlot.cpp.

246 {}

Member Function Documentation

QwtDoubleRect CBandedGraphData::boundingRect ( ) const
virtual

Definition at line 297 of file CopasiPlot.cpp.

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

298 {
299  if (mSize <= 0)
300  return QwtDoubleRect(1.0, 1.0, -2.0, -2.0); // invalid
301 
302  if (mLastRectangle == mSize)
303  return QwtDoubleRect(mMinX, mMinY, mMaxX - mMinX, mMaxY - mMinY);
304 
305  const double *xIt = mpX + mLastRectangle;
306  const double *yIt1 = mpY1 + mLastRectangle;
307  const double *yIt2 = mpY2 + mLastRectangle;
308  const double *end = mpX + mSize;
309 
310  mLastRectangle = mSize;
311 
312  // We have to remember whether we have an initial NaN
313  bool MinXisNaN = isnan(mMinX);
314  bool MaxXisNaN = isnan(mMaxX);
315  bool MinYisNaN = isnan(mMinY);
316  bool MaxYisNaN = isnan(mMaxY);
317 
318  while (xIt < end)
319  {
320  const double xv = *xIt++;
321 
322  if (!isnan(xv))
323  {
324  if (xv < mMinX || MinXisNaN)
325  {
326  mMinX = xv;
327  MinXisNaN = false;
328  }
329 
330  if (xv > mMaxX || MaxXisNaN)
331  {
332  mMaxX = xv;
333  MaxXisNaN = false;
334  }
335  }
336 
337  double yv1 = *yIt1++;
338  double yv2 = *yIt2++;
339 
340  if (isnan(yv1) || isnan(yv2))
341  {
342  yv1 = isnan(yv1) ? yv2 : yv1;
343  yv2 = yv1;
344  }
345  else if (yv1 > yv2)
346  {
347  double tmp = yv1;
348  yv1 = yv2;
349  yv2 = tmp;
350  } // now: yv1 <= yv2
351 
352  if (!isnan(yv1))
353  {
354  if (yv1 < mMinY || MinYisNaN)
355  {
356  mMinY = yv1;
357  MinYisNaN = false;
358  }
359 
360  if (yv2 > mMaxY || MaxYisNaN)
361  {
362  mMaxY = yv2;
363  MaxYisNaN = false;
364  }
365  }
366  }
367 
368  if (isnan(mMinX + mMaxX + mMinY + mMaxY))
369  return QwtDoubleRect(1.0, 1.0, -2.0, -2.0); // invalid
370 
371  // We need to avoid very small data ranges (absolute and relative)
372  C_FLOAT64 minRange = fabs(mMinX + mMaxX) * 5.e-5 + std::numeric_limits< C_FLOAT64 >::min() * 100.0;
373 
374  if (mMaxX - mMinX < minRange)
375  {
376  mMinX = mMinX - minRange * 0.5;
377  mMaxX = mMaxX + minRange * 0.5;
378  }
379 
380  minRange = fabs(mMinY + mMaxY) * 5e-5 + std::numeric_limits< C_FLOAT64 >::min() * 100.0;
381 
382  if (mMaxY - mMinY < minRange)
383  {
384  mMinY = mMinY - minRange * 0.5;
385  mMaxY = mMaxY + minRange * 0.5;
386  }
387 
388  return QwtDoubleRect(mMinX, mMinY, mMaxX - mMinX, mMaxY - mMinY);
389 }
const double * mpX
Definition: CopasiPlot.h:107
#define C_FLOAT64
Definition: copasi.h:92
const double * mpY2
Definition: CopasiPlot.h:109
size_t mLastRectangle
Definition: CopasiPlot.h:114
#define min(a, b)
Definition: f2c.h:175
const double * mpY1
Definition: CopasiPlot.h:108
QwtData * CBandedGraphData::copy ( ) const
virtual

Definition at line 249 of file CopasiPlot.cpp.

References CBandedGraphData().

250 {
251  CBandedGraphData * pCopy = new CBandedGraphData();
252 
253  *pCopy = *this;
254 
255  return pCopy;
256 }
CBandedGraphData & CBandedGraphData::operator= ( const CBandedGraphData rhs)
protected

Definition at line 409 of file CopasiPlot.cpp.

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

410 {
411  mpX = rhs.mpX;
412  mpY1 = rhs.mpY1;
413  mpY2 = rhs.mpY2;
414  mSize = rhs.mSize;
415  mMaxSize = rhs.mMaxSize;
417  mMinX = rhs.mMinX;
418  mMaxX = rhs.mMaxX;
419  mMinY = rhs.mMinY;
420  mMaxY = rhs.mMaxY;
421 
422  return * this;
423 }
const double * mpX
Definition: CopasiPlot.h:107
const double * mpY2
Definition: CopasiPlot.h:109
size_t mLastRectangle
Definition: CopasiPlot.h:114
const double * mpY1
Definition: CopasiPlot.h:108
void CBandedGraphData::reallocated ( const CVector< double > *  pX,
const CVector< double > *  pY1,
const CVector< double > *  pY2 
)

Definition at line 399 of file CopasiPlot.cpp.

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

400 {
401  mpX = pX->array();
402  mpY1 = pY1->array();
403  mpY2 = pY2->array();
404  mMaxSize = pX->size();
405 
406  assert(mSize <= mMaxSize);
407 }
const double * mpX
Definition: CopasiPlot.h:107
size_t size() const
Definition: CVector.h:100
CType * array()
Definition: CVector.h:139
const double * mpY2
Definition: CopasiPlot.h:109
const double * mpY1
Definition: CopasiPlot.h:108
void CBandedGraphData::setSize ( const size_t &  size)

Definition at line 392 of file CopasiPlot.cpp.

References mMaxSize, mSize, and size().

393 {
394  mSize = size;
395  assert(mSize <= mMaxSize);
396 }
virtual size_t size() const
Definition: CopasiPlot.cpp:259
size_t CBandedGraphData::size ( ) const
virtual

Definition at line 259 of file CopasiPlot.cpp.

References mSize.

Referenced by setSize().

260 {return 2 * mSize;}
double CBandedGraphData::x ( size_t  i) const
virtual

Definition at line 262 of file CopasiPlot.cpp.

References mpX, and mSize.

263 {
264  // to make a polygon out of the two data curves
265  // one curve goes in order, the other backwards
266  if (i >= mSize)
267  i = (2 * mSize - i - 1);
268 
269  return *(mpX + i);
270 }
const double * mpX
Definition: CopasiPlot.h:107
double CBandedGraphData::y ( size_t  i) const
virtual

Definition at line 272 of file CopasiPlot.cpp.

References mpY1, mpY2, and mSize.

273 {
274  double ret;
275 
276  // to make a polygon out of the two data curves
277  // one curve goes in order, the other backwards
278  if (i < mSize)
279  ret = *(mpY1 + i);
280  else
281  ret = *(mpY2 + (2 * mSize - i - 1));
282 
283  return ret;
284 }
const double * mpY2
Definition: CopasiPlot.h:109
const double * mpY1
Definition: CopasiPlot.h:108
double CBandedGraphData::y1 ( size_t  i) const

Definition at line 286 of file CopasiPlot.cpp.

References mpY1.

287 {
288  return *(mpY1 + i);
289 }
const double * mpY1
Definition: CopasiPlot.h:108
double CBandedGraphData::y2 ( size_t  i) const

Definition at line 291 of file CopasiPlot.cpp.

References mpY2.

292 {
293  return *(mpY2 + i);
294 }
const double * mpY2
Definition: CopasiPlot.h:109

Member Data Documentation

size_t CBandedGraphData::mLastRectangle
mutableprivate

Definition at line 114 of file CopasiPlot.h.

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

size_t CBandedGraphData::mMaxSize
private

Definition at line 112 of file CopasiPlot.h.

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

double CBandedGraphData::mMaxX
mutableprivate

Definition at line 116 of file CopasiPlot.h.

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

double CBandedGraphData::mMaxY
mutableprivate

Definition at line 118 of file CopasiPlot.h.

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

double CBandedGraphData::mMinX
mutableprivate

Definition at line 115 of file CopasiPlot.h.

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

double CBandedGraphData::mMinY
mutableprivate

Definition at line 117 of file CopasiPlot.h.

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

const double* CBandedGraphData::mpX
private

Definition at line 107 of file CopasiPlot.h.

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

const double* CBandedGraphData::mpY1
private

Definition at line 108 of file CopasiPlot.h.

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

const double* CBandedGraphData::mpY2
private

Definition at line 109 of file CopasiPlot.h.

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

size_t CBandedGraphData::mSize
private

Definition at line 111 of file CopasiPlot.h.

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


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