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

#include <ScanWidget.h>

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

Public Member Functions

virtual bool runTask ()
 
 ScanWidget (QWidget *parent=0, const char *name=0, Qt::WFlags fl=0)
 
 ~ScanWidget ()
 
- Public Member Functions inherited from TaskWidget
CCopasiTaskgetTask ()
 
virtual bool leave ()
 
 TaskWidget (QWidget *parent=0, const char *name=0, Qt::WFlags fl=0)
 
virtual bool update (ListViews::ObjectType objectType, ListViews::Action action, const std::string &key)
 
 ~TaskWidget ()
 
- 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

bool slotAddItem ()
 
- Protected Slots inherited from TaskWidget
void assistantBtnClicked ()
 
void reportBtnClicked ()
 
void revertBtnClicked ()
 
void runBtnClicked ()
 
- Protected Slots inherited from CopasiWidget
virtual bool protectedNotify (ListViews::ObjectType objectType, ListViews::Action action, const std::string &key="")
 

Protected Member Functions

virtual CCopasiMethodcreateMethod (const CCopasiMethod::SubType &)
 
virtual bool loadTask ()
 
virtual bool saveTask ()
 
- Protected Member Functions inherited from TaskWidget
bool commonAfterRunTask ()
 
bool commonBeforeRunTask ()
 
bool commonRunTask ()
 
virtual bool enterProtected ()
 
void finishTask ()
 
bool loadCommon ()
 
bool loadMethod ()
 
bool saveCommon ()
 
bool saveMethod ()
 
virtual bool taskFinishedEvent ()
 

Protected Attributes

QPushButton * buttonNewItem
 
QComboBox * comboType
 
QGridLayout * ScanWidgetLayout
 
CScanContainerWidgetscrollview
 
- Protected Attributes inherited from TaskWidget
bool mChanged
 
CQTaskBtnWidgetmpBtnWidget
 
CQTaskHeaderWidgetmpHeaderWidget
 
CCopasiMethodmpMethod
 
QGridLayout * mpMethodLayout
 
CQTaskMethodWidgetmpMethodWidget
 
CProgressBarmProgressBar
 
QSpacerItem * mpSpacer1
 
QSpacerItem * mpSpacer2
 
CCopasiTaskmpTask
 
CQTaskThreadmpTaskThread
 
- Protected Attributes inherited from CopasiWidget
int mFramework
 
bool mIgnoreUpdates
 
std::string mKey
 
CCopasiDataModelmpDataModel
 
ListViewsmpListView
 
CCopasiObjectmpObject
 

Additional Inherited Members

- Public Slots inherited from TaskWidget
void adjustTable ()
 
void slotFinishThread ()
 

Detailed Description

Definition at line 29 of file ScanWidget.h.

Constructor & Destructor Documentation

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

Definition at line 56 of file ScanWidget.cpp.

References buttonNewItem, comboType, TaskWidget::mpBtnWidget, TaskWidget::mpHeaderWidget, ScanWidgetLayout, scrollview, CQTaskHeaderWidget::setTaskName(), and slotAddItem().

