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

#include <ReactionsWidget1.h>

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

Public Member Functions

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

virtual void slotBtnCopy ()
 
virtual void slotBtnDelete ()
 
virtual void slotBtnNew ()
 
virtual void slotCheckBoxClicked ()
 
virtual void slotComboBoxSelectionChanged (const QString &)
 
virtual void slotGotoFunction ()
 
virtual void slotLineEditChanged ()
 
virtual void slotNewFunction ()
 
virtual void slotParameterStatusChanged (int index, bool local)
 
virtual void slotTableChanged (int index, int sub, QString newValue)
 
- Protected Slots inherited from CopasiWidget
virtual bool protectedNotify (ListViews::ObjectType objectType, ListViews::Action action, const std::string &key="")
 

Protected Member Functions

virtual bool enterProtected ()
 
void FillWidgetFromRI ()
 
bool loadFromReaction (const CReaction *reaction)
 
bool saveToReaction ()
 

Protected Attributes

CReactionInterfacempRi
 
- Protected Attributes inherited from CopasiWidget
int mFramework
 
bool mIgnoreUpdates
 
std::string mKey
 
CCopasiDataModelmpDataModel
 
ListViewsmpListView
 
CCopasiObjectmpObject
 

Detailed Description

Definition at line 35 of file ReactionsWidget1.h.

Constructor & Destructor Documentation

ReactionsWidget1::ReactionsWidget1 ( QWidget *  parent = 0,
const char *  name = 0,
Qt::WFlags  fl = 0 
)

Definition at line 53 of file ReactionsWidget1.cpp.

54  : CopasiWidget(parent, name, f),
55  mpRi(NULL)
56 {
57  setupUi(this);
58 
59  if (!name)
60  setObjectName("ReactionsWidget1");
61 
62  setWindowTitle(trUtf8("ReactionsWidget1"));
63 
64  LineEdit2->setValidator(new ChemEqValidator(LineEdit2));
65 
66 #ifndef COPASI_DEBUG
67  mpFast->hide();
68 #endif
69 }
CopasiWidget(QWidget *parent=0, const char *name=0, Qt::WFlags f=0)
CReactionInterface * mpRi
ReactionsWidget1::~ReactionsWidget1 ( )

Definition at line 71 of file ReactionsWidget1.cpp.

References mpRi, and pdelete.

72 {
73  pdelete(mpRi);
74 }
#define pdelete(p)
Definition: copasi.h:215
CReactionInterface * mpRi

Member Function Documentation

void ReactionsWidget1::copy ( )

Definition at line 278 of file ReactionsWidget1.cpp.

References CModelExpansion::ElementsMap::add(), CModelExpansion::SetOfModelElements::addCompartment(), CModelExpansion::SetOfModelElements::addMetab(), CModelExpansion::SetOfModelElements::addReaction(), CCopasiVector< T >::begin(), C_INVALID_INDEX, ListViews::COMPARTMENT, ListViews::DELETE, CModelExpansion::duplicateMetab(), CModelExpansion::duplicateReaction(), CCopasiVector< T >::end(), FROM_UTF8, CReaction::getChemEq(), CModel::getCompartments(), CModelExpansion::ElementsMap::getDuplicateKey(), CCopasiDataModel::getModel(), CChemEq::getModifiers(), CCopasiObject::getObjectName(), CChemEq::getProducts(), CChemEq::getSubstrates(), ListViews::METABOLITE, CopasiWidget::mKey, CopasiWidget::mpDataModel, CopasiWidget::mpListView, CopasiWidget::mpObject, pdelete, CopasiWidget::protectedNotify(), ListViews::REACTION, CQNameSelectionDialog::setSelectionList(), and ListViews::switchToOtherWidget().

Referenced by CQTabWidget::slotBtnCopy().

