diff --git a/GUI/coregui/Models/ApplicationModels.cpp b/GUI/coregui/Models/ApplicationModels.cpp index 277732a59d6c3558adeb814bb359f261a23d64f9..3879c1bea95e89fae896156c6052d7b67f7de537 100644 --- a/GUI/coregui/Models/ApplicationModels.cpp +++ b/GUI/coregui/Models/ApplicationModels.cpp @@ -27,7 +27,7 @@ ApplicationModels::ApplicationModels(QObject *parent) : QObject(parent) , m_materialModel(0) - , m_materialEditor(0) + , m_materialSvc(0) , m_instrumentModel(0) , m_sampleModel(0) , m_jobModel(0) @@ -35,12 +35,36 @@ ApplicationModels::ApplicationModels(QObject *parent) { createModels(); testGUIObjectBuilder(); - } ApplicationModels::~ApplicationModels() { - delete m_materialEditor; + delete m_materialSvc; +} + +MaterialModel *ApplicationModels::materialModel() +{ + return m_materialModel; +} + +InstrumentModel *ApplicationModels::instrumentModel() +{ + return m_instrumentModel; +} + +SampleModel *ApplicationModels::sampleModel() +{ + return m_sampleModel; +} + +JobModel *ApplicationModels::jobModel() +{ + return m_jobModel; +} + +FitModel *ApplicationModels::fitModel() +{ + return m_fitModel; } //! creates and initializes models @@ -94,11 +118,7 @@ void ApplicationModels::createMaterialModel() { delete m_materialModel; m_materialModel = new MaterialModel(this); -// m_materialModel->addMaterial("Default", 1e-3, 1e-5); -// m_materialModel->addMaterial("Air", 0.0, 0.0); -// m_materialModel->addMaterial("Particle", 6e-4, 2e-8); -// m_materialModel->addMaterial("Substrate", 6e-6, 2e-8); - m_materialEditor = new MaterialSvc(m_materialModel); + m_materialSvc = new MaterialSvc(m_materialModel); } void ApplicationModels::createSampleModel() diff --git a/GUI/coregui/Models/ApplicationModels.h b/GUI/coregui/Models/ApplicationModels.h index db8052970017429407e046e371c9ea1907b2eb36..55ee0ca5f75c2e3416b7159721f1d332176c8d05 100644 --- a/GUI/coregui/Models/ApplicationModels.h +++ b/GUI/coregui/Models/ApplicationModels.h @@ -34,11 +34,11 @@ public: ApplicationModels(QObject *parent); ~ApplicationModels(); - MaterialModel *materialModel() { return m_materialModel; } - InstrumentModel *instrumentModel() { return m_instrumentModel; } - SampleModel *sampleModel() { return m_sampleModel; } - JobModel *jobModel() { return m_jobModel; } - FitModel *fitModel() { return m_fitModel; } + MaterialModel *materialModel(); + InstrumentModel *instrumentModel(); + SampleModel *sampleModel(); + JobModel *jobModel(); + FitModel *fitModel(); void resetModels(); @@ -52,13 +52,11 @@ private: void testGUIObjectBuilder(); MaterialModel *m_materialModel; - MaterialSvc *m_materialEditor; + MaterialSvc *m_materialSvc; InstrumentModel *m_instrumentModel; SampleModel *m_sampleModel; JobModel *m_jobModel; FitModel *m_fitModel; }; - - #endif diff --git a/GUI/coregui/Views/TestView.cpp b/GUI/coregui/Views/TestView.cpp index 3c69bc78f2824b6921226bbda024cf17b75efb5c..dca102dfc74a551d719739666f5cf1bf589b416c 100644 --- a/GUI/coregui/Views/TestView.cpp +++ b/GUI/coregui/Views/TestView.cpp @@ -38,20 +38,6 @@ #include "ModelMapper.h" #include "DetectorItems.h" - - -// FIXME_DAVID Rename Ivona's FitView into ObsoleteFitView. And use nice name FitView for own purpose. -// -- suggestion: for consistency use prefix Obsolete for all classes you are goind to throw soon -// -- you may want to add to all Ivona's classes prefix Obsolete. Don't forget about 'ifndef' header guards - -// FIXME_DAVID Move your activity from TestView to FitView. -// - FitView should contain QTabWidget with 3 tabs: -// - 1) ImportDataWidget (empty for the moment) 2) FitSettingsWidget 3) RunFitWidget - -// FIXME_DAVID FitSettingsWidget should contain -// - FitParametersWidget (for the moment), and later sample/instrument selector + MinimizerSettingsWidgert - - TestView::TestView(MainWindow *mainWindow) : QWidget(mainWindow) , m_mainWindow(mainWindow) diff --git a/GUI/coregui/mainwindow/mainwindow.cpp b/GUI/coregui/mainwindow/mainwindow.cpp index cb5020ec181a5426fcd7afe4a829d0dedbd02367..096f02849c706743e98c5747ed36a0bf3a8a6b8e 100644 --- a/GUI/coregui/mainwindow/mainwindow.cpp +++ b/GUI/coregui/mainwindow/mainwindow.cpp @@ -50,6 +50,9 @@ MainWindow::MainWindow(QWidget *parent) : Manhattan::FancyMainWindow(parent) + , m_applicationModels(new ApplicationModels(this)) + , m_projectManager(new ProjectManager(this)) + , m_actionManager(new ActionManager(this)) , m_tabWidget(0) , m_welcomeView(0) , m_instrumentView(0) @@ -58,9 +61,6 @@ MainWindow::MainWindow(QWidget *parent) , m_jobView(0) , m_fitView(0) , m_progressBar(0) - , m_actionManager(0) - , m_projectManager(0) - , m_applicationModels(new ApplicationModels(this)) , m_toolTipDataBase(new ToolTipDataBase(this)) , m_updateNotifier(new UpdateNotifier(this)) { @@ -76,12 +76,11 @@ MainWindow::MainWindow(QWidget *parent) Manhattan::Utils::StyleHelper::setBaseColor(QColor(Constants::MAIN_THEME_COLOR)); setDockNestingEnabled(true); + setAcceptDrops(true); setCorner(Qt::BottomLeftCorner, Qt::LeftDockWidgetArea); setCorner(Qt::BottomRightCorner, Qt::BottomDockWidgetArea); - m_projectManager = new ProjectManager(this); - m_actionManager = new ActionManager(this); readSettings(); m_tabWidget = new Manhattan::FancyTabWidget(this); @@ -113,8 +112,6 @@ MainWindow::MainWindow(QWidget *parent) setCentralWidget(m_tabWidget); - setAcceptDrops(true); - // signals/slots connect(m_tabWidget, SIGNAL(currentChanged(int)), this, SLOT(onChangeTabWidget(int))); connect(m_jobView, SIGNAL(focusRequest(int)), this, SLOT(onFocusRequest(int))); @@ -149,6 +146,40 @@ FitModel *MainWindow::getFitModel() return models()->fitModel(); } +ApplicationModels *MainWindow::models() +{ + return m_applicationModels; +} + +//! updates views which depend on others +void MainWindow::onChangeTabWidget(int index) +{ + if(index == WELCOME) + { + m_welcomeView->updateRecentProjectPanel(); + } + else if (index == INSTRUMENT) { + m_instrumentView->updateView(); + } + else if(index == SIMULATION) { + m_simulationView->updateSimulationViewElements(); + } +} + +void MainWindow::onFocusRequest(int index) +{ + m_tabWidget->setCurrentIndex(index); +} + +void MainWindow::openRecentProject() +{ + if (const QAction *action = qobject_cast<const QAction*>(sender())) { + QString file = action->data().value<QString>(); + qDebug() << "MainWindow::openRecentProject() -> " << file; + m_projectManager->openProject(file); + } +} + void MainWindow::readSettings() { QSettings settings; @@ -180,35 +211,10 @@ void MainWindow::onRunSimulationShortcut() m_simulationView->onRunSimulationShortcut(); } -void MainWindow::openRecentProject() -{ - if (const QAction *action = qobject_cast<const QAction*>(sender())) { - QString file = action->data().value<QString>(); - qDebug() << "MainWindow::openRecentProject() -> " << file; - m_projectManager->openProject(file); - } -} - -void MainWindow::onChangeTabWidget(int index) -{ - // update views which depend on others - (void)index; - - if(index == WELCOME) - { - m_welcomeView->updateRecentProjectPanel(); - } - else if (index == INSTRUMENT) { - m_instrumentView->updateView(); - } - else if(index == SIMULATION) { - m_simulationView->updateSimulationViewElements(); - } -} - -void MainWindow::onFocusRequest(int index) +void MainWindow::onAboutApplication() { - m_tabWidget->setCurrentIndex(index); + AboutApplicationDialog dialog(this); + dialog.exec(); } void MainWindow::closeEvent(QCloseEvent *event) @@ -232,17 +238,6 @@ void MainWindow::closeEvent(QCloseEvent *event) } } -void MainWindow::onAboutApplication() -{ - AboutApplicationDialog dialog(this); - dialog.exec(); -} - -void MainWindow::resetModels() -{ - models()->resetModels(); -} - void MainWindow::showEvent(QShowEvent *event) { QWidget::showEvent( event ); diff --git a/GUI/coregui/mainwindow/mainwindow.h b/GUI/coregui/mainwindow/mainwindow.h index e8bb757a0184c2ee7b60fc0503fc53233a52d98e..13094a39ab37db531f98a43279742212ac7d0410 100644 --- a/GUI/coregui/mainwindow/mainwindow.h +++ b/GUI/coregui/mainwindow/mainwindow.h @@ -26,58 +26,49 @@ namespace Manhattan { class ProgressBar; } -class TaskSelectorWidget; class WelcomeView; class InstrumentView; class SampleView; -class PyScriptView; class SimulationView; class JobView; -class Instrument; -class ISample; -class ActionManager; -class ProjectManager; -class QCloseEvent; -class QSettings; -class InstrumentModel; -class MaterialSvc; -class ToolTipDataBase; +class FitView; + class MaterialModel; +class MaterialSvc; class SampleModel; -class FitView; +class InstrumentModel; class JobModel; -class UpdateNotifier; class FitModel; class ApplicationModels; +class ProjectManager; +class ActionManager; +class QSettings; +class ToolTipDataBase; +class UpdateNotifier; + + class BA_CORE_API_ MainWindow : public Manhattan::FancyMainWindow { Q_OBJECT public: - enum ETabViewId { WELCOME, INSTRUMENT, SAMPLE, SIMULATION, JOB, FIT, TESTVIEW}; + enum ETabViewId {WELCOME, INSTRUMENT, SAMPLE, SIMULATION, JOB, FIT, TESTVIEW}; explicit MainWindow(QWidget *parent = 0); -// MaterialModel *getMaterialModel() { return m_materialModel; } -// InstrumentModel *instrumentModel() { return m_instrumentModel; } -// SampleModel *sampleModel() { return m_sampleModel; } -// JobModel *jobModel() { return m_jobModel; } -// FitModel *getFitModel() { return m_fitModel; } - MaterialModel *getMaterialModel(); InstrumentModel *instrumentModel(); SampleModel *sampleModel(); JobModel *jobModel(); FitModel *getFitModel(); - + ApplicationModels *models(); Manhattan::ProgressBar *getProgressBar() { return m_progressBar; } ActionManager *getActionManager() { return m_actionManager; } ProjectManager *getProjectManager() { return m_projectManager; } UpdateNotifier *getUpdateNotifier() { return m_updateNotifier; } - ApplicationModels *models() { return m_applicationModels; } public slots: void onChangeTabWidget(int index); @@ -87,31 +78,26 @@ public slots: void writeSettings(); void onRunSimulationShortcut(); void onAboutApplication(); - void resetModels(); protected: virtual void closeEvent(QCloseEvent *event); + virtual void showEvent(QShowEvent *event); private: + ApplicationModels *m_applicationModels; + ProjectManager *m_projectManager; + ActionManager *m_actionManager; + Manhattan::FancyTabWidget *m_tabWidget; WelcomeView *m_welcomeView; InstrumentView *m_instrumentView; SampleView *m_sampleView; SimulationView *m_simulationView; - JobView *m_jobView; FitView *m_fitView; - Manhattan::ProgressBar *m_progressBar; - - ActionManager *m_actionManager; //!< responsible for menus and actions - ProjectManager *m_projectManager; //!< handles activity related to opening/saving projects - ApplicationModels *m_applicationModels; - ToolTipDataBase *m_toolTipDataBase; UpdateNotifier *m_updateNotifier; - - virtual void showEvent(QShowEvent *event); }; #endif // MAINWINDOW_H diff --git a/GUI/coregui/mainwindow/projectmanager.cpp b/GUI/coregui/mainwindow/projectmanager.cpp index f9fe7e9aa59c407112cc15fb3f4138ca1f4f4735..4f0c43aa9ba56ab07912cc7036b7ea9c2b004013 100644 --- a/GUI/coregui/mainwindow/projectmanager.cpp +++ b/GUI/coregui/mainwindow/projectmanager.cpp @@ -25,6 +25,7 @@ #include "WarningMessageService.h" #include "MessageContainer.h" #include "GUIMessage.h" +#include "ApplicationModels.h" #include <QDir> #include <QFileDialog> #include <QSettings> @@ -314,7 +315,7 @@ void ProjectManager::deleteCurrentProject() { delete m_project_document; m_project_document = 0; - m_mainWindow->resetModels(); + m_mainWindow->models()->resetModels(); }