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

#include <CQLyapResultWidget.h>

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

Public Member Functions

 CQLyapResultWidget (QWidget *parent=0, const char *name=0, Qt::WFlags fl=0)
 
virtual bool leave ()
 
virtual bool update (ListViews::ObjectType objectType, ListViews::Action action, const std::string &key)
 
 ~CQLyapResultWidget ()
 
- 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

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

Protected Member Functions

virtual bool enterProtected ()
 
bool loadFromBackend ()
 

Private Member Functions

void init ()
 

Private Attributes

CLyapTaskmpTask
 

Additional Inherited Members

- Protected Attributes inherited from CopasiWidget
int mFramework
 
bool mIgnoreUpdates
 
std::string mKey
 
CCopasiDataModelmpDataModel
 
ListViewsmpListView
 
CCopasiObjectmpObject
 

Detailed Description

Definition at line 30 of file CQLyapResultWidget.h.

Constructor & Destructor Documentation

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

Definition at line 36 of file CQLyapResultWidget.cpp.

References init().

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

Definition at line 47 of file CQLyapResultWidget.cpp.

48 {}

Member Function Documentation

bool CQLyapResultWidget::enterProtected ( )
protectedvirtual

Reimplemented from CopasiWidget.

Definition at line 155 of file CQLyapResultWidget.cpp.

References loadFromBackend().

156 {
157  return loadFromBackend();
158 }
void CQLyapResultWidget::init ( )
private

Definition at line 50 of file CQLyapResultWidget.cpp.

Referenced by CQLyapResultWidget().

51 {
52  /*
53  mSaveButton->setEnabled(false);
54  mSaveButton->hide();
55  */
56 }
bool CQLyapResultWidget::leave ( )
virtual

Reimplemented from CopasiWidget.

Definition at line 150 of file CQLyapResultWidget.cpp.

151 {
152  return true;
153 }
bool CQLyapResultWidget::loadFromBackend ( )
protected

Definition at line 60 of file CQLyapResultWidget.cpp.

References CLyapTask::averageDivergence(), C_FLOAT64, C_INT32, CLyapTask::exponents(), CCopasiRootContainer::getDatamodelList(), CLyapProblem::getExponentNumber(), CCopasiTask::getProblem(), CLyapTask::modelVariablesInResult(), mpTask, CLyapTask::numberOfExponentsCalculated(), CLyapTask::resultAvailable(), CLyapTask::resultHasDivergence(), and CLyapTask::sumOfExponents().

Referenced by enterProtected(), and update().

