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

#include <CQTaskMethodWidget.h>

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

Public Member Functions

void clearHistory ()
 
 CQTaskMethodWidget (QWidget *parent=0, Qt::WindowFlags f=0)
 
bool loadMethod ()
 
bool saveMethod ()
 
void setTask (CCopasiTask *pTask)
 
void setValidMethods (const unsigned int *validMethods)
 
void showMethodParameters (const bool &show)
 
virtual ~CQTaskMethodWidget ()
 

Protected Slots

void changeMethod (int)
 

Protected Member Functions

void addToHistory (CCopasiMethod *pMethod)
 
CCopasiMethodgetFromHistory (const CCopasiMethod::SubType &Type) const
 
void removeFromHistory (CCopasiMethod *pMethod)
 
void setActiveMethod (const CCopasiMethod::SubType &Type)
 

Protected Attributes

std::map
< CCopasiMethod::SubType,
CCopasiMethod * > 
mMethodHistory
 
CCopasiMethodmpActiveMethod
 
CCopasiMethodmpMethod
 
CCopasiTaskmpTask
 
bool mShowMethodParameters
 
bool mShowMethods
 

Detailed Description

Definition at line 16 of file CQTaskMethodWidget.h.

Constructor & Destructor Documentation

CQTaskMethodWidget::CQTaskMethodWidget ( QWidget *  parent = 0,
Qt::WindowFlags  f = 0 
)

Definition at line 15 of file CQTaskMethodWidget.cpp.

15  :
16  QWidget(parent, f),
17  mpTask(NULL),
18  mpMethod(NULL),
19  mpActiveMethod(NULL),
21  mShowMethods(false),
23 {
24  setupUi(this);
25 
26  mpTableParameter->verticalHeader()->setResizeMode(QHeaderView::ResizeToContents);
27  mpTableParameter->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents);
28  mpTableParameter->horizontalHeader()->hide();
29 
30  mpLblMethod->hide();
31  mpBoxMethod->hide();
32 
33  mpLblParameter->hide();
34  mpTableParameter->hide();
35 }
CCopasiMethod * mpActiveMethod
CCopasiMethod * mpMethod
std::map< CCopasiMethod::SubType, CCopasiMethod * > mMethodHistory
CQTaskMethodWidget::~CQTaskMethodWidget ( )
virtual

Definition at line 37 of file CQTaskMethodWidget.cpp.

References clearHistory().

38 {
39  clearHistory();
40 }

Member Function Documentation

void CQTaskMethodWidget::addToHistory ( CCopasiMethod pMethod)
protected

Definition at line 224 of file CQTaskMethodWidget.cpp.

References CCopasiMethod::getSubType(), and mMethodHistory.

Referenced by setActiveMethod().

225 {
226  if (pMethod == NULL)
227  {
228  return;
229  }
230 
231  std::map< CCopasiMethod::SubType, CCopasiMethod * >::iterator found = mMethodHistory.find(pMethod->getSubType());
232 
233  if (found != mMethodHistory.end())
234  {
235  if (found->second != pMethod)
236  {
237  delete found->second;
238  found->second = pMethod;
239  }
240 
241  return;
242  }
243 
244  mMethodHistory[pMethod->getSubType()] = pMethod;
245 }
const CCopasiMethod::SubType & getSubType() const
std::map< CCopasiMethod::SubType, CCopasiMethod * > mMethodHistory
void CQTaskMethodWidget::changeMethod ( int  )
protectedslot

Definition at line 42 of file CQTaskMethodWidget.cpp.

References C_INT32, loadMethod(), mpActiveMethod, mpTask, mShowMethodParameters, setActiveMethod(), setParameterValue(), CCopasiParameterGroup::size(), CCopasiMethod::SubTypeName, TO_UTF8, toEnum(), and CCopasiMethod::unset.

Referenced by setValidMethods().

