COPASI API  4.16.103
SteadyStateWidget.cpp
Go to the documentation of this file.
1 // Begin CVS Header
2 // $Source: /Volumes/Home/Users/shoops/cvs/copasi_dev/copasi/UI/SteadyStateWidget.cpp,v $
3 // $Revision: 1.131 $
4 // $Name: $
5 // $Author: shoops $
6 // $Date: 2012/01/06 19:13:45 $
7 // End CVS Header
8 
9 // Copyright (C) 2011 - 2010 by Pedro Mendes, Virginia Tech Intellectual
10 // Properties, Inc., University of Heidelberg, and The University
11 // of Manchester.
12 // All rights reserved.
13 
14 // Copyright (C) 2008 by Pedro Mendes, Virginia Tech Intellectual
15 // Properties, Inc., EML Research, gGmbH, University of Heidelberg,
16 // and The University of Manchester.
17 // All rights reserved.
18 
19 // Copyright (C) 2001 - 2007 by Pedro Mendes, Virginia Tech Intellectual
20 // Properties, Inc. and EML Research, gGmbH.
21 // All rights reserved.
22 
23 #include "DataModelGUI.h"
24 
25 #include "SteadyStateWidget.h"
26 #include "listviews.h"
27 #include "CQTaskBtnWidget.h"
28 #include "CQTaskHeaderWidget.h"
29 #include "CQTaskMethodWidget.h"
30 #include "CProgressBar.h"
31 #include "CQSteadyStateResult.h"
32 
33 #include "copasi.h"
34 #include "qtUtilities.h"
35 
40 #include "model/CModel.h"
42 #include "report/CKeyFactory.h"
43 
44 /**
45  * Constructs a SteadyStateWidget which is a child of 'parent', with the
46  * name 'name' and widget flags set to 'f'.
47  */
48 SteadyStateWidget::SteadyStateWidget(QWidget* parent, const char* name, Qt::WFlags fl)
49  : TaskWidget(parent, name, fl)
50 {
51  setupUi(this);
52 
53  init();
54  retranslateUi(this);
55 }
56 
57 /*
58  * Destroys the object and frees any allocated resources
59  */
61 {}
62 
64 {
65  mpHeaderWidget->setTaskName("Steady State");
66 
67  SteadyStateWidgetLayout->insertWidget(0, mpHeaderWidget); // header
68  // SteadyStateWidgetLayout->insertSpacing(1, 14); // space between header and body
69 
71  SteadyStateWidgetLayout->addWidget(mpMethodWidget);
72 
73  SteadyStateWidgetLayout->addWidget(mpBtnWidget); // 'footer'
74 }
75 
77 {return NULL; /*CTSSMethod::createTSSMethod(type);*/}
78 
80 {
81  bool success = true;
82 
83  if (!commonBeforeRunTask()) return false;
84 
85  if (!commonRunTask()) success = false;
86 
87  return success;
88 }
89 
91 {
92  bool success = false;
93 
94  CSteadyStateTask* pSteadyStateTask = dynamic_cast<CSteadyStateTask *>(mpObject);
95 
96  if (pSteadyStateTask == NULL)
97  return success;
98 
99  switch (pSteadyStateTask->getResult())
100  {
103  success = true;
104  break;
105 
107 
108  if (mpMethod != NULL)
109  {
110  const CCopasiParameter *pParm = mpMethod->getParameter("Accept Negative Concentrations");
111 
112  if (pParm != NULL)
113  {
114  success = *pParm->getValue().pBOOL;
115  }
116  }
117 
118  break;
119 
120  default:
121  break;
122  }
123 
125  dynamic_cast< CQSteadyStateResult * >(mpListView->findWidgetFromId(211));
126 
127  if (pResult)
128  pResult->loadResult();
129 
130  if (success && isVisible())
131  mpListView->switchToOtherWidget(211, ""); //change to the results window
132 
133  return success;
134 }
135 
137 {
138  loadCommon();
139  loadMethod();
140 
141  CSteadyStateTask* mSteadyStateTask =
143 
144  if (mSteadyStateTask == NULL)
145  return false;
146 
147  CSteadyStateProblem* steadystateproblem =
148  dynamic_cast<CSteadyStateProblem *>(mSteadyStateTask->getProblem());
149 
150  if (steadystateproblem == NULL)
151  return false;
152 
153  CSteadyStateMethod* steadystatemethod =
154  dynamic_cast<CSteadyStateMethod *>(mSteadyStateTask->getMethod());
155 
156  if (steadystatemethod == NULL)
157  return false;
158 
159  bool bJacobian = steadystateproblem->isJacobianRequested();
160  bool bStatistics = steadystateproblem->isStabilityAnalysisRequested();
161  taskJacobian->setChecked(bJacobian);
162 
163  if (bJacobian)
164  {
165  taskStability->setEnabled(true);
166  taskStability->setChecked(bStatistics);
167  }
168 
169  mChanged = false;
170 
171  return true;
172 }
173 
175 {
176  saveCommon();
177  saveMethod();
178 
179  CSteadyStateTask* mSteadyStateTask =
181 
182  if (mSteadyStateTask == NULL)
183  return false;
184 
185  CSteadyStateProblem* steadystateproblem =
186  dynamic_cast<CSteadyStateProblem *>(mSteadyStateTask->getProblem());
187 
188  if (steadystateproblem == NULL)
189  return false;
190 
191  CSteadyStateMethod* steadystatemethod =
192  dynamic_cast<CSteadyStateMethod *>(mSteadyStateTask->getMethod());
193 
194  if (steadystatemethod == NULL)
195  return false;
196 
197  bool bJacobian = taskJacobian->isChecked();
198  bool bStatistics = taskStability->isChecked();
199 
200  steadystateproblem->setJacobianRequested(bJacobian);
201  steadystateproblem->setStabilityAnalysisRequested(bStatistics);
202 
203  if (mChanged)
204  {
205  if (mpDataModel != NULL)
206  {
207  mpDataModel->changed();
208  }
209 
210  mChanged = false;
211  }
212 
213  return true;
214 }
215 
217 {
218  if (!taskJacobian->isChecked())
219  {
220  taskStability->setChecked(false);
221  taskStability->setEnabled(false);
222  }
223  else taskStability->setEnabled(true);
224 }
SteadyStateWidget(QWidget *parent=0, const char *name=0, Qt::WFlags fl=0)
const CSteadyStateMethod::ReturnCode & getResult() const
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
virtual bool saveTask()
CCopasiObject * get(const std::string &key)
bool saveCommon()
Definition: TaskWidget.cpp:258
bool loadMethod()
Definition: TaskWidget.cpp:284
CCopasiObject * mpObject
Definition: copasiWidget.h:64
bool isStabilityAnalysisRequested() const
virtual CCopasiMethod * createMethod(const CCopasiMethod::SubType &type)
void changed(const bool &changed=true)
bool setTaskName(const std::string &name)
bool mChanged
Definition: TaskWidget.h:133
void setJacobianRequested(bool &jacobianRequested)
CopasiWidget * findWidgetFromId(const size_t &id) const
Definition: listviews.cpp:678
virtual void taskJacobianToggled()
ListViews * mpListView
Definition: copasiWidget.h:62
const Value & getValue() const
void showMethodParameters(const bool &show)
CCopasiParameter * getParameter(const std::string &name)
CQTaskMethodWidget * mpMethodWidget
Definition: TaskWidget.h:123
const CArrayAnnotation * pResult
CCopasiDataModel * mpDataModel
Definition: copasiWidget.h:65
virtual bool loadTask()
CCopasiMethod * getMethod()
static CKeyFactory * getKeyFactory()
bool commonRunTask()
Definition: TaskWidget.cpp:395
CQTaskBtnWidget * mpBtnWidget
Definition: TaskWidget.h:124
CQTaskHeaderWidget * mpHeaderWidget
Definition: TaskWidget.h:122
bool fl(const C_FLOAT64 &d1, const C_FLOAT64 &d2)
void setStabilityAnalysisRequested(bool &stabilityAnalysisRequested)
bool isJacobianRequested() const
CCopasiMethod * mpMethod
Definition: TaskWidget.h:131
virtual bool taskFinishedEvent()
bool commonBeforeRunTask()
Definition: TaskWidget.cpp:317
std::string mKey
Definition: copasiWidget.h:63
virtual bool runTask()