57  : TaskWidget(parent, name, f)
58 {
59  if (!name)
60  setObjectName("ScanWidget");
61 
62  setWindowTitle(trUtf8("ScanWidget"));
63  ScanWidgetLayout = new QGridLayout(this);
64  ScanWidgetLayout->setMargin(11);
65  ScanWidgetLayout->setSpacing(6);
66  ScanWidgetLayout->setObjectName("ScanWidgetLayout");
67 
68  mpHeaderWidget->setTaskName("Parameter Scan");
69 
70  ScanWidgetLayout->addWidget(mpHeaderWidget, 0, 0);
71 
72  mpBtnWidget->verticalLayout->removeItem(mpBtnWidget->verticalSpacer);
73  ScanWidgetLayout->addWidget(mpBtnWidget, 3, 0);
74 
75  //*****************
76 
77  QHBoxLayout* tmpLayout = new QHBoxLayout();
78 
79  QSpacerItem* tmpSpacer = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum);
80  tmpLayout->addItem(tmpSpacer);
81 
82  QLabel* tmpLabel = new QLabel(this);
83  tmpLabel->setText("New scan item: ");
84  tmpLayout->addWidget(tmpLabel);
85 
86  comboType = new QComboBox(this);
87  //+++
88  comboType->addItem("Scan");
89  comboType->addItem("Repeat");
90  comboType->addItem("Random distribution");
91  tmpLayout->addWidget(comboType);
92 
93  QSpacerItem *mpSpacer = new QSpacerItem(20, 20, QSizePolicy::Maximum, QSizePolicy::Minimum);
94  tmpLayout->addItem(mpSpacer);
95 
96  buttonNewItem = new QPushButton(this);
97  buttonNewItem->setObjectName("buttonNewItem");
98  buttonNewItem->setText("Create");
99  //ScanWidgetLayout->addWidget(buttonNewItem, 1, 2);
100  tmpLayout->addWidget(buttonNewItem);
101 
102  ScanWidgetLayout->addLayout(tmpLayout, 1, 0);
103 
104  //*****************************
105 
106  scrollview = new CScanContainerWidget(this);
107  ScanWidgetLayout->addWidget(scrollview, 2, 0);
108 
109  // tab order
110  /*setTabOrder(taskName, sExecutable);
111  setTabOrder(sExecutable, steadyState);*/
112 
113  connect(buttonNewItem, SIGNAL(clicked()), this, SLOT(slotAddItem()));
114 }
CScanContainerWidget * scrollview
Definition: ScanWidget.h:46
QGridLayout * ScanWidgetLayout
Definition: ScanWidget.h:53
bool slotAddItem()
Definition: ScanWidget.cpp:203
bool setTaskName(const std::string &name)
QComboBox * comboType
Definition: ScanWidget.h:51
QPushButton * buttonNewItem
Definition: ScanWidget.h:50
CQTaskBtnWidget * mpBtnWidget
Definition: TaskWidget.h:124
CQTaskHeaderWidget * mpHeaderWidget
Definition: TaskWidget.h:122
TaskWidget(QWidget *parent=0, const char *name=0, Qt::WFlags fl=0)
Definition: TaskWidget.cpp:52
ScanWidget::~ScanWidget ( )

Definition at line 116 of file ScanWidget.cpp.

117 {}

Member Function Documentation

virtual CCopasiMethod* ScanWidget::createMethod ( const CCopasiMethod::SubType )
inlineprotectedvirtual

Implements TaskWidget.

Definition at line 46 of file ScanWidget.h.

46 {return NULL;};
bool ScanWidget::loadTask ( )
protectedvirtual

Implements TaskWidget.

Definition at line 130 of file ScanWidget.cpp.

References CScanContainerWidget::addWidget(), CScanContainerWidget::clearWidgetList(), CKeyFactory::get(), CCopasiRootContainer::getDatamodelList(), CCopasiRootContainer::getKeyFactory(), CScanProblem::getNumberOfScanItems(), CCopasiTask::getProblem(), CScanProblem::getScanItem(), CCopasiParameterGroup::getValue(), CScanWidgetRepeat::load(), CScanWidgetRandom::load(), CScanWidgetTask::load(), CScanWidgetScan::load(), TaskWidget::loadCommon(), TaskWidget::mChanged, CopasiWidget::mKey, CCopasiParameter::Value::pVOID, CScanProblem::SCAN_LINEAR, CScanProblem::SCAN_RANDOM, CScanProblem::SCAN_REPEAT, and scrollview.

