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

#include <CopasiPlot.h>

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

Public Member Functions

virtual QwtDoubleRect boundingRect () const
 
 CHistoCurveData ()
 
 CHistoCurveData (const CVector< double > &x, size_t size, const C_FLOAT64 &increment)
 
virtual QwtData * copy () const
 
void reallocated (const CVector< double > *pX)
 
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 ~CHistoCurveData ()
 

Protected Member Functions

CHistoCurveDataoperator= (const CHistoCurveData &rhs)
 

Private Attributes

CVector< double > mHistoX
 
CVector< double > mHistoY
 
double mIncrement
 
size_t mLastRectangle
 
std::map< C_INT32, C_INT32mMap
 
size_t mMaxSize
 
double mMaxX
 
double mMaxY
 
double mMinX
 
double mMinY
 
const double * mpX
 
size_t mSize
 

Detailed Description

Definition at line 121 of file CopasiPlot.h.

Constructor & Destructor Documentation

CHistoCurveData::CHistoCurveData ( )

Definition at line 426 of file CopasiPlot.cpp.

Referenced by copy().

426  :
427  QwtData(),
428  mpX(NULL),
429  mSize(0),
430  mMaxSize(0),
431  mLastRectangle(0),
432  mMinX(std::numeric_limits<double>::quiet_NaN()),
433  mMaxX(std::numeric_limits<double>::quiet_NaN()),
434  mMinY(std::numeric_limits<double>::quiet_NaN()),
435  mMaxY(std::numeric_limits<double>::quiet_NaN()),
436  mIncrement(1.0),
437  mMap(),
438  mHistoX(0),
439  mHistoY(0)
440 {}
CVector< double > mHistoX
Definition: CopasiPlot.h:159
CVector< double > mHistoY
Definition: CopasiPlot.h:160
size_t mLastRectangle
Definition: CopasiPlot.h:150
double mIncrement
Definition: CopasiPlot.h:156
std::map< C_INT32, C_INT32 > mMap
Definition: CopasiPlot.h:158
const double * mpX
Definition: CopasiPlot.h:146
CHistoCurveData::CHistoCurveData ( const CVector< double > &  x,
size_t  size,
const C_FLOAT64 increment 
)
CHistoCurveData::~CHistoCurveData ( )
virtual

Definition at line 462 of file CopasiPlot.cpp.

463 {}

Member Function Documentation

QwtDoubleRect CHistoCurveData::boundingRect ( ) const
virtual

Definition at line 489 of file CopasiPlot.cpp.

References CVectorCore< CType >::array(), C_FLOAT64, C_INT32, mHistoX, mHistoY, mIncrement, mLastRectangle, mMap, mMaxX, mMaxY, mMinX, mMinY, mpX, mSize, and CVector< CType >::resize().

490 {
491  if (mSize <= 0)
492  return QwtDoubleRect(1.0, 1.0, -2.0, -2.0); // invalid
493 
494  if (mLastRectangle == mSize)
495  return QwtDoubleRect(mMinX, mMinY, mMaxX - mMinX, mMaxY - mMinY);
496 
497  const double *xIt = mpX + mLastRectangle;
498  const double *end = mpX + mSize;
499 
500  mLastRectangle = mSize;
501 
502  double InvIncrement = 1.0 / mIncrement;
503 
504  for (; xIt != end; ++xIt)
505  {
506  //just ignore breaks. Later we perhaps want to start a new histogram...
507  if (isnan(*xIt)) //NaN
508  continue;
509 
510  if (-std::numeric_limits< C_FLOAT64 >::infinity() < *xIt &&
511  *xIt < std::numeric_limits< C_FLOAT64 >::infinity())
512  {
513  mMap[(C_INT32) floor(*xIt * InvIncrement)]++;
514  mMap[(C_INT32) floor(*xIt * InvIncrement) + 1];
515  }
516  }
517 
518  //construct arrays
519  mHistoX.resize(mMap.size() + 1);
520  mHistoY.resize(mMap.size() + 1);
521 
522  double *pX = mHistoX.array();
523  double *pY = mHistoY.array();
524 
525  //add one bin to the left
526  if (mMap.size() > 0)
527  {
528  *pX = (mMap.begin()->first - 1) * mIncrement;
529  }
530  else
531  {
532  *pX = 0.0;
533  }
534 
535  *pY = 0.0;
536 
537  mMinX = mMaxX = *pX++;
538  mMinY = mMaxY = *pY++;
539 
540  C_FLOAT64 tmpFactor = 1.0 / (mSize * mIncrement);
541  std::map<C_INT32, C_INT32>::const_iterator it = mMap.begin();
542  std::map<C_INT32, C_INT32>::const_iterator itEnd = mMap.end();
543 
544  for (; it != itEnd; ++it, ++pX, ++pY)
545  {
546  //TODO use pointer increments instead of [...]
547  *pX = it->first * mIncrement;
548  *pY = (double)it->second * 100.0 / (double)mSize;
549 
550  if (*pX < mMinX)
551  mMinX = *pX;
552 
553  if (*pX > mMaxX)
554  mMaxX = *pX;
555 
556  if (*pY < mMinY)
557  mMinY = *pY;
558 
559  if (*pY > mMaxY)
560  mMaxY = *pY;
561  }
562 
563  return QwtDoubleRect(mMinX, mMinY, mMaxX - mMinX, mMaxY - mMinY);
564 }
CVector< double > mHistoX
Definition: CopasiPlot.h:159
void resize(size_t size, const bool &copy=false)
Definition: CVector.h:301
#define C_INT32
Definition: copasi.h:90
CVector< double > mHistoY
Definition: CopasiPlot.h:160
size_t mLastRectangle
Definition: CopasiPlot.h:150
double mIncrement
Definition: CopasiPlot.h:156
std::map< C_INT32, C_INT32 > mMap
Definition: CopasiPlot.h:158
const double * mpX
Definition: CopasiPlot.h:146
#define C_FLOAT64
Definition: copasi.h:92
CType * array()
Definition: CVector.h:139
QwtData * CHistoCurveData::copy ( ) const
virtual

