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

#include <CQSpeciesDetail.h>

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

Public Member Functions

void copy ()
 
 CQSpeciesDetail (QWidget *parent=0, const char *name=0)
 
virtual bool leave ()
 
virtual void setFramework (int framework)
 
virtual bool update (ListViews::ObjectType objectType, ListViews::Action action, const std::string &key)
 
virtual ~CQSpeciesDetail ()
 
- 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 ()
 
void setIgnoreUpdates (bool v)
 

Protected Member Functions

virtual bool enterProtected ()
 

Private Slots

void slotBtnCopy ()
 
void slotBtnDelete ()
 
void slotBtnNew ()
 
void slotCompartmentChanged (int compartment)
 
void slotExpressionValid (bool valid)
 
void slotInitialExpressionValid (bool valid)
 
void slotInitialTypeChanged (bool useInitialExpression)
 
void slotInitialValueLostFocus ()
 
void slotNameLostFocus ()
 
void slotSwitchToReaction (int row, int column)
 
void slotTypeChanged (int type)
 

Private Member Functions

void load ()
 
void loadReactionTable ()
 
void save ()
 

Private Attributes

bool mChanged
 
bool mExpressionValid
 
double mInitialConcentration
 
bool mInitialExpressionValid
 
double mInitialNumber
 
std::vector< int > mItemToType
 
const CCompartmentmpCurrentCompartment
 
CMetabmpMetab
 

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 21 of file CQSpeciesDetail.h.

Constructor & Destructor Documentation

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

Definition at line 25 of file CQSpeciesDetail.cpp.

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

25  :
26  CopasiWidget(parent, name),
27  mChanged(false),
28  mpMetab(NULL),
30  mItemToType(),
31  mInitialNumber(0.0),
33  mExpressionValid(false),
35 {
36  setupUi(this);
37 
38  mpComboBoxType->insertItem(mpComboBoxType->count(), FROM_UTF8(CModelEntity::StatusName[CModelEntity::REACTIONS]));
39  mpComboBoxType->insertItem(mpComboBoxType->count(), FROM_UTF8(CModelEntity::StatusName[CModelEntity::FIXED]));
40  mpComboBoxType->insertItem(mpComboBoxType->count(), FROM_UTF8(CModelEntity::StatusName[CModelEntity::ASSIGNMENT]));
41  mpComboBoxType->insertItem(mpComboBoxType->count(), FROM_UTF8(CModelEntity::StatusName[CModelEntity::ODE]));
42 
46  mItemToType.push_back(CModelEntity::ODE);
47 
48 // assert(CCopasiRootContainer::getDatamodelList()->size() > 0);
49 // int Width = fontMetrics().width("Concentration (" +
50 // FROM_UTF8((*CCopasiRootContainer::getDatamodelList())[0]->getModel()->getConcentrationUnitsDisplayString()) +
51 // ")");
52 //
53 
54 // mpLblValue->setMinimumWidth(Width);
55 
56  mpExpressionEMW->mpExpressionWidget->setExpressionType(CQExpressionWidget::TransientExpression);
57 
58  mpInitialExpressionEMW->mpExpressionWidget->setExpressionType(CQExpressionWidget::InitialExpression);
59 
60  mpReactionTable->verticalHeader()->hide();
61  mpReactionTable->verticalHeader()->setResizeMode(QHeaderView::ResizeToContents);
62  mpReactionTable->horizontalHeader()->hide();
63  mpReactionTable->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents);
64 }
const CCompartment * mpCurrentCompartment
#define FROM_UTF8(__x)
Definition: qtUtilities.h:73
static const std::string StatusName[]
Definition: CModelValue.h:67
double mInitialConcentration
CopasiWidget(QWidget *parent=0, const char *name=0, Qt::WFlags f=0)
bool mInitialExpressionValid
std::vector< int > mItemToType
CQSpeciesDetail::~CQSpeciesDetail ( )
virtual

Definition at line 66 of file CQSpeciesDetail.cpp.

67 {
68 }

Member Function Documentation

void CQSpeciesDetail::copy ( )

Definition at line 505 of file CQSpeciesDetail.cpp.

References CModelExpansion::ElementsMap::add(), CModelExpansion::SetOfModelElements::addCompartment(), CModelExpansion::SetOfModelElements::addMetab(), CCopasiVector< T >::begin(), C_INVALID_INDEX, ListViews::COMPARTMENT, ListViews::DELETE, CModelExpansion::duplicateMetab(), CCopasiVector< T >::end(), FROM_UTF8, CMetab::getCompartment(), CModel::getCompartments(), CModelExpansion::ElementsMap::getDuplicateKey(), CCopasiDataModel::getModel(), CCopasiObject::getObjectName(), ListViews::METABOLITE, CopasiWidget::mKey, mpCurrentCompartment, CopasiWidget::mpDataModel, CopasiWidget::mpListView, mpMetab, pdelete, CopasiWidget::protectedNotify(), ListViews::REACTION, CQNameSelectionDialog::setSelectionList(), and ListViews::switchToOtherWidget().

Referenced by CQTabWidget::slotBtnCopy().

