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

#include <CQTSSAResultSubWidget.h>

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

Public Slots

void changeInterval ()
 

Public Member Functions

 CQTSSAResultSubWidget (QWidget *parent=0, const char *name=0, Qt::WindowFlags fl=0)
 
void discardOldResults ()
 
void displayResult ()
 
 ~CQTSSAResultSubWidget ()
 
- 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 bool leave ()
 
virtual void setFramework (int framework)
 
void setIgnoreUpdates (bool v)
 
virtual bool update (ListViews::ObjectType objectType, ListViews::Action action, const std::string &key)
 

Public Attributes

bool mAnnot
 
C_INT mpIndex
 
CTSSAMethodpMethod
 
CModelpModel
 
CTSSAProblempProblem
 
CTSSATaskpTSSATask
 

Protected Slots

void changeContents ()
 
virtual void init ()
 
void saveDataToFile ()
 
void slotTableChanged ()
 
void slotTimeAndStepChanged ()
 
- Protected Slots inherited from CopasiWidget
virtual bool protectedNotify (ListViews::ObjectType objectType, ListViews::Action action, const std::string &key="")
 

Additional Inherited Members

- Protected Member Functions inherited from CopasiWidget
virtual bool enterProtected ()
 
- Protected Attributes inherited from CopasiWidget
int mFramework
 
bool mIgnoreUpdates
 
std::string mKey
 
CCopasiDataModelmpDataModel
 
ListViewsmpListView
 
CCopasiObjectmpObject
 

Detailed Description

Definition at line 26 of file CQTSSAResultSubWidget.h.

Constructor & Destructor Documentation

CQTSSAResultSubWidget::CQTSSAResultSubWidget ( QWidget *  parent = 0,
const char *  name = 0,
Qt::WindowFlags  fl = 0 
)

Definition at line 34 of file CQTSSAResultSubWidget.cpp.

References init().

35  : CopasiWidget(parent, name, fl)
36 {
37  setupUi(this);
38 
39  init();
40 }
CopasiWidget(QWidget *parent=0, const char *name=0, Qt::WFlags f=0)
bool fl(const C_FLOAT64 &d1, const C_FLOAT64 &d2)
CQTSSAResultSubWidget::~CQTSSAResultSubWidget ( )

Definition at line 45 of file CQTSSAResultSubWidget.cpp.

46 {
47  // no need to delete child widgets, Qt does it all for us
48 }

Member Function Documentation

void CQTSSAResultSubWidget::changeContents ( )
protectedslot

Definition at line 148 of file CQTSSAResultSubWidget.cpp.

References mpIndex.

Referenced by init().

149 {
150 
151  if (mpIndex == 0)
152  {
153 
154  mpTimeScaleWidget->show();
155  mpArrayWidget->hide();
156  mpBox1->hide();
157  mpButton->setText("Show Tables");
158  mpIndex = 1;
159 
160  }
161  else
162  {
163  mpTimeScaleWidget->hide();
164  mpBox1->show();
165  mpArrayWidget->show();
166  mpButton->setText("Show Time scales");
167  mpIndex = 0;
168  }
169 }
void CQTSSAResultSubWidget::changeInterval ( )
slot

Get the results for the requested step from the method. Fill widgets with this results.

Definition at line 263 of file CQTSSAResultSubWidget.cpp.

References CTSSAMethod::getTable(), CTSSAMethod::getVec_TimeScale(), pMethod, CTSSAMethod::setAnnotationM(), and slotTimeAndStepChanged().

Referenced by displayResult(), and init().

264 {
265 
267 
268  int s = mpSlider->value();
269 
270  if (pMethod->setAnnotationM(s - 1))
271  {
272  std::string name = static_cast<std::string >(mpBox1->currentText().toUtf8());
273  pResult = pMethod->getTable(name);
274 
275  mpArrayWidget->setArrayAnnotation(pResult);
276 
278  mpTimeScaleWidget->paintTimeScale(vec);
279  }
280  else
281  {
282 
283  //mpSlider->setDisabled(true);
284  mpArrayWidget->setArrayAnnotation(NULL);
285  mpTimeScaleWidget->clearWidget();
286 
287  }
288 }
const CArrayAnnotation * getTable(std::string name)
Definition: CTSSAMethod.h:103
virtual bool setAnnotationM(size_t s)=0
CVector< C_FLOAT64 > getVec_TimeScale(int step)
const CArrayAnnotation * pResult
void CQTSSAResultSubWidget::discardOldResults ( )

Clear ArrayAnnotation-widgets.

Definition at line 251 of file CQTSSAResultSubWidget.cpp.

Referenced by CQTSSAResultWidget::enterProtected(), and CQTSSAWidget::taskFinishedEvent().

252 {
253  mpArrayWidget->setArrayAnnotation(NULL);
254  mpArrayWidget->clearWidget();
255  mpTimeScaleWidget->clearWidget();
256 }
void CQTSSAResultSubWidget::displayResult ( )

Definition at line 211 of file CQTSSAResultSubWidget.cpp.

