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

#include <CQCompartment.h>

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

Public Member Functions

void copy ()
 
 CQCompartment (QWidget *parent=0, const char *name=0)
 
virtual bool leave ()
 
virtual bool update (ListViews::ObjectType objectType, ListViews::Action action, const std::string &key)
 
 ~CQCompartment ()
 
- Public Member Functions inherited from CopasiWidget
 CopasiWidget (QWidget *parent=0, const char *name=0, Qt::WFlags f=0)
 
bool enter (const std::string &key)
 
CCopasiDataModelgetDataModel ()
 
bool getIgnoreUpdates ()
 
virtual void setFramework (int framework)
 
void setIgnoreUpdates (bool v)
 

Protected Member Functions

virtual bool enterProtected ()
 

Private Slots

void slotBtnCopy ()
 
void slotBtnDelete ()
 
void slotBtnNew ()
 
void slotExpressionValid (bool valid)
 
void slotInitialExpressionValid (bool valid)
 
void slotInitialTypeChanged (bool useInitialAssignment)
 
void slotMetaboliteTableCurrentChanged (int row, int col)
 
void slotTypeChanged (int type)
 

Private Member Functions

void destroy ()
 
void init ()
 
void load ()
 
void loadMetaboliteTable ()
 
void save ()
 

Private Attributes

bool mChanged
 
bool mExpressionValid
 
bool mInitialExpressionValid
 
std::vector< int > mItemToType
 
CCompartmentmpCompartment
 

Additional Inherited Members

- Protected Slots inherited from CopasiWidget
virtual bool protectedNotify (ListViews::ObjectType objectType, ListViews::Action action, const std::string &key="")
 
- Protected Attributes inherited from CopasiWidget
int mFramework
 
bool mIgnoreUpdates
 
std::string mKey
 
CCopasiDataModelmpDataModel
 
ListViewsmpListView
 
CCopasiObjectmpObject
 

Detailed Description

Definition at line 26 of file CQCompartment.h.

Constructor & Destructor Documentation

CQCompartment::CQCompartment ( QWidget *  parent = 0,
const char *  name = 0 
)

Definition at line 38 of file CQCompartment.cpp.

References CModelEntity::ASSIGNMENT, CModelEntity::FIXED, FROM_UTF8, CQExpressionWidget::InitialExpression, mExpressionValid, mInitialExpressionValid, mItemToType, CModelEntity::ODE, CModelEntity::StatusName, and CQExpressionWidget::TransientExpression.

38  :
39  CopasiWidget(parent, name),
40  mItemToType(),
41  mpCompartment(NULL),
42  mChanged(false),
43  mExpressionValid(true),
45 {
46  setupUi(this);
47 
48  mpComboBoxType->insertItem(mpComboBoxType->count(), FROM_UTF8(CModelEntity::StatusName[CModelEntity::FIXED]));
49  mpComboBoxType->insertItem(mpComboBoxType->count(), FROM_UTF8(CModelEntity::StatusName[CModelEntity::ASSIGNMENT]));
50  mpComboBoxType->insertItem(mpComboBoxType->count(), FROM_UTF8(CModelEntity::StatusName[CModelEntity::ODE]));
51 
54  mItemToType.push_back(CModelEntity::ODE);
55 
56  mpMetaboliteTable->horizontalHeader()->hide();
57 
58  mExpressionValid = false;
59  mpExpressionEMW->mpExpressionWidget->setExpressionType(CQExpressionWidget::TransientExpression);
60 
62  mpInitialExpressionEMW->mpExpressionWidget->setExpressionType(CQExpressionWidget::InitialExpression);
63 
64 #ifdef COPASI_EXTUNIT
65  mpLblDim->show();
66  mpComboBoxDim->show();
67 #else
68  mpLblDim->hide();
69  mpComboBoxDim->hide();
70 #endif
71 }
#define FROM_UTF8(__x)
Definition: qtUtilities.h:73
static const std::string StatusName[]
Definition: CModelValue.h:67
bool mExpressionValid
Definition: CQCompartment.h:47
CCompartment * mpCompartment
Definition: CQCompartment.h:45
CopasiWidget(QWidget *parent=0, const char *name=0, Qt::WFlags f=0)
bool mInitialExpressionValid
Definition: CQCompartment.h:48
std::vector< int > mItemToType
Definition: CQCompartment.h:44
CQCompartment::~CQCompartment ( )