279 {
280  CReaction* reac = dynamic_cast< CReaction * >(mpObject);
281 
282  if (reac == NULL) return;
283 
284  CModel * pModel = NULL;
285 
286  if (reac) pModel = mpDataModel->getModel();
287 
288  if (pModel == NULL) return; // for getting compartments and initializing cModelExpObj
289 
290  // Create and customize compartment choices dialog
291  CQNameSelectionDialog * pDialog = new CQNameSelectionDialog(this);
292  pDialog->resize(350, pDialog->height());
293  pDialog->setToolTip("Cancel to re-use original species");
294  pDialog->mpLblName->setText("compartment");
295  pDialog->mpSelectionBox->clear();
296  pDialog->mpSelectionBox->setDuplicatesEnabled(false);
297  pDialog->mpSelectionBox->setEditable(false); // at least for now, unless we want to add new compartment creation here.
298 
299  // Use CModelExpansion for duplication
300  CModelExpansion cModelExpObj = CModelExpansion(pModel);
302  CModelExpansion::ElementsMap origToCopyMapping;
303 
304  // for comboBox compartment list and setting compartment
305  CCopasiVectorNS< CCompartment > & Compartments = pModel->getCompartments();
306 
307  CCopasiVectorN< CCompartment >::const_iterator Compartment_it = Compartments.begin();
309  QStringList SelectionList;
310 
311  // Collect and load list of compartment names in comboBox
312  for (; Compartment_it != end; ++Compartment_it)
313  {
314  SelectionList.append(FROM_UTF8((*Compartment_it)->getObjectName()));
315  }
316 
317  pDialog->setSelectionList(SelectionList);
318 
319  const CCompartment * origCompartment = NULL;
320  // to use here, and for testing if compartment changed after executing the dialog
321  int origCompartmentIndex;
322 
324 
325  const CCopasiVector< CChemEqElement > & substratesToCopy = reac->getChemEq().getSubstrates();
326 
327  for (MetabIt = substratesToCopy.begin(); MetabIt != substratesToCopy.end(); MetabIt++)
328  {
329  pDialog->setWindowTitle("Create copy of " + FROM_UTF8((*MetabIt)->getMetabolite()->getObjectName()) + "?");
330  origCompartment = (*MetabIt)->getMetabolite()->getCompartment();
331  origCompartmentIndex = pDialog->mpSelectionBox->findText(FROM_UTF8(origCompartment->getObjectName()));
332  pDialog->mpSelectionBox->setCurrentIndex(origCompartmentIndex);
333 
334  Compartment_it = Compartments.begin(); // Reuse Compartments iterator to set compartment choice
335 
336  if (pDialog->exec() != QDialog::Rejected)
337  {
338  // Put species in different compartment (without name modification) by making
339  // duplicateMetab think the other compartment was duplicated from the original
340  if (origCompartmentIndex != pDialog->mpSelectionBox->currentIndex())
341  {
342  sourceObjects.addCompartment(origCompartment);
343  origToCopyMapping.add(origCompartment, *(Compartment_it + pDialog->mpSelectionBox->currentIndex()));
344  }
345 
346  sourceObjects.addMetab((*MetabIt)->getMetabolite());
347  cModelExpObj.duplicateMetab((*MetabIt)->getMetabolite(), "_copy", sourceObjects, origToCopyMapping);
348  }
349  }
350 
351  const CCopasiVector< CChemEqElement > & productsToCopy = reac->getChemEq().getProducts();
352 
353  for (MetabIt = productsToCopy.begin(); MetabIt != productsToCopy.end(); MetabIt++)
354  {
355  pDialog->setWindowTitle("Create copy of " + FROM_UTF8((*MetabIt)->getMetabolite()->getObjectName()) + "?");
356  origCompartment = (*MetabIt)->getMetabolite()->getCompartment();
357  origCompartmentIndex = pDialog->mpSelectionBox->findText(FROM_UTF8(origCompartment->getObjectName()));
358  pDialog->mpSelectionBox->setCurrentIndex(origCompartmentIndex);
359 
360  Compartment_it = Compartments.begin();
361 
362  if (pDialog->exec() != QDialog::Rejected)
363  {
364  if (origCompartmentIndex != pDialog->mpSelectionBox->currentIndex())
365  {
366  sourceObjects.addCompartment(origCompartment);
367  origToCopyMapping.add(origCompartment, *(Compartment_it + pDialog->mpSelectionBox->currentIndex()));
368  }
369 
370  sourceObjects.addMetab((*MetabIt)->getMetabolite());
371  cModelExpObj.duplicateMetab((*MetabIt)->getMetabolite(), "_copy", sourceObjects, origToCopyMapping);
372  }
373  }
374 
375  const CCopasiVector< CChemEqElement > & modifiersToCopy = reac->getChemEq().getModifiers();
376 
377  for (MetabIt = modifiersToCopy.begin(); MetabIt != modifiersToCopy.end(); MetabIt++)
378  {
379  pDialog->setWindowTitle("Create copy of " + FROM_UTF8((*MetabIt)->getMetabolite()->getObjectName()) + "?");
380  origCompartment = (*MetabIt)->getMetabolite()->getCompartment();
381  origCompartmentIndex = pDialog->mpSelectionBox->findText(FROM_UTF8(origCompartment->getObjectName()));
382  pDialog->mpSelectionBox->setCurrentIndex(origCompartmentIndex);
383 
384  Compartment_it = Compartments.begin();
385 
386  if (pDialog->exec() != QDialog::Rejected)
387  {
388  if (origCompartmentIndex != pDialog->mpSelectionBox->currentIndex())
389  {
390  sourceObjects.addCompartment(origCompartment);
391  origToCopyMapping.add(origCompartment, *(Compartment_it + pDialog->mpSelectionBox->currentIndex()));
392  }
393 
394  sourceObjects.addMetab((*MetabIt)->getMetabolite());
395  cModelExpObj.duplicateMetab((*MetabIt)->getMetabolite(), "_copy", sourceObjects, origToCopyMapping);
396  }
397  }
398 
399  sourceObjects.addReaction(reac);
400  cModelExpObj.duplicateReaction(reac, "_copy", sourceObjects, origToCopyMapping);
401 
406 
407  pdelete(pDialog);
408 }
void setSelectionList(const QStringList &selectionList)
#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
void addReaction(const CReaction *x)
const std::string & getObjectName() const
iterator begin()
CCopasiObject * mpObject
Definition: copasiWidget.h:64
#define C_INVALID_INDEX
Definition: copasi.h:222
void duplicateMetab(const CMetab *source, const std::string &index, const SetOfModelElements &sourceSet, ElementsMap &emap)
const CCopasiVector< CChemEqElement > & getProducts() const
Definition: CChemEq.cpp:63
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)
void duplicateReaction(const CReaction *source, const std::string &index, const SetOfModelElements &sourceSet, ElementsMap &emap)
const CCopasiVector< CChemEqElement > & getSubstrates() const
Definition: CChemEq.cpp:60
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)
const CCopasiVector< CChemEqElement > & getModifiers() const
Definition: CChemEq.cpp:66
Definition: CModel.h:50
std::string mKey
Definition: copasiWidget.h:63
const CChemEq & getChemEq() const
Definition: CReaction.cpp:223
bool ReactionsWidget1::enterProtected ( )
protectedvirtual