43 {
44  if (mpTask == NULL)
45  return;
46 
47  // We update the active methods parameters
49  {
50  unsigned C_INT32 i;
51  QString Value;
52 
53  for (i = 0; i < mpActiveMethod->size(); i++)
54  {
55  if (!mpTableParameter->item(i, 0))
56  continue;
57 
58  Value = mpTableParameter->item(i, 0)->text();
60  }
61  }
62 
64  toEnum(TO_UTF8(mpBoxMethod->currentText()), CCopasiMethod::SubTypeName, CCopasiMethod::unset);
65 
66  setActiveMethod(Type);
67  loadMethod();
68 
69  return;
70 }
CCopasiMethod * mpActiveMethod
bool setParameterValue(CCopasiParameterGroup *group, const size_t &index, const QString &value)
Definition: qtUtilities.cpp:94
void setActiveMethod(const CCopasiMethod::SubType &Type)
#define C_INT32
Definition: copasi.h:90
CType toEnum(const char *attribute, const char **enumNames, const CType &enumDefault)
Definition: utility.h:107
static const std::string SubTypeName[]
Definition: CCopasiMethod.h:95
#define TO_UTF8(__x)
Definition: qtUtilities.h:74
void CQTaskMethodWidget::clearHistory ( )

Definition at line 289 of file CQTaskMethodWidget.cpp.

References mMethodHistory.

Referenced by TaskWidget::update(), and ~CQTaskMethodWidget().

290 {
291  std::map< CCopasiMethod::SubType, CCopasiMethod * >::iterator it = mMethodHistory.begin();
292  std::map< CCopasiMethod::SubType, CCopasiMethod * >::iterator end = mMethodHistory.end();
293 
294  for (; it != end; ++it)
295  {
296  delete it->second;
297  }
298 
299  mMethodHistory.clear();
300 }
std::map< CCopasiMethod::SubType, CCopasiMethod * > mMethodHistory
CCopasiMethod * CQTaskMethodWidget::getFromHistory ( const CCopasiMethod::SubType Type) const
protected

Definition at line 262 of file CQTaskMethodWidget.cpp.

References mMethodHistory.

Referenced by setActiveMethod().

263 {
264  std::map< CCopasiMethod::SubType, CCopasiMethod * >::const_iterator found = mMethodHistory.find(Type);
265 
266  if (found != mMethodHistory.end())
267  {
268  return found->second;
269  }
270 
271  return NULL;
272 }
std::map< CCopasiMethod::SubType, CCopasiMethod * > mMethodHistory
bool CQTaskMethodWidget::loadMethod ( )

Definition at line 134 of file CQTaskMethodWidget.cpp.

References C_INT32, FROM_UTF8, CCopasiParameterGroup::getName(), getParameterValue(), CCopasiMethod::getSubType(), mpActiveMethod, mpTask, mShowMethodParameters, mShowMethods, CCopasiParameterGroup::size(), and CCopasiMethod::SubTypeName.

Referenced by changeMethod(), and TaskWidget::loadMethod().

135 {
136  if (!mpTask) return false;
137 
138  if (!mpActiveMethod) return false;
139 
140  if (mShowMethods)
141  {
142  mpBoxMethod->setCurrentIndex(mpBoxMethod->findText(FROM_UTF8(CCopasiMethod::SubTypeName[mpActiveMethod->getSubType()])));
143  }
144 
146  {
147  QString Value;
148 
149  mpTableParameter->setRowCount((int) mpActiveMethod->size());
150 
151  unsigned C_INT32 i;
153 
154  for (i = 0; i < mpActiveMethod->size(); i++)
155  {
156  // create item of the current row and give it a name
157  mpTableParameter->setVerticalHeaderItem(i, new QTableWidgetItem());
158  mpTableParameter->verticalHeaderItem(i)->setText(FROM_UTF8(mpActiveMethod->getName(i)));
159 
160  Value = getParameterValue(mpActiveMethod, i, &Type);
161 
162  QTableWidgetItem *pValueItem = new QTableWidgetItem();
163  pValueItem->setData(Qt::EditRole, QVariant(Value));
164  pValueItem->setTextAlignment(Qt::AlignRight);
165  mpTableParameter->setItem(i, 0, pValueItem);
166  }
167  }
168 
169  mpTableParameter->resizeColumnsToContents();
170 
171  return true;
172 }
virtual const std::string & getName(const size_t &index) const
#define FROM_UTF8(__x)
Definition: qtUtilities.h:73
CCopasiMethod * mpActiveMethod
const CCopasiMethod::SubType & getSubType() const
#define C_INT32
Definition: copasi.h:90
QString getParameterValue(const CCopasiParameterGroup *group, const size_t &index, CCopasiParameter::Type *type)
Definition: qtUtilities.cpp:28
static const std::string SubTypeName[]
Definition: CCopasiMethod.h:95
void CQTaskMethodWidget::removeFromHistory ( CCopasiMethod pMethod)
protected