131 {
132  loadCommon();
133 
134  CScanTask* scanTask =
135  dynamic_cast< CScanTask * >(CCopasiRootContainer::getKeyFactory()->get(mKey));
136 
137  if (!scanTask) return false;
138 
139  CScanProblem *scanProblem = dynamic_cast<CScanProblem *>(scanTask->getProblem());
140 
141  if (!scanProblem) return false;
142 
144 
145  //std::vector<QWidget*> & widgetList = scrollview->getWidgetList();
146 
147  //+++
148  CScanWidgetScan* tmp1;
149  CScanWidgetRepeat* tmp2;
150  CScanWidgetRandom* tmp3;
151  //CScanWidgetBreak* tmp4;
152 
153  // the scan items
154  assert(CCopasiRootContainer::getDatamodelList()->size() > 0);
155  //CCopasiDataModel* pDataModel = (*CCopasiRootContainer::getDatamodelList())[0];
156  //assert(pDataModel != NULL);
157  size_t i, imax = scanProblem->getNumberOfScanItems();
158 
159  for (i = 0; i < imax; ++i)
160  {
161  void * pTmp;
162 
163  if (!(pTmp = scanProblem->getScanItem(i)->getValue("Type").pVOID)) return false;
164 
165  CScanProblem::Type type = *(CScanProblem::Type*)pTmp;
166 
167  switch (type)
168  {
169  //+++
171  tmp1 = new CScanWidgetScan(scrollview);
172  tmp1->load(scanProblem->getScanItem(i));
173  scrollview->addWidget(tmp1);
174  break;
175 
177  tmp2 = new CScanWidgetRepeat(scrollview);
178  tmp2->load(scanProblem->getScanItem(i));
179  scrollview->addWidget(tmp2);
180  break;
181 
183  tmp3 = new CScanWidgetRandom(scrollview);
184  tmp3->load(scanProblem->getScanItem(i));
185  scrollview->addWidget(tmp3);
186  break;
187 
188  default:
189  break;
190  }
191  }
192 
193  // the widget for the subtask
195  tmpT->load(scanProblem);
196  scrollview->addWidget(tmpT, false); //false: no control buttons (up/down/del)
197 
198  mChanged = false;
199 
200  return true;
201 }
CCopasiProblem * getProblem()
bool loadCommon()
Definition: TaskWidget.cpp:247
CScanContainerWidget * scrollview
Definition: ScanWidget.h:46
CCopasiObject * get(const std::string &key)
virtual void load(const CCopasiParameterGroup *pItem)
virtual void load(const CScanProblem *pg)
virtual void load(const CCopasiParameterGroup *pItem)
size_t getNumberOfScanItems() const
bool mChanged
Definition: TaskWidget.h:133
static CCopasiVector< CCopasiDataModel > * getDatamodelList()
static CKeyFactory * getKeyFactory()
virtual void load(const CCopasiParameterGroup *pItem)
const CCopasiParameter::Value & getValue(const std::string &name) const
const CCopasiParameterGroup * getScanItem(size_t index) const
void addWidget(QWidget *widget, bool controls=true)
std::string mKey
Definition: copasiWidget.h:63
bool ScanWidget::runTask ( )
virtual

Implements TaskWidget.

Definition at line 119 of file ScanWidget.cpp.

References TaskWidget::commonBeforeRunTask(), and TaskWidget::commonRunTask().

Referenced by SliderDialog::runScanTask().

120 {
121  if (!commonBeforeRunTask()) return false;
122 
123  bool success = true;
124 
125  if (!commonRunTask()) success = false;
126 
127  return success;
128 }
bool commonRunTask()
Definition: TaskWidget.cpp:395
bool commonBeforeRunTask()
Definition: TaskWidget.cpp:317
bool ScanWidget::saveTask ( )
protectedvirtual

Implements TaskWidget.

Definition at line 304 of file ScanWidget.cpp.

References CScanProblem::addScanItem(), CCopasiDataModel::changed(), CKeyFactory::get(), CCopasiRootContainer::getKeyFactory(), CScanProblem::getNumberOfScanItems(), CCopasiTask::getProblem(), CScanProblem::getScanItem(), CScanContainerWidget::getWidgetList(), TaskWidget::mChanged, min, CopasiWidget::mKey, CopasiWidget::mpDataModel, CScanProblem::removeScanItem(), CScanWidgetTask::save(), TaskWidget::saveCommon(), CScanProblem::SCAN_LINEAR, and scrollview.

