diff --git a/GUI/coregui/Models/JobModel.cpp b/GUI/coregui/Models/JobModel.cpp new file mode 100644 index 0000000000000000000000000000000000000000..f76bee935e3629db1020207e41bf69197cf94105 --- /dev/null +++ b/GUI/coregui/Models/JobModel.cpp @@ -0,0 +1,18 @@ +#include "JobModel.h" + +#include "Simulation.h" + +JobModel::JobModel(Simulation *p_simulation) + : mp_simulation(p_simulation) +{ +} + +JobModel::~JobModel() +{ + delete mp_simulation; +} + +void JobModel::run() +{ + mp_simulation->runSimulation(); +} diff --git a/GUI/coregui/Models/JobModel.h b/GUI/coregui/Models/JobModel.h new file mode 100644 index 0000000000000000000000000000000000000000..d2f43ceb667555f076cdb738d18749b0c9b0c15a --- /dev/null +++ b/GUI/coregui/Models/JobModel.h @@ -0,0 +1,21 @@ +#ifndef JOBMODEL_H +#define JOBMODEL_H + +#include <QThread> + +class Simulation; + +class JobModel : public QThread +{ + Q_OBJECT + +public: + JobModel(Simulation *p_simulation); + virtual ~JobModel(); + +protected: + void run(); + Simulation *mp_simulation; +}; + +#endif // JOBMODEL_H diff --git a/GUI/coregui/Views/SimulationView.cpp b/GUI/coregui/Views/SimulationView.cpp index 1ee19bab2e37b44b9b50ce95bf93253f16fefcaa..5da1ac004148931df635f9bb151d45fc08891e6e 100644 --- a/GUI/coregui/Views/SimulationView.cpp +++ b/GUI/coregui/Views/SimulationView.cpp @@ -2,6 +2,8 @@ #include "SimulationDataModel.h" #include "Simulation.h" +#include "JobModel.h" +#include "mainwindow.h" #include <QGroupBox> #include <QPushButton> @@ -104,8 +106,16 @@ void SimulationView::onRunSimulation() Simulation *p_sim = new Simulation; p_sim->setSample(*p_sample); p_sim->setInstrument(*p_instrument); - p_sim->runSimulation(); + JobModel *p_new_job = new JobModel(p_sim); + connect(p_new_job, SIGNAL(finished()), this, SLOT(onJobFinished())); + p_new_job->start(); // initialize a Simulation object and run it - QMessageBox::information(this, tr("Simulation Done"), - tr("The simulation is done calculating.")); + QMessageBox::information(this, tr("Simulation Started"), + tr("The simulation is now calculating.")); +} + +void SimulationView::onJobFinished() +{ + QMessageBox::information(this, tr("Simulation Job Finished"), + tr("A simulation job has finished.")); } diff --git a/GUI/coregui/Views/SimulationView.h b/GUI/coregui/Views/SimulationView.h index a732d07c180d65159b5fbf31b8a028cc7777f87d..b8ee17b081163d25f1ff25ab730389aace7b912b 100644 --- a/GUI/coregui/Views/SimulationView.h +++ b/GUI/coregui/Views/SimulationView.h @@ -17,6 +17,7 @@ public: public slots: void onRunSimulation(); + void onJobFinished(); private: SimulationDataModel *mp_simulation_data_model; diff --git a/GUI/coregui/coregui.pro b/GUI/coregui/coregui.pro index c0cf6c6d9f031d37f478a3d7c2df341cfd1b6ae0..c3b7ebc1d54c4d058605a9e5efbf6899ff031deb 100644 --- a/GUI/coregui/coregui.pro +++ b/GUI/coregui/coregui.pro @@ -38,7 +38,8 @@ SOURCES += \ Views/SimulationView.cpp \ Views/WelcomeView.cpp \ Views/sampleeditor.cpp \ - Views/sampleeditorstack.cpp + Views/sampleeditorstack.cpp \ + Models/JobModel.cpp HEADERS += \ mainwindow/imode.h \ @@ -57,7 +58,8 @@ HEADERS += \ Views/SimulationView.h \ Views/WelcomeView.h \ Views/sampleeditor.h \ - Views/sampleeditorstack.h + Views/sampleeditorstack.h \ + Models/JobModel.h INCLUDEPATH += $$PWD/mainwindow $$PWD/utils $$PWD/welcomemanager $$PWD/samplemanager $$PWD/experimentmanager $$PWD/simulationmanager $$PWD/fitmanager INCLUDEPATH += $$PWD/mainwindow $$PWD/utils $$PWD/Views $$PWD/Models diff --git a/GUI/coregui/mainwindow/mainwindow.cpp b/GUI/coregui/mainwindow/mainwindow.cpp index cc7355c7f55487559661d2b46af42ade792d301b..1d420254591a838c2b1e21a02a83041b2998a0a5 100644 --- a/GUI/coregui/mainwindow/mainwindow.cpp +++ b/GUI/coregui/mainwindow/mainwindow.cpp @@ -48,12 +48,12 @@ MainWindow::MainWindow(QWidget *parent) setCorner(Qt::BottomRightCorner, Qt::BottomDockWidgetArea); //m_tabWidget = new TaskSelectorWidget(this); - m_tabWidget = new Manhattan::FancyTabWidget(this); - m_welcomeView = new WelcomeManager(this); - m_instrumentView = new InstrumentView(mp_sim_data_model, this); - m_sampleView = new SampleManager(this); - m_simulationView = new SimulationView(mp_sim_data_model, this); - m_fitView = new FitManager(this); + m_tabWidget = new Manhattan::FancyTabWidget(); + m_welcomeView = new WelcomeManager(); + m_instrumentView = new InstrumentView(mp_sim_data_model); + m_sampleView = new SampleManager(); + m_simulationView = new SimulationView(mp_sim_data_model); + m_fitView = new FitManager(); m_tabWidget->insertTab(0, m_welcomeView, QIcon(":/images/mode_welcome.png"), "Welcome"); m_tabWidget->insertTab(1, m_instrumentView, QIcon(":/images/mode_exp.png"), "Instrument"); @@ -77,6 +77,7 @@ MainWindow::~MainWindow() void MainWindow::onChangeTabWidget(int index) { // update views which depend on others + (void)index; m_simulationView->updateViewElements(); }