Definition at line 247 of file CQTaskMethodWidget.cpp.

References CCopasiMethod::getSubType(), and mMethodHistory.

248 {
249  if (pMethod == NULL)
250  {
251  return;
252  }
253 
254  std::map< CCopasiMethod::SubType, CCopasiMethod * >::iterator found = mMethodHistory.find(pMethod->getSubType());
255 
256  if (found != mMethodHistory.end())
257  {
258  mMethodHistory.erase(found);
259  }
260 }
const CCopasiMethod::SubType & getSubType() const
std::map< CCopasiMethod::SubType, CCopasiMethod * > mMethodHistory
bool CQTaskMethodWidget::saveMethod ( )

Definition at line 174 of file CQTaskMethodWidget.cpp.

References C_INT32, CCopasiTask::getMethod(), getParameterValue(), CCopasiMethod::getSubType(), mpActiveMethod, mpMethod, mpTask, mShowMethodParameters, mShowMethods, CCopasiTask::setMethodType(), setParameterValue(), and CCopasiParameterGroup::size().

Referenced by TaskWidget::saveMethod().

175 {
176  if (!mpTask) return false;
177 
178  const CCopasiMethod * pMethod = mpTask->getMethod();
179 
180  if (!pMethod) return false;
181 
182  bool changed = false;
183 
184  if (mShowMethods)
185  {
186  if (pMethod->getSubType() != mpActiveMethod->getSubType())
187  {
190 
191  changed = true;
192  }
193  }
194 
196  {
197  unsigned C_INT32 i;
198  QString Value;
200 
201  for (i = 0; i < mpActiveMethod->size(); i++)
202  {
203  if (!mpTableParameter->item(i, 0))
204  continue;
205 
206  Value = mpTableParameter->item(i, 0)->text();
207 
208  if (Value != getParameterValue(mpActiveMethod, i, &Type))
209  {
211  changed = true;
212  }
213  }
214  }
215 
216  if (changed)
217  {
219  }
220 
221  return changed;
222 }
CCopasiMethod * mpActiveMethod
bool setParameterValue(CCopasiParameterGroup *group, const size_t &index, const QString &value)
Definition: qtUtilities.cpp:94
const CCopasiMethod::SubType & getSubType() const
#define C_INT32
Definition: copasi.h:90
CCopasiMethod * mpMethod
QString getParameterValue(const CCopasiParameterGroup *group, const size_t &index, CCopasiParameter::Type *type)
Definition: qtUtilities.cpp:28
virtual bool setMethodType(const int &type)
CCopasiMethod * getMethod()
void CQTaskMethodWidget::setActiveMethod ( const CCopasiMethod::SubType Type)
protected

Definition at line 274 of file CQTaskMethodWidget.cpp.

References addToHistory(), CCopasiTask::createMethod(), getFromHistory(), mpActiveMethod, and mpTask.

Referenced by changeMethod(), and setTask().

275 {
277 
278  if (mpActiveMethod == NULL)
279  {
282  }
283 
284  assert(mpActiveMethod != NULL);
285 
286  return;
287 }
CCopasiMethod * mpActiveMethod
void addToHistory(CCopasiMethod *pMethod)
virtual CCopasiMethod * createMethod(const int &type) const
CCopasiMethod * getFromHistory(const CCopasiMethod::SubType &Type) const
void CQTaskMethodWidget::setTask ( CCopasiTask pTask)

Definition at line 72 of file CQTaskMethodWidget.cpp.

References CCopasiTask::getMethod(), CCopasiMethod::getSubType(), mpActiveMethod, mpMethod, mpTask, pTask, and setActiveMethod().

Referenced by TaskWidget::loadMethod().

