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

#include <CQExpandModelData.h>

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

Public Member Functions

 CQExpandModelData (QWidget *parent=0, Qt::WindowFlags fl=0)
 
 ~CQExpandModelData ()
 

Protected Slots

void slotCompartmentActivated (QTreeWidgetItem *pItem, int col)
 handles activation or deactivation of a compartment More...
 
void slotMode ()
 handles change of linear/rectangular mode More...
 

Protected Attributes

std::map< QTreeWidgetItem
*, const CCompartment * > 
mItemCompartmentMap
 
std::map< QTreeWidgetItem
*, const CMetab * > 
mItemMetabMap
 
CModelpModel
 

Private Slots

void slotCancel ()
 
void slotOK ()
 

Private Member Functions

void load ()
 

Detailed Description

Definition at line 32 of file CQExpandModelData.h.

Constructor & Destructor Documentation

CQExpandModelData::CQExpandModelData ( QWidget *  parent = 0,
Qt::WindowFlags  fl = 0 
)

Definition at line 22 of file CQExpandModelData.cpp.

References load().

23  : QDialog(parent, fl)
24 {
25  setupUi(this);
26 
27  mpLineEditSizeX->setValidator(new QIntValidator(1, 10000, this));
28  mpLineEditSizeY->setValidator(new QIntValidator(1, 10000, this));
29 
30  load();
31 }
bool fl(const C_FLOAT64 &d1, const C_FLOAT64 &d2)
CQExpandModelData::~CQExpandModelData ( )

Definition at line 33 of file CQExpandModelData.cpp.

34 {
35  // no need to delete child widgets, Qt does it all for us
36 }

Member Function Documentation

void CQExpandModelData::load ( )
private

Definition at line 38 of file CQExpandModelData.cpp.

References FROM_UTF8, CModel::getCompartments(), CCopasiRootContainer::getDatamodelList(), CCopasiObject::getObjectName(), mItemCompartmentMap, pModel, CCopasiVector< T >::size(), slotCompartmentActivated(), and slotMode().

Referenced by CQExpandModelData().

39 {
40  assert(CCopasiRootContainer::getDatamodelList()->size() > 0);
41 
42  pModel = (*CCopasiRootContainer::getDatamodelList())[0]->getModel();
43 
44  size_t i, imax = pModel->getCompartments().size();
45 
46  for (i = 0; i < imax; ++i)
47  {
48  QTreeWidgetItem * pItem = new QTreeWidgetItem((QTreeWidget*)NULL, 1000);
49  pItem->setText(0, FROM_UTF8(pModel->getCompartments()[i]->getObjectName()));
50  pItem->setCheckState(0, Qt::Unchecked);
52  mpTreeWidget->addTopLevelItem(pItem);
53  }
54 
55  connect(mpTreeWidget, SIGNAL(itemChanged(QTreeWidgetItem*, int)), this, SLOT(slotCompartmentActivated(QTreeWidgetItem*, int)));
56 
57  connect(mpRadioButtonLin, SIGNAL(toggled(bool)), this, SLOT(slotMode()));
58  connect(mpRadioButtonRec, SIGNAL(toggled(bool)), this, SLOT(slotMode()));
59 }
#define FROM_UTF8(__x)
Definition: qtUtilities.h:73
const std::string & getObjectName() const
virtual size_t size() const
void slotMode()
handles change of linear/rectangular mode
void slotCompartmentActivated(QTreeWidgetItem *pItem, int col)
handles activation or deactivation of a compartment
static CCopasiVector< CCopasiDataModel > * getDatamodelList()
CCopasiVectorNS< CCompartment > & getCompartments()
Definition: CModel.cpp:1145
std::map< QTreeWidgetItem *, const CCompartment * > mItemCompartmentMap
void CQExpandModelData::slotCancel ( )
privateslot

Definition at line 153 of file CQExpandModelData.cpp.

154 {
155  reject();
156 }
void CQExpandModelData::slotCompartmentActivated ( QTreeWidgetItem *  pItem,
int  col 
)
protectedslot

handles activation or deactivation of a compartment

Definition at line 61 of file CQExpandModelData.cpp.

References FROM_UTF8, CCompartment::getMetabolites(), CCopasiObject::getObjectName(), if(), mItemCompartmentMap, mItemMetabMap, and CCopasiVector< T >::size().

Referenced by load().

