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

#include <worker.h>

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

Public Slots

void finishedLoading (bool success)
 
bool slotNotify (ListViews::ObjectType objectType, ListViews::Action action, std::string key="")
 

Public Member Functions

 Worker (CopasiUI3Window *window, Arguments *args)
 

Static Public Member Functions

static int getIndexForTask (CCopasiTask *task)
 

Private Member Functions

TaskWidgetgetWidgetForTask (CCopasiTask *task) const
 

Static Private Member Functions

static int getIndexForWidget (TaskWidget *widget)
 

Private Attributes

ArgumentsmpArgs
 
DataModelGUImpDataModel
 
CopasiUI3WindowmpWindow
 
bool mTaskStarted
 

Detailed Description

Definition at line 18 of file worker.h.

Constructor & Destructor Documentation

Worker::Worker ( CopasiUI3Window window,
Arguments args 
)

Definition at line 25 of file worker.cpp.

References finishedLoading(), CopasiUI3Window::getDataModel(), Arguments::getFilename(), mpArgs, mpDataModel, mpWindow, CopasiUI3Window::openInitialDocument(), and slotNotify().

25  : mTaskStarted(false)
26 {
27  mpArgs = args;
28  mpWindow = window;
30 
31  // open the newly generated model
32  mpWindow->openInitialDocument(QString((args->getFilename() + ".view.cps").c_str()));
33 
34  // connect the finish slot, so it will switch to the correct tab
35  connect(mpDataModel, SIGNAL(finished(bool)), this, SLOT(finishedLoading(bool)));
36  connect(mpDataModel, SIGNAL(notifyView(ListViews::ObjectType, ListViews::Action, std::string)),
37  this, SLOT(slotNotify(ListViews::ObjectType, ListViews::Action, std::string)));
38 }
bool slotNotify(ListViews::ObjectType objectType, ListViews::Action action, std::string key="")
Definition: worker.cpp:40
CopasiUI3Window * mpWindow
Definition: worker.h:40
bool mTaskStarted
Definition: worker.h:46
void finishedLoading(bool success)
Definition: worker.cpp:169
Arguments * mpArgs
Definition: worker.h:44
void openInitialDocument(const QString &file)
const std::string & getFilename() const
Definition: arguments.cpp:255
DataModelGUI * getDataModel()
DataModelGUI * mpDataModel
Definition: worker.h:42

Member Function Documentation

void Worker::finishedLoading ( bool  success)
slot

Definition at line 169 of file worker.cpp.

References Arguments::getFirstScheduledTask(), getIndexForTask(), CopasiUI3Window::getMainWidget(), Arguments::getTaskToSwitchTo(), getWidgetForTask(), Arguments::isHideWindow(), Arguments::isRunScheduled(), Arguments::isSwitchToTask(), mpArgs, mpWindow, mTaskStarted, TaskWidget::runTask(), and ListViews::switchToOtherWidget().

Referenced by Worker().

170 {
171 
172  if (!success)
173  return;
174 
175  if (mpArgs->isSwitchToTask())
176  {
178  }
179 
180  if (mpArgs->isRunScheduled())
181  {
183 
184  if (task == NULL)
185  return;
186 
187  if (!mpArgs->isSwitchToTask())
188  mpWindow ->getMainWidget()->switchToOtherWidget(getIndexForTask(task), "");
189 
190  TaskWidget *widget = getWidgetForTask(task);
191  mTaskStarted = true;
192  widget->runTask();
193  }
194 
195  if (mpArgs->isHideWindow())
196  mpWindow->hide();
197 }
CopasiUI3Window * mpWindow
Definition: worker.h:40
bool mTaskStarted
Definition: worker.h:46
void switchToOtherWidget(const size_t &id, const std::string &key)
Definition: listviews.cpp:926
bool isHideWindow() const
Definition: arguments.cpp:305
Arguments * mpArgs
Definition: worker.h:44
static CCopasiTask * getFirstScheduledTask()
Definition: arguments.cpp:53
TaskWidget * getWidgetForTask(CCopasiTask *task) const
Definition: worker.cpp:79
bool isSwitchToTask() const
Definition: arguments.cpp:237
int getTaskToSwitchTo() const
Definition: arguments.cpp:242
ListViews * getMainWidget()
static int getIndexForTask(CCopasiTask *task)
Definition: worker.cpp:121
bool isRunScheduled() const
Definition: arguments.cpp:270
virtual bool runTask()=0
int Worker::getIndexForTask ( CCopasiTask task)
static