506 {
507  if (mpMetab == NULL) return;
508 
509  CModel * pModel = NULL;
510 
511  if (mpMetab) pModel = mpDataModel->getModel();
512 
513  if (pModel == NULL) return; // for getting compartments and initializing cModelExpObj
514 
515  // Create and customize compartment choices dialog
516  CQNameSelectionDialog * pDialog = new CQNameSelectionDialog(this);
517  pDialog->setWindowTitle("Choose a compartment");
518  pDialog->mpLblName->setText("compartment");
519  pDialog->mpSelectionBox->clear();
520  pDialog->mpSelectionBox->setDuplicatesEnabled(false);
521  pDialog->mpSelectionBox->setEditable(false); // at least for now, unless we want to add new compartment creation here.
522 
523  // Use CModelExpansion for duplication
524  CModelExpansion cModelExpObj = CModelExpansion(pModel);
526  CModelExpansion::ElementsMap origToCopyMapping;
527 
528  // for comboBox compartment list and setting compartment
529  CCopasiVectorNS< CCompartment > & Compartments = pModel->getCompartments();
530 
533  QStringList SelectionList;
534 
535  // Collect and load list of compartment names in comboBox
536  for (; it != end; ++it)
537  {
538  SelectionList.append(FROM_UTF8((*it)->getObjectName()));
539  }
540 
541  pDialog->setSelectionList(SelectionList);
542 
543  //Set the current compartment as the default
545  // to use here, and for testing if compartment changed after executing the dialog
546  int origCompartmentIndex = pDialog->mpSelectionBox->findText(FROM_UTF8(mpCurrentCompartment->getObjectName()));
547  pDialog->mpSelectionBox->setCurrentIndex(origCompartmentIndex);
548 
549  it = Compartments.begin(); // Reuse Compartments iterator to set compartment choice
550 
551  if (pDialog->exec() != QDialog::Rejected)
552  {
553  // Put species in different compartment (without name modification) by making
554  // duplicateMetab think the other compartment was duplicated from the original
555  if (origCompartmentIndex != pDialog->mpSelectionBox->currentIndex())
556  {
557  sourceObjects.addCompartment(mpMetab->getCompartment());
558  origToCopyMapping.add(mpMetab->getCompartment(), *(it + pDialog->mpSelectionBox->currentIndex()));
559  }
560 
561  sourceObjects.addMetab(mpMetab);
562  cModelExpObj.duplicateMetab(mpMetab, "_copy", sourceObjects, origToCopyMapping);
563 
568  }
569 
570  pdelete(pDialog);
571 }
void setSelectionList(const QStringList &selectionList)
const CCompartment * mpCurrentCompartment
#define pdelete(p)
Definition: copasi.h:215
#define FROM_UTF8(__x)
Definition: qtUtilities.h:73
void switchToOtherWidget(const size_t &id, const std::string &key)
Definition: listviews.cpp:926
const std::string & getObjectName() const
iterator begin()
#define C_INVALID_INDEX
Definition: copasi.h:222
void duplicateMetab(const CMetab *source, const std::string &index, const SetOfModelElements &sourceSet, ElementsMap &emap)
iterator end()
ListViews * mpListView
Definition: copasiWidget.h:62
void add(const CCopasiObject *source, CCopasiObject *copy)
add a source->duplicate mapping
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="")
CCopasiDataModel * mpDataModel
Definition: copasiWidget.h:65
CCopasiVectorNS< CCompartment > & getCompartments()
Definition: CModel.cpp:1145
void addCompartment(const CCompartment *x)
Definition: CModel.h:50
std::string mKey
Definition: copasiWidget.h:63
const CCompartment * getCompartment() const
Definition: CMetab.cpp:222
bool CQSpeciesDetail::enterProtected ( )
protectedvirtual

Reimplemented from CopasiWidget.

Definition at line 235 of file CQSpeciesDetail.cpp.

References load(), CopasiWidget::mpListView, mpMetab, CopasiWidget::mpObject, and ListViews::switchToOtherWidget().

236 {
237  mpMetab = dynamic_cast< CMetab * >(mpObject);
238 
239  if (!mpMetab)
240  {
241 
243  return false;
244  }
245 
246  load();
247 
248  return true;
249 }
void switchToOtherWidget(const size_t &id, const std::string &key)
Definition: listviews.cpp:926
CCopasiObject * mpObject
Definition: copasiWidget.h:64
Definition: CMetab.h:178
ListViews * mpListView
Definition: copasiWidget.h:62
bool CQSpeciesDetail::leave ( )
virtual

Reimplemented from CopasiWidget.

Definition at line 70 of file CQSpeciesDetail.cpp.

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

Referenced by slotBtnNew().

71 {
72  if ((CModelEntity::Status) mItemToType[mpComboBoxType->currentIndex()] != CModelEntity::FIXED &&
73  (CModelEntity::Status) mItemToType[mpComboBoxType->currentIndex()] != CModelEntity::REACTIONS)
74  {
75  // -- Expression --
76  mpExpressionEMW->updateWidget();
77  }
78 
79  if (mpBoxUseInitialExpression->isChecked())
80  {
81  // -- Initial Expression --
82  mpInitialExpressionEMW->updateWidget();
83  }
84 
85  save();
86 
87  return true;
88 }
std::vector< int > mItemToType
void CQSpeciesDetail::load ( )
private

Definition at line 251 of file CQSpeciesDetail.cpp.

References CModelEntity::ASSIGNMENT, FROM_UTF8, CMetab::getCompartment(), CModel::getCompartments(), CModelEntity::getExpression(), CMetab::getInitialConcentration(), CModelEntity::getInitialExpression(), CModelEntity::getInitialValue(), CMetab::getModel(), CCopasiObject::getObjectName(), CModelEntity::getStatus(), CModel::getTimeUnitsDisplayString(), CMetab::getTransitionTime(), loadReactionTable(), mChanged, CopasiWidget::mFramework, mInitialConcentration, mInitialNumber, mpCurrentCompartment, mpMetab, setFramework(), CCopasiVector< T >::size(), slotTypeChanged(), and CModelEntity::StatusName.

Referenced by enterProtected(), and update().