References C_INT, changeInterval(), FROM_UTF8, CCopasiRootContainer::getDatamodelList(), CCopasiTask::getMethod(), CCopasiProblem::getModel(), CCopasiTask::getProblem(), CTSSAProblem::getStepNumber(), CTSSAMethod::getTableName(), CModel::getTimeUnitName(), pMethod, pModel, pProblem, and pTSSATask.

Referenced by CQTSSAWidget::taskFinishedEvent().

212 {
213 
214  assert(CCopasiRootContainer::getDatamodelList()->size() > 0);
215  pTSSATask =
216  dynamic_cast<CTSSATask *>((*(*CCopasiRootContainer::getDatamodelList())[0]->getTaskList())["Time Scale Separation Analysis"]);
217 
218  if (!pTSSATask) return;
219 
220  pProblem = dynamic_cast<CTSSAProblem*>(pTSSATask->getProblem());
221 
222  pModel = pProblem->getModel();
223 
224  pMethod = dynamic_cast<CTSSAMethod*>(pTSSATask->getMethod());
225 
226  QString a = FROM_UTF8(pModel->getTimeUnitName());
227 
228  mpSlider->setRange(1, pProblem->getStepNumber());
229 
230  mpSlider->setValue(mpSlider->minimum());
231 
232 
233  mpBox1->clear();
234 
235  unsigned C_INT i;
236 
237  for (i = 0; i < pMethod->getTableName().size(); i++)
238  {
239  mpBox1->insertItem(0, FROM_UTF8(pMethod->getTableName()[i]));
240  }
241 
242  mpArrayWidget->switchToTable();
243  mpSlider->setDisabled(false);
244 
245  changeInterval();
246 }
#define C_INT
Definition: copasi.h:115
#define FROM_UTF8(__x)
Definition: qtUtilities.h:73
CCopasiProblem * getProblem()
std::string getTimeUnitName() const
Definition: CModel.cpp:2238
const std::vector< std::string > getTableName() const
Definition: CTSSAMethod.h:100
const unsigned C_INT32 & getStepNumber() const
static CCopasiVector< CCopasiDataModel > * getDatamodelList()
CCopasiMethod * getMethod()
CModel * getModel() const
void CQTSSAResultSubWidget::init ( )
protectedvirtualslot

Definition at line 171 of file CQTSSAResultSubWidget.cpp.

References changeContents(), changeInterval(), CCopasiRootContainer::getDatamodelList(), CCopasiTask::getMethod(), CCopasiProblem::getModel(), CCopasiTask::getProblem(), mpIndex, pMethod, pModel, pProblem, pTSSATask, saveDataToFile(), CColorScaleAdvanced::setColorMax(), CColorScaleAdvanced::setColorMin(), and slotTableChanged().

Referenced by CQTSSAResultSubWidget().

172 {
173  assert(CCopasiRootContainer::getDatamodelList()->size() > 0);
174  pTSSATask =
175  dynamic_cast<CTSSATask *>((*(*CCopasiRootContainer::getDatamodelList())[0]->getTaskList())["Time Scale Separation Analysis"]);
176 
177  if (!pTSSATask) return;
178 
179  pProblem = dynamic_cast<CTSSAProblem*>(pTSSATask->getProblem());
180  pModel = pProblem->getModel();
181 
182  pMethod = dynamic_cast<CTSSAMethod*>(pTSSATask->getMethod());
183 
184  mpLabelTime->setNum(0);
185  mpLabelStep->setNum(0);
186 
187  connect(mpBox1, SIGNAL(currentIndexChanged(int)), this, SLOT(slotTableChanged(/* int */)));
188 
189  //set colorsettings for ArrayAnnotationWidgets
190 
192  tcs->setColorMin(QColor(240, 240, 240));
193  tcs->setColorMax(QColor(0, 255, 0));
194  mpArrayWidget->setColorCoding(tcs);
195  mpArrayWidget->setColorScalingAutomatic(true);
196 
197 
198  connect(mpSlider, SIGNAL(valueChanged(int)), this, SLOT(changeInterval()));
199  connect(mpButton, SIGNAL(clicked()), this, SLOT(changeContents()));
200  connect(ButtonSaveData, SIGNAL(clicked()), this, SLOT(saveDataToFile()));
201 
202  mpBox1->setEditable(false);
203 
204  mpIndex = 0;
205  mpTimeScaleWidget->hide();
206  mpBox1->show();
207  mpArrayWidget->show();
208 
209 }
CCopasiProblem * getProblem()
void setColorMax(QColor col)
static CCopasiVector< CCopasiDataModel > * getDatamodelList()
void setColorMin(QColor col)
CCopasiMethod * getMethod()
CModel * getModel() const
void CQTSSAResultSubWidget::saveDataToFile ( )
protectedslot

Definition at line 50 of file CQTSSAResultSubWidget.cpp.

References C_INT32, checkSelection(), CLocaleString::fromUtf8(), CCopasiRootContainer::getDatamodelList(), CCopasiTask::getProblem(), CopasiFileDialog::getSaveFileName(), CCopasiProblem::printResult(), and TO_UTF8.

Referenced by init().