Definition at line 121 of file worker.cpp.

References CCopasiTask::crosssection, CCopasiTask::fluxMode, CCopasiTask::getType(), CCopasiTask::lna, CCopasiTask::lyap, CCopasiTask::mca, CCopasiTask::moieties, CCopasiTask::optimization, CCopasiTask::parameterFitting, CCopasiTask::scan, CCopasiTask::sens, CCopasiTask::steadyState, CCopasiTask::timeCourse, CCopasiTask::tssAnalysis, and CCopasiTask::unset.

Referenced by finishedLoading(), and getIndexForWidget().

122 {
123  if (task == NULL) return -1;
124 
125  switch (task->getType())
126  {
128  return 21;
129 
131  return 23;
132 
133  case CCopasiTask::scan:
134  return 31;
135 
137  return 32;
138 
140  return 33;
141 
142  case CCopasiTask::mca:
143  return 24;
144 
145  case CCopasiTask::lna:
146  return 35;
147 
148  case CCopasiTask::lyap:
151  case CCopasiTask::sens:
154  case CCopasiTask::unset:
155  default:
156  // have no id
157  return -1;
158  }
159 }
Type getType() const
int Worker::getIndexForWidget ( TaskWidget widget)
staticprivate

Definition at line 161 of file worker.cpp.

References getIndexForTask(), and TaskWidget::getTask().

162 {
163  if (widget == NULL) return -1;
164 
165  CCopasiTask *task = widget->getTask();
166  return getIndexForTask(task);
167 }
CCopasiTask * getTask()
Definition: TaskWidget.cpp:513
static int getIndexForTask(CCopasiTask *task)
Definition: worker.cpp:121
TaskWidget * Worker::getWidgetForTask ( CCopasiTask task) const
private

Definition at line 79 of file worker.cpp.

References CCopasiTask::crosssection, CCopasiTask::fluxMode, ListViews::getFittingWidget(), ListViews::getLNAWidget(), CopasiUI3Window::getMainWidget(), ListViews::getMCAWidget(), ListViews::getOptimizationWidget(), ListViews::getScanWidget(), ListViews::getSteadyStateWidget(), ListViews::getTrajectoryWidget(), CCopasiTask::getType(), CCopasiTask::lna, CCopasiTask::lyap, CCopasiTask::mca, CCopasiTask::moieties, mpWindow, CCopasiTask::optimization, CCopasiTask::parameterFitting, CCopasiTask::scan, CCopasiTask::sens, CCopasiTask::steadyState, CCopasiTask::timeCourse, CCopasiTask::tssAnalysis, and CCopasiTask::unset.

Referenced by finishedLoading().