305 {
306  saveCommon();
307 
308  CScanTask* scanTask =
309  dynamic_cast< CScanTask * >(CCopasiRootContainer::getKeyFactory()->get(mKey));
310 
311  if (!scanTask) return false;
312 
313  CScanProblem *scanProblem = dynamic_cast<CScanProblem *>(scanTask->getProblem());
314 
315  if (!scanProblem) return false;
316 
317  const std::vector< QWidget * > & widgetList = scrollview->getWidgetList();
318 
319  size_t newSize = widgetList.size() - 1; // The last widget is reserved for the subtask.
320  size_t oldSize = scanProblem->getNumberOfScanItems();
321 
322  size_t i, imax = std::min(newSize, oldSize);
323 
324  mChanged = false;
325 
326  for (i = 0; i < imax; ++i)
327  {
328  QWidget * pWidget = widgetList[i];
329 
330  if (pWidget->objectName() == "CScanWidgetScan")
331  {
332  mChanged |= static_cast< CScanWidgetScan * >(pWidget)->save(scanProblem->getScanItem(i));
333  }
334  else if (pWidget->objectName() == "CScanWidgetRandom")
335  {
336  mChanged |= static_cast< CScanWidgetRandom * >(pWidget)->save(scanProblem->getScanItem(i));
337  }
338  else if (pWidget->objectName() == "CScanWidgetRepeat")
339  {
340  mChanged |= static_cast< CScanWidgetRepeat * >(pWidget)->save(scanProblem->getScanItem(i));
341  }
342  }
343 
344  for (; i < newSize; ++i)
345  {
346  mChanged = true;
347  QWidget * pWidget = widgetList[i];
349 
350  if (pWidget->objectName() == "CScanWidgetScan")
351  {
352  static_cast< CScanWidgetScan * >(pWidget)->save(pItem);
353  }
354  else if (pWidget->objectName() == "CScanWidgetRandom")
355  {
356  static_cast< CScanWidgetRandom * >(pWidget)->save(pItem);
357  }
358  else if (pWidget->objectName() == "CScanWidgetRepeat")
359  {
360  static_cast< CScanWidgetRepeat * >(pWidget)->save(pItem);
361  }
362  }
363 
364  for (; i < oldSize; ++i)
365  {
366  mChanged = true;
367  scanProblem->removeScanItem(newSize);
368  }
369 
370  // the subtask
371  const CScanWidgetTask * tmpT = dynamic_cast<CScanWidgetTask*>(widgetList[newSize]);
372 
373  if (tmpT != NULL)
374  {
375  mChanged |= tmpT->save(scanProblem);
376  }
377 
378  // :TODO Bug 322: This should only be called when actual changes have been saved.
379  // However we do not check whether the scan item are mChanged we delete all
380  // and create them new.
381  if (mChanged)
382  {
383  if (mpDataModel != NULL)
384  {
385  mpDataModel->changed();
386  }
387 
388  mChanged = false;
389  }
390 
391  return true;
392 }
CCopasiProblem * getProblem()
CScanContainerWidget * scrollview
Definition: ScanWidget.h:46
CCopasiObject * get(const std::string &key)
bool saveCommon()
Definition: TaskWidget.cpp:258
size_t getNumberOfScanItems() const
void changed(const bool &changed=true)
bool mChanged
Definition: TaskWidget.h:133
CCopasiParameterGroup * addScanItem(CScanProblem::Type type, size_t steps=5, const CCopasiObject *obj=NULL)
std::vector< QWidget * > getWidgetList() const
CCopasiDataModel * mpDataModel
Definition: copasiWidget.h:65
static CKeyFactory * getKeyFactory()
const CCopasiParameterGroup * getScanItem(size_t index) const
std::string mKey
Definition: copasiWidget.h:63
#define min(a, b)
Definition: f2c.h:175
virtual bool save(CScanProblem *pg) const
bool removeScanItem(const size_t &index)
bool ScanWidget::slotAddItem ( )
protectedslot

Definition at line 203 of file ScanWidget.cpp.

References comboType, CScanProblem::createScanItem(), CCopasiSelectionDialog::getObjectVector(), CScanWidgetRandom::initFromObject(), CScanWidgetScan::initFromObject(), CQSimpleSelectionTree::InitialTime, CScanContainerWidget::insertWidget(), CScanWidgetRepeat::load(), CQSimpleSelectionTree::Parameters, pdelete, CScanProblem::SCAN_LINEAR, CScanProblem::SCAN_RANDOM, CScanProblem::SCAN_REPEAT, and scrollview.