62 {
63  //only do something if a checkbox in the first column is clicked
64  if (col != 0)
65  return;
66 
67  const CCompartment* pComp = NULL;
68  std::map<QTreeWidgetItem*, const CCompartment*>::const_iterator it = mItemCompartmentMap.find(pItem);
69 
70  if (it != mItemCompartmentMap.end())
71  pComp = it->second;
72 
73  if (!pComp)
74  return;
75 
76  //checked
77  if (pItem->checkState(0) == Qt::Checked)
78  {
79  size_t i, imax = pComp->getMetabolites().size();
80 
81  for (i = 0; i < imax; ++i)
82  {
83  QTreeWidgetItem * pChild = new QTreeWidgetItem(pItem, 1001);
84  pChild->setText(0, FROM_UTF8(pComp->getMetabolites()[i]->getObjectName()));
85  pChild->setCheckState(1, Qt::Unchecked);
86  mItemMetabMap[pChild] = pComp->getMetabolites()[i];
87  }
88 
89  pItem->setExpanded(true);
90  }
91 
92  //unchecked
93  if (pItem->checkState(0) == Qt::Unchecked)
94  {
95  //remove children
96  size_t i, imax = pItem->childCount();
97 
98  for (i = 0; i < imax; ++i)
99  {
100  pItem->removeChild(pItem->child(0));
101  }
102  }
103 }
#define FROM_UTF8(__x)
Definition: qtUtilities.h:73
CCopasiVectorNS< CMetab > & getMetabolites()
const std::string & getObjectName() const
virtual size_t size() const
std::map< QTreeWidgetItem *, const CMetab * > mItemMetabMap
std::map< QTreeWidgetItem *, const CCompartment * > mItemCompartmentMap
if(!yymsg) yymsg
void CQExpandModelData::slotMode ( )
protectedslot

handles change of linear/rectangular mode

Definition at line 158 of file CQExpandModelData.cpp.

Referenced by load().

159 {
160  if (mpRadioButtonLin->isChecked())
161  {
162  mpLabelCross->setEnabled(false);
163  mpLineEditSizeY->setEnabled(false);
164  }
165  else if (mpRadioButtonRec->isChecked())
166  {
167  mpLabelCross->setEnabled(true);
168  mpLineEditSizeY->setEnabled(true);
169  }
170 }
void CQExpandModelData::slotOK ( )
privateslot

Definition at line 105 of file CQExpandModelData.cpp.

References CModelExpansion::SetOfModelElements::addCompartment(), CModelExpansion::createLinearArray(), CModelExpansion::createRectangularArray(), CModelExpansion::SetOfModelElements::fillDependencies(), mItemCompartmentMap, mItemMetabMap, and pModel.

106 {
108  std::set<std::string> metabkeys;
109 
110  std::map<QTreeWidgetItem*, const CCompartment*>::const_iterator it;
111 
112  for (it = mItemCompartmentMap.begin(); it != mItemCompartmentMap.end(); ++it)
113  {
114  if (it->first->checkState(0) == Qt::Checked)
115  {
116  //the compartment is included
117  modelelements.addCompartment(it->second);
118 
119  //check whether diffusion is requested for the metabolites inside
120  size_t i;
121 
122  for (i = 0; i < it->first->childCount(); ++i)
123  {
124  if (it->first->child(i)->checkState(1) == Qt::Checked)
125  {
126  std::map<QTreeWidgetItem*, const CMetab*>::const_iterator itMetab = mItemMetabMap.find(it->first->child(i));
127  //const CMetab* pMetab = NULL;
128 
129  if (itMetab != mItemMetabMap.end())
130  metabkeys.insert(itMetab->second->getKey());
131  }
132  }
133  }
134  }
135 
137  modelelements.fillDependencies(pModel);
138 
139  int multx, multy;
140  multx = mpLineEditSizeX->text().toInt();
141  multy = mpLineEditSizeY->text().toInt();
142 
143  if (mpRadioButtonLin->isChecked())
144  me.createLinearArray(modelelements, multx, metabkeys);
145  else if (mpRadioButtonRec->isChecked())
146  me.createRectangularArray(modelelements, multx, multy, metabkeys);
147 
148  accept();
149 
150  // std::string name = static_cast<std::string >(mpBoxCompartmentName->currentText().toUtf8()); //toStdString();
151 }
std::map< QTreeWidgetItem *, const CMetab * > mItemMetabMap
void fillDependencies(const CModel *pModel)
void addCompartment(const CCompartment *x)
std::map< QTreeWidgetItem *, const CCompartment * > mItemCompartmentMap

Member Data Documentation

std::map<QTreeWidgetItem*, const CCompartment*> CQExpandModelData::mItemCompartmentMap
protected

Definition at line 42 of file CQExpandModelData.h.

Referenced by load(), slotCompartmentActivated(), and slotOK().

std::map<QTreeWidgetItem*, const CMetab*> CQExpandModelData::mItemMetabMap
protected

Definition at line 43 of file CQExpandModelData.h.

Referenced by slotCompartmentActivated(), and slotOK().

CModel* CQExpandModelData::pModel
protected

Definition at line 44 of file CQExpandModelData.h.

Referenced by load(), and slotOK().


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