Reimplemented from CopasiWidget.

Definition at line 624 of file ReactionsWidget1.cpp.

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

Referenced by slotTableChanged().

625 {
626  CReaction* reac = dynamic_cast< CReaction * >(mpObject);
627 
628  if (reac)
629  return loadFromReaction(reac);
630 
632  return false;
633 }
void switchToOtherWidget(const size_t &id, const std::string &key)
Definition: listviews.cpp:926
CCopasiObject * mpObject
Definition: copasiWidget.h:64
ListViews * mpListView
Definition: copasiWidget.h:62
bool loadFromReaction(const CReaction *reaction)
void ReactionsWidget1::FillWidgetFromRI ( )
protected

Definition at line 449 of file ReactionsWidget1.cpp.

References FROM_UTF8, CReactionInterface::getChemEqString(), CCopasiRootContainer::getDatamodelList(), CReactionInterface::getFunctionDescription(), CReactionInterface::getFunctionName(), CReactionInterface::getListOfPossibleFunctions(), CReactionInterface::isMulticompartment(), CReactionInterface::isReversible(), CopasiWidget::mFramework, CopasiWidget::mpObject, mpRi, setFramework(), and vectorOfStrings2QStringList().

Referenced by loadFromReaction(), slotCheckBoxClicked(), slotComboBoxSelectionChanged(), and slotLineEditChanged().

450 {
451  LineEdit2->setText(FROM_UTF8(mpRi->getChemEqString()));
452 
454 
455  // the reversibility checkbox
456  CheckBox->setChecked(false);
457 
458  if (mpRi->isReversible() == true)
459  {
460  CheckBox->setChecked(true);
461  }
462 
463  mpMultiCompartment->setChecked(mpRi->isMulticompartment());
464 
465  // the function combobox
466  QStringList comboEntries;
468 
469  ComboBox1->clear();
470  ComboBox1->insertItems(0, comboEntries);
471 
472  // if there is a current function the parameter table is initialized
473  if (mpRi->getFunctionName() != "")
474  {
475  if (comboEntries.filter(FROM_UTF8(mpRi->getFunctionName())).size() == 0)
476  ComboBox1->insertItem(0, FROM_UTF8(mpRi->getFunctionName()));
477 
478  ComboBox1->setCurrentIndex(ComboBox1->findText(FROM_UTF8(mpRi->getFunctionName())));
479  ComboBox1->setToolTip(FROM_UTF8(mpRi->getFunctionDescription()));
480 
481  assert(CCopasiRootContainer::getDatamodelList()->size() > 0);
482  table->updateTable(*mpRi, dynamic_cast< CReaction * >(mpObject));
483  }
484  else
485  {
486  ComboBox1->insertItem(0, "undefined");
487  ComboBox1->setCurrentIndex(0);
488  table->initTable();
489  }
490 }
#define FROM_UTF8(__x)
Definition: qtUtilities.h:73
CCopasiObject * mpObject
Definition: copasiWidget.h:64
const std::string & getFunctionDescription() const
void vectorOfStrings2QStringList(std::vector< std::string > vs, QStringList &qsl)
bool isReversible() const
static CCopasiVector< CCopasiDataModel > * getDatamodelList()
virtual void setFramework(int framework)
std::string getChemEqString() const
const std::string & getFunctionName() const
std::vector< std::string > getListOfPossibleFunctions() const
bool isMulticompartment() const
CReactionInterface * mpRi
bool ReactionsWidget1::leave ( )
virtual

Reimplemented from CopasiWidget.

Definition at line 617 of file ReactionsWidget1.cpp.

References saveToReaction().

Referenced by slotTableChanged().