252 {
253  if (mpMetab == NULL) return;
254 
255  const CModel * pModel = NULL;
256 
257  if (mpMetab)
258  pModel = mpMetab->getModel();
259 
260  QString TimeUnits;
261 
262  if (pModel)
263  TimeUnits = FROM_UTF8(pModel->getTimeUnitsDisplayString());
264 
265  if (!TimeUnits.isEmpty())
266  TimeUnits = " (" + TimeUnits + ")";
267 
268  // Update the labels to reflect the model units
269  mpLblTransitionTime->setText("Transition Time " + TimeUnits);
270 
271  // Compartment
272  const CCopasiVectorNS< CCompartment > & Compartments = pModel->getCompartments();
273  const CCompartment * pCompartment;
274  mpComboBoxCompartment->clear();
275 
276  mpComboBoxCompartment->setDuplicatesEnabled(false);
277  size_t m;
278 
279  for (m = 0; m < Compartments.size(); m++)
280  {
281  pCompartment = Compartments[m];
282  mpComboBoxCompartment->insertItem(mpComboBoxCompartment->count(), FROM_UTF8(pCompartment->getObjectName()));
283  }
284 
286  mpComboBoxCompartment->setCurrentIndex(mpComboBoxCompartment->findText(FROM_UTF8(mpCurrentCompartment->getObjectName())));
287 
288  // Simulation Type
289  mpComboBoxType->setCurrentIndex(mpComboBoxType->findText(FROM_UTF8(CModelEntity::StatusName[mpMetab->getStatus()])));
290 
291  // Initial Concentration handled in slotTypeChanged
293 
294  // Initial Number handled in slotTypeChanged
296 
297  // Transition Time
298  mpEditTransitionTime->setText(QString::number(mpMetab->getTransitionTime(), 'g', 10));
299 
300  // Expression
301  mpExpressionEMW->mpExpressionWidget->setExpression(mpMetab->getExpression());
302  mpExpressionEMW->updateWidget();
303 
304  // Initial Expression
305  mpInitialExpressionEMW->mpExpressionWidget->setExpression(mpMetab->getInitialExpression());
306  mpInitialExpressionEMW->updateWidget();
307 
308  // Type dependent display of values
309  slotTypeChanged(mpComboBoxType->currentIndex());
310 
311  // Use Initial Expression
313  mpMetab->getInitialExpression() == "")
314  {
315  mpBoxUseInitialExpression->setChecked(false);
316  // slotInitialTypeChanged(false);
317  }
318  else
319  {
320  mpBoxUseInitialExpression->setChecked(true);
321  // slotInitialTypeChanged(true);
322  }
323 
325 
326  // Update the units and values accordingly
328 
329  mChanged = false;
330  return;
331 }
const CCompartment * mpCurrentCompartment
virtual void setFramework(int framework)
#define FROM_UTF8(__x)
Definition: qtUtilities.h:73
std::string getTimeUnitsDisplayString() const
Definition: CModel.cpp:4531
static const std::string StatusName[]
Definition: CModelValue.h:67
const std::string & getObjectName() const
double mInitialConcentration
virtual size_t size() const
const C_FLOAT64 & getInitialConcentration() const
Definition: CMetab.cpp:220
std::string getExpression() const
const C_FLOAT64 & getInitialValue() const
const CModel * getModel() const
Definition: CMetab.cpp:224
std::string getInitialExpression() const
CCopasiVectorNS< CCompartment > & getCompartments()
Definition: CModel.cpp:1145
Definition: CModel.h:50
const CModelEntity::Status & getStatus() const
const C_FLOAT64 & getTransitionTime() const
Definition: CMetab.cpp:229
void slotTypeChanged(int type)
const CCompartment * getCompartment() const
Definition: CMetab.cpp:222
void CQSpeciesDetail::loadReactionTable ( )
private

Definition at line 440 of file CQSpeciesDetail.cpp.

References CModel::appendDependentReactions(), FROM_UTF8, CChemEqInterface::getChemEqString(), CMetab::getDeletedObjects(), CMetab::getModel(), CCopasiObject::getObjectName(), and mpMetab.

Referenced by load().

441 {
442  if (mpMetab == NULL) return;
443 
444  CModel * pModel = const_cast< CModel * >(mpMetab->getModel());
445 
446  if (pModel == NULL) return;
447 
448  std::set< const CCopasiObject * > Reactions;
449  pModel->appendDependentReactions(mpMetab->getDeletedObjects(), Reactions);
450 
451  mpReactionTable->setRowCount((int) Reactions.size());
452 
453  std::set< const CCopasiObject * >::const_iterator it = Reactions.begin();
454  std::set< const CCopasiObject * >::const_iterator end = Reactions.end();
455  int i = 0;
456  const CReaction * pReaction;
457 
458  for (; it != end; ++it, ++i)
459  {
460  pReaction = static_cast< const CReaction * >(*it);
461  mpReactionTable->setItem(i, 0, new QTableWidgetItem(FROM_UTF8(pReaction->getObjectName()) + ":"));
462  mpReactionTable->setItem(i, 1, new QTableWidgetItem(FROM_UTF8(CChemEqInterface::getChemEqString(pModel, *pReaction, false))));
463  }
464 
465  if (i == 0)
466  mpReactionTable->setItem(i, 0, new QTableWidgetItem("none"));
467 
468  // Provide count of reactions, in label.
469  mpLblReactions->setText("Involved in \n" + QString::number(mpReactionTable->rowCount()) + " Reactions");
470 
471  return;
472 }
#define FROM_UTF8(__x)
Definition: qtUtilities.h:73
const std::string & getObjectName() const
virtual DataObjectSet getDeletedObjects() const
Definition: CMetab.cpp:806
bool appendDependentReactions(std::set< const CCopasiObject * > candidates, std::set< const CCopasiObject * > &dependents) const
Definition: CModel.cpp:2472
const CModel * getModel() const
Definition: CMetab.cpp:224
std::string getChemEqString(bool expanded) const
Definition: CModel.h:50
void CQSpeciesDetail::save ( )
private

