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

#include <CScanWidgetRandom.h>

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

Public Member Functions

 CScanWidgetRandom (QWidget *parent=0)
 
 CScanWidgetRandom (const CScanWidgetRandom &src, QWidget *parent=0)
 
void initFromObject (const CCopasiObject *obj)
 
virtual void load (const CCopasiParameterGroup *pItem)
 
virtual bool save (CCopasiParameterGroup *pItem) const
 
virtual ~CScanWidgetRandom ()
 
- Public Member Functions inherited from CScanItemData
 CScanItemData (const CScanItemData &src)
 
const CScanProblem::TypegetType () const
 
virtual ~CScanItemData ()
 

Protected Slots

virtual void changeType ()
 
virtual void slotChooseObject ()
 

Protected Attributes

const CCopasiObjectmpObject
 
- Protected Attributes inherited from CScanItemData
CCopasiParameterGroupmpData
 
CScanProblem::Type mType
 

Private Member Functions

void init ()
 

Additional Inherited Members

- Protected Member Functions inherited from CScanItemData
 CScanItemData (const CScanProblem::Type &type)
 

Detailed Description

Definition at line 27 of file CScanWidgetRandom.h.

Constructor & Destructor Documentation

CScanWidgetRandom::CScanWidgetRandom ( QWidget *  parent = 0)

Definition at line 33 of file CScanWidgetRandom.cpp.

References CQIconResource::copasi, CQIconResource::icon(), and init().

33  :
34  QWidget(parent),
36 {
37  setupUi(this);
38  buttonObject->setIcon(CQIconResource::icon(CQIconResource::copasi));
39  init();
40  retranslateUi(this);
41 }
static const QIcon & icon(const IconID &id)
CScanWidgetRandom::CScanWidgetRandom ( const CScanWidgetRandom src,
QWidget *  parent = 0 
)

Definition at line 43 of file CScanWidgetRandom.cpp.

References CQIconResource::copasi, CQIconResource::icon(), init(), load(), and CScanItemData::mpData.

43  :
44  QWidget(parent),
45  CScanItemData(src)
46 {
47  setupUi(this);
48  buttonObject->setIcon(CQIconResource::icon(CQIconResource::copasi));
49  init();
50  load(mpData);
51  retranslateUi(this);
52 }
virtual void load(const CCopasiParameterGroup *pItem)
static const QIcon & icon(const IconID &id)
CCopasiParameterGroup * mpData
Definition: CScanItemData.h:42
CScanWidgetRandom::~CScanWidgetRandom ( )
virtual

Definition at line 57 of file CScanWidgetRandom.cpp.

58 {
59  // no need to delete child widgets, Qt does it all for us
60 }

Member Function Documentation

void CScanWidgetRandom::changeType ( )
protectedvirtualslot

Definition at line 206 of file CScanWidgetRandom.cpp.

References C_FLOAT64, C_INT32, CCopasiObject::getValuePointer(), and mpObject.

Referenced by load().

207 {
208  C_INT32 type = comboBoxType->currentIndex();
209  C_FLOAT64 value = 0.0;
210 
211  if (mpObject != NULL)
212  value = *(C_FLOAT64*)mpObject->getValuePointer();
213 
214  switch (type)
215  {
216  case 0: // uniform
217  lineEditMin->setEnabled(true);
218  lineEditMax->setEnabled(true);
219 
220  labelMin->setText("min");
221  labelMax->setText("max");
222 
223  if (mpObject != NULL)
224  {
225  lineEditMin->setText(QString::number(value * 0.5));
226  lineEditMax->setText(QString::number(value * 2));
227  }
228  else
229  {
230  lineEditMin->setText("");
231  lineEditMax->setText("");
232  }
233 
234  break;
235 
236  case 1: // normal
237  lineEditMin->setEnabled(true);
238  lineEditMax->setEnabled(true);
239 
240  labelMin->setText("mean");
241  labelMax->setText("standard deviation");
242 
243  if (mpObject != NULL)
244  {
245  lineEditMin->setText(QString::number(value));
246  lineEditMax->setText(QString::number(value * 0.1));
247  }
248  else
249  {
250  lineEditMin->setText("");
251  lineEditMax->setText("");
252  }
253 
254  break;
255 
256  case 2: // Poisson
257  lineEditMin->setEnabled(true);
258  lineEditMax->setEnabled(false);
259 
260  labelMin->setText("mean");
261  labelMax->setText("");
262 
263  if (mpObject != NULL)
264  lineEditMin->setText(QString::number(value));
265  else
266  lineEditMin->setText("");
267 
268  lineEditMax->setText("");
269 
270  break;
271 
272  case 3: // Gamma
273  lineEditMin->setEnabled(true);
274  lineEditMax->setEnabled(true);
275 
276  labelMin->setText("shape");
277  labelMax->setText("scale");
278 
279  if (mpObject != NULL)
280  {
281  lineEditMin->setText(QString::number(1.0 * value));
282  lineEditMax->setText(QString::number(0.1));
283  }
284  else
285  {
286  lineEditMin->setText("");
287  lineEditMax->setText("");
288  }
289 
290  break;
291  }
292 }
const CCopasiObject * mpObject
#define C_INT32
Definition: copasi.h:90
#define C_FLOAT64
Definition: copasi.h:92
virtual void * getValuePointer() const
void CScanWidgetRandom::init ( )
private

