COPASI API  4.16.103
Public Member Functions | Protected Attributes | List of all members
QTimeCourseAnimation Class Reference
Inheritance diagram for QTimeCourseAnimation:
Inheritance graph
[legend]
Collaboration diagram for QTimeCourseAnimation:
Collaboration graph
[legend]

Public Member Functions

size_t getIndex (const CTimeSeries *series, const std::string &cn)
 
double getMax (const CTimeSeries *series, size_t index=C_INVALID_INDEX)
 
virtual void getScales (std::vector< qreal > &scales, int step)
 
double getValue (const CTimeSeries *series, const std::string &cn, int step)
 
virtual void initialize (const CCopasiDataModel &dataModel)
 
- Public Member Functions inherited from CQCopasiAnimation
virtual void applyToScene (CQLayoutScene &scene, int step)
 
 CQCopasiAnimation ()
 
std::vector
< CQEffectDescription * > & 
getEntries ()
 
virtual int getNumSteps ()
 
ScaleMode getScaleMode () const
 
virtual void removeFromScene (CQLayoutScene &scene)
 
void setScaleMode (ScaleMode mode)
 
virtual ~CQCopasiAnimation ()
 

Protected Attributes

std::map< std::string,
std::string > 
keyMap
 
- Protected Attributes inherited from CQCopasiAnimation
std::vector
< CQEffectDescription * > 
mEntries
 
ScaleMode mMode
 
int mNumSteps
 
const CCopasiDataModelmpDataModel
 

Additional Inherited Members

- Public Types inherited from CQCopasiAnimation
enum  ScaleMode { Global, Individual }
 

Detailed Description

Animation that displays the concentrations per time

Definition at line 160 of file CQAnimationWindow.cpp.

Member Function Documentation

size_t QTimeCourseAnimation::getIndex ( const CTimeSeries series,
const std::string &  cn 
)
inline

Definition at line 189 of file CQAnimationWindow.cpp.

References C_INVALID_INDEX, CTimeSeries::getKey(), CTimeSeries::getNumVariables(), and keyMap.

Referenced by getScales(), and getValue().

190  {
191  const std::string& key = keyMap[cn];
192 
193  for (size_t i = 0; i < series->getNumVariables(); ++i)
194  if (series->getKey(i) == key)
195  return i;
196 
197  return C_INVALID_INDEX;
198  }
const size_t & getNumVariables() const
#define C_INVALID_INDEX
Definition: copasi.h:222
const std::string & getKey(const size_t &variable) const
std::map< std::string, std::string > keyMap
double QTimeCourseAnimation::getMax ( const CTimeSeries series,
size_t  index = C_INVALID_INDEX 
)
inline

Definition at line 163 of file CQAnimationWindow.cpp.

References C_INVALID_INDEX, CTimeSeries::getData(), CTimeSeries::getNumVariables(), CTimeSeries::getRecordedSteps(), and max.

Referenced by getScales().

164  {
165  double max = 0;
166 
167  if (index != C_INVALID_INDEX)
168  {
169  for (size_t i = 0; i < series->getRecordedSteps(); ++i)
170  {
171  max = qMax(max, series->getData(i, index));
172  }
173  }
174  else
175  {
176 
177  for (size_t i = 0; i < series->getRecordedSteps(); ++i)
178  {
179  for (size_t j = 0; j < series->getNumVariables(); ++j)
180  {
181  max = qMax(max, series->getData(i, j));
182  }
183  }
184  }
185 
186  return max;
187  }
const size_t & getRecordedSteps() const
const size_t & getNumVariables() const
#define C_INVALID_INDEX
Definition: copasi.h:222
const C_FLOAT64 & getData(const size_t &step, const size_t &variable) const
#define max(a, b)
Definition: f2c.h:176
virtual void QTimeCourseAnimation::getScales ( std::vector< qreal > &  scales,
int  step 
)
inlinevirtual

Reimplemented from CQCopasiAnimation.

Definition at line 205 of file CQAnimationWindow.cpp.

References getIndex(), getMax(), CTimeSeries::getRecordedSteps(), CCopasiDataModel::getTaskList(), CTrajectoryTask::getTimeSeries(), getValue(), CQCopasiAnimation::Global, CQCopasiAnimation::Individual, max, CQCopasiAnimation::mEntries, CQCopasiAnimation::mMode, CQCopasiAnimation::mNumSteps, and CQCopasiAnimation::mpDataModel.