Definition at line 333 of file CQSpeciesDetail.cpp.

References CModelEntity::ASSIGNMENT, ListViews::CHANGE, CCopasiDataModel::changed(), ListViews::COMPARTMENT, FROM_UTF8, CMetab::getCompartment(), CModel::getCompartments(), CModelEntity::getExpression(), CMetab::getInitialConcentration(), CModelEntity::getInitialExpression(), CModelEntity::getInitialValue(), CMetab::getModel(), CCopasiObject::getObjectName(), CModelEntity::getStatus(), CQMessageBox::information(), CModel::initializeMetabolites(), mChanged, ListViews::METABOLITE, CopasiWidget::mFramework, mInitialConcentration, mInitialNumber, mItemToType, CopasiWidget::mKey, mpCurrentCompartment, CopasiWidget::mpDataModel, mpMetab, CopasiWidget::protectedNotify(), CCopasiVectorN< CType >::remove(), CModel::setCompileFlag(), CModelEntity::setExpression(), CMetab::setInitialConcentration(), CModelEntity::setInitialExpression(), CModelEntity::setInitialValue(), CMetab::setStatus(), slotCompartmentChanged(), and TO_UTF8.

Referenced by leave().

334 {
335  if (mpMetab == NULL) return;
336 
337  CModel * pModel = const_cast< CModel * >(mpMetab->getModel());
338 
339  if (pModel == NULL) return;
340 
341  // Compartment
343  {
344  QString Compartment = mpComboBoxCompartment->currentText();
345  std::string CompartmentToRemove = mpMetab->getCompartment()->getObjectName();
346 
347  if (!pModel->getCompartments()[TO_UTF8(Compartment)]->addMetabolite(mpMetab))
348  {
349  QString msg;
350  msg = "Unable to move species '" + FROM_UTF8(mpMetab->getObjectName()) + "'\n"
351  + "from compartment '" + FROM_UTF8(CompartmentToRemove) + "' to compartment '" + Compartment + "'\n"
352  + "since a species with that name already exist in the target compartment.";
353 
355  "Unable to move Species",
356  msg,
357  QMessageBox::Ok, QMessageBox::Ok);
358 
359  // Revert the changes
360  mpComboBoxCompartment->setCurrentIndex(mpComboBoxCompartment->findText(FROM_UTF8(CompartmentToRemove)));
361 
362  slotCompartmentChanged(mpComboBoxCompartment->currentIndex());
363  }
364  else
365  {
366  pModel->getCompartments()[CompartmentToRemove]->getMetabolites().remove(mpMetab->getObjectName());
367  pModel->setCompileFlag();
368  pModel->initializeMetabolites();
370  mChanged = true;
371  }
372  }
373 
374  // Type
375  if (mpMetab->getStatus() != (CModelEntity::Status) mItemToType[mpComboBoxType->currentIndex()])
376  {
377  mpMetab->setStatus((CModelEntity::Status) mItemToType[mpComboBoxType->currentIndex()]);
378  mChanged = true;
379  }
380 
381  // Initial Concentration and Initial Number
382  switch (mFramework)
383  {
384  case 0:
385 
387  {
389  mChanged = true;
390  }
391 
392  break;
393 
394  case 1:
395 
397  {
399  mChanged = true;
400  }
401 
402  break;
403  }
404 
405  // Expression
406  if (mpMetab->getExpression() != mpExpressionEMW->mpExpressionWidget->getExpression())
407  {
408  mpMetab->setExpression(mpExpressionEMW->mpExpressionWidget->getExpression());
409  mChanged = true;
410  }
411 
412  // Initial Expression
413  if ((CModelEntity::Status) mItemToType[mpComboBoxType->currentIndex()] != CModelEntity::ASSIGNMENT)
414  {
415  if (mpBoxUseInitialExpression->isChecked() &&
416  mpMetab->getInitialExpression() != (mpInitialExpressionEMW->mpExpressionWidget->getExpression()))
417  {
418  mpMetab->setInitialExpression(mpInitialExpressionEMW->mpExpressionWidget->getExpression());
419  mChanged = true;
420  }
421  else if (!mpBoxUseInitialExpression->isChecked() &&
422  mpMetab->getInitialExpression() != "")
423  {
425  mChanged = true;
426  }
427  }
428 
429  if (mChanged)
430  {
431  if (mpDataModel)
432  mpDataModel->changed();
433 
435  }
436 
437  mChanged = false;
438 }
const CCompartment * mpCurrentCompartment
void setInitialConcentration(const C_FLOAT64 &initialConcentration)
Definition: CMetab.cpp:257
#define FROM_UTF8(__x)
Definition: qtUtilities.h:73
const std::string & getObjectName() const
void slotCompartmentChanged(int compartment)
virtual void setStatus(const CModelEntity::Status &status)
Definition: CMetab.cpp:291
double mInitialConcentration
const C_FLOAT64 & getInitialConcentration() const
Definition: CMetab.cpp:220
bool setInitialExpression(const std::string &expression)
static StandardButton information(QWidget *parent, const QString &title, const QString &text, StandardButtons buttons=Ok, StandardButton defaultButton=NoButton)
std::string getExpression() const
void changed(const bool &changed=true)
const C_FLOAT64 & getInitialValue() const
const CModel * getModel() const
Definition: CMetab.cpp:224
std::string getInitialExpression() const
void initializeMetabolites()
Definition: CModel.cpp:942
virtual bool protectedNotify(ListViews::ObjectType objectType, ListViews::Action action, const std::string &key="")
void setCompileFlag(bool flag=true)
Definition: CModel.cpp:607
virtual void remove(const std::string &name)
CCopasiDataModel * mpDataModel
Definition: copasiWidget.h:65
CCopasiVectorNS< CCompartment > & getCompartments()
Definition: CModel.cpp:1145
std::vector< int > mItemToType
#define TO_UTF8(__x)
Definition: qtUtilities.h:74
virtual void setInitialValue(const C_FLOAT64 &initialValue)
Definition: CModel.h:50
const CModelEntity::Status & getStatus() const
bool setExpression(const std::string &expression)
std::string mKey
Definition: copasiWidget.h:63
const CCompartment * getCompartment() const
Definition: CMetab.cpp:222
void CQSpeciesDetail::setFramework ( int  framework)
virtual