Definition at line 76 of file CQCompartment.cpp.

77 {
78  // no need to delete child widgets, Qt does it all for us
79 }

Member Function Documentation

void CQCompartment::copy ( )

Definition at line 103 of file CQCompartment.cpp.

References CModelExpansion::SetOfModelElements::addMetab(), CModelExpansion::SetOfModelElements::addObject(), CModelExpansion::SetOfModelElements::addReaction(), CQCompartmentCopyOptions::ALLREAC, CCopasiVector< T >::begin(), C_INVALID_INDEX, CQCompartmentCopyOptions::COMP, ListViews::COMPARTMENT, ListViews::DELETE, CModelExpansion::duplicate(), CCopasiVector< T >::end(), CModelExpansion::SetOfModelElements::fillDependencies(), CReactionInterface::getChemEqInterface(), CChemEqInterface::getCompartment(), CModelExpansion::ElementsMap::getDuplicateKey(), CModelEntity::getKey(), CCompartment::getMetabolites(), CCopasiDataModel::getModel(), CModel::getReactions(), CReactionInterface::initFromReaction(), CQCompartmentCopyOptions::INTREAC, CReactionInterface::isMulticompartment(), ListViews::METABOLITE, CopasiWidget::mKey, mpCompartment, CopasiWidget::mpDataModel, CopasiWidget::mpListView, CopasiWidget::mpObject, pdelete, CopasiWidget::protectedNotify(), ListViews::REACTION, CQCompartmentCopyOptions::SPECIES, and ListViews::switchToOtherWidget().

Referenced by CQTabWidget::slotBtnCopy().

104 {
105  CModel * pModel = mpDataModel->getModel();
106  CModelExpansion cModelExpObj = CModelExpansion(pModel);
107  CModelExpansion::SetOfModelElements compartmentObjectsToCopy;
108  CModelExpansion::ElementsMap origToCopyMappings;
109 
111  pDialog->exec();
112 
113  bool success = false;
114 
115  switch (pDialog->result())
116  {
117  case QDialog::Rejected:
118  break;
119 
120  case CQCompartmentCopyOptions::COMP: //compartment only
121 
122  compartmentObjectsToCopy.addObject(mpObject);
123  success = true;
124  break;
125 
126  case CQCompartmentCopyOptions::SPECIES: // include the species
127  {
128  compartmentObjectsToCopy.addObject(mpObject);
131 
132  for (itMetab = Metabolites.begin(); itMetab != Metabolites.end(); ++itMetab)
133  {
134  compartmentObjectsToCopy.addMetab(*itMetab);
135  }
136  }
137 
138  success = true;
139  break;
140 
141  case CQCompartmentCopyOptions::INTREAC: //also include the internal reactions
142  {
143  compartmentObjectsToCopy.addObject(mpObject);
144 
145  // Get all the compartment's species first
148 
149  for (itMetab = Metabolites.begin(); itMetab != Metabolites.end(); ++itMetab)
150  {
151  compartmentObjectsToCopy.addMetab(*itMetab);
152  }
153 
154  // Now get the reactions which are not multi-compartment
157  CReactionInterface * pRi = new CReactionInterface(pModel);
158 
159  for (; it != end; ++it)
160  {
161  pRi->initFromReaction((*it)->getKey());
162 
163  if (!pRi->isMulticompartment())
164  {
165  if (pRi->getChemEqInterface().getCompartment()->getKey() == mKey)
166  compartmentObjectsToCopy.addReaction(*it);
167  }
168  }
169 
170  pdelete(pRi);
171  success = true;
172  break;
173  }
174 
175  case CQCompartmentCopyOptions::ALLREAC: //get everything in compartment
176 
177  compartmentObjectsToCopy.addObject(mpObject);
178  compartmentObjectsToCopy.fillDependencies(pModel);
179  success = true;
180  break;
181  }
182 
183  pdelete(pDialog);
184 
185  if (success)
186  {
187  cModelExpObj.duplicate(compartmentObjectsToCopy, "_copy", origToCopyMappings);
188 
193  }
194 }
#define pdelete(p)
Definition: copasi.h:215
CCopasiVectorNS< CMetab > & getMetabolites()
void switchToOtherWidget(const size_t &id, const std::string &key)
Definition: listviews.cpp:926
void addReaction(const CReaction *x)
const CChemEqInterface & getChemEqInterface() const
iterator begin()
void initFromReaction(const std::string &key)
CCopasiObject * mpObject
Definition: copasiWidget.h:64
const CCompartment * getCompartment() const
#define C_INVALID_INDEX
Definition: copasi.h:222
bool duplicate(const SetOfModelElements &source, const std::string &index, ElementsMap &emap)
iterator end()
ListViews * mpListView
Definition: copasiWidget.h:62
virtual const std::string & getKey() const
CCompartment * mpCompartment
Definition: CQCompartment.h:45
std::string getDuplicateKey(const std::string &sourceKey) const
find the key of the duplicated object from the source object (if it exists)
virtual bool protectedNotify(ListViews::ObjectType objectType, ListViews::Action action, const std::string &key="")
void fillDependencies(const CModel *pModel)
CCopasiDataModel * mpDataModel
Definition: copasiWidget.h:65
bool addObject(const CCopasiObject *x)
CCopasiVectorNS< CReaction > & getReactions()
Definition: CModel.cpp:1039
Definition: CModel.h:50
bool isMulticompartment() const
std::string mKey
Definition: copasiWidget.h:63
void CQCompartment::destroy ( )
private