Definition at line 62 of file CScanWidgetRandom.cpp.

References mpObject.

Referenced by CScanWidgetRandom().

63 {
64  lineEditObject->setReadOnly(true);
65 
66  lineEditMin->setValidator(new QDoubleValidator(lineEditMin));
67  lineEditMax->setValidator(new QDoubleValidator(lineEditMax));
68 
69  mpObject = NULL;
70 }
const CCopasiObject * mpObject
void CScanWidgetRandom::initFromObject ( const CCopasiObject obj)

Definition at line 84 of file CScanWidgetRandom.cpp.

References C_FLOAT64, C_INT32, FROM_UTF8, CCopasiObject::getObjectDisplayName(), CCopasiObject::getValuePointer(), CCopasiObject::isValueDbl(), and mpObject.

Referenced by ScanWidget::slotAddItem(), and slotChooseObject().

85 {
86  mpObject = obj;
87 
88  if (obj)
89  {
90  lineEditObject->setText(FROM_UTF8(obj->getObjectDisplayName()));
91 
92  if (obj->isValueDbl())
93  {
94  C_FLOAT64 value = *(C_FLOAT64*)obj->getValuePointer();
95  C_INT32 type = comboBoxType->currentIndex();
96 
97  if (type == 0) //uniform
98  {
99  lineEditMin->setText(QString::number(value * 0.5));
100  lineEditMax->setText(QString::number(value * 2));
101  }
102 
103  if (type == 1) //normal
104  {
105  lineEditMin->setText(QString::number(value));
106  lineEditMax->setText(QString::number(value * 0.1));
107  }
108 
109  if (type == 2) //poisson
110  {
111  lineEditMin->setText(QString::number(value));
112  lineEditMax->setText("");
113  }
114  }
115  }
116  else
117  {
118  lineEditObject->setText("");
119  lineEditMin->setText("");
120  lineEditMax->setText("");
121  }
122 }
virtual std::string getObjectDisplayName(bool regular=true, bool richtext=false) const
const CCopasiObject * mpObject
#define FROM_UTF8(__x)
Definition: qtUtilities.h:73
#define C_INT32
Definition: copasi.h:90
#define C_FLOAT64
Definition: copasi.h:92
bool isValueDbl() const
virtual void * getValuePointer() const
void CScanWidgetRandom::load ( const CCopasiParameterGroup pItem)
virtual

Implements CScanItemData.

Definition at line 125 of file CScanWidgetRandom.cpp.

References C_INT32, changeType(), FROM_UTF8, CCopasiRootContainer::getDatamodelList(), CCopasiDataModel::getDataObject(), CCopasiObject::getObjectDisplayName(), getParameterValue(), CCopasiParameterGroup::getValue(), CScanItemData::mpData, mpObject, CCopasiParameter::Value::pBOOL, CCopasiParameter::Value::pSTRING, CCopasiParameter::Value::pUINT, and CScanProblem::SCAN_RANDOM.

Referenced by CScanWidgetRandom(), and ScanWidget::loadTask().