206  {
207  if (mpDataModel == NULL) return;
208 
209  CTrajectoryTask *task = dynamic_cast< CTrajectoryTask * >((*mpDataModel->getTaskList())["Time-Course"]);
210 
211  if (task == NULL) return;
212 
213  const CTimeSeries* series = &task->getTimeSeries();
214 
215  if (series == NULL) return;
216 
217  mNumSteps = series->getRecordedSteps();
218 
219  if (series->getRecordedSteps() < (size_t)step)
220  return;
221 
222  double max = mMode == CQCopasiAnimation::Global ? getMax(series) : 0;
223 
224  for (size_t i = 0; i < mEntries.size(); ++i)
225  {
227  max = getMax(series, getIndex(series, mEntries[i]->getCN()));
228 
229  double value = getValue(series, mEntries[i]->getCN(), step);
230  scales.push_back(value / max);
231  }
232  }
const size_t & getRecordedSteps() const
double getMax(const CTimeSeries *series, size_t index=C_INVALID_INDEX)
size_t getIndex(const CTimeSeries *series, const std::string &cn)
CCopasiVectorN< CCopasiTask > * getTaskList()
const CTimeSeries & getTimeSeries() const
std::vector< CQEffectDescription * > mEntries
const CCopasiDataModel * mpDataModel
double getValue(const CTimeSeries *series, const std::string &cn, int step)
#define max(a, b)
Definition: f2c.h:176
double QTimeCourseAnimation::getValue ( const CTimeSeries series,
const std::string &  cn,
int  step 
)
inline

Definition at line 200 of file CQAnimationWindow.cpp.

References CTimeSeries::getData(), and getIndex().

Referenced by getScales().

201  {
202  return series->getData(step, getIndex(series, cn));
203  }
size_t getIndex(const CTimeSeries *series, const std::string &cn)
const C_FLOAT64 & getData(const size_t &step, const size_t &variable) const
virtual void QTimeCourseAnimation::initialize ( const CCopasiDataModel dataModel)
inlinevirtual

Implements CQCopasiAnimation.

Definition at line 234 of file CQAnimationWindow.cpp.

References CCopasiVector< T >::begin(), CCopasiVector< T >::end(), CModel::getMetabolites(), CCopasiDataModel::getModel(), CTimeSeries::getRecordedSteps(), CCopasiDataModel::getTaskList(), CTrajectoryTask::getTimeSeries(), keyMap, CQCopasiAnimation::mEntries, CQCopasiAnimation::mNumSteps, CQCopasiAnimation::mpDataModel, and CQEffectDescription::Scale.

235  {
236  mpDataModel = &dataModel;
237  const CModel& model = *dataModel.getModel();
238  const CCopasiVector< CMetab > & metabs = model.getMetabolites();
240 
241  while (it != metabs.end())
242  {
243  mEntries.push_back(new CQEffectDescription((*it)->getCN(), CQEffectDescription::Scale));
244  keyMap[(*it)->getCN()] = (*it)->getKey();
245  ++it;
246  }
247 
248  // initialize number of steps
249  CTrajectoryTask *task = dynamic_cast< CTrajectoryTask * >((*mpDataModel->getTaskList())["Time-Course"]);
250 
251  if (task == NULL) return;
252 
253  const CTimeSeries* series = &task->getTimeSeries();
254 
255  if (series == NULL) return;
256 
257  mNumSteps = series->getRecordedSteps();
258  }
const size_t & getRecordedSteps() const
const CCopasiVector< CMetab > & getMetabolites() const
Definition: CModel.cpp:1051
iterator begin()
iterator end()
CCopasiVectorN< CCopasiTask > * getTaskList()
const CTimeSeries & getTimeSeries() const
std::vector< CQEffectDescription * > mEntries
const CCopasiDataModel * mpDataModel
Definition: CModel.h:50
std::map< std::string, std::string > keyMap

Member Data Documentation

std::map<std::string, std::string> QTimeCourseAnimation::keyMap
protected

Definition at line 260 of file CQAnimationWindow.cpp.

Referenced by getIndex(), and initialize().


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