51 {
52  C_INT32 Answer = QMessageBox::No;
53  QString fileName;
54 
55  while (Answer == QMessageBox::No)
56  {
57  fileName =
58  CopasiFileDialog::getSaveFileName(this, "Save File Dialog",
59  "untitled.txt", "Text Files (*.txt)", "Save to");
60 
61  if (fileName.isEmpty()) return;
62 
63  // Checks whether the file exists
64  Answer = checkSelection(fileName);
65 
66  if (Answer == QMessageBox::Cancel) return;
67  }
68 
69  std::ofstream file(CLocaleString::fromUtf8(TO_UTF8(fileName)).c_str());
70 
71  if (file.fail()) return;
72 
73  assert(CCopasiRootContainer::getDatamodelList()->size() > 0);
74  CCopasiTask* mpTask =
75  dynamic_cast<CTSSATask *>((*(*CCopasiRootContainer::getDatamodelList())[0]->getTaskList())["Time Scale Separation Analysis"]);
76 
77  if (!mpTask) return;
78 
79  CCopasiProblem* mpProblem = mpTask->getProblem();
80 
81  mpProblem->printResult(&file);
82 
83 
84  return;
85 }
CCopasiProblem * getProblem()
#define C_INT32
Definition: copasi.h:90
C_INT32 checkSelection(const QString &file)
static CCopasiVector< CCopasiDataModel > * getDatamodelList()
#define TO_UTF8(__x)
Definition: qtUtilities.h:74
static CLocaleString fromUtf8(const std::string &utf8)
virtual void printResult(std::ostream *ostream) const
static QString getSaveFileName(QWidget *parent=0, const char *name=0, const QString &startWith=QString::null, const QString &filter=QString::null, const QString &caption=QString::null, QString *pSelectedFilter=NULL, QFileDialog::Options options=0)
void CQTSSAResultSubWidget::slotTableChanged ( )
protectedslot

Definition at line 88 of file CQTSSAResultSubWidget.cpp.

References CTSSAMethod::getTable(), pMethod, and CColorScaleSimple::setSymmetric().

Referenced by init().

89 {
90 
91  std::string name = static_cast<std::string >(mpBox1->currentText().toUtf8());
92 
93 
94  if (name == "Reactions slow space" ||
95  name == "Reactions contribution to the mode" ||
96  name == "Reactions distribution between modes " ||
97  name == "Reactions fast space" ||
98  name == "Participation Index" ||
99  name == "Fast Participation Index" ||
100  name == "Slow Participation Index" ||
101  name == "Normed Participation Index (by column)" ||
102  name == "Normed Participation Index (by row)" ||
103  name == "Importance Index" ||
104  name == "Normed Importance Index (by row)")
105  {
107  tcs->setSymmetric(true);
108  mpArrayWidget->setColorCoding(tcs);
109  mpArrayWidget->setColorScalingAutomatic(true);
110  }
111  else
112  {
113  //CColorScaleAdvanced * tcs = new CColorScaleAdvanced() ;
114  //tcs->setColorMin(QColor(240, 240, 240));
115  //tcs->setColorMax(QColor(0, 255, 0));
116 
118  tcs->setSymmetric(true);
119 
120  mpArrayWidget->setColorCoding(tcs);
121  mpArrayWidget->setColorScalingAutomatic(true);
122 
123  }
124 
125 
126  pResult = pMethod->getTable(name);
127  mpArrayWidget->setArrayAnnotation(pResult);
128 
129 
130 }
void setSymmetric(bool s)
Definition: CColorScale.h:120
const CArrayAnnotation * getTable(std::string name)
Definition: CTSSAMethod.h:103
const CArrayAnnotation * pResult
void CQTSSAResultSubWidget::slotTimeAndStepChanged ( )
protectedslot

Definition at line 134 of file CQTSSAResultSubWidget.cpp.

References pMethod, and CTSSAMethod::returnCurrentTime().

Referenced by changeInterval().

135 {
136 
137  int s = mpSlider->value();
138 
139  if (s > 1)
140  mpLabelTime->setNum((double)pMethod->returnCurrentTime(s - 1));
141  else
142  mpLabelTime->setNum(0);
143 
144  mpLabelStep->setNum(s);
145 }
C_FLOAT64 returnCurrentTime(int step)

Member Data Documentation

bool CQTSSAResultSubWidget::mAnnot

Definition at line 40 of file CQTSSAResultSubWidget.h.

C_INT CQTSSAResultSubWidget::mpIndex

Definition at line 39 of file CQTSSAResultSubWidget.h.

Referenced by changeContents(), and init().

CTSSAMethod* CQTSSAResultSubWidget::pMethod
CModel* CQTSSAResultSubWidget::pModel

Definition at line 38 of file CQTSSAResultSubWidget.h.

Referenced by displayResult(), and init().

CTSSAProblem* CQTSSAResultSubWidget::pProblem

Definition at line 35 of file CQTSSAResultSubWidget.h.

Referenced by displayResult(), and init().

CTSSATask* CQTSSAResultSubWidget::pTSSATask

Definition at line 34 of file CQTSSAResultSubWidget.h.

Referenced by displayResult(), and init().


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