618 {
619  saveToReaction();
620  return true; //always return true. That means that the widget can be
621  //left without saving
622 }
bool ReactionsWidget1::loadFromReaction ( const CReaction reaction)
protected

Definition at line 78 of file ReactionsWidget1.cpp.

References FillWidgetFromRI(), CCopasiRootContainer::getDatamodelList(), CReaction::getKey(), CReactionInterface::initFromReaction(), CReaction::isFast(), CopasiWidget::mpObject, mpRi, and pdelete.

Referenced by enterProtected(), and update().

79 {
80  if (!reaction) return false;
81 
82  // this function is also called via notify, when the control has
83  // not been entered, thus we need to ensure we are pointing to the
84  // right object
85  mpObject = const_cast<CReaction*>(reaction);
86 
87  // this loads the reaction into a CReactionInterface object.
88  // the gui works on this object and later writes back the changes to the reaction
89  pdelete(mpRi);
91 
92  mpRi->initFromReaction(reaction->getKey());
93 
94  // update the widget.
96 
97  mpFast->setChecked(reaction->isFast());
98 
99  return true; //TODO: really check
100 }
#define pdelete(p)
Definition: copasi.h:215
virtual const std::string & getKey() const
Definition: CReaction.cpp:190
void initFromReaction(const std::string &key)
CCopasiObject * mpObject
Definition: copasiWidget.h:64
static CCopasiVector< CCopasiDataModel > * getDatamodelList()
const bool & isFast() const
Definition: CReaction.cpp:1712
CReactionInterface * mpRi
bool ReactionsWidget1::saveToReaction ( )
protected

Definition at line 102 of file ReactionsWidget1.cpp.

References ListViews::ADD, ListViews::CHANGE, CQMessageBox::confirmDelete(), CReactionInterface::createMetabolites(), CReactionInterface::createOtherObjects(), ListViews::DELETE, FROM_UTF8, CKeyFactory::get(), CCopasiRootContainer::getDatamodelList(), CReactionInterface::getDeletedParameters(), CCopasiRootContainer::getKeyFactory(), CCopasiDataModel::getModel(), CReaction::isFast(), CReactionInterface::isValid(), ListViews::METABOLITE, CopasiWidget::mKey, ListViews::MODEL, mpRi, CopasiWidget::protectedNotify(), ListViews::REACTION, CModel::removeLocalReactionParameter(), CReaction::setFast(), CReactionInterface::setFunctionWithEmptyMapping(), and CReactionInterface::writeBackToReaction().

Referenced by leave().