61 {
62  //bool success = true;
63  //std::ostringstream os;
64 
65  assert(CCopasiRootContainer::getDatamodelList()->size() > 0);
66  mpTask = dynamic_cast<CLyapTask*>((*(*CCopasiRootContainer::getDatamodelList())[0]->getTaskList())["Lyapunov Exponents"]);
67 
68  if (!mpTask) return false;
69 
70  CLyapProblem * pProblem = dynamic_cast< CLyapProblem * >(mpTask->getProblem());
71 
72  if (!pProblem) return false;
73 
74  if (!mpTask->resultAvailable())
75  {
76  mTableExponents->setEnabled(false);
77  mTableExponents->setRowCount(0);
78  mLineEditSum->setEnabled(false);
79  mLineEditSum->setText("");
80  mLineEditDivergence->setEnabled(false);
81  mLineEditDivergence->setText("");
82  mLabelComment->setText("No result available.");
83  return false;
84  }
85 
86  mTableExponents->setEnabled(true);
87  mLineEditSum->setEnabled(true);
88  mLineEditDivergence->setEnabled(true);
89 
90  unsigned C_INT32 i, imax = pProblem->getExponentNumber();
91 
92  mTableExponents->setRowCount(imax);
93 
94  for (i = 0; i < imax; ++i)
95  {
96  QTableWidgetItem *pItem = mTableExponents->item(i, 0);
97 
98  if (pItem == NULL)
99  {
100  pItem = new QTableWidgetItem(QString::number(mpTask->exponents()[i]));
101  pItem->setFlags(Qt::ItemIsDragEnabled | Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
102  mTableExponents->setItem(i, 0, pItem);
103  }
104  else
105  {
106  pItem->setText(QString::number(mpTask->exponents()[i]));
107  }
108  }
109 
110  mLineEditSum->setText(QString::number(mpTask->sumOfExponents()));
111 
113  {
114  mLineEditDivergence->setEnabled(true);
115  mLineEditDivergence->setText(QString::number(mpTask->averageDivergence()));
116  }
117  else
118  {
119  mLineEditDivergence->setEnabled(false);
120  mLineEditDivergence->setText("");
121  }
122 
123  //comment
124  mLabelComment->setText("");
125 
128  {
129  if ((mpTask->sumOfExponents() < 0.0) && (mpTask->averageDivergence() < 0.0))
130  {
132 
133  if (factor > 1.01)
134  mLabelComment->setText("Warning: Divergence differs from sum of exponents. This may indicate that the strongly negative exponents are calculated inaccuratly.");
135  }
136  }
137 
138  return true;
139 }
const C_FLOAT64 & averageDivergence() const
Definition: CLyapTask.h:135
const CVector< C_FLOAT64 > & exponents() const
Definition: CLyapTask.h:126
size_t modelVariablesInResult() const
Definition: CLyapTask.cpp:330
CCopasiProblem * getProblem()
size_t numberOfExponentsCalculated() const
Definition: CLyapTask.cpp:335
bool resultAvailable() const
Definition: CLyapTask.cpp:320
#define C_INT32
Definition: copasi.h:90
static CCopasiVector< CCopasiDataModel > * getDatamodelList()
const unsigned C_INT32 & getExponentNumber() const
const C_FLOAT64 & sumOfExponents() const
Definition: CLyapTask.h:132
#define C_FLOAT64
Definition: copasi.h:92
bool resultHasDivergence() const
Definition: CLyapTask.cpp:325
void CQLyapResultWidget::saveToFile ( )
protectedslot

Definition at line 160 of file CQLyapResultWidget.cpp.

References C_INT32, checkSelection(), CLocaleString::fromUtf8(), CopasiFileDialog::getSaveFileName(), mpTask, CLyapTask::printResult(), and TO_UTF8.

161 {
162  C_INT32 Answer = QMessageBox::No;
163  QString fileName;
164 
165  while (Answer == QMessageBox::No)
166  {
167  fileName =
168  CopasiFileDialog::getSaveFileName(this, "Save File Dialog",
169  "untitled.txt", "TEXT Files (*.txt)", "Save to");
170 
171  if (fileName.isEmpty()) return;
172 
173  // Checks whether the file exists
174  Answer = checkSelection(fileName);
175 
176  if (Answer == QMessageBox::Cancel) return;
177  }
178 
179  std::ofstream file(CLocaleString::fromUtf8(TO_UTF8(fileName)).c_str());
180 
181  if (file.fail())
182  return;
183 
184  if (mpTask != NULL)
185  mpTask->printResult(&file);
186 
187  return;
188 }
#define C_INT32
Definition: copasi.h:90
C_INT32 checkSelection(const QString &file)
void printResult(std::ostream *ostream) const
Definition: CLyapTask.cpp:292
#define TO_UTF8(__x)
Definition: qtUtilities.h:74
static CLocaleString fromUtf8(const std::string &utf8)
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)
bool CQLyapResultWidget::update ( ListViews::ObjectType  objectType,
ListViews::Action  action,
const std::string &  key 
)
virtual

Reimplemented from CopasiWidget.

Definition at line 141 of file CQLyapResultWidget.cpp.

References loadFromBackend().

143 {
144  if (this->isVisible())
145  return loadFromBackend();
146  else
147  return true;
148 }

Member Data Documentation

CLyapTask* CQLyapResultWidget::mpTask
private

Definition at line 52 of file CQLyapResultWidget.h.

Referenced by loadFromBackend(), and saveToFile().


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