Referenced by ScanWidget().

204 {
205  int totalRows = -1;
206  //+++
207  CScanWidgetScan* tmp1;
208  CScanWidgetRepeat* tmp2;
209  CScanWidgetRandom* tmp3;
210  //CScanWidgetBreak* tmp4;
211 
212  int intType = comboType->currentIndex();
213  CScanProblem::Type type;
214 
215  switch (intType)
216  {
217  case 0:
219  break;
220 
221  case 1:
223  break;
224 
225  case 2:
227  break;
228 
229  default:
231  break;
232  }
233 
234  switch (type)
235  {
237  {
238  tmp2 = new CScanWidgetRepeat(scrollview);
239 
240  //create item to get the default values
242  tmp2->load(pItem);
243  pdelete(pItem);
244 
245  scrollview->insertWidget(tmp2);
246  totalRows = scrollview->rowCount();
247  tmp2->lineEditNumber->setFocus();
248  }
249  break;
250 
252  {
255 
256  std::vector< const CCopasiObject * > Selection = CCopasiSelectionDialog::getObjectVector(this, Classes);
257 
258  // create scan widgets as many as the number of selected objects
259  std::vector< const CCopasiObject * >::iterator it = Selection.begin();
260  std::vector< const CCopasiObject * >::iterator end = Selection.end();
261 
262  for (; it != end; ++it)
263  {
264  tmp1 = new CScanWidgetScan(scrollview);
265  tmp1->initFromObject(*it);
266  scrollview->insertWidget(tmp1);
267  totalRows = scrollview->rowCount();
268  tmp1->lineEditMin->setFocus();
269  }
270 
271  break;
272  }
273 
275  {
278 
279  std::vector< const CCopasiObject * > Selection = CCopasiSelectionDialog::getObjectVector(this, Classes);
280 
281  // create scan widgets as many as the number of selected objects
282  std::vector< const CCopasiObject * >::iterator it = Selection.begin();
283  std::vector< const CCopasiObject * >::iterator end = Selection.end();
284 
285  for (; it != end; ++it)
286  {
287  tmp3 = new CScanWidgetRandom(scrollview);
288  tmp3->initFromObject(*it);
289  scrollview->insertWidget(tmp3);
290  totalRows = scrollview->rowCount();
291  tmp3->lineEditMin->setFocus();
292  }
293 
294  break;
295  }
296 
297  default:
298  break;
299  }
300 
301  return true;
302 }
#define pdelete(p)
Definition: copasi.h:215
void initFromObject(const CCopasiObject *obj)
CScanContainerWidget * scrollview
Definition: ScanWidget.h:46
virtual void load(const CCopasiParameterGroup *pItem)
static std::vector< const CCopasiObject * > getObjectVector(QWidget *pParent, const CQSimpleSelectionTree::ObjectClasses &classes, const std::vector< const CCopasiObject * > *pCurrentSelection=NULL)
QComboBox * comboType
Definition: ScanWidget.h:51
static CCopasiParameterGroup * createScanItem(CScanProblem::Type type, size_t steps=5, const CCopasiObject *obj=NULL)
void initFromObject(const CCopasiObject *obj)
void insertWidget(QWidget *widget, int row=-1)

Member Data Documentation

QPushButton* ScanWidget::buttonNewItem
protected

Definition at line 50 of file ScanWidget.h.

Referenced by ScanWidget().

QComboBox* ScanWidget::comboType
protected

Definition at line 51 of file ScanWidget.h.

Referenced by ScanWidget(), and slotAddItem().

QGridLayout* ScanWidget::ScanWidgetLayout
protected

Definition at line 53 of file ScanWidget.h.

Referenced by ScanWidget().

CScanContainerWidget* ScanWidget::scrollview
protected

Definition at line 46 of file ScanWidget.h.

Referenced by loadTask(), saveTask(), ScanWidget(), and slotAddItem().


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