103 {
104  CReaction* reac = dynamic_cast< CReaction * >(CCopasiRootContainer::getKeyFactory()->get(mKey));
105 
106  if (reac == NULL) return true;
107 
108  if (!LineEdit2->isValid()) return false;
109 
110  LineEdit2->slotForceUpdate();
111 
112  if (!mpRi->isValid()) return false;
113 
114  assert(CCopasiRootContainer::getDatamodelList()->size() > 0);
116  assert(pDataModel != NULL);
117 
118  CModel * pModel = pDataModel->getModel();
119 
120  if (pModel == NULL) return false;
121 
122  if (reac->isFast() != mpFast->isChecked())
123  {
124  reac->setFast(mpFast->isChecked());
125  }
126 
127  // Before we save any changes we must check whether any local reaction parameters,
128  // which are used in any mathematical expression in the model are removed.
129  // If that is the case the user must have option to cancel the changes or remove the
130  // affected expressions.
131  std::set< const CCopasiObject * > DeletedParameters = mpRi->getDeletedParameters();
132 
133  if (DeletedParameters.size() != 0)
134  {
135  QString ObjectType = "parameter(s)";
136  QString Objects;
137 
138  std::set< const CCopasiObject * >::const_iterator itParameter, endParameter = DeletedParameters.end();
139  std::set< const CCopasiObject * > DeletedObjects;
140 
141  for (itParameter = DeletedParameters.begin(); itParameter != endParameter; ++itParameter) //all parameters
142  {
143  Objects.append(FROM_UTF8((*itParameter)->getObjectName()) + ", ");
144  DeletedObjects.insert(static_cast< const CCopasiObject * >((*itParameter)->getObject(CCopasiObjectName("Reference=Value"))));
145  }
146 
147  Objects.remove(Objects.length() - 2, 2);
148 
149  QMessageBox::StandardButton choice =
150  CQMessageBox::confirmDelete(NULL, ObjectType,
151  Objects, DeletedObjects);
152 
153  switch (choice)
154  {
155  case QMessageBox::Ok:
156 
157  for (itParameter = DeletedParameters.begin(); itParameter != endParameter; ++itParameter) //all parameters
158  pModel->removeLocalReactionParameter((*itParameter)->getKey());
159 
161  break;
162 
163  default:
164  return true;
165  break;
166  }
167  }
168 
169  // We need to check whether the current reaction still exists, since it is possible that
170  // removing a local reaction parameter triggers its deletion.
171  reac = dynamic_cast< CReaction * >(CCopasiRootContainer::getKeyFactory()->get(mKey));
172 
173  if (reac == NULL)
174  {
176 
178  protectedNotify(ListViews::REACTION, ListViews::DELETE, ""); //Refresh all as there may be dependencies.
179  return true;
180  }
181 
182  //first check if new metabolites need to be created
183  bool createdMetabs = mpRi->createMetabolites();
184  bool createdObjects = mpRi->createOtherObjects();
185 
186  //this writes all changes to the reaction
187  mpRi->writeBackToReaction(reac);
188 
189  assert(CCopasiRootContainer::getDatamodelList()->size() > 0);
190  //(*CCopasiRootContainer::getDatamodelList())[0]->getModel()->compile();
191 
192  //this tells the gui what it needs to know.
193  if (createdObjects)
195  else
196  {
197  if (createdMetabs) protectedNotify(ListViews::METABOLITE, ListViews::ADD, "");
198 
199  // :TODO Bug 322: This should only be called when actual changes have been saved.
200  if (!this->isHidden())
202  }
203 
204  //TODO: detect rename events (mpRi->writeBackToReaction has to do this)
205 
206  // :TODO Bug 322: This should only be called when actual changes have been saved.
207  if (!this->isHidden())
208  (*CCopasiRootContainer::getDatamodelList())[0]->changed();
209 
210  return true;
211 }
bool createOtherObjects() const
#define FROM_UTF8(__x)
Definition: qtUtilities.h:73
CCopasiObject * get(const std::string &key)
static StandardButton confirmDelete(QWidget *parent, const QString &objectType, const QString &objects, const std::set< const CCopasiObject * > &deletedObjects)
static CCopasiVector< CCopasiDataModel > * getDatamodelList()
virtual bool protectedNotify(ListViews::ObjectType objectType, ListViews::Action action, const std::string &key="")
const bool & isFast() const
Definition: CReaction.cpp:1712
std::set< const CCopasiObject * > getDeletedParameters() const
static CKeyFactory * getKeyFactory()
Definition: CModel.h:50
void setFast(const bool &fast)
Definition: CReaction.cpp:1703
bool writeBackToReaction(CReaction *rea)
std::string mKey
Definition: copasiWidget.h:63
bool removeLocalReactionParameter(const std::string &key, const bool &recursive=true)
Definition: CModel.cpp:2818
CReactionInterface * mpRi
void setFunctionWithEmptyMapping(const std::string &fn)
void ReactionsWidget1::setFramework ( int  framework)
virtual

Reimplemented from CopasiWidget.

Definition at line 635 of file ReactionsWidget1.cpp.

References FROM_UTF8, CKeyFactory::get(), CReaction::getFlux(), CModel::getFrequencyUnitsDisplayString(), CCopasiRootContainer::getKeyFactory(), CCopasiObject::getObjectAncestor(), CReaction::getParticleFlux(), CModel::getQuantityRateUnitsDisplayString(), CopasiWidget::mFramework, CopasiWidget::mKey, and CopasiWidget::setFramework().

Referenced by FillWidgetFromRI().

636 {
637  CopasiWidget::setFramework(framework);
638 
639  const CReaction * pReaction = dynamic_cast< CReaction * >(CCopasiRootContainer::getKeyFactory()->get(mKey));
640 
641  const CModel * pModel = NULL;
642 
643  if (pReaction != NULL)
644  pModel = dynamic_cast<const CModel *>(pReaction->getObjectAncestor("Model"));
645 
646  QString Units;
647 
648  switch (mFramework)
649  {
650  case 0:
651 
652  if (pModel)
653  Units = FROM_UTF8(pModel->getQuantityRateUnitsDisplayString());
654 
655  if (!Units.isEmpty())
656  Units = " (" + Units + ")";
657 
658  TextLabel8->setText("Flux" + Units);
659 
660  if (pReaction != NULL)
661  LineEdit3->setText(QString::number(pReaction->getFlux(), 'g', 10));
662 
663  break;
664 
665  case 1:
666 
667  if (pModel)
668  Units = FROM_UTF8(pModel->getFrequencyUnitsDisplayString());
669 
670  if (!Units.isEmpty())
671  Units = " (" + Units + ")";
672 
673  TextLabel8->setText("Particle Flux" + Units);
674 
675  if (pReaction != NULL)
676  LineEdit3->setText(QString::number(pReaction->getParticleFlux(), 'g', 10));
677 
678  break;
679  }
680 }
CCopasiContainer * getObjectAncestor(const std::string &type) const
#define FROM_UTF8(__x)
Definition: qtUtilities.h:73
const C_FLOAT64 & getParticleFlux() const
Definition: CReaction.cpp:201
std::string getFrequencyUnitsDisplayString() const
Definition: CModel.cpp:4539
CCopasiObject * get(const std::string &key)
std::string getQuantityRateUnitsDisplayString() const
Definition: CModel.cpp:4657
const C_FLOAT64 & getFlux() const
Definition: CReaction.cpp:192
static CKeyFactory * getKeyFactory()
Definition: CModel.h:50
virtual void setFramework(int framework)
std::string mKey
Definition: copasiWidget.h:63
virtual void ReactionsWidget1::slotBtnCopy ( )
inlineprotectedvirtualslot