Definition at line 465 of file CopasiPlot.cpp.

References CHistoCurveData().

466 {
467  CHistoCurveData * pCopy = new CHistoCurveData();
468 
469  *pCopy = *this;
470 
471  return pCopy;
472 }
CHistoCurveData & CHistoCurveData::operator= ( const CHistoCurveData rhs)
protected

Definition at line 580 of file CopasiPlot.cpp.

References mHistoX, mHistoY, mIncrement, mLastRectangle, mMap, mMaxSize, mMaxX, mMaxY, mMinX, mMinY, mpX, and mSize.

581 {
582  mpX = rhs.mpX;
583  mSize = rhs.mSize;
584  mMaxSize = rhs.mMaxSize;
585 
587  mMinX = rhs.mMinX;
588  mMaxX = rhs.mMaxX;
589  mMinY = rhs.mMinY;
590  mMaxY = rhs.mMaxY;
591 
592  mIncrement = rhs.mIncrement;
593  mMap = rhs.mMap;
594  mHistoX = rhs.mHistoX;
595  mHistoY = rhs.mHistoY;
596 
597  return * this;
598 }
CVector< double > mHistoX
Definition: CopasiPlot.h:159
CVector< double > mHistoY
Definition: CopasiPlot.h:160
size_t mLastRectangle
Definition: CopasiPlot.h:150
double mIncrement
Definition: CopasiPlot.h:156
std::map< C_INT32, C_INT32 > mMap
Definition: CopasiPlot.h:158
const double * mpX
Definition: CopasiPlot.h:146
void CHistoCurveData::reallocated ( const CVector< double > *  pX)

Definition at line 572 of file CopasiPlot.cpp.

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

573 {
574  mpX = pX->array();
575  mMaxSize = pX->size();
576 
577  assert(mSize <= mMaxSize);
578 }
size_t size() const
Definition: CVector.h:100
const double * mpX
Definition: CopasiPlot.h:146
CType * array()
Definition: CVector.h:139
void CHistoCurveData::setSize ( const size_t &  size)

Definition at line 566 of file CopasiPlot.cpp.

References mMaxSize, mSize, and size().

567 {
568  mSize = size;
569  assert(mSize <= mMaxSize);
570 }
virtual size_t size() const
Definition: CopasiPlot.cpp:474
size_t CHistoCurveData::size ( ) const
virtual

Definition at line 474 of file CopasiPlot.cpp.

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

Referenced by CopasiPlot::saveData(), and setSize().

475 {
476  return mHistoX.size();
477 }
CVector< double > mHistoX
Definition: CopasiPlot.h:159
size_t size() const
Definition: CVector.h:100
double CHistoCurveData::x ( size_t  i) const
virtual

Definition at line 479 of file CopasiPlot.cpp.

References mHistoX.

Referenced by CopasiPlot::saveData().

480 {
481  return mHistoX[i];
482 }
CVector< double > mHistoX
Definition: CopasiPlot.h:159
double CHistoCurveData::y ( size_t  i) const
virtual

Definition at line 484 of file CopasiPlot.cpp.

References mHistoY.

Referenced by CopasiPlot::saveData().

485 {
486  return mHistoY[i];
487 }
CVector< double > mHistoY
Definition: CopasiPlot.h:160

Member Data Documentation

CVector< double > CHistoCurveData::mHistoX
mutableprivate

Definition at line 159 of file CopasiPlot.h.

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

CVector< double > CHistoCurveData::mHistoY
mutableprivate

Definition at line 160 of file CopasiPlot.h.

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

double CHistoCurveData::mIncrement
private

Definition at line 156 of file CopasiPlot.h.

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

size_t CHistoCurveData::mLastRectangle
mutableprivate

Definition at line 150 of file CopasiPlot.h.

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

std::map<C_INT32, C_INT32> CHistoCurveData::mMap
mutableprivate

Definition at line 158 of file CopasiPlot.h.

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

size_t CHistoCurveData::mMaxSize
private

Definition at line 148 of file CopasiPlot.h.

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

double CHistoCurveData::mMaxX
mutableprivate

Definition at line 152 of file CopasiPlot.h.

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

double CHistoCurveData::mMaxY
mutableprivate

Definition at line 154 of file CopasiPlot.h.

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

double CHistoCurveData::mMinX
mutableprivate

Definition at line 151 of file CopasiPlot.h.

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

double CHistoCurveData::mMinY
mutableprivate

Definition at line 153 of file CopasiPlot.h.

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

const double* CHistoCurveData::mpX
private

Definition at line 146 of file CopasiPlot.h.

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

size_t CHistoCurveData::mSize
private

Definition at line 147 of file CopasiPlot.h.

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


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