Definition at line 521 of file CQCompartment.cpp.

522 {}
bool CQCompartment::enterProtected ( )
protectedvirtual

Reimplemented from CopasiWidget.

Definition at line 330 of file CQCompartment.cpp.

References load(), mpCompartment, and CopasiWidget::mpObject.

331 {
332  mpCompartment = dynamic_cast< CCompartment * >(mpObject);
333 
334  load();
335 
336  return true;
337 }
CCopasiObject * mpObject
Definition: copasiWidget.h:64
CCompartment * mpCompartment
Definition: CQCompartment.h:45
void CQCompartment::init ( )
private
bool CQCompartment::leave ( )
virtual

Reimplemented from CopasiWidget.

Definition at line 339 of file CQCompartment.cpp.

References CModelEntity::FIXED, mItemToType, and save().

Referenced by slotBtnNew().

340 {
341  if ((CModelEntity::Status) mItemToType[mpComboBoxType->currentIndex()] != CModelEntity::FIXED)
342  {
343  // -- Expression --
344  mpExpressionEMW->updateWidget();
345  }
346 
347  if (mpBoxUseInitialExpression->isChecked())
348  {
349  // -- Initial Expression --
350  mpInitialExpressionEMW->updateWidget();
351  }
352 
353  save();
354 
355  return true;
356 }
std::vector< int > mItemToType
Definition: CQCompartment.h:44
void CQCompartment::load ( )
private

Definition at line 380 of file CQCompartment.cpp.

References CModelEntity::ASSIGNMENT, FROM_UTF8, CCopasiRootContainer::getDatamodelList(), CCompartment::getDimensionality(), CModelEntity::getExpression(), CModelEntity::getInitialExpression(), CModelEntity::getInitialValue(), CCopasiObject::getObjectAncestor(), CModelEntity::getRate(), CModelEntity::getStatus(), CModelEntity::getValue(), CModel::getVolumeRateUnitsDisplayString(), CModel::getVolumeUnitsDisplayString(), loadMetaboliteTable(), mChanged, mpCompartment, slotTypeChanged(), and CModelEntity::StatusName.

Referenced by enterProtected(), and update().