Reimplemented from CopasiWidget.

Definition at line 135 of file CQSpeciesDetail.cpp.

References CModelEntity::ASSIGNMENT, FROM_UTF8, CMetab::getConcentration(), CMetab::getConcentrationRate(), CModel::getConcentrationRateUnitsDisplayString(), CModel::getConcentrationUnitsDisplayString(), CModel::getFrequencyUnitsDisplayString(), CMetab::getModel(), CModelEntity::getRate(), CModelEntity::getStatus(), CModelEntity::getValue(), CMetab::isInitialConcentrationChangeAllowed(), CopasiWidget::mFramework, mInitialConcentration, mInitialNumber, mItemToType, mpMetab, and CopasiWidget::setFramework().

Referenced by load(), and slotTypeChanged().

136 {
137  CopasiWidget::setFramework(framework);
138 
139  const CModel * pModel = NULL;
140 
141  if (mpMetab)
142  pModel = mpMetab->getModel();
143 
144  QString ValueUnits;
145 
146  if (pModel)
147  ValueUnits = FROM_UTF8(pModel->getConcentrationUnitsDisplayString());
148 
149  if (!ValueUnits.isEmpty())
150  ValueUnits = " (" + ValueUnits + ")";
151 
152  QString RateUnits;
153 
154  if (pModel)
155  RateUnits = FROM_UTF8(pModel->getConcentrationRateUnitsDisplayString());
156 
157  if (!RateUnits.isEmpty())
158  RateUnits = " (" + RateUnits + ")";
159 
160  QString FrequencyUnits;
161 
162  if (pModel)
163  FrequencyUnits = FROM_UTF8(pModel->getFrequencyUnitsDisplayString());
164 
165  if (!FrequencyUnits.isEmpty())
166  FrequencyUnits = " (" + FrequencyUnits + ")";
167 
168  switch (mFramework)
169  {
170  case 0:
171  mpLblValue->setText("Concentration" + ValueUnits);
172 
173  if (mpMetab != NULL &&
174  (CModelEntity::Status) mItemToType[mpComboBoxType->currentIndex()] == CModelEntity::ASSIGNMENT)
175  mpLblExpression->setText("Expression" + ValueUnits);
176  else
177  mpLblExpression->setText("Expression" + RateUnits);
178 
179  mpLblRate->setText("Rate" + RateUnits);
180 
181  ValueUnits.replace(0, 1, '\n'); // Line break instead of space
182  mpLblInitialValue->setText("Initial Concentration" + ValueUnits);
183  mpLblInitialExpression->setText("Initial Expression" + ValueUnits);
184 
185  mpEditInitialValue->setText(QString::number(mInitialConcentration, 'g', 10));
186 
187  if (mpMetab != NULL)
188  {
189  mpEditInitialValue->setReadOnly(!mpMetab->isInitialConcentrationChangeAllowed());
190  mpEditCurrentValue->setText(QString::number(mpMetab->getConcentration(), 'g', 10));
191  mpEditRate->setText(QString::number(mpMetab->getConcentrationRate(), 'g', 10));
192  }
193  else
194  {
195  mpEditInitialValue->setReadOnly(false);
196  mpEditCurrentValue->setText("");
197  mpEditRate->setText("");
198  }
199 
200  break;
201 
202  case 1:
203  mpLblInitialValue->setText("Initial Particle Number");
204 
205  ValueUnits.replace(0, 1, '\n'); // Line break instead of space
206  mpLblInitialExpression->setText("Initial Expression" + ValueUnits);
207 
208  if (mpMetab != NULL &&
210  mpLblExpression->setText("Expression" + ValueUnits);
211  else
212  mpLblExpression->setText("Expression" + RateUnits);
213 
214  mpLblValue->setText("Particle Number");
215  mpLblRate->setText("Rate" + FrequencyUnits);
216 
217  mpEditInitialValue->setText(QString::number(mInitialNumber, 'g', 10));
218  mpEditInitialValue->setReadOnly(false);
219 
220  if (mpMetab != NULL)
221  {
222  mpEditCurrentValue->setText(QString::number(mpMetab->getValue(), 'g', 10));
223  mpEditRate->setText(QString::number(mpMetab->getRate(), 'g', 10));
224  }
225  else
226  {
227  mpEditCurrentValue->setText("");
228  mpEditRate->setText("");
229  }
230 
231  break;
232  }
233 }
#define FROM_UTF8(__x)
Definition: qtUtilities.h:73
const C_FLOAT64 & getRate() const
std::string getConcentrationRateUnitsDisplayString() const
Definition: CModel.cpp:4607
std::string getFrequencyUnitsDisplayString() const
Definition: CModel.cpp:4539
double mInitialConcentration
const bool & isInitialConcentrationChangeAllowed() const
Definition: CMetab.cpp:664
const CModel * getModel() const
Definition: CMetab.cpp:224
std::string getConcentrationUnitsDisplayString() const
Definition: CModel.cpp:4587
const C_FLOAT64 & getValue() const
std::vector< int > mItemToType
const C_FLOAT64 & getConcentration() const
Definition: CMetab.cpp:218
Definition: CModel.h:50
const CModelEntity::Status & getStatus() const
C_FLOAT64 getConcentrationRate() const
Definition: CMetab.cpp:870
virtual void setFramework(int framework)
void CQSpeciesDetail::slotBtnCopy ( )
inlineprivateslot

Definition at line 56 of file CQSpeciesDetail.h.

56 {};
void CQSpeciesDetail::slotBtnDelete ( )
privateslot

Definition at line 474 of file CQSpeciesDetail.cpp.

References CQMessageBox::confirmDelete(), ListViews::DELETE, FROM_UTF8, CMetab::getDeletedObjects(), CMetab::getModel(), CCopasiObject::getObjectName(), ListViews::METABOLITE, CopasiWidget::mKey, mpMetab, CopasiWidget::protectedNotify(), and CModel::removeMetabolite().

475 {
476  if (mpMetab == NULL) return;
477 
478  CModel * pModel = const_cast< CModel *>(mpMetab->getModel());
479 
480  if (pModel == NULL) return;
481 
482  QMessageBox::StandardButton choice =
483  CQMessageBox::confirmDelete(this, "species",
486 
487  switch (choice)
488  {
489  case QMessageBox::Ok:
490  {
491  pModel->removeMetabolite(mKey);
492 
493 #undef DELETE
495  protectedNotify(ListViews::METABOLITE, ListViews::DELETE, "");//Refresh all as there may be dependencies.
496  //TODO notify about reactions
497  break;
498  }
499 
500  default:
501  break;
502  }
503 }
#define FROM_UTF8(__x)
Definition: qtUtilities.h:73
const std::string & getObjectName() const
bool removeMetabolite(const std::string &key, const bool &recursive=true)
Definition: CModel.cpp:2667
virtual DataObjectSet getDeletedObjects() const
Definition: CMetab.cpp:806
static StandardButton confirmDelete(QWidget *parent, const QString &objectType, const QString &objects, const std::set< const CCopasiObject * > &deletedObjects)
const CModel * getModel() const
Definition: CMetab.cpp:224
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 CQSpeciesDetail::slotBtnNew ( )
privateslot

Definition at line 573 of file CQSpeciesDetail.cpp.

References ListViews::ADD, C_INVALID_INDEX, CModel::createCompartment(), CModel::createMetabolite(), CModel::getCompartments(), CCopasiRootContainer::getDatamodelList(), CModelEntity::getKey(), CCopasiDataModel::getModel(), leave(), ListViews::METABOLITE, CopasiWidget::mFramework, CopasiWidget::mpListView, mpMetab, CopasiWidget::protectedNotify(), CModelEntity::REACTIONS, CMetab::setInitialConcentration(), CModelEntity::setInitialValue(), CCopasiVector< T >::size(), ListViews::switchToOtherWidget(), and TO_UTF8.

574 {
575  leave();
576 
577  assert(CCopasiRootContainer::getDatamodelList()->size() > 0);
579  assert(pDataModel != NULL);
580 
581  CModel * pModel = pDataModel->getModel();
582 
583  if (pModel == NULL)
584  return;
585 
586  if (pModel->getCompartments().size() == 0)
587  pModel->createCompartment("compartment");
588 
589  std::string name = "species_1";
590  int i = 1;
591 
592  while (!(mpMetab = pModel->createMetabolite(name, "", 1.0, CModelEntity::REACTIONS)))
593  {
594  i++;
595  name = "species_";
596  name += TO_UTF8(QString::number(i));
597  }
598 
599  switch (mFramework)
600  {
601  case 0:
603  break;
604 
605  case 1:
606  mpMetab->setInitialValue(100.0);
607  break;
608  }
609 
610  std::string key = mpMetab->getKey();
613 }
void setInitialConcentration(const C_FLOAT64 &initialConcentration)
Definition: CMetab.cpp:257
void switchToOtherWidget(const size_t &id, const std::string &key)
Definition: listviews.cpp:926
virtual size_t size() const
#define C_INVALID_INDEX
Definition: copasi.h:222
ListViews * mpListView
Definition: copasiWidget.h:62
virtual const std::string & getKey() const
virtual bool leave()
static CCopasiVector< CCopasiDataModel > * getDatamodelList()
virtual bool protectedNotify(ListViews::ObjectType objectType, ListViews::Action action, const std::string &key="")
CCopasiVectorNS< CCompartment > & getCompartments()
Definition: CModel.cpp:1145
#define TO_UTF8(__x)
Definition: qtUtilities.h:74
virtual void setInitialValue(const C_FLOAT64 &initialValue)
Definition: CModel.h:50
CCompartment * createCompartment(const std::string &name, const C_FLOAT64 &volume=1.0)
Definition: CModel.cpp:2698
CMetab * createMetabolite(const std::string &name, const std::string &compartment, const C_FLOAT64 &iconc=1.0, const CModelEntity::Status &status=CModelEntity::REACTIONS)
Definition: CModel.cpp:2622
void CQSpeciesDetail::slotCompartmentChanged ( int  compartment)
privateslot

Definition at line 615 of file CQSpeciesDetail.cpp.

References CModel::getCompartments(), CModelEntity::getInitialValue(), CMetab::getModel(), CopasiWidget::mFramework, mInitialNumber, mpCurrentCompartment, mpMetab, and TO_UTF8.

Referenced by save().

616 {
617  if (!mpMetab || !mpCurrentCompartment) return;
618 
619  const CModel * pModel = mpMetab->getModel();
620 
621  if (pModel == NULL)
622  return;
623 
624  QString Compartment = mpComboBoxCompartment->itemText(compartment);
625  const CCompartment * pNewCompartment =
626  pModel->getCompartments()[TO_UTF8(Compartment)];
627 
628  if (pNewCompartment == mpCurrentCompartment ||
629  pNewCompartment == NULL) return;
630 
632 
633  if (mFramework == 1)
634  mpEditInitialValue->setText(QString::number(mInitialNumber, 'g', 10));
635 
636  mpCurrentCompartment = pNewCompartment;
637 }
const CCompartment * mpCurrentCompartment
const C_FLOAT64 & getInitialValue() const
const CModel * getModel() const
Definition: CMetab.cpp:224
CCopasiVectorNS< CCompartment > & getCompartments()
Definition: CModel.cpp:1145
#define TO_UTF8(__x)
Definition: qtUtilities.h:74
Definition: CModel.h:50
void CQSpeciesDetail::slotExpressionValid ( bool  valid)
privateslot

Definition at line 639 of file CQSpeciesDetail.cpp.

References mExpressionValid.

640 {
641  mExpressionValid = valid;
642 }
void CQSpeciesDetail::slotInitialExpressionValid ( bool  valid)
privateslot

Definition at line 644 of file CQSpeciesDetail.cpp.

References mInitialExpressionValid.

645 {
646  mInitialExpressionValid = valid;
647 }
bool mInitialExpressionValid
void CQSpeciesDetail::slotInitialTypeChanged ( bool  useInitialExpression)
privateslot

Definition at line 649 of file CQSpeciesDetail.cpp.

References CModelEntity::ASSIGNMENT, and mItemToType.

Referenced by slotTypeChanged().

650 {
651  if (useInitialExpression)
652  {
653  mpLblInitialExpression->show();
654  mpInitialExpressionEMW->show();
655 
656  mpEditInitialValue->setEnabled(false);
657  mpInitialExpressionEMW->updateWidget();
658  }
659  else
660  {
661  mpLblInitialExpression->hide();
662  mpInitialExpressionEMW->hide();
663 
664  mpEditInitialValue->setEnabled((CModelEntity::Status) mItemToType[mpComboBoxType->currentIndex()] != CModelEntity::ASSIGNMENT);
665  }
666 }
std::vector< int > mItemToType
void CQSpeciesDetail::slotInitialValueLostFocus ( )
privateslot

Definition at line 668 of file CQSpeciesDetail.cpp.

References CMetab::convertToConcentration(), CMetab::convertToNumber(), CMetab::getModel(), CopasiWidget::mFramework, mInitialConcentration, mInitialNumber, mpCurrentCompartment, and mpMetab.

669 {
670  if (!mpMetab || !mpCurrentCompartment) return;
671 
672  const CModel * pModel = mpMetab->getModel();
673 
674  if (pModel == NULL)
675  return;
676 
677  switch (mFramework)
678  {
679  case 0:
680 
681  if (QString::number(mInitialConcentration, 'g', 10) == mpEditInitialValue->text())
682  return;
683 
684  mInitialConcentration = mpEditInitialValue->text().toDouble();
687  *pModel);
688  break;
689 
690  case 1:
691 
692  if (QString::number(mInitialNumber, 'g', 10) == mpEditInitialValue->text())
693  return;
694 
695  mInitialNumber = mpEditInitialValue->text().toDouble();
698  *pModel);
699  break;
700  }
701 }
const CCompartment * mpCurrentCompartment
double mInitialConcentration
const CModel * getModel() const
Definition: CMetab.cpp:224
static C_FLOAT64 convertToNumber(const C_FLOAT64 &concentration, const CCompartment &compartment, const CModel &model)
Definition: CMetab.cpp:35
Definition: CModel.h:50
static C_FLOAT64 convertToConcentration(const C_FLOAT64 &number, const CCompartment &compartment, const CModel &model)
Definition: CMetab.cpp:41
void CQSpeciesDetail::slotNameLostFocus ( )
privateslot

