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

#include <CQSteadyStateResult.h>

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

Public Member Functions

 CQSteadyStateResult (QWidget *parent=0, const char *name=0)
 
virtual bool leave ()
 
void loadResult ()
 
virtual bool update (ListViews::ObjectType objectType, ListViews::Action action, const std::string &key)
 
 ~CQSteadyStateResult ()
 
- 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 Member Functions

virtual bool enterProtected ()
 

Private Slots

void slotSave (void)
 
void slotUpdateModel ()
 

Private Member Functions

void init ()
 

Private Attributes

const CSteadyStateProblemmpProblem
 
CSteadyStateTaskmpTask
 
bool mUpToDate
 

Additional Inherited Members

- Protected Slots inherited from CopasiWidget
virtual bool protectedNotify (ListViews::ObjectType objectType, ListViews::Action action, const std::string &key="")
 
- Protected Attributes inherited from CopasiWidget
int mFramework
 
bool mIgnoreUpdates
 
std::string mKey
 
CCopasiDataModelmpDataModel
 
ListViewsmpListView
 
CCopasiObjectmpObject
 

Detailed Description

Definition at line 16 of file CQSteadyStateResult.h.

Constructor & Destructor Documentation

CQSteadyStateResult::CQSteadyStateResult ( QWidget *  parent = 0,
const char *  name = 0 
)

Definition at line 31 of file CQSteadyStateResult.cpp.

References init().

32  : CopasiWidget(parent, name)
33 {
34  setupUi(this);
35 
36  init();
37 }
CopasiWidget(QWidget *parent=0, const char *name=0, Qt::WFlags f=0)
CQSteadyStateResult::~CQSteadyStateResult ( )

Definition at line 42 of file CQSteadyStateResult.cpp.

43 {
44  // no need to delete child widgets, Qt does it all for us
45 }

Member Function Documentation

bool CQSteadyStateResult::enterProtected ( )
protectedvirtual

Reimplemented from CopasiWidget.

Definition at line 69 of file CQSteadyStateResult.cpp.

70 {
71  return true;
72 }
void CQSteadyStateResult::init ( )
private

Definition at line 47 of file CQSteadyStateResult.cpp.

References mpProblem, mpTask, and mUpToDate.

Referenced by CQSteadyStateResult().

48 {
49  mpProblem = NULL;
50  mpTask = NULL;
51  mUpToDate = false;
52 }
const CSteadyStateProblem * mpProblem
CSteadyStateTask * mpTask
bool CQSteadyStateResult::leave ( )
virtual

Reimplemented from CopasiWidget.

Definition at line 64 of file CQSteadyStateResult.cpp.

65 {
66  return true;
67 }
void CQSteadyStateResult::loadResult ( )

Definition at line 74 of file CQSteadyStateResult.cpp.

References CCopasiParameterGroup::clear(), CCopasiRootContainer::getDatamodelList(), CCopasiTask::getProblem(), CSteadyStateTask::getState(), mpProblem, mpTask, and mUpToDate.

Referenced by SteadyStateWidget::taskFinishedEvent().

75 {
76  assert(CCopasiRootContainer::getDatamodelList()->size() > 0);
77  mpTask =
78  dynamic_cast<CSteadyStateTask *>((*(*CCopasiRootContainer::getDatamodelList())[0]->getTaskList())["Steady-State"]);
79 
80  if (!mpTask) return;
81 
82  mpProblem = dynamic_cast<const CSteadyStateProblem *>(mpTask->getProblem());
83 
84  if (!mpProblem) return;
85 
86  if (!mpTask) return;
87 
88  if (!mpTask->getState())
89  {
90  mpCentralWidget->clear();
91  mUpToDate = false;
92  return;
93  }
94 
95  mpCentralWidget->loadAll(mpTask);
96  mUpToDate = true;
97 
98  return;
99 }
CCopasiProblem * getProblem()
const CState * getState() const
static CCopasiVector< CCopasiDataModel > * getDatamodelList()
const CSteadyStateProblem * mpProblem
CSteadyStateTask * mpTask
void CQSteadyStateResult::slotSave ( void  )
privateslot