381 {
382  if (mpCompartment == NULL) return;
383 
384  assert(CCopasiRootContainer::getDatamodelList()->size() > 0);
385 
386  const CModel * pModel = NULL;
387 
388  if (mpCompartment != NULL)
389  pModel = dynamic_cast<const CModel *>(mpCompartment->getObjectAncestor("Model"));
390 
391  // Update the labels to reflect the model units
392  QString ValueUnits;
393 
394  if (pModel)
395  ValueUnits = FROM_UTF8(pModel->getVolumeUnitsDisplayString());
396 
397  if (!ValueUnits.isEmpty())
398  ValueUnits = " (" + ValueUnits + ")";
399 
400  QString RateUnits;
401 
402  if (pModel)
403  RateUnits = FROM_UTF8(pModel->getVolumeRateUnitsDisplayString());
404 
405  if (!RateUnits.isEmpty())
406  RateUnits = " (" + RateUnits + ")";
407 
408  mpLblInitialValue->setText("Initial Volume" + ValueUnits);
409  mpLblInitialExpression->setText("Initial Expression" + ValueUnits);
410  mpLblVolume->setText("Volume" + ValueUnits);
411  mpLblRate->setText("Rate" + RateUnits);
412 
413  //Dimensionality
414  mpComboBoxDim->setCurrentIndex(mpCompartment->getDimensionality());
415  //this assumes the indices of the entries in the combobox correspond 1to1 to the values of dimensionality
416 
417  // Simulation Type
418  mpComboBoxType->setCurrentIndex(mpComboBoxType->findText(FROM_UTF8(CModelEntity::StatusName[mpCompartment->getStatus()])));
419 
420  // Initial Volume
421  mpEditInitialVolume->setText(QString::number(mpCompartment->getInitialValue(), 'g', 10));
422 
423  // Transient Volume
424  mpEditCurrentVolume->setText(QString::number(mpCompartment->getValue(), 'g', 10));
425 
426  // Concentration Rate
427  mpEditRate->setText(QString::number(mpCompartment->getRate(), 'g', 10));
428 
429  // Expression
430  mpExpressionEMW->mpExpressionWidget->setExpression(mpCompartment->getExpression());
431  mpExpressionEMW->updateWidget();
432 
433  // Initial Expression
434  mpInitialExpressionEMW->mpExpressionWidget->setExpression(mpCompartment->getInitialExpression());
435  mpInitialExpressionEMW->updateWidget();
436 
437  // Type dependent display of values
438  slotTypeChanged(mpComboBoxType->currentIndex());
439 
440  // Use Initial Expression
443  {
444  mpBoxUseInitialExpression->setChecked(false);
445  }
446  else
447  {
448  mpBoxUseInitialExpression->setChecked(true);
449  }
450 
452 
453  mChanged = false;
454  return;
455 }
CCopasiContainer * getObjectAncestor(const std::string &type) const
#define FROM_UTF8(__x)
Definition: qtUtilities.h:73
static const std::string StatusName[]
Definition: CModelValue.h:67
const C_FLOAT64 & getRate() const
unsigned C_INT32 getDimensionality() const
std::string getVolumeRateUnitsDisplayString() const
Definition: CModel.cpp:4571
std::string getExpression() const
const C_FLOAT64 & getInitialValue() const
void slotTypeChanged(int type)
std::string getVolumeUnitsDisplayString() const
Definition: CModel.cpp:4547
void loadMetaboliteTable()
CCompartment * mpCompartment
Definition: CQCompartment.h:45
std::string getInitialExpression() const
static CCopasiVector< CCopasiDataModel > * getDatamodelList()
const C_FLOAT64 & getValue() const
Definition: CModel.h:50
const CModelEntity::Status & getStatus() const
void CQCompartment::loadMetaboliteTable ( )
private

Definition at line 548 of file CQCompartment.cpp.

References FROM_UTF8, CCompartment::getMetabolites(), CCopasiContainer::getObjects(), mpCompartment, and CCopasiVector< T >::size().

Referenced by load().