Definition at line 50 of file ReactionsWidget1.h.

50 {}; //dummy, to bypass warnings from TabWidget connections
void ReactionsWidget1::slotBtnDelete ( )
protectedvirtualslot

Definition at line 411 of file ReactionsWidget1.cpp.

References CQMessageBox::confirmDelete(), ListViews::DELETE, FROM_UTF8, CKeyFactory::get(), CCopasiRootContainer::getDatamodelList(), CReaction::getDeletedObjects(), CCopasiRootContainer::getKeyFactory(), CCopasiDataModel::getModel(), CCopasiObject::getObjectName(), CopasiWidget::mKey, mpRi, CopasiWidget::protectedNotify(), ListViews::REACTION, CModel::removeReaction(), and CReactionInterface::setFunctionWithEmptyMapping().

412 {
413  assert(CCopasiRootContainer::getDatamodelList()->size() > 0);
415  assert(pDataModel != NULL);
416  CModel * pModel = pDataModel->getModel();
417 
418  if (pModel == NULL)
419  return;
420 
421  CReaction * pReaction =
422  dynamic_cast< CReaction * >(CCopasiRootContainer::getKeyFactory()->get(mKey));
423 
424  if (pReaction == NULL) return;
425 
426  QMessageBox::StandardButton choice =
427  CQMessageBox::confirmDelete(NULL, "reaction",
428  FROM_UTF8(pReaction->getObjectName()),
429  pReaction->getDeletedObjects());
430 
431  switch (choice)
432  {
433  case QMessageBox::Ok: // Yes or Enter
434  {
435  pDataModel->getModel()->removeReaction(mKey);
436 
438 
440  protectedNotify(ListViews::REACTION, ListViews::DELETE, "");//Refresh all as there may be dependencies.
441  break;
442  }
443 
444  default: // No or Escape
445  break;
446  }
447 }
#define FROM_UTF8(__x)
Definition: qtUtilities.h:73
const std::string & getObjectName() const
CCopasiObject * get(const std::string &key)
virtual std::set< const CCopasiObject * > getDeletedObjects() const
Definition: CReaction.cpp:959
static StandardButton confirmDelete(QWidget *parent, const QString &objectType, const QString &objects, const std::set< const CCopasiObject * > &deletedObjects)
static CCopasiVector< CCopasiDataModel > * getDatamodelList()
virtual bool protectedNotify(ListViews::ObjectType objectType, ListViews::Action action, const std::string &key="")
static CKeyFactory * getKeyFactory()
Definition: CModel.h:50
std::string mKey
Definition: copasiWidget.h:63
CReactionInterface * mpRi
bool removeReaction(const CReaction *pReaction, const bool &recursive=true)
Definition: CModel.cpp:2792
void setFunctionWithEmptyMapping(const std::string &fn)
void ReactionsWidget1::slotBtnNew ( )
protectedvirtualslot

Definition at line 257 of file ReactionsWidget1.cpp.

References ListViews::ADD, C_INVALID_INDEX, CModel::createReaction(), CCopasiRootContainer::getDatamodelList(), CCopasiObject::getKey(), CCopasiDataModel::getModel(), CModel::getReactions(), CopasiWidget::mpListView, CopasiWidget::protectedNotify(), ListViews::REACTION, ListViews::switchToOtherWidget(), and TO_UTF8.

258 {
259  std::string name = "reaction_1";
260  size_t i = 1;
261  assert(CCopasiRootContainer::getDatamodelList()->size() > 0);
263  assert(pDataModel != NULL);
264 
265  while (!pDataModel->getModel()->createReaction(name))
266  {
267  i++;
268  name = "reaction_";
269  name += TO_UTF8(QString::number(i));
270  }
271 
272  std::string key = pDataModel->getModel()->getReactions()[name]->getKey();
274 // enter(key);
276 }
void switchToOtherWidget(const size_t &id, const std::string &key)
Definition: listviews.cpp:926
#define C_INVALID_INDEX
Definition: copasi.h:222
virtual const std::string & getKey() const
ListViews * mpListView
Definition: copasiWidget.h:62
CReaction * createReaction(const std::string &name)
Definition: CModel.cpp:2760
static CCopasiVector< CCopasiDataModel > * getDatamodelList()
virtual bool protectedNotify(ListViews::ObjectType objectType, ListViews::Action action, const std::string &key="")
CCopasiVectorNS< CReaction > & getReactions()
Definition: CModel.cpp:1039
#define TO_UTF8(__x)
Definition: qtUtilities.h:74
void ReactionsWidget1::slotCheckBoxClicked ( )
protectedvirtualslot

