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

#include <CQModelWidget.h>

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

Public Member Functions

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

Protected Slots

virtual void slotBtnOKClicked ()
 
virtual void slotBtnRevertClicked ()
 
- Protected Slots inherited from CopasiWidget
virtual bool protectedNotify (ListViews::ObjectType objectType, ListViews::Action action, const std::string &key="")
 

Protected Member Functions

virtual bool enterProtected ()
 

Private Member Functions

void load ()
 
void save ()
 

Private Attributes

CModelmpModel
 

Additional Inherited Members

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

Detailed Description

Definition at line 23 of file CQModelWidget.h.

Constructor & Destructor Documentation

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

Definition at line 19 of file CQModelWidget.cpp.

References CModel::AreaUnitNames, CModel::LengthUnitNames, CModel::QuantityUnitNames, CModel::TimeUnitNames, and CModel::VolumeUnitNames.

19  :
20  CopasiWidget(parent, name),
21  mpModel(NULL)
22 {
23  setupUi(this);
24 
25  QStringList ComboEntries;
26  const char ** pComboEntries;
27 
28  for (pComboEntries = CModel::TimeUnitNames; *pComboEntries != NULL; ++pComboEntries)
29  {
30  ComboEntries.push_front(QString::fromUtf8(*pComboEntries));
31  }
32 
33  mpComboTimeUnit->clear();
34  mpComboTimeUnit->insertItems(0, ComboEntries);
35 
36  ComboEntries.clear();
37 
38  for (pComboEntries = CModel::VolumeUnitNames; *pComboEntries != NULL; ++pComboEntries)
39  {
40  ComboEntries.push_front(QString::fromUtf8(*pComboEntries));
41  }
42 
43  mpComboVolumeUnit->clear();
44  mpComboVolumeUnit->insertItems(0, ComboEntries);
45 
46  ComboEntries.clear();
47 
48  for (pComboEntries = CModel::AreaUnitNames; *pComboEntries != NULL; ++pComboEntries)
49  {
50  ComboEntries.push_front(QString::fromUtf8(*pComboEntries));
51  }
52 
53  mpComboAreaUnit->clear();
54  mpComboAreaUnit->insertItems(0, ComboEntries);
55 
56  ComboEntries.clear();
57 
58  for (pComboEntries = CModel::LengthUnitNames; *pComboEntries != NULL; ++pComboEntries)
59  {
60  ComboEntries.push_front(QString::fromUtf8(*pComboEntries));
61  }
62 
63  mpComboLengthUnit->clear();
64  mpComboLengthUnit->insertItems(0, ComboEntries);
65 
66  ComboEntries.clear();
67 
68  for (pComboEntries = CModel::QuantityUnitNames; *pComboEntries != NULL; ++pComboEntries)
69  {
70  ComboEntries.push_front(QString::fromUtf8(*pComboEntries));
71  }
72 
73  mpComboQuantityUnit->clear();
74  mpComboQuantityUnit->insertItems(0, ComboEntries);
75 
76 #ifndef COPASI_EXTUNIT
77  mpLblAreaUnit->hide();
78  mpComboAreaUnit->hide();
79 
80  mpLblLengthUnit->hide();
81  mpComboLengthUnit->hide();
82 #endif
83 }
static const char * LengthUnitNames[]
Definition: CModel.h:81
CModel * mpModel
Definition: CQModelWidget.h:46
CopasiWidget(QWidget *parent=0, const char *name=0, Qt::WFlags f=0)
static const char * AreaUnitNames[]
Definition: CModel.h:71
static const char * TimeUnitNames[]
Definition: CModel.h:91
static const char * QuantityUnitNames[]
Definition: CModel.h:107
static const char * VolumeUnitNames[]
Definition: CModel.h:61
CQModelWidget::~CQModelWidget ( )

Definition at line 85 of file CQModelWidget.cpp.

86 {}

Member Function Documentation

bool CQModelWidget::enterProtected ( )
protectedvirtual

Reimplemented from CopasiWidget.

Definition at line 219 of file CQModelWidget.cpp.

References load(), CopasiWidget::mKey, mpModel, and CopasiWidget::mpObject.

220 {
221  if (mpObject != NULL)
222  mpModel = dynamic_cast< CModel * >(mpObject);
223  else
224  mpModel = NULL;
225 
226  load();
227 
228  mpNotes->enter(mKey);
229 
230  return true;
231 }
CModel * mpModel
Definition: CQModelWidget.h:46
CCopasiObject * mpObject
Definition: copasiWidget.h:64
Definition: CModel.h:50
std::string mKey
Definition: copasiWidget.h:63
bool CQModelWidget::leave ( )
virtual