549 {
550  if (mpCompartment == NULL) return;
551 
552  mpMetaboliteTable->setRowCount(mpCompartment->getMetabolites().size());
553 
554  CCopasiContainer::objectMap::const_iterator it =
556  CCopasiContainer::objectMap::const_iterator end =
558 
559  for (int i = 0; it != end; ++it)
560  {
561  if (dynamic_cast< CMetab * >(it->second) != NULL)
562  {
563  mpMetaboliteTable->setItem(i++, 0, new QTableWidgetItem(FROM_UTF8(it->second->getObjectName())));
564  }
565  }
566 
567  mpMetaboliteTable->resizeRowsToContents();
568 
569  return;
570 }
#define FROM_UTF8(__x)
Definition: qtUtilities.h:73
CCopasiVectorNS< CMetab > & getMetabolites()
virtual size_t size() const
virtual const objectMap & getObjects() const
CCompartment * mpCompartment
Definition: CQCompartment.h:45
void CQCompartment::save ( )
private

Definition at line 457 of file CQCompartment.cpp.

References CModelEntity::ASSIGNMENT, C_INT32, ListViews::CHANGE, ListViews::COMPARTMENT, CCopasiRootContainer::getDatamodelList(), CCompartment::getDimensionality(), CModelEntity::getExpression(), CModelEntity::getInitialExpression(), CModelEntity::getInitialValue(), CModelEntity::getStatus(), mChanged, mItemToType, CopasiWidget::mKey, mpCompartment, CopasiWidget::protectedNotify(), CCompartment::setDimensionality(), CModelEntity::setExpression(), CModelEntity::setInitialExpression(), CModelEntity::setInitialValue(), and CModelEntity::setStatus().

Referenced by leave().