Definition at line 213 of file ReactionsWidget1.cpp.

References FillWidgetFromRI(), mpRi, and CReactionInterface::setReversibility().

214 {
215  LineEdit2->slotForceUpdate();
216 
217  // tell the reaction interface
218  mpRi->setReversibility(CheckBox->isChecked(), "");
219 
220  // update the widget
222 }
void setReversibility(bool rev, const std::string &newFunction)
CReactionInterface * mpRi
void ReactionsWidget1::slotComboBoxSelectionChanged ( const QString &  p2)
protectedvirtualslot

Definition at line 225 of file ReactionsWidget1.cpp.

References FillWidgetFromRI(), mpRi, CReactionInterface::setFunctionAndDoMapping(), and TO_UTF8.

226 {
227  // tell the reaction interface
229 
230  // update the widget
232 }
#define TO_UTF8(__x)
Definition: qtUtilities.h:74
void setFunctionAndDoMapping(const std::string &fn)
CReactionInterface * mpRi
void ReactionsWidget1::slotGotoFunction ( )
protectedvirtualslot

Definition at line 556 of file ReactionsWidget1.cpp.

References C_INVALID_INDEX, CKeyFactory::get(), CReaction::getFunction(), CFunction::getKey(), CCopasiRootContainer::getKeyFactory(), CopasiWidget::mKey, CopasiWidget::mpListView, and ListViews::switchToOtherWidget().

557 {
558  CReaction * pReaction =
559  dynamic_cast< CReaction * >(CCopasiRootContainer::getKeyFactory()->get(mKey));
560 
561  if (pReaction == NULL) return;
562 
563  const CFunction * pFunc = pReaction->getFunction();
564 
565  if (pFunc == NULL) return;
566 
568 }
void switchToOtherWidget(const size_t &id, const std::string &key)
Definition: listviews.cpp:926
CCopasiObject * get(const std::string &key)
#define C_INVALID_INDEX
Definition: copasi.h:222
const std::string & getKey() const
Definition: CFunction.cpp:58
const CFunction * getFunction() const
Definition: CReaction.cpp:252
ListViews * mpListView
Definition: copasiWidget.h:62
static CKeyFactory * getKeyFactory()
The class for handling a chemical kinetic function.
Definition: CFunction.h:29
std::string mKey
Definition: copasiWidget.h:63
void ReactionsWidget1::slotLineEditChanged ( )
protectedvirtualslot

Definition at line 235 of file ReactionsWidget1.cpp.

References FillWidgetFromRI(), CChemEqInterface::isValidEq(), mpRi, CReactionInterface::setChemEqString(), and TO_UTF8.

236 {
237  //std::string rName = TO_UTF8(LineEdit1->text());
238 
239  std::string eq = TO_UTF8(LineEdit2->text());
240 
241  //first check if the string is a valid equation
243  {
244  return; // abort further processing
245  }
246 
247  // tell the reaction interface
248  //mpRi->setReactionName(rName);
249 
250  mpRi->setChemEqString(eq, "");
251 
252  // update the widget
254 }
void setChemEqString(const std::string &eq, const std::string &newFunction)
static bool isValidEq(const std::string &eq)
#define TO_UTF8(__x)
Definition: qtUtilities.h:74
CReactionInterface * mpRi
void ReactionsWidget1::slotNewFunction ( )
protectedvirtualslot

Definition at line 570 of file ReactionsWidget1.cpp.

References CFunctionDB::add(), ListViews::ADD, C_INVALID_INDEX, ListViews::FUNCTION, CCopasiRootContainer::getFunctionList(), CCopasiVectorN< CType >::getIndex(), CFunction::getKey(), CCopasiObject::getObjectName(), CFunctionDB::loadedFunctions(), CopasiWidget::mpListView, CopasiWidget::mpObject, CopasiWidget::protectedNotify(), ListViews::switchToOtherWidget(), and TO_UTF8.

571 {
572  // FunctionWidget1 * fw = new FunctionWidget1(NULL);
573  // fw->show();
574  // TODO: we could think about calling the function widget as a dialogue here...
575 
576  std::string name = std::string("Rate Law for ") + mpObject->getObjectName();
577  std::string nname = name;
578  size_t i = 0;
579  CCopasiVectorN<CFunction>& FunctionList
581  CFunction* pFunc;
582 
583  while (FunctionList.getIndex(nname) != C_INVALID_INDEX)
584  {
585  i++;
586  nname = name + "_";
587  nname += TO_UTF8(QString::number(i));
588  }
589 
590  CCopasiRootContainer::getFunctionList()->add(pFunc = new CKinFunction(nname), true);
592 
594 }
CCopasiVectorN< CFunction > & loadedFunctions()
void switchToOtherWidget(const size_t &id, const std::string &key)
Definition: listviews.cpp:926
const std::string & getObjectName() const
CCopasiObject * mpObject
Definition: copasiWidget.h:64
#define C_INVALID_INDEX
Definition: copasi.h:222
virtual size_t getIndex(const std::string &name) const
const std::string & getKey() const
Definition: CFunction.cpp:58
ListViews * mpListView
Definition: copasiWidget.h:62
static CFunctionDB * getFunctionList()
virtual bool protectedNotify(ListViews::ObjectType objectType, ListViews::Action action, const std::string &key="")
The class for handling a chemical kinetic function.
Definition: CFunction.h:29
#define TO_UTF8(__x)
Definition: qtUtilities.h:74
bool add(CFunction *pFunction, const bool &adopt)
void ReactionsWidget1::slotParameterStatusChanged ( int  index,
bool  local 
)
protectedvirtualslot