Definition at line 703 of file CQSpeciesDetail.cpp.

704 {}
void CQSpeciesDetail::slotSwitchToReaction ( int  row,
int  column 
)
privateslot

Definition at line 706 of file CQSpeciesDetail.cpp.

References CModel::appendDependentReactions(), C_INT32, C_INVALID_INDEX, CMetab::getDeletedObjects(), CReaction::getKey(), CMetab::getModel(), CCopasiObject::getObjectName(), CopasiWidget::mpListView, mpMetab, ListViews::switchToOtherWidget(), and TO_UTF8.

707 {
708  if (mpMetab == NULL) return;
709 
710  const CModel * pModel = mpMetab->getModel();
711 
712  if (pModel == NULL) return;
713 
714  std::set< const CCopasiObject * > Reactions;
715  pModel->appendDependentReactions(mpMetab->getDeletedObjects(), Reactions);
716 
717  std::string s1, s2;
718  s1 = TO_UTF8(mpReactionTable->item(row, 0)->text());
719  s1 = s1.substr(0, s1.length() - 1);
720 
721  C_INT32 i = 0;
722  std::set< const CCopasiObject * >::const_iterator it = Reactions.begin();
723  std::set< const CCopasiObject * >::const_iterator end = Reactions.end();
724  const CReaction * pReaction;
725 
726  for (; it != end; ++it, ++i)
727  {
728  pReaction = static_cast< const CReaction * >(*it);
729  s2 = pReaction->getObjectName();
730 
731  if (s1 == s2)
733  }
734 }
void switchToOtherWidget(const size_t &id, const std::string &key)
Definition: listviews.cpp:926
const std::string & getObjectName() const
virtual const std::string & getKey() const
Definition: CReaction.cpp:190
#define C_INVALID_INDEX
Definition: copasi.h:222
#define C_INT32
Definition: copasi.h:90
virtual DataObjectSet getDeletedObjects() const
Definition: CMetab.cpp:806
bool appendDependentReactions(std::set< const CCopasiObject * > candidates, std::set< const CCopasiObject * > &dependents) const
Definition: CModel.cpp:2472
ListViews * mpListView
Definition: copasiWidget.h:62
const CModel * getModel() const
Definition: CMetab.cpp:224
#define TO_UTF8(__x)
Definition: qtUtilities.h:74
Definition: CModel.h:50
void CQSpeciesDetail::slotTypeChanged ( int  type)
privateslot