458 {
459 
460  if (mpCompartment == NULL) return;
461 
462 #ifdef COPASI_EXTUNIT
463 
464  //Dimensionality
465  if ((C_INT32)mpCompartment->getDimensionality() != mpComboBoxDim->currentIndex()) //this makes assumptions about the order of entries in the combo box!
466  {
467  mpCompartment->setDimensionality(mpComboBoxDim->currentIndex());
468  mChanged = true;
469  }
470 
471 #endif
472 
473  // Type
474  if (mpCompartment->getStatus() != (CModelEntity::Status) mItemToType[mpComboBoxType->currentIndex()])
475  {
476  mpCompartment->setStatus((CModelEntity::Status) mItemToType[mpComboBoxType->currentIndex()]);
477  mChanged = true;
478  }
479 
480  // Initial Volume
481  if (QString::number(mpCompartment->getInitialValue(), 'g', 10) != mpEditInitialVolume->text())
482  {
483  mpCompartment->setInitialValue(mpEditInitialVolume->text().toDouble());
484  mChanged = true;
485  }
486 
487  // Expression
488  if (mpCompartment->getExpression() != mpExpressionEMW->mpExpressionWidget->getExpression())
489  {
490  mpCompartment->setExpression(mpExpressionEMW->mpExpressionWidget->getExpression());
491  mChanged = true;
492  }
493 
494  // Initial Expression
495  if ((CModelEntity::Status) mItemToType[mpComboBoxType->currentIndex()] != CModelEntity::ASSIGNMENT)
496  {
497  if (mpBoxUseInitialExpression->isChecked() &&
498  mpCompartment->getInitialExpression() != mpInitialExpressionEMW->mpExpressionWidget->getExpression())
499  {
500  mpCompartment->setInitialExpression(mpInitialExpressionEMW->mpExpressionWidget->getExpression());
501  mChanged = true;
502  }
503  else if (!mpBoxUseInitialExpression->isChecked() &&
505  {
507  mChanged = true;
508  }
509  }
510 
511  if (mChanged)
512  {
513  assert(CCopasiRootContainer::getDatamodelList()->size() > 0);
514  (*CCopasiRootContainer::getDatamodelList())[0]->changed();
516  }
517 
518  mChanged = false;
519 }
bool setDimensionality(unsigned C_INT32 dim)
unsigned C_INT32 getDimensionality() const
bool setInitialExpression(const std::string &expression)
std::string getExpression() const
#define C_INT32
Definition: copasi.h:90
const C_FLOAT64 & getInitialValue() const
virtual void setStatus(const CModelEntity::Status &status)
CCompartment * mpCompartment
Definition: CQCompartment.h:45
std::string getInitialExpression() const
static CCopasiVector< CCopasiDataModel > * getDatamodelList()
std::vector< int > mItemToType
Definition: CQCompartment.h:44
virtual bool protectedNotify(ListViews::ObjectType objectType, ListViews::Action action, const std::string &key="")
virtual void setInitialValue(const C_FLOAT64 &initialValue)
const CModelEntity::Status & getStatus() const
bool setExpression(const std::string &expression)
std::string mKey
Definition: copasiWidget.h:63
void CQCompartment::slotBtnCopy ( )
inlineprivateslot

Definition at line 58 of file CQCompartment.h.

58 {}; //dummy, to bypass warnings from TabWidget connections
void CQCompartment::slotBtnDelete ( )
privateslot

Definition at line 196 of file CQCompartment.cpp.

References ListViews::COMPARTMENT, CQMessageBox::confirmDelete(), ListViews::DELETE, FROM_UTF8, CCopasiRootContainer::getDatamodelList(), CCompartment::getDeletedObjects(), CCopasiDataModel::getModel(), CCopasiObject::getObjectName(), CopasiWidget::mKey, mpCompartment, CopasiWidget::protectedNotify(), and CModel::removeCompartment().

197 {
198  assert(CCopasiRootContainer::getDatamodelList()->size() > 0);
200  assert(pDataModel != NULL);
201  CModel * pModel = pDataModel->getModel();
202 
203  if (pModel == NULL) return;
204 
205  if (mpCompartment == NULL) return;
206 
207  QMessageBox::StandardButton choice =
208  CQMessageBox::confirmDelete(this, "compartment",
211 
212  switch (choice)
213  {
214  case QMessageBox::Ok:
215  {
216  pDataModel->getModel()->removeCompartment(mKey);
217 
219  protectedNotify(ListViews::COMPARTMENT, ListViews::DELETE, ""); //Refresh all as there may be dependencies.
220  break;
221  }
222 
223  default:
224  break;
225  }
226 }
#define FROM_UTF8(__x)
Definition: qtUtilities.h:73
const std::string & getObjectName() const
bool removeCompartment(const size_t index, const bool &recursive=true)
Definition: CModel.cpp:2720
virtual std::set< const CCopasiObject * > getDeletedObjects() const
static StandardButton confirmDelete(QWidget *parent, const QString &objectType, const QString &objects, const std::set< const CCopasiObject * > &deletedObjects)
CCompartment * mpCompartment
Definition: CQCompartment.h:45
static CCopasiVector< CCopasiDataModel > * getDatamodelList()
virtual bool protectedNotify(ListViews::ObjectType objectType, ListViews::Action action, const std::string &key="")
Definition: CModel.h:50
std::string mKey
Definition: copasiWidget.h:63
void CQCompartment::slotBtnNew ( )
privateslot

Definition at line 81 of file CQCompartment.cpp.

References ListViews::ADD, C_INVALID_INDEX, ListViews::COMPARTMENT, CCopasiRootContainer::getDatamodelList(), CModelEntity::getKey(), leave(), mpCompartment, CopasiWidget::mpListView, CopasiWidget::protectedNotify(), ListViews::switchToOtherWidget(), and TO_UTF8.

82 {
83  leave();
84 
85  std::string name = "compartment_1";
86  int i = 1;
87 
88  assert(CCopasiRootContainer::getDatamodelList()->size() > 0);
89 
90  while (!(mpCompartment = (*CCopasiRootContainer::getDatamodelList())[0]->getModel()->createCompartment(name)))
91  {
92  i++;
93  name = "compartment_";
94  name += TO_UTF8(QString::number(i));
95  }
96 
97  std::string key = mpCompartment->getKey();
98 
101 }
void switchToOtherWidget(const size_t &id, const std::string &key)
Definition: listviews.cpp:926
#define C_INVALID_INDEX
Definition: copasi.h:222
virtual bool leave()
ListViews * mpListView
Definition: copasiWidget.h:62
virtual const std::string & getKey() const
CCompartment * mpCompartment
Definition: CQCompartment.h:45
static CCopasiVector< CCopasiDataModel > * getDatamodelList()
virtual bool protectedNotify(ListViews::ObjectType objectType, ListViews::Action action, const std::string &key="")
#define TO_UTF8(__x)
Definition: qtUtilities.h:74
void CQCompartment::slotExpressionValid ( bool  valid)
privateslot

Definition at line 320 of file CQCompartment.cpp.

References mExpressionValid.

321 {
322  mExpressionValid = valid;
323 }
bool mExpressionValid
Definition: CQCompartment.h:47
void CQCompartment::slotInitialExpressionValid ( bool  valid)
privateslot

Definition at line 325 of file CQCompartment.cpp.

References mInitialExpressionValid.

326 {
327  mInitialExpressionValid = valid;
328 }
bool mInitialExpressionValid
Definition: CQCompartment.h:48
void CQCompartment::slotInitialTypeChanged ( bool  useInitialAssignment)
privateslot

This function is used in case of not FIXED type

Definition at line 298 of file CQCompartment.cpp.

References CModelEntity::ASSIGNMENT, and mItemToType.

Referenced by slotTypeChanged().

299 {
300  if (useInitialAssignment)
301  {
302  mpLblInitialExpression->show();
303  mpInitialExpressionEMW->show();
304 
305  mpEditInitialVolume->setEnabled(false);
306  mpInitialExpressionEMW->updateWidget();
307  }
308  else
309  {
310  mpLblInitialExpression->hide();
311  mpInitialExpressionEMW->hide();
312 
313  mpEditInitialVolume->setEnabled((CModelEntity::Status) mItemToType[mpComboBoxType->currentIndex()] != CModelEntity::ASSIGNMENT);
314  }
315 }
std::vector< int > mItemToType
Definition: CQCompartment.h:44
void CQCompartment::slotMetaboliteTableCurrentChanged ( int  row,
int  col 
)
privateslot

Definition at line 524 of file CQCompartment.cpp.

References C_INVALID_INDEX, CCompartment::getMetabolites(), CCopasiContainer::getObjects(), mpCompartment, CopasiWidget::mpListView, ListViews::switchToOtherWidget(), and TO_UTF8.

525 {
526  if (mpCompartment == NULL) return;
527 
528  QTableWidgetItem * pItem = mpMetaboliteTable->item(row, col);
529 
530  std::string s1, s2;
531  s1 = TO_UTF8(pItem->text());
532 
533  CCopasiContainer::objectMap::const_iterator it =
535  CCopasiContainer::objectMap::const_iterator end =
537 
538  for (; it != end; ++it)
539  if (dynamic_cast< CMetab * >(it->second) != NULL)
540  {
541  s2 = it->second->getObjectName();
542 
543  if (s1 == s2)
544  mpListView->switchToOtherWidget(C_INVALID_INDEX, it->second->getKey());
545  }
546 }
CCopasiVectorNS< CMetab > & getMetabolites()
void switchToOtherWidget(const size_t &id, const std::string &key)
Definition: listviews.cpp:926
virtual const objectMap & getObjects() const
#define C_INVALID_INDEX
Definition: copasi.h:222
ListViews * mpListView
Definition: copasiWidget.h:62
CCompartment * mpCompartment
Definition: CQCompartment.h:45
#define TO_UTF8(__x)
Definition: qtUtilities.h:74
void CQCompartment::slotTypeChanged ( int  type)
privateslot

If the simulation type is changed then COPASI will automatically adjust its appearance, especially correlating to the Expression Widget and its buttons.

Definition at line 232 of file CQCompartment.cpp.

References CModelEntity::ASSIGNMENT, CModelEntity::FIXED, FROM_UTF8, CCopasiObject::getObjectAncestor(), CModel::getVolumeRateUnitsDisplayString(), CModel::getVolumeUnitsDisplayString(), mItemToType, mpCompartment, CModelEntity::ODE, and slotInitialTypeChanged().

Referenced by load().

233 {
234  QString Units;
235 
236  const CModel * pModel = NULL;
237 
238  if (mpCompartment != NULL)
239  pModel = dynamic_cast<const CModel *>(mpCompartment->getObjectAncestor("Model"));
240 
241  switch ((CModelEntity::Status) mItemToType[type])
242  {
243  case CModelEntity::FIXED:
244  mpLblExpression->hide();
245  mpExpressionEMW->hide();
246 
247  mpBoxUseInitialExpression->setEnabled(true);
248  slotInitialTypeChanged(mpBoxUseInitialExpression->isChecked());
249  break;
250 
252 
253  if (pModel)
254  Units = FROM_UTF8(pModel->getVolumeUnitsDisplayString());
255 
256  if (!Units.isEmpty())
257  Units = " (" + Units + ")";
258 
259  mpLblExpression->setText("Expression" + Units);
260 
261  mpLblExpression->show();
262  mpExpressionEMW->show();
263 
264  mpBoxUseInitialExpression->setEnabled(false);
265  slotInitialTypeChanged(false);
266 
267  mpExpressionEMW->updateWidget();
268  break;
269 
270  case CModelEntity::ODE:
271 
272  if (pModel)
273  Units = FROM_UTF8(pModel->getVolumeRateUnitsDisplayString());
274 
275  if (!Units.isEmpty())
276  Units = " (" + Units + ")";
277 
278  mpLblExpression->setText("Expression" + Units);
279 
280  mpLblExpression->show();
281  mpExpressionEMW->show();
282 
283  mpBoxUseInitialExpression->setEnabled(true);
284  slotInitialTypeChanged(mpBoxUseInitialExpression->isChecked());
285 
286  mpExpressionEMW->updateWidget();
287 
288  break;
289 
290  default:
291  break;
292  }
293 }
CCopasiContainer * getObjectAncestor(const std::string &type) const
#define FROM_UTF8(__x)
Definition: qtUtilities.h:73
std::string getVolumeRateUnitsDisplayString() const
Definition: CModel.cpp:4571
void slotInitialTypeChanged(bool useInitialAssignment)
std::string getVolumeUnitsDisplayString() const
Definition: CModel.cpp:4547
CCompartment * mpCompartment
Definition: CQCompartment.h:45
std::vector< int > mItemToType
Definition: CQCompartment.h:44
Definition: CModel.h:50
bool CQCompartment::update ( ListViews::ObjectType  objectType,
ListViews::Action  action,
const std::string &  key 
)
virtual

Reimplemented from CopasiWidget.

Definition at line 358 of file CQCompartment.cpp.

References ListViews::COMPARTMENT, load(), ListViews::METABOLITE, CopasiWidget::mIgnoreUpdates, ListViews::MODEL, and ListViews::STATE.

361 {
362  if (!isVisible() || mIgnoreUpdates) return true;
363 
364  switch (objectType)
365  {
366  case ListViews::STATE:
367  case ListViews::MODEL:
370  load();
371  break;
372 
373  default:
374  break;
375  }
376 
377  return true;
378 }
objectType
bool mIgnoreUpdates
Definition: copasiWidget.h:67

Member Data Documentation

bool CQCompartment::mChanged
private

Definition at line 46 of file CQCompartment.h.

Referenced by load(), and save().

bool CQCompartment::mExpressionValid
private

Definition at line 47 of file CQCompartment.h.

Referenced by CQCompartment(), and slotExpressionValid().

bool CQCompartment::mInitialExpressionValid
private

Definition at line 48 of file CQCompartment.h.

Referenced by CQCompartment(), and slotInitialExpressionValid().

std::vector< int > CQCompartment::mItemToType
private

Definition at line 44 of file CQCompartment.h.

Referenced by CQCompartment(), leave(), save(), slotInitialTypeChanged(), and slotTypeChanged().

CCompartment* CQCompartment::mpCompartment
private

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