Reimplemented from CopasiWidget.

Definition at line 210 of file CQModelWidget.cpp.

References save().

211 {
212  save();
213 
214  mpNotes->leave();
215 
216  return true;
217 }
void CQModelWidget::load ( )
private

Definition at line 88 of file CQModelWidget.cpp.

References CModel::deterministic, FROM_UTF8, CModel::getAreaUnitName(), CModel::getInitialTime(), CModel::getLengthUnitName(), CModel::getModelType(), CModel::getQuantityUnitName(), CModel::getTime(), CModel::getTimeUnitName(), CModel::getVolumeUnitName(), CModel::isAutonomous(), and mpModel.

Referenced by enterProtected(), slotBtnOKClicked(), and slotBtnRevertClicked().

89 {
90  if (mpModel == NULL)
91  return;
92 
93  mpComboTimeUnit->setCurrentIndex(mpComboTimeUnit->findText(FROM_UTF8(mpModel->getTimeUnitName())));
94  mpComboVolumeUnit->setCurrentIndex(mpComboVolumeUnit->findText(FROM_UTF8(mpModel->getVolumeUnitName())));
95  mpComboQuantityUnit->setCurrentIndex(mpComboQuantityUnit->findText(FROM_UTF8(mpModel->getQuantityUnitName())));
96  mpComboAreaUnit->setCurrentIndex(mpComboAreaUnit->findText(FROM_UTF8(mpModel->getAreaUnitName())));
97  mpComboLengthUnit->setCurrentIndex(mpComboLengthUnit->findText(FROM_UTF8(mpModel->getLengthUnitName())));
98 
99  mpCheckStochasticCorrection->setChecked(mpModel->getModelType() == CModel::deterministic);
100 
101  mpLblInitialTime->setText("Initial Time (" + mpComboTimeUnit->currentText() + ")");
102  mpEditInitialTime->setText(QString::number(mpModel->getInitialTime()));
103  mpEditInitialTime->setReadOnly(mpModel->isAutonomous());
104 
105  mpLblCurrentTime->setText("Time (" + mpComboTimeUnit->currentText() + ")");
106  mpEditCurrentTime->setText(QString::number(mpModel->getTime()));
107 
108  return;
109 }
#define FROM_UTF8(__x)
Definition: qtUtilities.h:73
std::string getTimeUnitName() const
Definition: CModel.cpp:2238
CModel * mpModel
Definition: CQModelWidget.h:46
const bool & isAutonomous() const
Definition: CModel.cpp:3956
const C_FLOAT64 & getInitialTime() const
Definition: CModel.cpp:1184
std::string getLengthUnitName() const
Definition: CModel.cpp:2215
const C_FLOAT64 & getTime() const
Definition: CModel.cpp:1190
std::string getAreaUnitName() const
Definition: CModel.cpp:2193
std::string getQuantityUnitName() const
Definition: CModel.cpp:2321
const ModelType & getModelType() const
Definition: CModel.cpp:2339
std::string getVolumeUnitName() const
Definition: CModel.cpp:2170
void CQModelWidget::save ( )
private

Definition at line 111 of file CQModelWidget.cpp.

References ListViews::CHANGE, CCopasiDataModel::changed(), CModel::deterministic, CModel::getAreaUnitName(), CModel::getInitialTime(), CModel::getLengthUnitName(), CModel::getModelType(), CModel::getQuantityUnitName(), CModel::getTimeUnitName(), CModel::getVolumeUnitName(), CopasiWidget::mKey, ListViews::MODEL, CopasiWidget::mpDataModel, mpModel, CopasiWidget::protectedNotify(), CModel::setAreaUnit(), CModel::setInitialTime(), CModel::setLengthUnit(), CModel::setModelType(), CModel::setQuantityUnit(), CModel::setTimeUnit(), CModel::setVolumeUnit(), CModel::stochastic, and TO_UTF8.

Referenced by leave(), and slotBtnOKClicked().