Definition at line 545 of file ReactionsWidget1.cpp.

References mpRi, CReactionInterface::setLocal(), and CReactionInterface::setMapping().

546 {
547  // slot is a reminant of when a checkbox handled this.
548  // This could be added in to slotTableChanged
549 
550  if (local)
551  mpRi->setLocal(index);
552  else
553  mpRi->setMapping(index, "unknown"); //TODO keep global parameter
554 }
void setLocal(size_t index)
void setMapping(size_t index, std::string mn)
CReactionInterface * mpRi
void ReactionsWidget1::slotTableChanged ( int  index,
int  sub,
QString  newValue 
)
protectedvirtualslot

Definition at line 492 of file ReactionsWidget1.cpp.

References enterProtected(), CReactionInterface::getUsage(), CReactionInterface::isLocalValue(), CReactionInterface::isValid(), leave(), mpRi, CFunctionParameter::PARAMETER, CReactionInterface::setLocalValue(), CReactionInterface::setMapping(), TO_UTF8, and CFunctionParameter::VOLUME.

493 {
494  size_t Index = index;
495  bool SkipFillWidget = false;
496 
497  // setValue
499  {
500  if (sub != 0) return;
501 
502  if (mpRi->isLocalValue(Index))
503  {
504  mpRi->setLocalValue(Index, newValue.toDouble()); // TODO: check
505  SkipFillWidget = true;
506  }
507  else
508  mpRi->setMapping(Index, TO_UTF8(newValue));
509  }
510  else if (mpRi->getUsage(Index) == CFunctionParameter::VOLUME)
511  {
512  if (sub != 0) return;
513 
514  mpRi->setMapping(Index, TO_UTF8(newValue));
515  }
516  else
517  {
518  if (sub == 0) //here we assume that vector parameters cannot be edited
519  {
520 // mpRi->setMapping((int) Index, TO_UTF8(table->item((int) table->mIndex2Line[index], 3)->text()));
521  mpRi->setMapping((int) Index, TO_UTF8(newValue));
522  }
523  }
524 
525  // if we don't stop here, we loose changes!
526  // instead just prevent updating, that way the user has a chance to correct the reaction,
527  // only if the user selects another reaction (or somehow else leaves the editing,
528  // the changes will be lost)
529  //
530  if (!mpRi->isValid())
531  return;
532 
533  // update the widget
534  int rrr = table->currentRow();
535  int ccc = table->currentColumn();
536  table->setCurrentCell(rrr, ccc);
537 
538  // Save changes when leaving cell
539  leave();
540 
541  // Will ultimately update mpRi for updateTable and FillWidgetFromRI
542  enterProtected();
543 }
virtual bool enterProtected()
CFunctionParameter::Role getUsage(size_t index) const
void setMapping(size_t index, std::string mn)
virtual bool leave()
void setLocalValue(size_t index, C_FLOAT64 value)
#define TO_UTF8(__x)
Definition: qtUtilities.h:74
bool isLocalValue(size_t index) const
CReactionInterface * mpRi
bool ReactionsWidget1::update ( ListViews::ObjectType  objectType,
ListViews::Action  action,
const std::string &  key 
)
virtual

Reimplemented from CopasiWidget.

Definition at line 596 of file ReactionsWidget1.cpp.

References ListViews::COMPARTMENT, CCopasiRootContainer::getKeyFactory(), loadFromReaction(), ListViews::METABOLITE, CopasiWidget::mIgnoreUpdates, CopasiWidget::mKey, ListViews::MODEL, and ListViews::STATE.

598 {
599  if (mIgnoreUpdates) return true;
600 
601  switch (objectType)
602  {
603  case ListViews::MODEL:
604  case ListViews::STATE:
607  return loadFromReaction(dynamic_cast< CReaction * >(CCopasiRootContainer::getKeyFactory()->get(mKey)));
608  break;
609 
610  default:
611  break;
612  }
613 
614  return true;
615 }
objectType
bool mIgnoreUpdates
Definition: copasiWidget.h:67
bool loadFromReaction(const CReaction *reaction)
static CKeyFactory * getKeyFactory()
std::string mKey
Definition: copasiWidget.h:63

Member Data Documentation

CReactionInterface* ReactionsWidget1::mpRi
protected

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