73 {
74  mpTask = pTask;
75 
76  if (mpTask != NULL)
77  {
79 
80  if (mpMethod != NULL)
81  {
84  }
85  }
86  else
87  {
88  mpMethod = NULL;
89  mpActiveMethod = NULL;
90  }
91 }
CCopasiMethod * mpActiveMethod
void setActiveMethod(const CCopasiMethod::SubType &Type)
const CCopasiMethod::SubType & getSubType() const
CCopasiMethod * mpMethod
CTSSATask * pTask
CCopasiMethod * getMethod()
void CQTaskMethodWidget::setValidMethods ( const unsigned int *  validMethods)

Definition at line 93 of file CQTaskMethodWidget.cpp.

References C_INT32, changeMethod(), FROM_UTF8, mShowMethods, CCopasiMethod::SubTypeName, and CCopasiMethod::unset.

Referenced by CQFittingWidget::init(), CQTSSAWidget::init(), CQOptimizationWidget::init(), and CQTrajectoryWidget::init().

94 {
95  unsigned C_INT32 i;
96 
97  for (i = 0; validMethods[i] != CCopasiMethod::unset; i++)
98  mpBoxMethod->insertItem(mpBoxMethod->count(), FROM_UTF8(CCopasiMethod::SubTypeName[validMethods[i]]));
99 
100  if (i > 0)
101  {
102  mShowMethods = true;
103  mpLblMethod->show();
104  mpBoxMethod->show();
105 
106  connect(mpBoxMethod, SIGNAL(activated(int)), this, SLOT(changeMethod(int)));
107  }
108  else
109  {
110  mShowMethods = false;
111  mpLblMethod->hide();
112  mpBoxMethod->hide();
113 
114  disconnect(mpBoxMethod, SIGNAL(activated(int)), this, SLOT(changeMethod(int)));
115  }
116 }
#define FROM_UTF8(__x)
Definition: qtUtilities.h:73
#define C_INT32
Definition: copasi.h:90
static const std::string SubTypeName[]
Definition: CCopasiMethod.h:95
void CQTaskMethodWidget::showMethodParameters ( const bool &  show)

Definition at line 118 of file CQTaskMethodWidget.cpp.

References mShowMethodParameters.

Referenced by CQCrossSectionTaskWidget::init(), CQLyapWidget::init(), CQMCAWidget::init(), CQLNAWidget::init(), SensitivitiesWidget::init(), SteadyStateWidget::init(), CQFittingWidget::init(), CQOptimizationWidget::init(), CQTSSAWidget::init(), and CQTrajectoryWidget::init().

119 {
120  mShowMethodParameters = show;
121 
123  {
124  mpLblParameter->show();
125  mpTableParameter->show();
126  }
127  else
128  {
129  mpLblParameter->hide();
130  mpTableParameter->hide();
131  }
132 }

Member Data Documentation

std::map< CCopasiMethod::SubType, CCopasiMethod * > CQTaskMethodWidget::mMethodHistory
protected

Definition at line 51 of file CQTaskMethodWidget.h.

Referenced by addToHistory(), clearHistory(), getFromHistory(), and removeFromHistory().

CCopasiMethod* CQTaskMethodWidget::mpActiveMethod
protected

Definition at line 50 of file CQTaskMethodWidget.h.

Referenced by changeMethod(), loadMethod(), saveMethod(), setActiveMethod(), and setTask().

CCopasiMethod* CQTaskMethodWidget::mpMethod
protected

Definition at line 49 of file CQTaskMethodWidget.h.

Referenced by saveMethod(), and setTask().

CCopasiTask* CQTaskMethodWidget::mpTask
protected

Definition at line 48 of file CQTaskMethodWidget.h.

Referenced by changeMethod(), loadMethod(), saveMethod(), setActiveMethod(), and setTask().

bool CQTaskMethodWidget::mShowMethodParameters
protected

Definition at line 53 of file CQTaskMethodWidget.h.

Referenced by changeMethod(), loadMethod(), saveMethod(), and showMethodParameters().

bool CQTaskMethodWidget::mShowMethods
protected

Definition at line 52 of file CQTaskMethodWidget.h.

Referenced by loadMethod(), saveMethod(), and setValidMethods().


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