diff --git a/GUI/Model/Descriptor/SelectionProperty.h b/GUI/Model/Descriptor/SelectionProperty.h index fa2bed2e96a972c18ddbd60e36be301e479e8a45..05ebd9e8b54efb54984fdf52188db56ff6d48a8a 100644 --- a/GUI/Model/Descriptor/SelectionProperty.h +++ b/GUI/Model/Descriptor/SelectionProperty.h @@ -217,7 +217,7 @@ private: //! A special kind of owning vector, providing "standard" interfaces for //! 'std::vector<SelectionProperty<Catalog>>', used in classes that work not just with single -//! SelectionProperty but with the set of them, for example 'InstrumentModel', 'CompoundItem', +//! SelectionProperty but with the set of them, for example 'InstrumentsSet', 'CompoundItem', //! 'ParticleLayoutItems', 'MaskItems' template <typename Catalog> class SelectionVector { diff --git a/GUI/Model/Device/InstrumentLibrary.cpp b/GUI/Model/Device/InstrumentLibrary.cpp index 710cb0fec5dac49287e939308d5a333aec959bf2..db9a8f783ee2a36961d52e7a539a426098b5d25c 100644 --- a/GUI/Model/Device/InstrumentLibrary.cpp +++ b/GUI/Model/Device/InstrumentLibrary.cpp @@ -142,7 +142,7 @@ bool InstrumentLibrary::load() } } -InstrumentModel* InstrumentLibrary::instrumentModel() +InstrumentsSet* InstrumentLibrary::instrumentModel() { return &m_instrument_model; } diff --git a/GUI/Model/Device/InstrumentLibrary.h b/GUI/Model/Device/InstrumentLibrary.h index 68943960492ed3c34098402c41347f08441e1034..3e56ca8279e67bc7ca1a5e72930af2c0a6208ae2 100644 --- a/GUI/Model/Device/InstrumentLibrary.h +++ b/GUI/Model/Device/InstrumentLibrary.h @@ -15,7 +15,7 @@ #ifndef BORNAGAIN_GUI_MODEL_DEVICE_INSTRUMENTLIBRARY_H #define BORNAGAIN_GUI_MODEL_DEVICE_INSTRUMENTLIBRARY_H -#include "GUI/Model/Device/InstrumentModel.h" +#include "GUI/Model/Device/InstrumentsSet.h" #include "GUI/Model/Device/MultiInstrumentNotifier.h" class InstrumentLibrary { @@ -32,12 +32,12 @@ public: bool saveIfModified(); bool load(); - InstrumentModel* instrumentModel(); + InstrumentsSet* instrumentModel(); MultiInstrumentNotifier* editController(); private: - InstrumentModel m_instrument_model; + InstrumentsSet m_instrument_model; MultiInstrumentNotifier m_ec; bool m_modified; }; diff --git a/GUI/Model/Device/InstrumentModel.cpp b/GUI/Model/Device/InstrumentsSet.cpp similarity index 73% rename from GUI/Model/Device/InstrumentModel.cpp rename to GUI/Model/Device/InstrumentsSet.cpp index 080b55c1a498b5f605b2c597c707d49e4b3f02bb..be696b01e83c278d030168aa32b02f4df3d2e4d6 100644 --- a/GUI/Model/Device/InstrumentModel.cpp +++ b/GUI/Model/Device/InstrumentsSet.cpp @@ -2,8 +2,8 @@ // // BornAgain: simulate and fit reflection and scattering // -//! @file GUI/Model/Device/InstrumentModel.cpp -//! @brief Implement class InstrumentModel +//! @file GUI/Model/Device/InstrumentsSet.cpp +//! @brief Implement class InstrumentsSet //! //! @homepage http://www.bornagainproject.org //! @license GNU General Public License v3 or higher (see COPYING) @@ -12,7 +12,7 @@ // // ************************************************************************************************ -#include "GUI/Model/Device/InstrumentModel.h" +#include "GUI/Model/Device/InstrumentsSet.h" #include "GUI/Model/Device/BackgroundItems.h" #include "GUI/Model/Device/InstrumentItems.h" #include "GUI/Support/Util/String.h" @@ -27,14 +27,14 @@ const QString SelectedIndex("SelectedIndex"); } // namespace Tag } // namespace -InstrumentModel::~InstrumentModel() = default; +InstrumentsSet::~InstrumentsSet() = default; -void InstrumentModel::clear() +void InstrumentsSet::clear() { m_instruments.clear(); } -void InstrumentModel::writeTo(QXmlStreamWriter* w) const +void InstrumentsSet::writeTo(QXmlStreamWriter* w) const { XML::writeAttribute(w, XML::Attrib::version, uint(1)); @@ -51,7 +51,7 @@ void InstrumentModel::writeTo(QXmlStreamWriter* w) const w->writeEndElement(); } -void InstrumentModel::readFrom(QXmlStreamReader* r) +void InstrumentsSet::readFrom(QXmlStreamReader* r) { m_instruments.clear(); @@ -76,12 +76,12 @@ void InstrumentModel::readFrom(QXmlStreamReader* r) } } -void InstrumentModel::emplace_back(InstrumentItem* item) +void InstrumentsSet::emplace_back(InstrumentItem* item) { addEmptyInstrumentSelection().setCurrentItem(item); } -InstrumentItem* InstrumentModel::insertItemCopy(const InstrumentItem& source) +InstrumentItem* InstrumentsSet::insertItemCopy(const InstrumentItem& source) { auto* copy = source.createItemCopy(); copy->setId(QUuid::createUuid().toString()); @@ -89,7 +89,7 @@ InstrumentItem* InstrumentModel::insertItemCopy(const InstrumentItem& source) return copy; } -QVector<InstrumentItem*> InstrumentModel::instrumentItems() const +QVector<InstrumentItem*> InstrumentsSet::instrumentItems() const { QVector<InstrumentItem*> output; for (const auto& sel : m_instruments) @@ -97,7 +97,7 @@ QVector<InstrumentItem*> InstrumentModel::instrumentItems() const return output; } -QStringList InstrumentModel::instrumentNames() const +QStringList InstrumentsSet::instrumentNames() const { QStringList existingNames; for (const auto* item : instrumentItems()) @@ -105,19 +105,19 @@ QStringList InstrumentModel::instrumentNames() const return existingNames; } -SelectionProperty<InstrumentItemCatalog>& InstrumentModel::addEmptyInstrumentSelection() +SelectionProperty<InstrumentItemCatalog>& InstrumentsSet::addEmptyInstrumentSelection() { m_instruments.push_back(nullptr); return m_instruments.back(); } -QString InstrumentModel::suggestInstrumentName(const QString& baseName) const +QString InstrumentsSet::suggestInstrumentName(const QString& baseName) const { return GUI::Util::String::suggestName(instrumentNames(), baseName); } QVector<InstrumentItem*> -InstrumentModel::instrumentItems(const std::function<bool(const InstrumentItem*)>& accept) const +InstrumentsSet::instrumentItems(const std::function<bool(const InstrumentItem*)>& accept) const { QVector<InstrumentItem*> result; for (auto* p : instrumentItems()) @@ -127,7 +127,7 @@ InstrumentModel::instrumentItems(const std::function<bool(const InstrumentItem*) return result; } -QVector<InstrumentItem*> InstrumentModel::instrument2DItems() const +QVector<InstrumentItem*> InstrumentsSet::instrument2DItems() const { QVector<InstrumentItem*> result; for (auto* p : instrumentItems()) @@ -137,7 +137,7 @@ QVector<InstrumentItem*> InstrumentModel::instrument2DItems() const return result; } -InstrumentItem* InstrumentModel::findInstrumentItemById(const QString& instrumentId) const +InstrumentItem* InstrumentsSet::findInstrumentItemById(const QString& instrumentId) const { for (auto* instrument : instrumentItems()) if (instrument->id() == instrumentId) @@ -146,12 +146,12 @@ InstrumentItem* InstrumentModel::findInstrumentItemById(const QString& instrumen return nullptr; } -bool InstrumentModel::instrumentExists(const QString& instrumentId) const +bool InstrumentsSet::instrumentExists(const QString& instrumentId) const { return findInstrumentItemById(instrumentId) != nullptr; } -void InstrumentModel::removeInstrument(InstrumentItem* instrument) +void InstrumentsSet::removeInstrument(InstrumentItem* instrument) { m_instruments.delete_element(instrument); } diff --git a/GUI/Model/Device/InstrumentModel.h b/GUI/Model/Device/InstrumentsSet.h similarity index 87% rename from GUI/Model/Device/InstrumentModel.h rename to GUI/Model/Device/InstrumentsSet.h index 3fad5992257f2b50844422dff11e61cd42c5a17d..e4040af39a122a6463eed4afa92c7c372c943620 100644 --- a/GUI/Model/Device/InstrumentModel.h +++ b/GUI/Model/Device/InstrumentsSet.h @@ -2,8 +2,8 @@ // // BornAgain: simulate and fit reflection and scattering // -//! @file GUI/Model/Device/InstrumentModel.h -//! @brief Defines class InstrumentModel. +//! @file GUI/Model/Device/InstrumentsSet.h +//! @brief Defines class InstrumentsSet. //! //! @homepage http://www.bornagainproject.org //! @license GNU General Public License v3 or higher (see COPYING) @@ -12,8 +12,8 @@ // // ************************************************************************************************ -#ifndef BORNAGAIN_GUI_MODEL_DEVICE_INSTRUMENTMODEL_H -#define BORNAGAIN_GUI_MODEL_DEVICE_INSTRUMENTMODEL_H +#ifndef BORNAGAIN_GUI_MODEL_DEVICE_INSTRUMENTSSET_H +#define BORNAGAIN_GUI_MODEL_DEVICE_INSTRUMENTSSET_H #include "GUI/Model/Descriptor/SelectionProperty.h" #include "GUI/Model/Device/InstrumentItemCatalog.h" @@ -25,9 +25,9 @@ class InstrumentItem; -class InstrumentModel { +class InstrumentsSet { public: - ~InstrumentModel(); + ~InstrumentsSet(); template <typename T> T* addInstrumentItem() { @@ -69,4 +69,4 @@ private: int m_selected_index = -1; }; -#endif // BORNAGAIN_GUI_MODEL_DEVICE_INSTRUMENTMODEL_H +#endif // BORNAGAIN_GUI_MODEL_DEVICE_INSTRUMENTSSET_H diff --git a/GUI/Model/Device/MultiInstrumentNotifier.cpp b/GUI/Model/Device/MultiInstrumentNotifier.cpp index 100406df592603e72544c6a68a220a242032924c..42b7569dfa04c3aa029b6c78a07145beb2d2a565 100644 --- a/GUI/Model/Device/MultiInstrumentNotifier.cpp +++ b/GUI/Model/Device/MultiInstrumentNotifier.cpp @@ -15,7 +15,7 @@ #include "GUI/Model/Device/MultiInstrumentNotifier.h" #include "GUI/Model/Device/InstrumentItems.h" -MultiInstrumentNotifier::MultiInstrumentNotifier(InstrumentModel* instruments) +MultiInstrumentNotifier::MultiInstrumentNotifier(InstrumentsSet* instruments) : m_instruments(instruments) { } diff --git a/GUI/Model/Device/MultiInstrumentNotifier.h b/GUI/Model/Device/MultiInstrumentNotifier.h index 3c03f1e27ece7544fb7c7f13a2ca9d92ea851165..1a126572f80cd7f92bce28ea7d757423b38946a1 100644 --- a/GUI/Model/Device/MultiInstrumentNotifier.h +++ b/GUI/Model/Device/MultiInstrumentNotifier.h @@ -15,12 +15,12 @@ #ifndef BORNAGAIN_GUI_MODEL_DEVICE_MULTIINSTRUMENTNOTIFIER_H #define BORNAGAIN_GUI_MODEL_DEVICE_MULTIINSTRUMENTNOTIFIER_H -#include "GUI/Model/Device/InstrumentModel.h" +#include "GUI/Model/Device/InstrumentsSet.h" #include <QObject> class DatafileItem; class InstrumentItem; -class InstrumentModel; +class InstrumentsSet; //! Class to modify the instruments list or a single instrument and provide the necessary signaling //! within BornAgain. @@ -40,10 +40,10 @@ class InstrumentModel; class MultiInstrumentNotifier : public QObject { Q_OBJECT public: - MultiInstrumentNotifier(InstrumentModel* instruments); + MultiInstrumentNotifier(InstrumentsSet* instruments); //! The list of existing instruments. - InstrumentModel* instrumentModel() { return m_instruments; } + InstrumentsSet* instrumentModel() { return m_instruments; } //! Add an instrument and emit the respective signal. template <typename T> T* addInstrumentItem(); @@ -80,8 +80,8 @@ signals: void instrumentNameChanged(const InstrumentItem* instrument); private: - InstrumentModel* m_instruments; //!< The edited/controlled instruments. This pointer is - //!< borrowed, not owned. + InstrumentsSet* m_instruments; //!< The edited/controlled instruments. This pointer is + //!< borrowed, not owned. }; template <typename T> T* MultiInstrumentNotifier::addInstrumentItem() diff --git a/GUI/Model/Files/DatafilesSet.h b/GUI/Model/Files/DatafilesSet.h index f7e78827f05dc4ad059f9d7f2ac7134eabd017c2..66b19b0ddcef48dab9aaee6d50a2844a3aba6075 100644 --- a/GUI/Model/Files/DatafilesSet.h +++ b/GUI/Model/Files/DatafilesSet.h @@ -22,7 +22,7 @@ class DataItem; class Datafield; class DatafileItem; -class InstrumentModel; +class InstrumentsSet; class MessageService; //! The DatafilesSet class is a model to store all imported DatafileItem's. diff --git a/GUI/Model/FromCore/ItemizeSimulation.cpp b/GUI/Model/FromCore/ItemizeSimulation.cpp index 335c9772f8bb924de3680981cf01a855abb46cc6..69a44b8a373e47dff86a12e211e0a2afa6c4b2c9 100644 --- a/GUI/Model/FromCore/ItemizeSimulation.cpp +++ b/GUI/Model/FromCore/ItemizeSimulation.cpp @@ -37,7 +37,7 @@ #include "GUI/Model/Detector/ResolutionFunctionItems.h" #include "GUI/Model/Device/BackgroundItems.h" #include "GUI/Model/Device/InstrumentItems.h" -#include "GUI/Model/Device/InstrumentModel.h" +#include "GUI/Model/Device/InstrumentsSet.h" #include "GUI/Model/Mask/MaskItems.h" #include "GUI/Model/Mask/MaskList.h" #include "GUI/Support/Data/SimulationOptionsItem.h" diff --git a/GUI/Model/Project/LinkInstrumentManager.h b/GUI/Model/Project/LinkInstrumentManager.h index 822260148b85cf7bd006baa7f3c51696dc2c018a..b31fbf4abed81f370b9707a94c3f9ee65b3d6774 100644 --- a/GUI/Model/Project/LinkInstrumentManager.h +++ b/GUI/Model/Project/LinkInstrumentManager.h @@ -24,7 +24,7 @@ class DatafileItem; class InstrumentItem; class ProjectDocument; -//! The LinkInstrumentManager class provides communication between InstrumentModel and +//! The LinkInstrumentManager class provides communication between InstrumentsSet and //! DatafilesSet. Particularly, it notifies DatafileItem about changes in linked instruments //! to adjust axes of Data2DItem. diff --git a/GUI/Model/Project/ProjectDocument.cpp b/GUI/Model/Project/ProjectDocument.cpp index b8c2ed983b7580e472ce5a071542622c08b4553a..47a1d8e05a16cdbe0492602abc82e416ce5af333 100644 --- a/GUI/Model/Project/ProjectDocument.cpp +++ b/GUI/Model/Project/ProjectDocument.cpp @@ -39,7 +39,7 @@ namespace Tag { const QString BornAgain("BornAgain"); const QString DocumentInfo("DocumentInfo"); const QString SimulationOptions("SimulationOptions"); -const QString InstrumentModel("InstrumentModel"); +const QString InstrumentsSet("InstrumentsSet"); const QString SampleModel("SampleModel"); const QString JobsSet("JobsSet"); const QString RealModel("RealModel"); @@ -101,7 +101,7 @@ void ProjectDocument::setProjectFullPath(const QString& fullPath) setProjectDir(GUI::Project::Util::projectDir(fullPath)); } -InstrumentModel* ProjectDocument::instrumentModel() +InstrumentsSet* ProjectDocument::instrumentModel() { return &m_instrument_model; } @@ -238,7 +238,7 @@ void ProjectDocument::writeProject(QIODevice* device) w.writeEndElement(); // instruments - w.writeStartElement(Tag::InstrumentModel); + w.writeStartElement(Tag::InstrumentsSet); m_instrument_model.writeTo(&w); w.writeEndElement(); @@ -300,7 +300,7 @@ ProjectDocument::ReadResult ProjectDocument::readProject(QIODevice* device, XML::gotoEndElementOfTag(&r, tag); // instruments - } else if (tag == Tag::InstrumentModel) { + } else if (tag == Tag::InstrumentsSet) { m_instrument_model.readFrom(&r); XML::gotoEndElementOfTag(&r, tag); diff --git a/GUI/Model/Project/ProjectDocument.h b/GUI/Model/Project/ProjectDocument.h index 4756804448f339de0fdc3c547654939d0997d9ed..2a44cf1868e9ae2565a2cd191c4beb20793cd5f6 100644 --- a/GUI/Model/Project/ProjectDocument.h +++ b/GUI/Model/Project/ProjectDocument.h @@ -55,7 +55,7 @@ public: QString projectFullPath() const; void setProjectFullPath(const QString& fullPath); - InstrumentModel* instrumentModel(); + InstrumentsSet* instrumentModel(); SampleModel* sampleModel(); DatafilesSet* realModel(); JobsSet* jobModel(); @@ -103,7 +103,7 @@ private: std::unique_ptr<LinkInstrumentManager> m_link_manager; SimulationOptionsItem m_simulation_options_item; MultiInstrumentNotifier m_instrument_edit_controller; - InstrumentModel m_instrument_model; + InstrumentsSet m_instrument_model; SampleModel m_sample_model; DatafilesSet m_real_model; JobsSet m_job_model; diff --git a/GUI/View/Instrument/InstrumentsTreeModel.cpp b/GUI/View/Instrument/InstrumentsTreeModel.cpp index 7397c0d884b505d173428a23c3e05fe6fd37a7b2..b78c5e536eec6341a40adf4607aca5480fe1ecdd 100644 --- a/GUI/View/Instrument/InstrumentsTreeModel.cpp +++ b/GUI/View/Instrument/InstrumentsTreeModel.cpp @@ -15,7 +15,7 @@ #include "GUI/View/Instrument/InstrumentsTreeModel.h" #include "Base/Util/Assert.h" #include "GUI/Model/Device/InstrumentItems.h" -#include "GUI/Model/Device/InstrumentModel.h" +#include "GUI/Model/Device/InstrumentsSet.h" #include <QApplication> #include <QtGui> @@ -28,7 +28,7 @@ const auto types = {IType::Gisas, IType::Offspec, IType::Specular, IType::Depthp } // namespace -InstrumentsTreeModel::InstrumentsTreeModel(QObject* parent, InstrumentModel* model) +InstrumentsTreeModel::InstrumentsTreeModel(QObject* parent, InstrumentsSet* model) : QAbstractItemModel(parent) , m_model(model) , m_names_are_editable(false) diff --git a/GUI/View/Instrument/InstrumentsTreeModel.h b/GUI/View/Instrument/InstrumentsTreeModel.h index 8dfb9fd4a78534cae3b868e5bffd2ec0ea18a567..3c8c5429f5a694d8fdd2f6bd3c1ceb6879ba7c24 100644 --- a/GUI/View/Instrument/InstrumentsTreeModel.h +++ b/GUI/View/Instrument/InstrumentsTreeModel.h @@ -18,13 +18,13 @@ #include <QAbstractItemModel> class InstrumentItem; -class InstrumentModel; +class InstrumentsSet; //! Tree model for instrument item selection. Used e.g. for the instrument library. class InstrumentsTreeModel : public QAbstractItemModel { Q_OBJECT public: - InstrumentsTreeModel(QObject* parent, InstrumentModel* model); + InstrumentsTreeModel(QObject* parent, InstrumentsSet* model); enum InstrumentType { None = 0x0, @@ -64,7 +64,7 @@ private: void clear(); QVector<InstrumentItem*> instrumentItemsOfType(InstrumentType type) const; - InstrumentModel* m_model = nullptr; + InstrumentsSet* m_model = nullptr; bool m_names_are_editable; bool m_enable_empty_headlines; InstrumentItem* m_new_instrument = nullptr; diff --git a/Tests/Unit/GUI/TestDatafilesModel.cpp b/Tests/Unit/GUI/TestDatafilesModel.cpp index e989389f6eb72e7b795f8b73eab97fe423c0a316..3afdd05a14269ff5020c75023bd94ea87fcf677f 100644 --- a/Tests/Unit/GUI/TestDatafilesModel.cpp +++ b/Tests/Unit/GUI/TestDatafilesModel.cpp @@ -6,7 +6,7 @@ #include "GUI/Model/Device/BackgroundItems.h" #include "GUI/Model/Device/DatafileItem.h" #include "GUI/Model/Device/InstrumentItems.h" -#include "GUI/Model/Device/InstrumentModel.h" +#include "GUI/Model/Device/InstrumentsSet.h" #include "GUI/Model/Files/DatafilesSet.h" #include "Tests/GTestWrapper/google_test.h" #include "Tests/Unit/GUI/Utils.h" @@ -77,7 +77,7 @@ TEST(TestDatafilesSet, saveXMLData) const QString dir = dir_test_real_model + "/saveXMLData"; UTest::GUI::create_dir(dir); - InstrumentModel instrument_model; + InstrumentsSet instrument_model; DatafilesSet model1; Datafield df1 = UTest::GUI::makeData1D(201.);