80 {
81  if (task == NULL) return NULL;
82 
83  ListViews* views = mpWindow->getMainWidget();
84 
85  switch (task->getType())
86  {
88  return reinterpret_cast<TaskWidget*>(views->getSteadyStateWidget());
89 
91  return reinterpret_cast<TaskWidget*>(views->getTrajectoryWidget());
92 
93  case CCopasiTask::scan:
94  return reinterpret_cast<TaskWidget*>(views->getScanWidget());
95 
97  return reinterpret_cast<TaskWidget*>(views->getOptimizationWidget());
98 
100  return reinterpret_cast<TaskWidget*>(views->getFittingWidget());
101 
102  case CCopasiTask::mca:
103  return reinterpret_cast<TaskWidget*>(views->getMCAWidget());
104 
105  case CCopasiTask::lna:
106  return reinterpret_cast<TaskWidget*>(views->getLNAWidget());
107 
108  case CCopasiTask::lyap:
111  case CCopasiTask::sens:
114  case CCopasiTask::unset:
115  default:
116  // have no widget for these
117  return NULL;
118  }
119 }
SteadyStateWidget * getSteadyStateWidget()
Definition: listviews.cpp:1054
CopasiUI3Window * mpWindow
Definition: worker.h:40
CQLNAWidget * getLNAWidget()
Definition: listviews.cpp:1069
CQFittingWidget * getFittingWidget()
Definition: listviews.cpp:1074
CQMCAWidget * getMCAWidget()
Definition: listviews.cpp:1064
CQTrajectoryWidget * getTrajectoryWidget()
Definition: listviews.cpp:1049
ListViews * getMainWidget()
Type getType() const
CQOptimizationWidget * getOptimizationWidget()
Definition: listviews.cpp:1079
ScanWidget * getScanWidget()
Definition: listviews.cpp:1059
bool Worker::slotNotify ( ListViews::ObjectType  objectType,
ListViews::Action  action,
std::string  key = "" 
)
slot

Definition at line 40 of file worker.cpp.

References ListViews::CHANGE, Arguments::getFileType(), Arguments::getOutputDir(), CopasiUI3Window::getWindows(), Arguments::haveOutputDir(), Arguments::isQuitAfterTaskExecution(), mpArgs, mpWindow, mTaskStarted, CWindowInterface::saveToFile(), and ListViews::STATE.

Referenced by Worker().

41 {
42 
44  {
45  mTaskStarted = false;
46 
47  if (mpArgs->haveOutputDir())
48  {
49  const QList< QPointer<QMainWindow> >& windows = mpWindow->getWindows();
50 
51  for (int index = 0; index < windows.count(); ++index)
52  {
53  const QMainWindow* mainWindow = windows[index];
54 
55  if (mainWindow == NULL) continue;
56 
57  const CWindowInterface* window = dynamic_cast<const CWindowInterface*>(mainWindow);
58 
59  if (window == NULL) continue;
60 
61  QString fileName = QString("%1/plot%2.%3")
62  .arg(mpArgs->getOutputDir().c_str())
63  .arg(index + 1)
64  .arg(mpArgs->getFileType().c_str());
65  window->saveToFile(fileName);
66  }
67  }
68 
70  {
71  // quit
72  qApp->quit();
73  }
74  }
75 
76  return true;
77 }
bool haveOutputDir() const
Definition: arguments.cpp:101
const QList< QPointer< QMainWindow > > & getWindows() const
CopasiUI3Window * mpWindow
Definition: worker.h:40
bool mTaskStarted
Definition: worker.h:46
virtual void saveToFile(const QString &fileName) const
objectType
Arguments * mpArgs
Definition: worker.h:44
bool isQuitAfterTaskExecution() const
Definition: arguments.cpp:310
const std::string & getOutputDir() const
Definition: arguments.cpp:106
const std::string & getFileType() const
Definition: arguments.cpp:260

Member Data Documentation

Arguments* Worker::mpArgs
private

Definition at line 44 of file worker.h.

Referenced by finishedLoading(), slotNotify(), and Worker().

DataModelGUI* Worker::mpDataModel
private

Definition at line 42 of file worker.h.

Referenced by Worker().

CopasiUI3Window* Worker::mpWindow
private

Definition at line 40 of file worker.h.

Referenced by finishedLoading(), getWidgetForTask(), slotNotify(), and Worker().

bool Worker::mTaskStarted
private

Definition at line 46 of file worker.h.

Referenced by finishedLoading(), and slotNotify().


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