112 {
113  if (mpModel == NULL)
114  return;
115 
116  bool changed = false;
117 
118  if (TO_UTF8(mpComboTimeUnit->currentText()) != mpModel->getTimeUnitName())
119  {
120  mpModel->setTimeUnit(TO_UTF8(mpComboTimeUnit->currentText()));
121  changed = true;
122  }
123 
124  if (TO_UTF8(mpComboVolumeUnit->currentText()) != mpModel->getVolumeUnitName())
125  {
126  mpModel->setVolumeUnit(TO_UTF8(mpComboVolumeUnit->currentText()));
127  changed = true;
128  }
129 
130  if (TO_UTF8(mpComboAreaUnit->currentText()) != mpModel->getAreaUnitName())
131  {
132  mpModel->setAreaUnit(TO_UTF8(mpComboAreaUnit->currentText()));
133  changed = true;
134  }
135 
136  if (TO_UTF8(mpComboLengthUnit->currentText()) != mpModel->getLengthUnitName())
137  {
138  mpModel->setLengthUnit(TO_UTF8(mpComboLengthUnit->currentText()));
139  changed = true;
140  }
141 
142  if (TO_UTF8(mpComboQuantityUnit->currentText()) != mpModel->getQuantityUnitName())
143  {
144  mpModel->setQuantityUnit(TO_UTF8(mpComboQuantityUnit->currentText()));
145  changed = true;
146  }
147 
148  if (mpCheckStochasticCorrection->isChecked() != (mpModel->getModelType() == CModel::deterministic))
149  {
150  if (mpCheckStochasticCorrection->isChecked())
151  {
153  }
154  else
155  {
157  }
158 
159  changed = true;
160  }
161 
162  if (mpEditInitialTime->text() != QString::number(mpModel->getInitialTime()))
163  {
164  mpModel->setInitialTime(mpEditInitialTime->text().toDouble());
165  changed = true;
166  }
167 
168  if (changed)
169  {
170  if (mpDataModel != NULL)
171  {
172  mpDataModel->changed();
173  }
174 
176  }
177 
178  return;
179 }
bool setAreaUnit(const std::string &name)
Definition: CModel.cpp:2182
bool setVolumeUnit(const std::string &name)
Definition: CModel.cpp:2159
bool setLengthUnit(const std::string &name)
Definition: CModel.cpp:2204
bool setTimeUnit(const std::string &name)
Definition: CModel.cpp:2227
std::string getTimeUnitName() const
Definition: CModel.cpp:2238
CModel * mpModel
Definition: CQModelWidget.h:46
void changed(const bool &changed=true)
void setInitialTime(const C_FLOAT64 &time)
Definition: CModel.cpp:1181
const C_FLOAT64 & getInitialTime() const
Definition: CModel.cpp:1184
std::string getLengthUnitName() const
Definition: CModel.cpp:2215
virtual bool protectedNotify(ListViews::ObjectType objectType, ListViews::Action action, const std::string &key="")
CCopasiDataModel * mpDataModel
Definition: copasiWidget.h:65
std::string getAreaUnitName() const
Definition: CModel.cpp:2193
std::string getQuantityUnitName() const
Definition: CModel.cpp:2321
const ModelType & getModelType() const
Definition: CModel.cpp:2339
#define TO_UTF8(__x)
Definition: qtUtilities.h:74
bool setQuantityUnit(const std::string &name)
Definition: CModel.cpp:2250
std::string getVolumeUnitName() const
Definition: CModel.cpp:2170
std::string mKey
Definition: copasiWidget.h:63
void setModelType(const ModelType &modelType)
Definition: CModel.cpp:2336
void CQModelWidget::slotBtnOKClicked ( )
protectedvirtualslot

Definition at line 186 of file CQModelWidget.cpp.

References load(), and save().

187 {
188  save();
189  load();
190 }
void CQModelWidget::slotBtnRevertClicked ( )
protectedvirtualslot

Definition at line 181 of file CQModelWidget.cpp.

References load().

182 {
183  load();
184 }
bool CQModelWidget::update ( ListViews::ObjectType  objectType,
ListViews::Action  action,
const std::string &  key 
)
virtual

Reimplemented from CopasiWidget.

Definition at line 192 of file CQModelWidget.cpp.

References CopasiWidget::enter(), CopasiWidget::mIgnoreUpdates, and ListViews::MODEL.

194 {
195  if (mIgnoreUpdates) return true;
196 
197  switch (objectType)
198  {
199  case ListViews::MODEL:
200  enter(key);
201  break;
202 
203  default:
204  break;
205  }
206 
207  return true;
208 }
objectType
bool mIgnoreUpdates
Definition: copasiWidget.h:67
bool enter(const std::string &key)

Member Data Documentation

CModel* CQModelWidget::mpModel
private

Definition at line 46 of file CQModelWidget.h.

Referenced by enterProtected(), load(), and save().


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