Definition at line 102 of file CQSteadyStateResult.cpp.

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

103 {
104  C_INT32 Answer = QMessageBox::No;
105  QString fileName;
106 
107  while (Answer == QMessageBox::No)
108  {
109  fileName =
110  CopasiFileDialog::getSaveFileName(this, "Save File Dialog",
111  "untitled.txt", "TEXT Files (*.txt)", "Save to");
112 
113  if (fileName.isEmpty()) return;
114 
115  // Checks whether the file exists
116  Answer = checkSelection(fileName);
117 
118  if (Answer == QMessageBox::Cancel) return;
119  }
120 
121  std::ofstream file(CLocaleString::fromUtf8(TO_UTF8(fileName)).c_str());
122 
123  if (file.fail()) return;
124 
125  if (mpTask != NULL)
126  file << *mpTask;
127 
128  return;
129 }
#define C_INT32
Definition: copasi.h:90
C_INT32 checkSelection(const QString &file)
#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)
CSteadyStateTask * mpTask
void CQSteadyStateResult::slotUpdateModel ( )
privateslot

Definition at line 131 of file CQSteadyStateResult.cpp.

References ListViews::CHANGE, CModel::compileIfNecessary(), CModel::getKey(), CCopasiProblem::getModel(), CSteadyStateTask::getState(), CCopasiTask::isUpdateModel(), mpProblem, mpTask, mUpToDate, CopasiWidget::protectedNotify(), CSteadyStateTask::restore(), CCopasiTask::setUpdateModel(), and ListViews::STATE.

132 {
133  if (mUpToDate &&
134  mpTask != NULL &&
135  mpProblem != NULL &&
136  mpTask->getState() != NULL)
137  {
138  CModel *pModel = mpProblem->getModel();
139 
140  if (pModel != NULL)
141  {
142  pModel->compileIfNecessary(NULL);
143 
144  if (mpTask->isUpdateModel())
145  {
146  mpTask->restore();
147  }
148  else
149  {
150  mpTask->setUpdateModel(true);
151  mpTask->restore();
152  mpTask->setUpdateModel(false);
153  }
154 
156  }
157  }
158 }
const bool & isUpdateModel() const
const CState * getState() const
const std::string & getKey() const
Definition: CModel.cpp:1142
virtual bool protectedNotify(ListViews::ObjectType objectType, ListViews::Action action, const std::string &key="")
bool compileIfNecessary(CProcessReport *pProcessReport)
Definition: CModel.cpp:612
Definition: CModel.h:50
const CSteadyStateProblem * mpProblem
void setUpdateModel(const bool &updateModel)
virtual bool restore()
CModel * getModel() const
CSteadyStateTask * mpTask
bool CQSteadyStateResult::update ( ListViews::ObjectType  objectType,
ListViews::Action  action,
const std::string &  key 
)
virtual

Reimplemented from CopasiWidget.

Definition at line 54 of file CQSteadyStateResult.cpp.

References mUpToDate, and ListViews::STATE.

57 {
59  mUpToDate = false;
60 
61  return true;
62 }
objectType

Member Data Documentation

const CSteadyStateProblem* CQSteadyStateResult::mpProblem
private

Definition at line 35 of file CQSteadyStateResult.h.

Referenced by init(), loadResult(), and slotUpdateModel().

CSteadyStateTask* CQSteadyStateResult::mpTask
private

Definition at line 36 of file CQSteadyStateResult.h.

Referenced by init(), loadResult(), slotSave(), and slotUpdateModel().

bool CQSteadyStateResult::mUpToDate
private

Definition at line 37 of file CQSteadyStateResult.h.

Referenced by init(), loadResult(), slotUpdateModel(), and update().


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