Definition at line 736 of file CQSpeciesDetail.cpp.

References CModelEntity::ASSIGNMENT, CModelEntity::FIXED, CopasiWidget::mFramework, mItemToType, CModelEntity::ODE, CModelEntity::REACTIONS, setFramework(), and slotInitialTypeChanged().

Referenced by load().

737 {
738  switch ((CModelEntity::Status) mItemToType[type])
739  {
740  case CModelEntity::FIXED:
741  mpLblExpression->hide();
742  mpExpressionEMW->hide();
743 
744  mpBoxUseInitialExpression->setEnabled(true);
745  slotInitialTypeChanged(mpBoxUseInitialExpression->isChecked());
746  break;
747 
749  mpLblExpression->show();
750  mpExpressionEMW->show();
751 
752  mpBoxUseInitialExpression->setEnabled(false);
753  slotInitialTypeChanged(false);
754 
755  mpExpressionEMW->updateWidget();
756  break;
757 
758  case CModelEntity::ODE:
759  mpLblExpression->show();
760  mpExpressionEMW->show();
761 
762  mpBoxUseInitialExpression->setEnabled(true);
763  slotInitialTypeChanged(mpBoxUseInitialExpression->isChecked());
764 
765  mpExpressionEMW->updateWidget();
766  break;
767 
769  mpLblExpression->hide();
770  mpExpressionEMW->hide();
771 
772  mpBoxUseInitialExpression->setEnabled(true);
773  slotInitialTypeChanged(mpBoxUseInitialExpression->isChecked());
774  break;
775 
776  default:
777  break;
778  }
779 
780  // This will update the unit display.
782 }
virtual void setFramework(int framework)
void slotInitialTypeChanged(bool useInitialExpression)
std::vector< int > mItemToType
bool CQSpeciesDetail::update ( ListViews::ObjectType  objectType,
ListViews::Action  action,
const std::string &  key 
)
virtual

