diff --git a/GUI/Model/Project/LinkInstrumentManager.cpp b/GUI/Model/Project/LinkInstrumentManager.cpp index 91653641a05aca3e88de24f3f576e3a35677f20e..382a0b798c9e421abb780b37e17fcfe7c973f551 100644 --- a/GUI/Model/Project/LinkInstrumentManager.cpp +++ b/GUI/Model/Project/LinkInstrumentManager.cpp @@ -13,8 +13,10 @@ // ************************************************************************************************ #include "GUI/Model/Project/LinkInstrumentManager.h" +#include "Base/Util/Assert.h" #include "GUI/Model/Device/DatafileItem.h" #include "GUI/Model/Device/InstrumentItems.h" +#include "GUI/Model/Device/MultiInstrumentNotifier.h" #include "GUI/Model/Files/DatafilesSet.h" #include "GUI/Model/Project/ProjectDocument.h" #include <QMessageBox> diff --git a/GUI/Model/Project/ProjectDocument.cpp b/GUI/Model/Project/ProjectDocument.cpp index d80b6b93808b0753e8156edb9643a462e087e05a..adfabacf3fb037cde020b19d4a2c6c77f0e2b439 100644 --- a/GUI/Model/Project/ProjectDocument.cpp +++ b/GUI/Model/Project/ProjectDocument.cpp @@ -16,12 +16,17 @@ #include "GUI/Model/Device/BackgroundItems.h" #include "GUI/Model/Device/DatafileItem.h" #include "GUI/Model/Device/InstrumentItems.h" +#include "GUI/Model/Device/MultiInstrumentNotifier.h" +#include "GUI/Model/Files/DatafilesSet.h" #include "GUI/Model/Material/MaterialItem.h" #include "GUI/Model/Project/LinkInstrumentManager.h" #include "GUI/Model/Project/ProjectUtil.h" #include "GUI/Model/Sample/ItemWithMaterial.h" #include "GUI/Model/Sample/SampleItem.h" +#include "GUI/Model/Sample/SamplesSet.h" +#include "GUI/Model/Tune/JobsSet.h" #include "GUI/Support/Data/ID.h" +#include "GUI/Support/Data/SimulationOptionsItem.h" #include "GUI/Support/Util/MessageService.h" #include "GUI/Support/Util/Path.h" #include "GUI/Support/XML/DeserializationException.h" @@ -52,12 +57,19 @@ const QString ActiveView("ActiveView"); ProjectDocument::ProjectDocument() : m_modified(false) - , m_instrument_edit_controller(&m_instrument_model) + , m_link_manager(std::unique_ptr<LinkInstrumentManager>()) + , m_simulation_options_item(std::make_unique<SimulationOptionsItem>()) + , m_instrument_model(std::make_unique<InstrumentsSet>()) + , m_instrument_edit_controller( + std::make_unique<MultiInstrumentNotifier>(m_instrument_model.get())) + , m_sample_model(std::make_unique<SamplesSet>()) + , m_real_model(std::make_unique<DatafilesSet>()) + , m_job_model(std::make_unique<JobsSet>()) , m_last_view_active(GUI::ID::ViewId::Instrument) { - connect(&m_instrument_edit_controller, &MultiInstrumentNotifier::instrumentAddedOrRemoved, this, - &ProjectDocument::onModelChanged); - connect(&m_instrument_edit_controller, &MultiInstrumentNotifier::instrumentChanged, this, + connect(m_instrument_edit_controller.get(), &MultiInstrumentNotifier::instrumentAddedOrRemoved, + this, &ProjectDocument::onModelChanged); + connect(m_instrument_edit_controller.get(), &MultiInstrumentNotifier::instrumentChanged, this, &ProjectDocument::onModelChanged); m_link_manager = std::make_unique<LinkInstrumentManager>(this); @@ -108,27 +120,27 @@ void ProjectDocument::setProjectFullPath(const QString& fullPath) InstrumentsSet* ProjectDocument::instrumentModel() { - return &m_instrument_model; + return m_instrument_model.get(); } SamplesSet* ProjectDocument::sampleModel() { - return &m_sample_model; + return m_sample_model.get(); } DatafilesSet* ProjectDocument::realModel() { - return &m_real_model; + return m_real_model.get(); } JobsSet* ProjectDocument::jobModel() { - return &m_job_model; + return m_job_model.get(); } SimulationOptionsItem* ProjectDocument::simulationOptionsItem() { - return &m_simulation_options_item; + return m_simulation_options_item.get(); } LinkInstrumentManager* ProjectDocument::linkInstrumentManager() @@ -138,7 +150,7 @@ LinkInstrumentManager* ProjectDocument::linkInstrumentManager() MultiInstrumentNotifier* ProjectDocument::multiNotifier() { - return &m_instrument_edit_controller; + return m_instrument_edit_controller.get(); } void ProjectDocument::saveProjectFileWithData(const QString& projectPullPath) @@ -151,8 +163,8 @@ void ProjectDocument::saveProjectFileWithData(const QString& projectPullPath) writeProject(&file); file.close(); - m_job_model.writeDatafiles(GUI::Util::Project::projectDir(projectPullPath)); - m_real_model.writeDatafiles(GUI::Util::Project::projectDir(projectPullPath)); + m_job_model->writeDatafiles(GUI::Util::Project::projectDir(projectPullPath)); + m_real_model->writeDatafiles(GUI::Util::Project::projectDir(projectPullPath)); const bool autoSave = GUI::Util::Project::isAutosave(projectPullPath); if (!autoSave) { @@ -180,9 +192,10 @@ ProjectDocument::ReadResult ProjectDocument::loadProjectFileWithData(const QStri if (result == ReadResult::error) return result; - m_job_model.readDatafiles(GUI::Util::Project::projectDir(projectPullPath), &messageService); - m_real_model.readDatafiles(GUI::Util::Project::projectDir(projectPullPath), + m_job_model->readDatafiles(GUI::Util::Project::projectDir(projectPullPath), &messageService); + m_real_model->readDatafiles(GUI::Util::Project::projectDir(projectPullPath), + &messageService); if (!messageService.warnings().empty()) result = ReadResult::warning; @@ -239,27 +252,27 @@ void ProjectDocument::writeProject(QIODevice* device) // simulation options w.writeStartElement(Tag::SimulationOptions); - m_simulation_options_item.writeTo(&w); + m_simulation_options_item->writeTo(&w); w.writeEndElement(); // instruments w.writeStartElement(Tag::InstrumentsSet); - m_instrument_model.writeTo(&w); + m_instrument_model->writeTo(&w); w.writeEndElement(); // samples w.writeStartElement(Tag::SamplesSet); - m_sample_model.writeTo(&w); + m_sample_model->writeTo(&w); w.writeEndElement(); // real model w.writeStartElement(Tag::RealModel); - m_real_model.writeTo(&w); + m_real_model->writeTo(&w); w.writeEndElement(); // job model w.writeStartElement(Tag::JobsSet); - m_job_model.writeTo(&w); + m_job_model->writeTo(&w); w.writeEndElement(); // active view @@ -301,28 +314,28 @@ ProjectDocument::ReadResult ProjectDocument::readProject(QIODevice* device, // simulation options if (tag == Tag::SimulationOptions) { - m_simulation_options_item.readFrom(&r); + m_simulation_options_item->readFrom(&r); XML::gotoEndElementOfTag(&r, tag); // instruments } else if (tag == Tag::InstrumentsSet) { - m_instrument_model.readFrom(&r); + m_instrument_model->readFrom(&r); XML::gotoEndElementOfTag(&r, tag); // samples } else if (tag == Tag::SamplesSet) { - m_sample_model.readFrom(&r); + m_sample_model->readFrom(&r); XML::gotoEndElementOfTag(&r, tag); // real model } else if (tag == Tag::RealModel) { // 'm_instrument_model' should be read before - m_real_model.readFrom(&r); + m_real_model->readFrom(&r); XML::gotoEndElementOfTag(&r, tag); // job model } else if (tag == Tag::JobsSet) { - m_job_model.readFrom(&r); + m_job_model->readFrom(&r); XML::gotoEndElementOfTag(&r, tag); // active view diff --git a/GUI/Model/Project/ProjectDocument.h b/GUI/Model/Project/ProjectDocument.h index c870f4a9b29afd5cd5e839ecb380fa7e337588a8..f88df8e1f744bde4183d82471261c0d4b5d67aec 100644 --- a/GUI/Model/Project/ProjectDocument.h +++ b/GUI/Model/Project/ProjectDocument.h @@ -15,12 +15,14 @@ #ifndef BORNAGAIN_GUI_MODEL_PROJECT_PROJECTDOCUMENT_H #define BORNAGAIN_GUI_MODEL_PROJECT_PROJECTDOCUMENT_H -#include "GUI/Model/Device/MultiInstrumentNotifier.h" -#include "GUI/Model/Files/DatafilesSet.h" -#include "GUI/Model/Sample/SamplesSet.h" -#include "GUI/Model/Tune/JobsSet.h" -#include "GUI/Support/Data/SimulationOptionsItem.h" - +#include <QObject> + +class SimulationOptionsItem; +class MultiInstrumentNotifier; +class InstrumentsSet; +class SamplesSet; +class DatafilesSet; +class JobsSet; class LinkInstrumentManager; class MessageService; class ProjectDocument; @@ -102,12 +104,12 @@ private: bool m_modified; QString m_current_version; std::unique_ptr<LinkInstrumentManager> m_link_manager; - SimulationOptionsItem m_simulation_options_item; - MultiInstrumentNotifier m_instrument_edit_controller; - InstrumentsSet m_instrument_model; - SamplesSet m_sample_model; - DatafilesSet m_real_model; - JobsSet m_job_model; + std::unique_ptr<SimulationOptionsItem> m_simulation_options_item; + std::unique_ptr<InstrumentsSet> m_instrument_model; + std::unique_ptr<MultiInstrumentNotifier> m_instrument_edit_controller; + std::unique_ptr<SamplesSet> m_sample_model; + std::unique_ptr<DatafilesSet> m_real_model; + std::unique_ptr<JobsSet> m_job_model; int m_last_view_active; }; diff --git a/GUI/View/Data/DatafileEditor.cpp b/GUI/View/Data/DatafileEditor.cpp index 8f5c57383265b520b0decd5cb5a898d2fe9480c0..3939e0918e134fb1a11d1f63578242e13a81b7e6 100644 --- a/GUI/View/Data/DatafileEditor.cpp +++ b/GUI/View/Data/DatafileEditor.cpp @@ -15,6 +15,7 @@ #include "GUI/View/Data/DatafileEditor.h" #include "GUI/Model/Device/DatafileItem.h" #include "GUI/Model/Device/InstrumentItems.h" +#include "GUI/Model/Device/MultiInstrumentNotifier.h" #include "GUI/Model/Project/LinkInstrumentManager.h" #include "GUI/Model/Project/ProjectDocument.h" #include "GUI/View/Tool/Globals.h" diff --git a/GUI/View/Data/DatafilesSelector.cpp b/GUI/View/Data/DatafilesSelector.cpp index 12a2de1f1d36743faa93e6072bf81e3e172416e7..95d95c2a679f16ada87ea95be81b6c4505358b81 100644 --- a/GUI/View/Data/DatafilesSelector.cpp +++ b/GUI/View/Data/DatafilesSelector.cpp @@ -19,6 +19,7 @@ #include "GUI/Model/Data/DataItem.h" #include "GUI/Model/Device/DatafileItem.h" #include "GUI/Model/Files/DatafilesQModel.h" +#include "GUI/Model/Files/DatafilesSet.h" #include "GUI/View/Data/DatafileEditor.h" #include "GUI/View/Data/StackedFrames.h" #include "GUI/View/Info/MessageBox.h" diff --git a/GUI/View/Instrument/InstrumentView.cpp b/GUI/View/Instrument/InstrumentView.cpp index 28a488279403420e92c579cba2bc8f5f09a0bd94..66fcf259d4c60452e2604daac561f5d4310799a9 100644 --- a/GUI/View/Instrument/InstrumentView.cpp +++ b/GUI/View/Instrument/InstrumentView.cpp @@ -13,7 +13,9 @@ // ************************************************************************************************ #include "GUI/View/Instrument/InstrumentView.h" +#include "Base/Util/Assert.h" #include "GUI/Model/Device/InstrumentItems.h" +#include "GUI/Model/Device/MultiInstrumentNotifier.h" #include "GUI/Model/Project/ProjectDocument.h" #include "GUI/View/Instrument/DepthprobeInstrumentEditor.h" #include "GUI/View/Instrument/GISASInstrumentEditor.h" diff --git a/GUI/View/Job/JobView.cpp b/GUI/View/Job/JobView.cpp index 45645d59cf54e02fc88832fec22653cc4d663a22..da3e0a23643f2d2cc6bb2c0368cbe5dd84f0f299 100644 --- a/GUI/View/Job/JobView.cpp +++ b/GUI/View/Job/JobView.cpp @@ -15,7 +15,9 @@ #include "GUI/View/Job/JobView.h" #include "GUI/Model/Data/DataItem.h" #include "GUI/Model/Job/JobItem.h" +#include "GUI/Model/Tune/JobsSet.h" #include "GUI/Support/Data/ID.h" +#include "GUI/Support/Data/SimulationOptionsItem.h" #include "GUI/View/Data/StackedFrames.h" #include "GUI/View/Dock/DocksController.h" #include "GUI/View/Fit/FitActivityPanel.h" diff --git a/GUI/View/JobControl/JobListModel.cpp b/GUI/View/JobControl/JobListModel.cpp index b1d81587b2d9bcb75f6c5f100a17d59f364f0c7e..51428944ca117c9ab8ee208f27eb994bdcc4249c 100644 --- a/GUI/View/JobControl/JobListModel.cpp +++ b/GUI/View/JobControl/JobListModel.cpp @@ -16,6 +16,7 @@ #include "GUI/Model/Job/BatchInfo.h" #include "GUI/Model/Job/JobItem.h" #include "GUI/Model/Project/ProjectDocument.h" +#include "GUI/Model/Tune/JobsSet.h" //================================================================================================== // JobListModel diff --git a/GUI/View/JobControl/JobListing.cpp b/GUI/View/JobControl/JobListing.cpp index e8edf86734212b1c1cf383586397658d3a52da52..c7bd8af37d08a1446510a151466644a2b2d6675d 100644 --- a/GUI/View/JobControl/JobListing.cpp +++ b/GUI/View/JobControl/JobListing.cpp @@ -17,6 +17,7 @@ #include "GUI/Model/Data/Data2DItem.h" #include "GUI/Model/Job/BatchInfo.h" #include "GUI/Model/Project/ProjectDocument.h" +#include "GUI/Model/Tune/JobsSet.h" #include "GUI/Support/Data/JobStatus.h" #include "GUI/View/JobControl/JobListModel.h" #include "GUI/View/JobControl/JobProgressDelegate.h" diff --git a/GUI/View/Plotter/ColorMap.cpp b/GUI/View/Plotter/ColorMap.cpp index ea645ea7ec703bdbd84d8387554446b546b50878..f4a4d043772d543218b12fefd220f12a24ac3f48 100644 --- a/GUI/View/Plotter/ColorMap.cpp +++ b/GUI/View/Plotter/ColorMap.cpp @@ -14,6 +14,7 @@ #include "GUI/View/Plotter/ColorMap.h" #include "Base/Py/PyFmt.h" +#include "Base/Util/Assert.h" #include "Device/Data/Datafield.h" #include "GUI/Model/Axis/AmplitudeAxisItem.h" #include "GUI/Model/Axis/BasicAxisItem.h" diff --git a/GUI/View/Project/SimulationView.cpp b/GUI/View/Project/SimulationView.cpp index 54f07bd3f084d30932f40bd0ec0cda27584ded47..f16deaaa7ff326271d1a20b20020a512b7180104 100644 --- a/GUI/View/Project/SimulationView.cpp +++ b/GUI/View/Project/SimulationView.cpp @@ -16,11 +16,13 @@ #include "GUI/Model/Data/DataItem.h" #include "GUI/Model/Device/DatafileItem.h" #include "GUI/Model/Device/InstrumentItems.h" +#include "GUI/Model/Device/InstrumentsSet.h" #include "GUI/Model/Files/DatafilesSet.h" #include "GUI/Model/Job/JobItem.h" #include "GUI/Model/Project/ProjectDocument.h" #include "GUI/Model/Sample/SampleItem.h" #include "GUI/Model/Sample/SampleValidator.h" +#include "GUI/Model/Sample/SamplesSet.h" #include "GUI/Model/Tune/JobsSet.h" #include "GUI/Support/Data/SimulationOptionsItem.h" #include "GUI/View/Manager/ProjectManager.h" diff --git a/GUI/View/Sample/SampleListing.cpp b/GUI/View/Sample/SampleListing.cpp index 7a42410a307bb4acefea5ca0e0fa0140bbb83c19..12301603db6a6c19508d59cd6ba9923e22838a80 100644 --- a/GUI/View/Sample/SampleListing.cpp +++ b/GUI/View/Sample/SampleListing.cpp @@ -17,6 +17,7 @@ #include "GUI/Model/FromCore/GUIExamplesFactory.h" #include "GUI/Model/Project/ProjectDocument.h" #include "GUI/Model/Sample/SampleItem.h" +#include "GUI/Model/Sample/SamplesSet.h" #include "GUI/View/Layout/ApplicationSettings.h" #include "GUI/View/Sample/SamplesQModel.h" #include "GUI/View/Tool/ItemDelegateForHTML.h" diff --git a/GUI/View/Tuning/ParameterTuningWidget.cpp b/GUI/View/Tuning/ParameterTuningWidget.cpp index 20b3062af817dcbd39e2c013c2094f6c1d60ae38..8fed0fffacc94bddc9224462d7b9884c5656e4b3 100644 --- a/GUI/View/Tuning/ParameterTuningWidget.cpp +++ b/GUI/View/Tuning/ParameterTuningWidget.cpp @@ -19,6 +19,7 @@ #include "GUI/Model/Job/JobItem.h" #include "GUI/Model/Job/ParameterTreeItems.h" #include "GUI/Model/Project/ProjectDocument.h" +#include "GUI/Model/Tune/JobsSet.h" #include "GUI/Model/Tune/PartunerQModel.h" #include "GUI/Support/Data/JobStatus.h" #include "GUI/View/Info/CautionSign.h" diff --git a/Tests/Unit/GUI/TestAutosaveController.cpp b/Tests/Unit/GUI/TestAutosaveController.cpp index 8c0c815ea551722484884b2a89e4449749f0f287..a76abb20c0f0435cb0a51a4e98d2079d2ffd6b50 100644 --- a/Tests/Unit/GUI/TestAutosaveController.cpp +++ b/Tests/Unit/GUI/TestAutosaveController.cpp @@ -4,6 +4,8 @@ #include "GUI/Model/Data/Data2DItem.h" #include "GUI/Model/Device/DatafileItem.h" #include "GUI/Model/Device/InstrumentItems.h" +#include "GUI/Model/Device/InstrumentsSet.h" +#include "GUI/Model/Device/MultiInstrumentNotifier.h" #include "GUI/Model/Project/ProjectUtil.h" #include "GUI/Support/Util/Path.h" #include "GUI/View/Manager/AutosaveController.h" diff --git a/Tests/Unit/GUI/TestInstrumentItems.cpp b/Tests/Unit/GUI/TestInstrumentItems.cpp index 03443d7190200d919e6c59a35c5dbba158a74f76..57fc8c5588734f0801350fdc81fd0e9595abdc2d 100644 --- a/Tests/Unit/GUI/TestInstrumentItems.cpp +++ b/Tests/Unit/GUI/TestInstrumentItems.cpp @@ -1,5 +1,6 @@ #include "GUI/Model/Device/InstrumentItems.h" +#include "GUI/Model/Device/MultiInstrumentNotifier.h" #include "GUI/Model/Project/ProjectDocument.h" #include "Tests/GTestWrapper/google_test.h" #include <QSignalSpy> diff --git a/Tests/Unit/GUI/TestLinkInstrument.cpp b/Tests/Unit/GUI/TestLinkInstrument.cpp index c86347612698fe44ccd95dcb6ed63c24c1145b0f..4531e1492c516b6a95b1dc08a18f0b58f61673ee 100644 --- a/Tests/Unit/GUI/TestLinkInstrument.cpp +++ b/Tests/Unit/GUI/TestLinkInstrument.cpp @@ -8,6 +8,8 @@ #include "GUI/Model/Detector/DetectorItem.h" #include "GUI/Model/Device/DatafileItem.h" #include "GUI/Model/Device/InstrumentItems.h" +#include "GUI/Model/Device/InstrumentsSet.h" +#include "GUI/Model/Device/MultiInstrumentNotifier.h" #include "GUI/Model/Files/DatafilesSet.h" #include "GUI/Model/Project/LinkInstrumentManager.h" #include "GUI/Model/Project/ProjectDocument.h" diff --git a/Tests/Unit/GUI/TestProjectDocument.cpp b/Tests/Unit/GUI/TestProjectDocument.cpp index f161c592801333ff16225b7e256cc4456402e9bf..3d798484204d75eae1196346f1999c23296fc375 100644 --- a/Tests/Unit/GUI/TestProjectDocument.cpp +++ b/Tests/Unit/GUI/TestProjectDocument.cpp @@ -4,6 +4,8 @@ #include "GUI/Model/Data/Data2DItem.h" #include "GUI/Model/Device/DatafileItem.h" #include "GUI/Model/Device/InstrumentItems.h" +#include "GUI/Model/Device/InstrumentsSet.h" +#include "GUI/Model/Device/MultiInstrumentNotifier.h" #include "GUI/Model/Files/DatafilesSet.h" #include "GUI/Model/Project/ProjectDocument.h" #include "GUI/Model/Project/ProjectUtil.h"