COPASI API  4.16.103
Macros | Functions
CQExpressionWidget.cpp File Reference
#include <iostream>
#include <QtGui/QLabel>
#include <QtGui/QComboBox>
#include <QtGui/QKeyEvent>
#include "CQExpressionWidget.h"
#include "CQMessageBox.h"
#include "CCopasiSelectionDialog.h"
#include "qtUtilities.h"
#include "copasi.h"
#include "CopasiDataModel/CCopasiDataModel.h"
#include "function/CExpression.h"
#include "function/CFunctionDB.h"
#include "function/CMassAction.h"
#include "utilities/CAnnotatedMatrix.h"
#include "model/CModel.h"
#include "CQMatrixDialog.h"
#include "report/CCopasiRootContainer.h"
#include "commandline/CConfigurationFile.h"
Include dependency graph for CQExpressionWidget.cpp:

Go to the source code of this file.

Macros

#define DEBUG_UI
 

Functions

const CCopasiObjectfindObjectByDisplayName (const CCopasiDataModel *dataModel, const std::string displayString)
 
std::ostream & operator<< (std::ostream &os, const QTextCursor &d)
 

Macro Definition Documentation

#define DEBUG_UI

Definition at line 40 of file CQExpressionWidget.cpp.

Function Documentation

const CCopasiObject* findObjectByDisplayName ( const CCopasiDataModel dataModel,
const std::string  displayString 
)

Definition at line 655 of file CQExpressionWidget.cpp.

References CCopasiVector< T >::begin(), CCopasiVector< T >::end(), CModel::getCompartments(), CMetab::getConcentrationRateReference(), CMetab::getConcentrationReference(), CMetab::getInitialConcentrationReference(), CModelEntity::getInitialValueReference(), CModel::getMetabolites(), CCopasiDataModel::getModel(), CModel::getModelValues(), CCopasiContainer::getObject(), CCopasiObjectReference< CType >::getObjectDisplayName(), CMetab::getObjectDisplayName(), CCopasiObject::getObjectDisplayName(), CModelEntity::getRateReference(), and CModelEntity::getValueReference().

Referenced by CQExpressionWidget::getExpression().