Reimplemented from CopasiWidget.

Definition at line 90 of file CQSpeciesDetail.cpp.

References ListViews::ADD, ListViews::COMPARTMENT, ListViews::DELETE, load(), ListViews::METABOLITE, CopasiWidget::mIgnoreUpdates, CopasiWidget::mKey, ListViews::MODEL, mpMetab, CopasiWidget::mpObject, and ListViews::STATE.

93 {
94  switch (objectType)
95  {
96  case ListViews::MODEL:
97 
98  // For a new model we need to remove references to no longer existing metabolites
99  if (action == ListViews::ADD)
100  {
101  mKey = "";
102  mpObject = NULL;
103  mpMetab = NULL;
104  }
105 
106  break;
107 
109 
110  // If the currently displayed metabolite is deleted we need to remove its references.
111  if (action == ListViews::DELETE && mKey == key)
112  {
113  mKey = "";
114  mpObject = NULL;
115  mpMetab = NULL;
116  }
117 
118  break;
119 
120  case ListViews::STATE:
122  break;
123 
124  default:
125  return true;
126  break;
127  }
128 
129  if (isVisible() && !mIgnoreUpdates)
130  load();
131 
132  return true;
133 }
objectType
CCopasiObject * mpObject
Definition: copasiWidget.h:64
bool mIgnoreUpdates
Definition: copasiWidget.h:67
std::string mKey
Definition: copasiWidget.h:63

Member Data Documentation

bool CQSpeciesDetail::mChanged
private

Definition at line 41 of file CQSpeciesDetail.h.

Referenced by load(), and save().

bool CQSpeciesDetail::mExpressionValid
private

Definition at line 47 of file CQSpeciesDetail.h.

Referenced by slotExpressionValid().

double CQSpeciesDetail::mInitialConcentration
private

Definition at line 46 of file CQSpeciesDetail.h.

Referenced by load(), save(), setFramework(), and slotInitialValueLostFocus().

bool CQSpeciesDetail::mInitialExpressionValid
private

Definition at line 48 of file CQSpeciesDetail.h.

Referenced by slotInitialExpressionValid().

double CQSpeciesDetail::mInitialNumber
private
std::vector< int > CQSpeciesDetail::mItemToType
private
const CCompartment* CQSpeciesDetail::mpCurrentCompartment
private

Definition at line 43 of file CQSpeciesDetail.h.

Referenced by copy(), load(), save(), slotCompartmentChanged(), and slotInitialValueLostFocus().

CMetab* CQSpeciesDetail::mpMetab
private

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