COPASI API  4.16.103
CQLyapWidget.cpp
Go to the documentation of this file.
1 // Copyright (C) 2010 - 2013 by Pedro Mendes, Virginia Tech Intellectual
2 // Properties, Inc., University of Heidelberg, and The University
3 // of Manchester.
4 // All rights reserved.
5 
6 // Copyright (C) 2008 - 2009 by Pedro Mendes, Virginia Tech Intellectual
7 // Properties, Inc., EML Research, gGmbH, University of Heidelberg,
8 // and The University of Manchester.
9 // All rights reserved.
10 
11 // Copyright (C) 2006 - 2007 by Pedro Mendes, Virginia Tech Intellectual
12 // Properties, Inc. and EML Research, gGmbH.
13 // All rights reserved.
14 
15 #include "CQLyapWidget.h"
16 
17 #include <QtGui/QMessageBox>
18 
19 #include "CQTaskBtnWidget.h"
20 #include "CQTaskHeaderWidget.h"
21 #include "CQTaskMethodWidget.h"
22 #include "CProgressBar.h"
23 
24 #include "lyap/CLyapTask.h"
25 #include "lyap/CLyapProblem.h"
26 #include "model/CModel.h"
27 #include "report/CKeyFactory.h"
30 
31 /*
32  * Constructs a CQLyapWidget which is a child of 'parent', with the
33  * name 'name'.'
34  */
35 CQLyapWidget::CQLyapWidget(QWidget* parent, const char* name)
36  : TaskWidget(parent, name)
37 {
38  setupUi(this);
39 
40  init();
41 }
42 
43 /*
44  * Destroys the object and frees any allocated resources
45  */
47 {
48  // no need to delete child widgets, Qt does it all for us
49 }
50 
52 {
53  CLyapTask * pTask =
55 
56  if (!pTask) return false;
57 
58  if (!commonBeforeRunTask()) return false;
59 
60  return commonRunTask();
61 }
62 
64 {
65  mpListView->switchToOtherWidget(261, ""); //change to the results window
66  return true;
67 }
68 
70 {return CLyapMethod::createMethod(type);}
71 
73 {
74  CLyapTask * pTask = dynamic_cast< CLyapTask * >(mpTask);
75 
76  if (!pTask) return false;
77 
78  loadCommon();
79  loadMethod();
80 
81  CLyapProblem* pProblem =
82  dynamic_cast< CLyapProblem * >(mpTask->getProblem());
83 
84  if (!pProblem) return false;
85 
86  mpEditExponent->setText(QString::number(pProblem->getExponentNumber()));
87 
88  assert(CCopasiRootContainer::getDatamodelList()->size() > 0);
89  bool enabled =
90  ((*CCopasiRootContainer::getDatamodelList())[0]->getModel()->getInitialTime() != pProblem->getTransientTime());
91 
92  mpCheckDelay->setChecked(enabled);
93  mpEditDelay->setEnabled(enabled);
94  mpEditDelay->setText(QString::number(pProblem->getTransientTime()));
95 
96  mpCheckDivergence->setChecked(pProblem->divergenceRequested());
97 
98  mChanged = false;
99 
100  return true;
101 }
102 
104 {
105  CLyapTask * pTask = dynamic_cast< CLyapTask * >(mpTask);
106 
107  if (!pTask) return false;
108 
109  saveCommon();
110  saveMethod();
111 
112  CLyapProblem* pProblem =
113  dynamic_cast< CLyapProblem * >(mpTask->getProblem());
114 
115  if (!pProblem) return false;
116 
117  if (QString::number(pProblem->getExponentNumber()) != mpEditExponent->text())
118  {
119  pProblem->setExponentNumber(std::max(0, mpEditExponent->text().toInt()));
120  mChanged = true;
121  }
122 
123  assert(CCopasiRootContainer::getDatamodelList()->size() > 0);
124  bool enabled =
125  ((*CCopasiRootContainer::getDatamodelList())[0]->getModel()->getInitialTime() != pProblem->getTransientTime());
126 
127  if (mpCheckDelay->isChecked() != enabled ||
128  (mpCheckDelay->isChecked() &&
129  mpEditDelay->text() != QString::number(pProblem->getTransientTime())))
130  {
131  if (mpCheckDelay->isChecked())
132  pProblem->setTransientTime(mpEditDelay->text().toDouble());
133  else
134  pProblem->setTransientTime((*CCopasiRootContainer::getDatamodelList())[0]->getModel()->getInitialTime());
135 
136  mChanged = true;
137  }
138 
139  if (mpCheckDivergence->isChecked() != pProblem->divergenceRequested())
140  {
141  pProblem->setDivergenceRequested(mpCheckDivergence->isChecked());
142  mChanged = true;
143  }
144 
145  if (mChanged)(*CCopasiRootContainer::getDatamodelList())[0]->changed();
146 
147  mChanged = false;
148  return true;
149 }
150 
152 {
153  mpHeaderWidget->setTaskName("Lyapunov Exponents");
154 
155  vboxLayout->insertWidget(0, mpHeaderWidget); // header
156  // vboxLayout->insertSpacing(1, 14); // space between header and body
157 
159  vboxLayout->addWidget(mpMethodWidget);
160 
161  vboxLayout->addWidget(mpBtnWidget); // 'footer'
162 }
163 
165 {
166  mpEditDelay->setEnabled(mpCheckDelay->isChecked());
167 }
virtual CCopasiMethod * createMethod(const CCopasiMethod::SubType &type)
bool saveMethod()
Definition: TaskWidget.cpp:308
CCopasiProblem * getProblem()
void switchToOtherWidget(const size_t &id, const std::string &key)
Definition: listviews.cpp:926
bool loadCommon()
Definition: TaskWidget.cpp:247
CCopasiObject * get(const std::string &key)
void setDivergenceRequested(bool flag)
bool saveCommon()
Definition: TaskWidget.cpp:258
bool loadMethod()
Definition: TaskWidget.cpp:284
virtual bool taskFinishedEvent()
void setTransientTime(const C_FLOAT64 &endTime)
bool setTaskName(const std::string &name)
bool mChanged
Definition: TaskWidget.h:133
virtual bool loadTask()
CTSSATask * pTask
CQLyapWidget(QWidget *parent=0, const char *name=0)
ListViews * mpListView
Definition: copasiWidget.h:62
void setExponentNumber(const unsigned C_INT32 &number)
const C_FLOAT64 & getTransientTime() const
static CCopasiVector< CCopasiDataModel > * getDatamodelList()
virtual bool saveTask()
static CLyapMethod * createMethod(CCopasiMethod::SubType subType=CCopasiMethod::lyapWolf)
Definition: CLyapMethod.cpp:58
CCopasiTask * mpTask
Definition: TaskWidget.h:130
void slotDelayChecked()
void showMethodParameters(const bool &show)
const unsigned C_INT32 & getExponentNumber() const
CQTaskMethodWidget * mpMethodWidget
Definition: TaskWidget.h:123
virtual bool runTask()
static CKeyFactory * getKeyFactory()
bool commonRunTask()
Definition: TaskWidget.cpp:395
CQTaskBtnWidget * mpBtnWidget
Definition: TaskWidget.h:124
CQTaskHeaderWidget * mpHeaderWidget
Definition: TaskWidget.h:122
bool divergenceRequested() const
bool commonBeforeRunTask()
Definition: TaskWidget.cpp:317
std::string mKey
Definition: copasiWidget.h:63
#define max(a, b)
Definition: f2c.h:176