656 {
657  if (dataModel == NULL || displayString.empty()) return NULL;
658 
659  const CModel* model = dataModel->getModel();
660 
661  if (displayString == "Time") return model;
662 
663  if (displayString == "Avogadro Constant") return dynamic_cast<const CCopasiObject* >(model->getObject("Reference=" + displayString));
664 
665  if (displayString == "Quantity Conversion Factor") return dynamic_cast<const CCopasiObject* >(model->getObject("Reference=" + displayString));
666 
667  size_t pos = displayString.find("Compartments[");
668 
669  if (pos != std::string::npos)
670  {
671  const CCopasiVectorN< CCompartment > & compartments = model->getCompartments();
672 
673  for (CCopasiVectorN< CCompartment >::const_iterator it = compartments.begin(); it != compartments.end(); ++it)
674  {
675  const CCompartment *current = *it;
676 
677  if (current->getObjectDisplayName() == displayString)
678  {
679  return current;
680  }
681  else if (current->getInitialValueReference() != NULL &&
682  current->getInitialValueReference()->getObjectDisplayName() == displayString)
683  {
684  return current->getInitialValueReference();
685  }
686  else if (current->getValueReference() != NULL &&
687  current->getValueReference()->getObjectDisplayName() == displayString)
688  {
689  return current->getValueReference();
690  }
691  else if (current->getRateReference() != NULL &&
692  current->getRateReference()->getObjectDisplayName() == displayString)
693  {
694  return current->getRateReference();
695  }
696  }
697  }
698 
699  pos = displayString.find("Values[");
700 
701  if (pos != std::string::npos)
702  {
703  const CCopasiVectorN< CModelValue > & values = model->getModelValues();
704 
705  for (CCopasiVectorN< CModelValue >::const_iterator it = values.begin(); it != values.end(); ++it)
706  {
707  const CModelValue *current = *it;
708 
709  if (current->getObjectDisplayName() == displayString)
710  {
711  return current;
712  }
713  else if (current->getInitialValueReference() != NULL &&
714  current->getInitialValueReference()->getObjectDisplayName() == displayString)
715  {
716  return current->getInitialValueReference();
717  }
718  else if (current->getValueReference() != NULL &&
719  current->getValueReference()->getObjectDisplayName() == displayString)
720  {
721  return current->getValueReference();
722  }
723  else if (current->getRateReference() != NULL &&
724  current->getRateReference()->getObjectDisplayName() == displayString)
725  {
726  return current->getRateReference();
727  }
728  }
729  }
730 
731  // no reasonable check for metabolites, so lets just go through them
732  {
733  const CCopasiVector< CMetab > & metabs = model->getMetabolites();
734 
735  for (CCopasiVector< CMetab >::const_iterator it = metabs.begin(); it != metabs.end(); ++it)
736  {
737  const CMetab *current = *it;
738 
739  if (current->getObjectDisplayName() == displayString)
740  {
741  return current;
742  }
743  else if (current->getInitialValueReference() != NULL &&
744  current->getInitialValueReference()->getObjectDisplayName() == displayString)
745  {
746  return current->getInitialValueReference();
747  }
748  else if (current->getInitialConcentrationReference() != NULL &&
749  current->getInitialConcentrationReference()->getObjectDisplayName() == displayString)
750  {
751  return current->getInitialConcentrationReference();
752  }
753  else if (current->getValueReference() != NULL &&
754  current->getValueReference()->getObjectDisplayName() == displayString)
755  {
756  return current->getValueReference();
757  }
758  else if (current->getConcentrationReference() != NULL &&
759  current->getConcentrationReference()->getObjectDisplayName() == displayString)
760  {
761  return current->getConcentrationReference();
762  }
763  else if (current->getRateReference() != NULL &&
764  current->getRateReference()->getObjectDisplayName() == displayString)
765  {
766  return current->getRateReference();
767  }
768  else if (current->getConcentrationRateReference() != NULL &&
769  current->getConcentrationRateReference()->getObjectDisplayName() == displayString)
770  {
771  return current->getConcentrationRateReference();
772  }
773  }
774  }
775 
776  return NULL;
777 }
virtual std::string getObjectDisplayName(bool regular=true, bool richtext=false) const
const CCopasiVector< CMetab > & getMetabolites() const
Definition: CModel.cpp:1051
const CCopasiVectorN< CModelValue > & getModelValues() const
Definition: CModel.cpp:1060
CCopasiObject * getInitialValueReference() const
iterator begin()
virtual std::string getObjectDisplayName(bool regular=true, bool richtext=false) const
Definition: CMetab.cpp:974
Definition: CMetab.h:178
iterator end()
virtual std::string getObjectDisplayName(bool regular=true, bool richtext=false) const
CCopasiObject * getConcentrationRateReference() const
Definition: CMetab.cpp:867
CCopasiVectorNS< CCompartment > & getCompartments()
Definition: CModel.cpp:1145
Definition: CModel.h:50
virtual const CObjectInterface * getObject(const CCopasiObjectName &cn) const
CConcentrationReference * getInitialConcentrationReference() const
Definition: CMetab.cpp:861
CCopasiObject * getRateReference() const
CConcentrationReference * getConcentrationReference() const
Definition: CMetab.cpp:864
CCopasiObject * getValueReference() const
std::ostream& operator<< ( std::ostream &  os,
const QTextCursor &  d 
)

Definition at line 43 of file CQExpressionWidget.cpp.

References TO_UTF8.

44 {
45  os << "Position: " << d.position() << std::endl;
46  os << "Selection Start: " << d.selectionStart() << std::endl;
47  os << "Selection End: " << d.selectionEnd() << std::endl;
48  os << "Anchor: " << d.anchor() << std::endl;
49  os << "Selected Text: " << TO_UTF8(d.selectedText()) << std::endl;
50 
51  return os;
52 }
#define TO_UTF8(__x)
Definition: qtUtilities.h:74