126 {
127  if (pItem == NULL) return;
128 
129  *mpData = *pItem;
130 
131  unsigned C_INT32 * tmp;
132 
133  if (!(tmp = mpData->getValue("Type").pUINT))
134  return;
135 
137  return;
138 
139  std::string *pString;
140 
141  if (!(pString = mpData->getValue("Object").pSTRING))
142  return;
143 
144  if (*pString == "")
145  mpObject = NULL;
146  else
147  {
148  assert(CCopasiRootContainer::getDatamodelList()->size() > 0);
150  assert(pDataModel != NULL);
151  mpObject = pDataModel->getDataObject(*pString);
152  }
153 
154  if (mpObject)
155  lineEditObject->setText(FROM_UTF8(mpObject->getObjectDisplayName()));
156  else
157  lineEditObject->setText("");
158 
159  if (!(tmp = mpData->getValue("Distribution type").pUINT))
160  return;
161 
162  comboBoxType->setCurrentIndex(*tmp);
163  changeType();
164 
165  lineEditMin->setText(getParameterValue(mpData, "Minimum"));
166  lineEditMax->setText(getParameterValue(mpData, "Maximum"));
167 
168  bool * pBool;
169 
170  if (!(pBool = mpData->getValue("log").pBOOL))
171  return;
172 
173  checkBoxLog->setChecked(* pBool);
174 
175  return;
176 }
CCopasiObject * getDataObject(const CCopasiObjectName &CN) const
virtual std::string getObjectDisplayName(bool regular=true, bool richtext=false) const
const CCopasiObject * mpObject
#define FROM_UTF8(__x)
Definition: qtUtilities.h:73
virtual void changeType()
#define C_INT32
Definition: copasi.h:90
CCopasiParameterGroup * mpData
Definition: CScanItemData.h:42
static CCopasiVector< CCopasiDataModel > * getDatamodelList()
unsigned C_INT32 * pUINT
QString getParameterValue(const CCopasiParameterGroup *group, const size_t &index, CCopasiParameter::Type *type)
Definition: qtUtilities.cpp:28
const CCopasiParameter::Value & getValue(const std::string &name) const
bool CScanWidgetRandom::save ( CCopasiParameterGroup pItem) const
virtual

Implements CScanItemData.

Definition at line 179 of file CScanWidgetRandom.cpp.

References C_INT32, CCopasiObject::getCN(), CScanItemData::mpData, mpObject, and CCopasiParameterGroup::setValue().

180 {
181  mpData->setValue("Distribution type", (unsigned C_INT32) comboBoxType->currentIndex());
182  mpData->setValue("Minimum", lineEditMin->text().toDouble());
183  mpData->setValue("Maximum", lineEditMax->text().toDouble());
184  mpData->setValue("log", checkBoxLog->isChecked());
185 
186  if (mpObject != NULL)
187  {
188  mpData->setValue("Object", mpObject->getCN());
189  }
190  else
191  {
192  mpData->setValue("Object", std::string(""));
193  }
194 
195  if (pItem != NULL)
196  {
197  if (*mpData == *pItem) return false;
198 
199  *pItem = *mpData;
200  return true;
201  }
202 
203  return false;
204 }
const CCopasiObject * mpObject
virtual CCopasiObjectName getCN() const
#define C_INT32
Definition: copasi.h:90
CCopasiParameterGroup * mpData
Definition: CScanItemData.h:42
bool setValue(const std::string &name, const CType &value)
void CScanWidgetRandom::slotChooseObject ( )
protectedvirtualslot

Definition at line 72 of file CScanWidgetRandom.cpp.

References CCopasiSelectionDialog::getObjectSingle(), initFromObject(), CQSimpleSelectionTree::InitialTime, mpObject, and CQSimpleSelectionTree::Parameters.

73 {
74  const CCopasiObject * pObject =
78  mpObject);
79 
80  if (mpObject != pObject) // Object selection changed.
81  initFromObject(pObject);
82 }
const CCopasiObject * mpObject
void initFromObject(const CCopasiObject *obj)
static const CCopasiObject * getObjectSingle(QWidget *pParent, const CQSimpleSelectionTree::ObjectClasses &classes, const CCopasiObject *pCurrentObject=NULL)

Member Data Documentation

const CCopasiObject* CScanWidgetRandom::mpObject
protected

Definition at line 45 of file CScanWidgetRandom.h.

Referenced by changeType(), init(), initFromObject(), load(), save(), and slotChooseObject().


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