diff --git a/GUI/Model/BaseItem/ModelMapper.cpp b/GUI/Model/BaseItem/ModelMapper.cpp index 2057ef9430f7bda9cfb841839d458f453ea22c51..19351c855785e751b072178fce9f9fca3e6af2fa 100644 --- a/GUI/Model/BaseItem/ModelMapper.cpp +++ b/GUI/Model/BaseItem/ModelMapper.cpp @@ -56,16 +56,6 @@ void ModelMapper::setOnChildPropertyChange(std::function<void(SessionItem*, QStr m_onChildPropertyChange.emplace_back(f, caller); } -//! Calls back when parent has changed, reports newParent. -//! If newParent=0, the item is about being to be removed from children. Method parent() -//! will still report old parent. -//! If newParent!=0, it is just the same as parent(). - -void ModelMapper::setOnParentChange(std::function<void(SessionItem*)> f, const void* caller) -{ - m_onParentChange.emplace_back(f, caller); -} - //! Calls back when number of children has changed, reports newChild. //! newChild == nullptr denotes the case when number of children has decreased. @@ -74,15 +64,6 @@ void ModelMapper::setOnChildrenChange(std::function<void(SessionItem*)> f, const m_onChildrenChange.emplace_back(f, caller); } -//! Calls back on any change in children (number of children or their properties), -//! reports childItem. -//! childItem == nullptr denotes the case when child was removed. - -void ModelMapper::setOnAnyChildChange(std::function<void(SessionItem*)> f, const void* caller) -{ - m_onAnyChildChange.emplace_back(f, caller); -} - void ModelMapper::setOnItemDestroy(std::function<void(SessionItem*)> f, const void* caller) { m_onItemDestroy.emplace_back(f, caller); @@ -93,15 +74,13 @@ void ModelMapper::setOnAboutToRemoveChild(std::function<void(SessionItem*)> f, c m_onAboutToRemoveChild.emplace_back(f, caller); } -//! Cancells all subscribtion of given caller +//! Cancels all subscriptions of given caller void ModelMapper::unsubscribe(const void* caller) { clean_container(m_onValueChange, caller); clean_container(m_onPropertyChange, caller); clean_container(m_onChildPropertyChange, caller); - clean_container(m_onParentChange, caller); clean_container(m_onChildrenChange, caller); - clean_container(m_onAnyChildChange, caller); clean_container(m_onItemDestroy, caller); clean_container(m_onAboutToRemoveChild, caller); } @@ -156,13 +135,6 @@ void ModelMapper::callOnChildPropertyChange(SessionItem* item, const QString& na f.first(item, name); } -void ModelMapper::callOnParentChange(SessionItem* new_parent) -{ - if (m_active) - for (const auto& f : m_onParentChange) - f.first(new_parent); -} - void ModelMapper::callOnChildrenChange(SessionItem* item) { if (m_active) @@ -170,13 +142,6 @@ void ModelMapper::callOnChildrenChange(SessionItem* item) f.first(item); } -void ModelMapper::callOnAnyChildChange(SessionItem* item) -{ - if (m_active) - for (const auto& f : m_onAnyChildChange) - f.first(item); -} - void ModelMapper::callOnAboutToRemoveChild(SessionItem* item) { if (m_active) @@ -199,9 +164,7 @@ void ModelMapper::clearMapper() m_onValueChange.clear(); m_onPropertyChange.clear(); m_onChildPropertyChange.clear(); - m_onParentChange.clear(); m_onChildrenChange.clear(); - m_onAnyChildChange.clear(); m_onItemDestroy.clear(); m_onAboutToRemoveChild.clear(); } @@ -234,23 +197,14 @@ void ModelMapper::onDataChanged(const QModelIndex& topLeft, const QModelIndex& b callOnChildPropertyChange(parent, tag); } } - if (nestling > 0) - callOnAnyChildChange(item); } void ModelMapper::onRowsInserted(const QModelIndex& parent, int first, int /*last*/) { SessionItem* newChild = m_model->itemForIndex(m_model->index(first, 0, parent)); - int nestling = nestlingDepth(newChild); - - if (newChild) - if (m_item == newChild) - callOnParentChange(m_model->itemForIndex(parent)); - if (nestling == 1) + if (nestlingDepth(newChild) == 1) callOnChildrenChange(newChild); - if (nestling > 0) - callOnAnyChildChange(newChild); } void ModelMapper::onBeginRemoveRows(const QModelIndex& parent, int first, int /*last*/) @@ -259,12 +213,8 @@ void ModelMapper::onBeginRemoveRows(const QModelIndex& parent, int first, int /* int nestling = nestlingDepth(m_model->itemForIndex(parent)); - if (oldChild) { - if (m_item == oldChild) - callOnParentChange(nullptr); - if (nestling == 0) - callOnAboutToRemoveChild(oldChild); - } + if (oldChild && nestling == 0) + callOnAboutToRemoveChild(oldChild); if (m_item == oldChild) m_aboutToDelete = m_model->index(first, 0, parent); @@ -272,12 +222,7 @@ void ModelMapper::onBeginRemoveRows(const QModelIndex& parent, int first, int /* void ModelMapper::onRowRemoved(const QModelIndex& parent, int first, int /*last*/) { - int nestling = nestlingDepth(m_model->itemForIndex(parent)); - - if (nestling >= 0 || m_model->itemForIndex(parent) == m_item->parent()) - callOnAnyChildChange(nullptr); - - if (nestling == 0) + if (nestlingDepth(m_model->itemForIndex(parent)) == 0) callOnChildrenChange(nullptr); if (m_aboutToDelete.isValid() && m_aboutToDelete == m_model->index(first, 0, parent)) diff --git a/GUI/Model/BaseItem/ModelMapper.h b/GUI/Model/BaseItem/ModelMapper.h index 414931a570702eaf0ceb692cc2e38e077eb9f263..297996be75b5f34c86f8b19cff7da8fcca0841f9 100644 --- a/GUI/Model/BaseItem/ModelMapper.h +++ b/GUI/Model/BaseItem/ModelMapper.h @@ -38,12 +38,8 @@ public: void setOnChildPropertyChange(std::function<void(SessionItem*, QString)> f, const void* caller = nullptr); - void setOnParentChange(std::function<void(SessionItem*)> f, const void* caller = nullptr); - void setOnChildrenChange(std::function<void(SessionItem*)> f, const void* caller = nullptr); - void setOnAnyChildChange(std::function<void(SessionItem*)> f, const void* caller = nullptr); - void setActive(bool state) { m_active = state; } void setOnItemDestroy(std::function<void(SessionItem*)> f, const void* caller = nullptr); @@ -74,9 +70,7 @@ private: void callOnValueChange(); void callOnPropertyChange(const QString& name); void callOnChildPropertyChange(SessionItem* item, const QString& name); - void callOnParentChange(SessionItem* new_parent); void callOnChildrenChange(SessionItem* item); - void callOnAnyChildChange(SessionItem* item); void callOnAboutToRemoveChild(SessionItem* item); void clearMapper(); @@ -93,9 +87,7 @@ private: std::vector<call_t> m_onValueChange; std::vector<call_item_str_t> m_onPropertyChange; std::vector<call_item_str_t> m_onChildPropertyChange; - std::vector<call_item_t> m_onParentChange; std::vector<call_item_t> m_onChildrenChange; - std::vector<call_item_t> m_onAnyChildChange; std::vector<call_item_t> m_onItemDestroy; std::vector<call_item_t> m_onAboutToRemoveChild; QModelIndex m_aboutToDelete; diff --git a/GUI/Model/Item/InstrumentItems.cpp b/GUI/Model/Item/InstrumentItems.cpp index 197f4eff8428427048bb8d5fd972696a0423a7f8..ea18870b459edabe77bd4481a940208fa8fbe472 100644 --- a/GUI/Model/Item/InstrumentItems.cpp +++ b/GUI/Model/Item/InstrumentItems.cpp @@ -187,24 +187,29 @@ bool SpecularInstrumentItem::alignedWith(const RealDataItem* item) const { const QString native_units = item->nativeDataUnits(); if (native_units == "nbins") { - return beamItem()->inclinationAxis()->modelType() == BasicAxisItem::M_TYPE + return beamItem()->inclinationAngleItem()->uniformAlphaAxisSelected() && shape() == item->shape(); } - auto* axis_item = dynamic_cast<PointwiseAxisItem*>(beamItem()->inclinationAxis()); - if (!axis_item) + + if (!beamItem()->inclinationAngleItem()->pointwiseAlphaAxisSelected()) return false; - if (axis_item->getUnitsLabel() != native_units) + + const auto* axisItem = + dynamic_cast<const PointwiseAxisItem*>(beamItem()->inclinationAngleItem()->alphaAxis()); + ASSERT(axisItem); + + if (axisItem->getUnitsLabel() != native_units) return false; - const auto* instrument_axis = axis_item->axis(); - if (!instrument_axis) + const auto* instrumentAxis = axisItem->axis(); + if (!instrumentAxis) return false; if (!item->hasNativeData()) return false; const auto& native_axis = item->nativeOutputData()->axis(0); - return *instrument_axis == native_axis; + return *instrumentAxis == native_axis; } ICoordSystem* SpecularInstrumentItem::createCoordSystem() const diff --git a/GUI/Model/Item/JobFunctions.cpp b/GUI/Model/Item/JobFunctions.cpp index 925ad6c0ef9252b1140821f774b14f233b505d49..2377acbdbad444f81d1305ddf19a1e06c24dd75b 100644 --- a/GUI/Model/Item/JobFunctions.cpp +++ b/GUI/Model/Item/JobFunctions.cpp @@ -172,7 +172,7 @@ void GUI::Model::JobFunctions::copyRealDataItem(JobItem* jobItem, const RealData // adapting the name to job name realDataItemCopy->dataItem()->setFileName( - GUI::Model::FilenameUtils::jobReferenceFileName(jobItem->itemName())); + GUI::Model::FilenameUtils::jobReferenceFileName(jobItem->jobName())); // #baimport ++ copy members of realDataItem? diff --git a/GUI/Model/Item/JobItem.cpp b/GUI/Model/Item/JobItem.cpp index 3b074f319d1f2b6a8126479770b7b9ec343bb294..25a8e8e8597eae644b5291c7e752e0e490870f79 100644 --- a/GUI/Model/Item/JobItem.cpp +++ b/GUI/Model/Item/JobItem.cpp @@ -87,6 +87,16 @@ void JobItem::setIdentifier(const QString& identifier) setItemValue(JobItem::P_IDENTIFIER, identifier); } +QString JobItem::jobName() const +{ + return itemName(); +} + +void JobItem::setJobName(const QString& name) +{ + setItemName(name); +} + IntensityDataItem* JobItem::intensityDataItem() { return dynamic_cast<IntensityDataItem*>(getItem(T_OUTPUT)); diff --git a/GUI/Model/Item/JobItem.h b/GUI/Model/Item/JobItem.h index 30761c46a5f47b28bc3553a66e75e82723532ad2..3d29e7cde98569e840bd91a186d6b8542056f327 100644 --- a/GUI/Model/Item/JobItem.h +++ b/GUI/Model/Item/JobItem.h @@ -17,9 +17,9 @@ #include "GUI/Model/BaseItem/SessionItem.h" #include "GUI/Model/Item/InstrumentItems.h" +#include "GUI/Model/Item/MaterialItems.h" #include "GUI/Model/Item/MultiLayerItem.h" #include "GUI/Model/Item/ParameterTreeItems.h" -#include "GUI/Model/Item/MaterialItems.h" #include "GUI/Model/Model/SessionModel.h" // call to model() from templated fct #include "GUI/Support/Data/JobStatus.h" // enum cannot be forward declared #include "GUI/Support/Data/SimulationOptionsItem.h" @@ -64,6 +64,9 @@ public: QString getIdentifier() const; void setIdentifier(const QString& identifier); + QString jobName() const; + void setJobName(const QString& name); + IntensityDataItem* intensityDataItem(); DataItem* dataItem(); template <typename T> T* setDataType(); diff --git a/GUI/Model/Model/SampleModel.cpp b/GUI/Model/Item/MultiLayerItems.cpp similarity index 59% rename from GUI/Model/Model/SampleModel.cpp rename to GUI/Model/Item/MultiLayerItems.cpp index f4c8700d0a9842f8ded50170494ed2da47226a13..499b2127e5f5e27e0f961bf0f4040451ae748762 100644 --- a/GUI/Model/Model/SampleModel.cpp +++ b/GUI/Model/Item/MultiLayerItems.cpp @@ -2,8 +2,8 @@ // // BornAgain: simulate and fit reflection and scattering // -//! @file GUI/Model/Model/SampleModel.cpp -//! @brief Implements class SampleModel +//! @file GUI/Model/Item/MultiLayerItems.cpp +//! @brief Implements class MultiLayerItems //! //! @homepage http://www.bornagainproject.org //! @license GNU General Public License v3 or higher (see COPYING) @@ -12,46 +12,40 @@ // // ************************************************************************************************ -#include "GUI/Model/Model/SampleModel.h" +#include "GUI/Model/Item/MultiLayerItems.h" #include "GUI/Model/Item/ItemWithMaterial.h" #include "GUI/Model/Item/MultiLayerItem.h" #include "GUI/Model/XML/Serializer.h" #include <QApplication> -SampleModel::SampleModel() {} - -QVector<MultiLayerItem*> SampleModel::multiLayerItems() const +MultiLayerItems::~MultiLayerItems() { - return m_multiLayers; + qDeleteAll(m_multiLayers); } -QVector<ItemWithMaterial*> SampleModel::itemsWithMaterial() const +QVector<MultiLayerItem*> MultiLayerItems::multiLayerItems() const { - QVector<ItemWithMaterial*> result; - - for (auto* m : m_multiLayers) - result << m->itemsWithMaterial(); - - return result; + return m_multiLayers; } -MultiLayerItem* SampleModel::addMultiLayer() +MultiLayerItem* MultiLayerItems::addMultiLayer() { m_multiLayers << new MultiLayerItem(); return m_multiLayers.back(); } -void SampleModel::addMultiLayer(MultiLayerItem* multilayer) +void MultiLayerItems::addMultiLayer(MultiLayerItem* multilayer) { m_multiLayers << multilayer; } -void SampleModel::removeMultiLayer(MultiLayerItem* item) +void MultiLayerItems::removeMultiLayer(MultiLayerItem* multilayer) { - m_multiLayers.removeAll(item); + m_multiLayers.removeAll(multilayer); + delete multilayer; } -QStringList SampleModel::multiLayerNames() const +QStringList MultiLayerItems::multiLayerNames() const { QStringList existingNames; for (const auto* item : m_multiLayers) @@ -59,7 +53,7 @@ QStringList SampleModel::multiLayerNames() const return existingNames; } -void SampleModel::serialize(Serializer& s) +void MultiLayerItems::serialize(Serializer& s) { s.assertVersion(0); s.rw("Multilayers", m_multiLayers); diff --git a/GUI/Model/Model/SampleModel.h b/GUI/Model/Item/MultiLayerItems.h similarity index 66% rename from GUI/Model/Model/SampleModel.h rename to GUI/Model/Item/MultiLayerItems.h index ddb4cc45709c7bb9bd5681322c478e2872163b51..245669258fcf1c24ab2dd4552d295db0f5455573 100644 --- a/GUI/Model/Model/SampleModel.h +++ b/GUI/Model/Item/MultiLayerItems.h @@ -2,8 +2,8 @@ // // BornAgain: simulate and fit reflection and scattering // -//! @file GUI/Model/Model/SampleModel.h -//! @brief Defines class SampleModel +//! @file GUI/Model/Item/MultiLayerItems.h +//! @brief Defines class MultiLayerItems //! //! @homepage http://www.bornagainproject.org //! @license GNU General Public License v3 or higher (see COPYING) @@ -12,31 +12,25 @@ // // ************************************************************************************************ -#ifndef BORNAGAIN_GUI_MODEL_MODEL_SAMPLEMODEL_H -#define BORNAGAIN_GUI_MODEL_MODEL_SAMPLEMODEL_H +#ifndef BORNAGAIN_GUI_MODEL_ITEM_MULTILAYERITEMS_H +#define BORNAGAIN_GUI_MODEL_ITEM_MULTILAYERITEMS_H #include <QVector> class MultiLayerItem; -class ItemWithMaterial; class Serializer; //! Main model to hold sample items. -class SampleModel { - +class MultiLayerItems { public: - SampleModel(); - + ~MultiLayerItems(); QVector<MultiLayerItem*> multiLayerItems() const; - //! Returns vector of SessionItems having MaterialProperty on board. - QVector<ItemWithMaterial*> itemsWithMaterial() const; - //! Adds a multilayer and returns the new item. MultiLayerItem* addMultiLayer(); void addMultiLayer(MultiLayerItem* multilayer); - void removeMultiLayer(MultiLayerItem* item); + void removeMultiLayer(MultiLayerItem* multilayer); QStringList multiLayerNames() const; @@ -46,4 +40,4 @@ private: QVector<MultiLayerItem*> m_multiLayers; }; -#endif // BORNAGAIN_GUI_MODEL_MODEL_SAMPLEMODEL_H +#endif // BORNAGAIN_GUI_MODEL_ITEM_MULTILAYERITEMS_H diff --git a/GUI/Model/Item/SpecularBeamInclinationItem.cpp b/GUI/Model/Item/SpecularBeamInclinationItem.cpp index 99e467a81665e3e2d13194a0bf141d7ae68b215c..ad30a137f1f563013a5812b0468dfff75e01abc8 100644 --- a/GUI/Model/Item/SpecularBeamInclinationItem.cpp +++ b/GUI/Model/Item/SpecularBeamInclinationItem.cpp @@ -105,6 +105,16 @@ bool SpecularBeamInclinationItem::pointwiseAlphaAxisDefined() const return m_pointwiseAlphaAxis.get() != nullptr; } +bool SpecularBeamInclinationItem::pointwiseAlphaAxisSelected() const +{ + return !m_currentAxisIsUniformAxis; +} + +bool SpecularBeamInclinationItem::uniformAlphaAxisSelected() const +{ + return m_currentAxisIsUniformAxis; +} + void SpecularBeamInclinationItem::selectUniformAxis() { m_currentAxisIsUniformAxis = true; diff --git a/GUI/Model/Item/SpecularBeamInclinationItem.h b/GUI/Model/Item/SpecularBeamInclinationItem.h index a8cdabe61c3d351ec1b129e1758275580c85b777..f8334bc414b480b87fdeda2b6ae890cdb9c4d750 100644 --- a/GUI/Model/Item/SpecularBeamInclinationItem.h +++ b/GUI/Model/Item/SpecularBeamInclinationItem.h @@ -33,9 +33,20 @@ public: //! The currently selected axis BasicAxisItem* alphaAxis() const; - //! True when a pointwise axis was defined. It still is no necessarily the selected axis! + //! True if a pointwise axis was defined. + //! + //! It still is no necessarily the selected axis! + //! Not to be confused with pointwiseAlphaAxisSelected bool pointwiseAlphaAxisDefined() const; + //! True if pointwise axis is selected. + //! + //! Not to be confused with pointwiseAlphaAxisDefined + bool pointwiseAlphaAxisSelected() const; + + //! True if uniform axis is selected. + bool uniformAlphaAxisSelected() const; + void selectUniformAxis(); void selectPointwiseAxis(); diff --git a/GUI/Model/Model/ApplicationModels.cpp b/GUI/Model/Model/ApplicationModels.cpp index 3b5734dc05a45b2e035313e3abafa483708fe028..d1ccc9cc41297cca1c18abcbbe30bfe7de62304b 100644 --- a/GUI/Model/Model/ApplicationModels.cpp +++ b/GUI/Model/Model/ApplicationModels.cpp @@ -13,17 +13,14 @@ // ************************************************************************************************ #include "GUI/Model/Model/ApplicationModels.h" -#include "GUI/Model/Item/InstrumentItems.h" #include "GUI/Model/Model/JobModel.h" #include "GUI/Model/Model/RealDataModel.h" -#include "GUI/Model/Model/SampleModel.h" #include "GUI/Support/Data/SimulationOptionsItem.h" #include "GUI/Util/DeserializationException.h" #include <QXmlStreamWriter> -ApplicationModels::ApplicationModels(QObject* parent) - : QObject(parent) - , m_realDataModel(nullptr) +ApplicationModels::ApplicationModels() + : m_realDataModel(nullptr) , m_jobModel(nullptr) { //! creates and initializes models, order is important @@ -32,8 +29,6 @@ ApplicationModels::ApplicationModels(QObject* parent) connectModel(m_realDataModel); connectModel(m_jobModel); - - resetModels(); } RealDataModel* ApplicationModels::realDataModel() const @@ -46,62 +41,28 @@ JobModel* ApplicationModels::jobModel() const return m_jobModel; } -//! reset all models to initial state -void ApplicationModels::resetModels() -{ - m_realDataModel->clear(); - m_jobModel->clear(); -} - //! Writes all model in file one by one void ApplicationModels::writeTo(QXmlStreamWriter* writer) { - for (auto* model : modelList()) - model->writeTo(writer); + m_realDataModel->writeTo(writer); + m_jobModel->writeTo(writer); } void ApplicationModels::readFrom(QXmlStreamReader* reader, MessageService* messageService) { try { - for (auto* model : modelList()) { - if (reader->name().toString() == "DocumentModel") { - reader->skipCurrentElement(); - break; - } - if (reader->name().toString() == "MaterialModel") { - reader->skipCurrentElement(); - break; - } - if (reader->name().toString() == "SampleModel") { - reader->skipCurrentElement(); - break; - } - if (reader->name().toString() == "InstrumentModel") { - reader->skipCurrentElement(); - break; - } - - if (model->getModelTag() == reader->name()) { - model->readFrom(reader, messageService); - break; - } - } + if (m_realDataModel->getModelTag() == reader->name()) + m_realDataModel->readFrom(reader, messageService); + else if (m_jobModel->getModelTag() == reader->name()) + m_jobModel->readFrom(reader, messageService); } catch (DeserializationException& ex) { - resetModels(); + m_realDataModel->clear(); + m_jobModel->clear(); reader->raiseError(ex.text()); } } -//! Returns the list of all GUI models - -QList<SessionModel*> ApplicationModels::modelList() -{ - QList<SessionModel*> result; - result.append(m_realDataModel); - result.append(m_jobModel); - return result; -} QVector<SessionItem*> ApplicationModels::nonXMLItems() const { diff --git a/GUI/Model/Model/ApplicationModels.h b/GUI/Model/Model/ApplicationModels.h index 32760c1725d169f4a3ea1c3086cda56c8a3a3a98..7251cff5a4b81c3b0c664beac3bcf8f5e8fa6c4e 100644 --- a/GUI/Model/Model/ApplicationModels.h +++ b/GUI/Model/Model/ApplicationModels.h @@ -28,18 +28,14 @@ class MessageService; class ApplicationModels : public QObject { Q_OBJECT public: - explicit ApplicationModels(QObject* parent = nullptr); + ApplicationModels(); RealDataModel* realDataModel() const; JobModel* jobModel() const; - void resetModels(); - void writeTo(class QXmlStreamWriter* writer); void readFrom(class QXmlStreamReader* reader, MessageService* messageService); - QList<SessionModel*> modelList(); - //! Returns all non-XML items QVector<SessionItem*> nonXMLItems() const; diff --git a/GUI/Model/Project/ProjectDocument.cpp b/GUI/Model/Project/ProjectDocument.cpp index 947e2ebb5caf9f6a59ff725a56f34b55902c220d..13590477bd90ad1439486c6fe962b1e6b693a865 100644 --- a/GUI/Model/Project/ProjectDocument.cpp +++ b/GUI/Model/Project/ProjectDocument.cpp @@ -18,7 +18,6 @@ #include "GUI/Model/Item/MaterialItem.h" #include "GUI/Model/Item/MultiLayerItem.h" #include "GUI/Model/Model/JobModel.h" -#include "GUI/Model/Model/SampleModel.h" #include "GUI/Model/Project/LinkInstrumentManager.h" #include "GUI/Model/Project/OutputDataIOService.h" #include "GUI/Model/XML/Serializer.h" @@ -132,9 +131,9 @@ InstrumentItems* ProjectDocument::instrumentItems() const return const_cast<InstrumentItems*>(&m_instruments); } -SampleModel* ProjectDocument::sampleModel() +MultiLayerItems* ProjectDocument::multiLayerItems() { - return &m_samples; + return &m_multiLayerItems; } RealDataModel* ProjectDocument::realDataModel() const @@ -348,7 +347,7 @@ ProjectDocument::ReadResult ProjectDocument::readProject(QIODevice* device, GUI::Session::XML::assertExpectedTag(&reader, SimulationOptionsTag); } else if (reader.name() == SamplesTag) { Serializer s(&reader); - m_samples.serialize(s); + m_multiLayerItems.serialize(s); // cleanup if (reader.name() != SamplesTag) { if (!reader.isEndElement()) @@ -378,15 +377,6 @@ ProjectDocument::ReadResult ProjectDocument::readProject(QIODevice* device, } } - // make a sanity check whether all materials are present - for (const auto* multiLayerItem : m_samples.multiLayerItems()) - for (const auto* itemWithMaterial : multiLayerItem->itemsWithMaterial()) - if (itemWithMaterial->materialItem() == nullptr) { - QString message = QString("Material link is broken (id: '%1')") - .arg(itemWithMaterial->materialIdentifier()); - messageService.addError(this, message); - return ReadResult::error; - } } catch (DeserializationException& ex) { reader.raiseError(ex.text()); } @@ -422,7 +412,7 @@ void ProjectDocument::writeTo(QIODevice* device) writer.writeStartElement(SamplesTag); Serializer s(&writer); - m_samples.serialize(s); + m_multiLayerItems.serialize(s); writer.writeEndElement(); writer.writeStartElement(InstrumentsTag); diff --git a/GUI/Model/Project/ProjectDocument.h b/GUI/Model/Project/ProjectDocument.h index 20684b85f63a6aaa7c08bc329918cec3f6d817b8..cf4312be473a42a60b84f64ce5e538152f99d329 100644 --- a/GUI/Model/Project/ProjectDocument.h +++ b/GUI/Model/Project/ProjectDocument.h @@ -17,7 +17,7 @@ #include "GUI/Model/Item/InstrumentItems.h" #include "GUI/Model/Model/ApplicationModels.h" -#include "GUI/Model/Model/SampleModel.h" +#include "GUI/Model/Item/MultiLayerItems.h" #include "GUI/Model/Project/InstrumentsEditController.h" #include "GUI/Support/Data/SimulationOptionsItem.h" #include <QObject> @@ -27,8 +27,6 @@ class QIODevice; class MessageService; class OutputDataIOService; -class InstrumentItems; -class SampleModel; class RealDataModel; class JobModel; class LinkInstrumentManager; @@ -72,7 +70,7 @@ public: void setProjectFileName(const QString& projectFileName); InstrumentItems* instrumentItems() const; - SampleModel* sampleModel(); + MultiLayerItems* multiLayerItems(); RealDataModel* realDataModel() const; JobModel* jobModel() const; SimulationOptionsItem* simulationOptionsItem(); @@ -144,7 +142,7 @@ private: bool m_singleSampleMode; Functionalities m_functionalities; SimulationOptionsItem m_simulationOptionsItem; - SampleModel m_samples; + MultiLayerItems m_multiLayerItems; InstrumentsEditController m_instrumentEditController; InstrumentItems m_instruments; }; diff --git a/GUI/Model/Sample/SampleValidator.h b/GUI/Model/Sample/SampleValidator.h index dd0e6a207fafba97b892ec156e67bf1cf2b8548c..139f9b1abc5fdfb6e5141b6543b3ee6fb961ce7f 100644 --- a/GUI/Model/Sample/SampleValidator.h +++ b/GUI/Model/Sample/SampleValidator.h @@ -21,7 +21,7 @@ class MultiLayerItem; class LayerItem; class ItemWithParticles; -//! Validates SampleModel for MultiLayerItem suitable for simulation +//! Validates whether MultiLayerItem is suitable for simulation class SampleValidator { public: bool isValidMultiLayer(const MultiLayerItem* multilayer); diff --git a/GUI/View/FromDomain/GUIObjectBuilder.h b/GUI/View/FromDomain/GUIObjectBuilder.h index c256a13ac27b05d66456523a9e8fe9c9f11a077b..badc0c8adc78be8ec6e90052d3ebe928aeb8d34c 100644 --- a/GUI/View/FromDomain/GUIObjectBuilder.h +++ b/GUI/View/FromDomain/GUIObjectBuilder.h @@ -21,8 +21,6 @@ class SimulationOptionsItem; class ISimulation; class InstrumentItems; class MultiLayer; -class SampleModel; -class SessionItem; class MultiLayerItem; //! Contains set of methods to populate GUI models with content from domain. diff --git a/GUI/View/Instrument/InclinationAnglesEditor.cpp b/GUI/View/Instrument/InclinationAnglesEditor.cpp index 05ee1cab4a9578b938eaf8b3c983ac1e69289207..4c987e1e548570423f127f3893105ac615d6fbee 100644 --- a/GUI/View/Instrument/InclinationAnglesEditor.cpp +++ b/GUI/View/Instrument/InclinationAnglesEditor.cpp @@ -51,7 +51,7 @@ InclinationAnglesEditor::InclinationAnglesEditor(QWidget* parent, SpecularBeamIn m_form = new SphericalAxisForm(gform, gbox); - const int idx = dynamic_cast<const PointwiseAxisItem*>(m_item->alphaAxis()) ? 1 : 0; + const int idx = m_item->pointwiseAlphaAxisSelected() ? 1 : 0; ASSERT(idx != -1); if (idx != m_typeComboBox->currentIndex()) m_typeComboBox->setCurrentIndex(idx); @@ -76,10 +76,10 @@ void InclinationAnglesEditor::updateIndicators() void InclinationAnglesEditor::onAxisTypeSelected(int index) { if (m_item) { - if (index == 0 && dynamic_cast<const PointwiseAxisItem*>(m_item->alphaAxis())) { + if (index == 0 && m_item->pointwiseAlphaAxisSelected()) { m_item->selectUniformAxis(); emit dataChanged(); - } else if (index == 1 && !dynamic_cast<const PointwiseAxisItem*>(m_item->alphaAxis())) { + } else if (index == 1 && !m_item->pointwiseAlphaAxisSelected()) { m_item->selectPointwiseAxis(); emit dataChanged(); } diff --git a/GUI/View/Job/JobListModel.cpp b/GUI/View/Job/JobListModel.cpp index bdd5838026e704d8e2aaea90ee9152d07ea86bc1..e69395a86b8143ed81b014157c9f008e1184e1d2 100644 --- a/GUI/View/Job/JobListModel.cpp +++ b/GUI/View/Job/JobListModel.cpp @@ -55,7 +55,7 @@ QVariant JobListModel::data(const QModelIndex& index, int role) const JobItem* item = jobs[index.row()]; if (role == Qt::DisplayRole) - return item->itemName(); + return item->jobName(); return {}; } diff --git a/GUI/View/Job/JobListView.cpp b/GUI/View/Job/JobListView.cpp index dd09a20745e31ce61c516c87e206c8ee6ab83d6f..72fd803d422f2357993764da7bd1d7dfca491fb3 100644 --- a/GUI/View/Job/JobListView.cpp +++ b/GUI/View/Job/JobListView.cpp @@ -207,7 +207,7 @@ void JobListView::showContextMenu(const QPoint&) std::sort(indexes.begin(), indexes.end(), row_ascending); for (const QModelIndex& index : indexes) { JobItem* job = m_model->jobForIndex(index); - QAction* action = m_equalizeMenu->addAction(QString("to ").append(job->itemName())); + QAction* action = m_equalizeMenu->addAction(QString("to ").append(job->jobName())); connect(action, &QAction::triggered, this, [this, job] { equalizeSelectedToJob(job); }); } m_equalizeMenu->setEnabled(true); diff --git a/GUI/View/Job/JobListViewDelegate.cpp b/GUI/View/Job/JobListViewDelegate.cpp index 5254735e3bffc495513cb92aaa64493eecec5709..c9911c9a6ff0f5117528ca4018ea2430531533fc 100644 --- a/GUI/View/Job/JobListViewDelegate.cpp +++ b/GUI/View/Job/JobListViewDelegate.cpp @@ -49,9 +49,8 @@ void JobListViewDelegate::paint(QPainter* painter, const QStyleOptionViewItem& o painter->setRenderHint(QPainter::Antialiasing, true); - QString text = item->itemName(); QRect textRect = getTextRect(option.rect); - painter->drawText(textRect, text); + painter->drawText(textRect, item->jobName()); drawCustomProjectBar(item, painter, option); diff --git a/GUI/View/Job/JobPropertiesTableModel.cpp b/GUI/View/Job/JobPropertiesTableModel.cpp index 78523d95a4db3afdf21f5a265968908e8cc7ff08..52c695d144178d09d55ca39de05a3777eaf266f8 100644 --- a/GUI/View/Job/JobPropertiesTableModel.cpp +++ b/GUI/View/Job/JobPropertiesTableModel.cpp @@ -83,7 +83,7 @@ QVariant JobPropertiesTableModel::data(const QModelIndex& index, int role) const case Column::Value: { switch (index.row()) { case Row::Name: - return m_item->itemName(); + return m_item->jobName(); case Row::Sample: return m_item->sampleName(); case Row::Instrument: @@ -135,7 +135,7 @@ bool JobPropertiesTableModel::setData(const QModelIndex& index, const QVariant& if (role != Qt::EditRole || index.column() != Column::Value || index.row() != Row::Name || !m_item) return false; - m_item->setItemName(value.toString()); + m_item->setJobName(value.toString()); emit dataChanged(index, index, {role}); return true; } diff --git a/GUI/View/MaterialEditor/MaterialEditorDialog.cpp b/GUI/View/MaterialEditor/MaterialEditorDialog.cpp index 76ea098c1e4d7cadf49bc2052e10bbcf19a5c4a5..545c6f06c9207f36f520511382669fa5f1cbcc65 100644 --- a/GUI/View/MaterialEditor/MaterialEditorDialog.cpp +++ b/GUI/View/MaterialEditor/MaterialEditorDialog.cpp @@ -18,7 +18,6 @@ #include "GUI/Model/Item/MaterialItem.h" #include "GUI/Model/Item/MultiLayerItem.h" #include "GUI/Model/Item/MaterialItems.h" -#include "GUI/Model/Model/SampleModel.h" #include "GUI/Model/Types/DoubleDescriptor.h" #include "GUI/View/MaterialEditor/MaterialEditorModel.h" #include "GUI/View/Tool/EditUtil.h" diff --git a/GUI/View/Project/PyImportAssistant.h b/GUI/View/Project/PyImportAssistant.h index 4a0ee3e76ce93e5e1432a1041e626dd336a2522a..e3fce3462b5c0a486ed0fdddbd47f75226fb0262 100644 --- a/GUI/View/Project/PyImportAssistant.h +++ b/GUI/View/Project/PyImportAssistant.h @@ -19,7 +19,6 @@ #include <memory> -class SampleModel; class MultiLayerItem; class MultiLayer; diff --git a/GUI/View/SampleDesigner/SampleListModel.cpp b/GUI/View/SampleDesigner/SampleListModel.cpp index fc36ea5c0d57261c184c6c6875e2ba54396a6938..af562f3f9b171ba12ee756162427a05836dbc390 100644 --- a/GUI/View/SampleDesigner/SampleListModel.cpp +++ b/GUI/View/SampleDesigner/SampleListModel.cpp @@ -15,7 +15,7 @@ #include "GUI/View/SampleDesigner/SampleListModel.h" #include "Base/Util/Assert.h" #include "GUI/Model/Item/MultiLayerItem.h" -#include "GUI/Model/Model/SampleModel.h" +#include "GUI/Model/Item/MultiLayerItems.h" #include "GUI/Util/String.h" #include "GUI/View/FromDomain/GUIExamplesFactory.h" #include "GUI/View/FromDomain/GUISampleBuilder.h" @@ -25,24 +25,18 @@ #include "Sample/Multilayer/MultiLayer.h" #include <QIcon> -SampleListModel::SampleListModel(QObject* parent, SampleModel* model) +SampleListModel::SampleListModel(QObject* parent, MultiLayerItems* model) : QAbstractListModel(parent) - , m_sampleModel(model) + , m_multiLayerItems(model) { } -MultiLayerItem* SampleListModel::topMostItem() const -{ - ASSERT(!m_sampleModel->multiLayerItems().isEmpty()); - return m_sampleModel->multiLayerItems().first(); -} - int SampleListModel::rowCount(const QModelIndex& parent) const { if (parent.isValid()) return 0; - return m_sampleModel->multiLayerItems().size(); + return m_multiLayerItems->multiLayerItems().size(); } QVariant SampleListModel::data(const QModelIndex& index, int role) const @@ -105,12 +99,12 @@ MultiLayerItem* SampleListModel::itemForIndex(const QModelIndex& index) const if (!index.isValid()) return nullptr; - return m_sampleModel->multiLayerItems()[index.row()]; + return m_multiLayerItems->multiLayerItems()[index.row()]; } QModelIndex SampleListModel::indexForItem(MultiLayerItem* item) const { - if (auto row = m_sampleModel->multiLayerItems().indexOf(item); row >= 0) + if (auto row = m_multiLayerItems->multiLayerItems().indexOf(item); row >= 0) return index(row, 0); return QModelIndex(); @@ -123,17 +117,17 @@ void SampleListModel::removeSample(MultiLayerItem* item) return; beginRemoveRows(index.parent(), index.row(), index.row()); - m_sampleModel->removeMultiLayer(item); + m_multiLayerItems->removeMultiLayer(item); endRemoveRows(); } QModelIndex SampleListModel::createSample() { - const QStringList existingNames = m_sampleModel->multiLayerNames(); + const QStringList existingNames = m_multiLayerItems->multiLayerNames(); - const int row = m_sampleModel->multiLayerItems().size(); + const int row = m_multiLayerItems->multiLayerItems().size(); beginInsertRows(QModelIndex(), row, row); - auto* multilayer_item = m_sampleModel->addMultiLayer(); + auto* multilayer_item = m_multiLayerItems->addMultiLayer(); multilayer_item->setSampleName(GUI::Util::String::suggestName(existingNames, "Sample")); multilayer_item->addStandardMaterials(); endInsertRows(); @@ -152,9 +146,9 @@ QModelIndex SampleListModel::createSampleFromExamples(const QString& className, sample->setSampleName(title); sample->setDescription(description); - const int row = m_sampleModel->multiLayerItems().size(); + const int row = m_multiLayerItems->multiLayerItems().size(); beginInsertRows(QModelIndex(), row, row); - m_sampleModel->addMultiLayer(sample); + m_multiLayerItems->addMultiLayer(sample); endInsertRows(); return indexForItem(sample); } catch (const GUI::Transform::FromDomain::GUISampleBuilder::Exception& ex) { @@ -180,9 +174,9 @@ QModelIndex SampleListModel::createSampleFromPython() sample->setDescription("Imported from python code"); - const int row = m_sampleModel->multiLayerItems().size(); + const int row = m_multiLayerItems->multiLayerItems().size(); beginInsertRows(QModelIndex(), row, row); - m_sampleModel->addMultiLayer(sample); + m_multiLayerItems->addMultiLayer(sample); endInsertRows(); return indexForItem(sample); } diff --git a/GUI/View/SampleDesigner/SampleListModel.h b/GUI/View/SampleDesigner/SampleListModel.h index 30167e59dd25b74388b25dff8a2b5199de79a617..f2dbf8a594f0be4e0e9572729d05ede9d1dac1e2 100644 --- a/GUI/View/SampleDesigner/SampleListModel.h +++ b/GUI/View/SampleDesigner/SampleListModel.h @@ -17,13 +17,13 @@ #include <QAbstractItemModel> -class SampleModel; +class MultiLayerItems; class MultiLayerItem; //! List model for sample selection (used in the left pane of the layer oriented sample editor) class SampleListModel : public QAbstractListModel { public: - SampleListModel(QObject* parent, SampleModel* model); + SampleListModel(QObject* parent, MultiLayerItems* model); int rowCount(const QModelIndex& parent = QModelIndex()) const override; QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override; @@ -36,9 +36,6 @@ public: //! Remove the given multilayer. nullptr is allowed. void removeSample(MultiLayerItem* item); - //! The topmost visible item. Can be null of course. - MultiLayerItem* topMostItem() const; - //! Create a new sample (multilayer) and return the index of it. QModelIndex createSample(); @@ -56,7 +53,7 @@ public: #endif private: - SampleModel* m_sampleModel = nullptr; + MultiLayerItems* m_multiLayerItems = nullptr; }; #endif // BORNAGAIN_GUI_VIEW_SAMPLEDESIGNER_SAMPLELISTMODEL_H diff --git a/GUI/View/SampleDesigner/SampleListView.cpp b/GUI/View/SampleDesigner/SampleListView.cpp index 0a6ed8f0598cda8cdd0af60174d70705c412b79d..dc9782a73383655609662a2f990d31c73e2b9f61 100644 --- a/GUI/View/SampleDesigner/SampleListView.cpp +++ b/GUI/View/SampleDesigner/SampleListView.cpp @@ -71,7 +71,7 @@ SampleListView::SampleListView(QWidget* parent, ProjectDocument* document) : QListView(parent) , m_document(document) { - m_model = new SampleListModel(this, document->sampleModel()); + m_model = new SampleListModel(this, document->multiLayerItems()); setContextMenuPolicy(Qt::CustomContextMenu); setModel(m_model); @@ -145,9 +145,9 @@ MultiLayerItem* SampleListView::currentSample() void SampleListView::selectFirstSample() { - if (m_document->sampleModel()->multiLayerItems().isEmpty()) + if (m_document->multiLayerItems()->multiLayerItems().isEmpty()) return; - setCurrentSample(m_document->sampleModel()->multiLayerItems()[0]); + setCurrentSample(m_document->multiLayerItems()->multiLayerItems()[0]); } QAction* SampleListView::newSampleAction() diff --git a/GUI/View/SampleDesigner/SampleView.cpp b/GUI/View/SampleDesigner/SampleView.cpp index 163f728640017379c4c8e8279da7ae7873c89145..950befca21c9a4a85d6746569283b7719cfe204a 100644 --- a/GUI/View/SampleDesigner/SampleView.cpp +++ b/GUI/View/SampleDesigner/SampleView.cpp @@ -17,7 +17,6 @@ #include "GUI/Model/Item/LayerItem.h" #include "GUI/Model/Item/MultiLayerItem.h" #include "GUI/Model/Item/ParticleLayoutItem.h" -#include "GUI/Model/Model/SampleModel.h" #include "GUI/Model/Project/ProjectDocument.h" #include "GUI/View/Common/DocksController.h" #include "GUI/View/Common/StyledToolBar.h" @@ -67,7 +66,7 @@ SampleView::SampleView(QWidget* parent, ProjectDocument* document) m_sampleSelectionView->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); - auto* scriptPanel = new ScriptPanel(m_document->sampleModel(), this); + auto* scriptPanel = new ScriptPanel(this); m_realSpacePanel = new RealSpacePanel(this); sampleSelectionPane->setWindowTitle("Samples"); diff --git a/GUI/View/SampleDesigner/ScriptPanel.cpp b/GUI/View/SampleDesigner/ScriptPanel.cpp index 5eda1982bcbee86842b366fa1329a85e6a2b7355..d16dd9ce8e8e5e3b184053ffd75bb3b2ff58ebf0 100644 --- a/GUI/View/SampleDesigner/ScriptPanel.cpp +++ b/GUI/View/SampleDesigner/ScriptPanel.cpp @@ -32,10 +32,9 @@ namespace { const int accumulateUpdatesDuringMsec = 20.; } -ScriptPanel::ScriptPanel(SampleModel* sampleModel, QWidget* parent) +ScriptPanel::ScriptPanel(QWidget* parent) : QWidget(parent) , m_textEdit(new QTextEdit) - , m_sampleModel(sampleModel) , m_highlighter(nullptr) , m_updateTimer(new UpdateTimer(accumulateUpdatesDuringMsec, this)) , m_cautionSign(new CautionSign(m_textEdit)) diff --git a/GUI/View/SampleDesigner/ScriptPanel.h b/GUI/View/SampleDesigner/ScriptPanel.h index 8c799f37e690096a80e02c9e443337d704764fdd..df24407c04d46c9aa1da98c9783dc171564d8b25 100644 --- a/GUI/View/SampleDesigner/ScriptPanel.h +++ b/GUI/View/SampleDesigner/ScriptPanel.h @@ -17,7 +17,6 @@ #include <QWidget> -class SampleModel; class PythonSyntaxHighlighter; class UpdateTimer; class CautionSign; @@ -33,7 +32,7 @@ class ScriptPanel : public QWidget { Q_OBJECT public: - explicit ScriptPanel(SampleModel* sampleModel, QWidget* parent); + explicit ScriptPanel(QWidget* parent); void setCurrentSample(MultiLayerItem* multiLayerItem); void onSampleModified(); @@ -50,7 +49,6 @@ private: void updateEditor(); QTextEdit* m_textEdit; - SampleModel* m_sampleModel; PythonSyntaxHighlighter* m_highlighter; UpdateTimer* m_updateTimer; CautionSign* m_cautionSign; diff --git a/GUI/View/Toplevel/ProjectSettingsView.cpp b/GUI/View/Toplevel/ProjectSettingsView.cpp index 3b37320984692ca2a24fa97de20d46baf35e2c3d..49ad78501ad23378f838cf36f34791d5d6ba0248 100644 --- a/GUI/View/Toplevel/ProjectSettingsView.cpp +++ b/GUI/View/Toplevel/ProjectSettingsView.cpp @@ -14,8 +14,6 @@ #include "GUI/View/Toplevel/ProjectSettingsView.h" #include "GUI/Application/ApplicationSettings.h" -#include "GUI/Model/Item/InstrumentItems.h" -#include "GUI/Model/Model/SampleModel.h" #include "GUI/Util/Path.h" #include "GUI/View/Tool/GroupBoxCollapser.h" #include "ui_ProjectSettingsView.h" @@ -137,7 +135,7 @@ void ProjectSettingsView::onSingleInstrumentRadioToggled(bool newState) void ProjectSettingsView::onSingleSampleRadioToggled(bool newState) { if (newState) { - if (m_document->sampleModel()->multiLayerItems().size() > 1) { + if (m_document->multiLayerItems()->multiLayerItems().size() > 1) { QMessageBox::warning(this, "Select single sample mode", "This project already contains more than one sample. Changing " "this setting is not possible."); diff --git a/GUI/View/Toplevel/SessionModelView.cpp b/GUI/View/Toplevel/SessionModelView.cpp index bb8ad32c611f5750cfe8254a4a8513fa97d2ce22..2015b27bc7ed398ae9d3743832aa9ccbb52ff37c 100644 --- a/GUI/View/Toplevel/SessionModelView.cpp +++ b/GUI/View/Toplevel/SessionModelView.cpp @@ -17,7 +17,6 @@ #include "GUI/Model/Model/JobModel.h" #include "GUI/Model/Item/MaterialItems.h" #include "GUI/Model/Model/RealDataModel.h" -#include "GUI/Model/Model/SampleModel.h" #include "GUI/Util/ComboProperty.h" #include "GUI/View/Project/ProjectManager.h" #include "GUI/View/Tool/StyleUtils.h" diff --git a/GUI/View/Toplevel/SimulationView.cpp b/GUI/View/Toplevel/SimulationView.cpp index 016f6313069148ef2110d49a50f65161adc683b4..c67a78f966e5682aceb3cfbfeacdf587b2241468 100644 --- a/GUI/View/Toplevel/SimulationView.cpp +++ b/GUI/View/Toplevel/SimulationView.cpp @@ -19,7 +19,6 @@ #include "GUI/Model/Item/RealDataItem.h" #include "GUI/Model/Model/JobModel.h" #include "GUI/Model/Model/RealDataModel.h" -#include "GUI/Model/Model/SampleModel.h" #include "GUI/Model/Project/ProjectDocument.h" #include "GUI/Model/Sample/SampleValidator.h" #include "GUI/Support/Data/SimulationOptionsItem.h" @@ -108,7 +107,7 @@ void SimulationView::writeOptionsToUI() // -- selection group updateSelection(m_ui->instrumentCombo, m_document->instrumentItems()->instrumentNames()); - updateSelection(m_ui->sampleCombo, m_document->sampleModel()->multiLayerNames()); + updateSelection(m_ui->sampleCombo, m_document->multiLayerItems()->multiLayerNames()); updateSelection(m_ui->realDataCombo, m_document->realDataModel()->realDataNames(), true); // -- options group @@ -233,7 +232,7 @@ void SimulationView::updateFunctionalityNarrowing() QVector<MultiLayerItem*> SimulationView::multiLayerItems() const { - return m_document->sampleModel()->multiLayerItems(); + return m_document->multiLayerItems()->multiLayerItems(); } QVector<InstrumentItem*> SimulationView::instrumentItems() const diff --git a/Tests/Functional/GUI/Check.cpp b/Tests/Functional/GUI/Check.cpp index dbb8ad08dfb026e6f6f4d19d0c5bac5f08eeaa1e..1f4e303f49559c8b3ed69b6cc763c61afecb7257 100644 --- a/Tests/Functional/GUI/Check.cpp +++ b/Tests/Functional/GUI/Check.cpp @@ -22,7 +22,6 @@ #include "GUI/Model/Item/InstrumentItems.h" #include "GUI/Model/Item/MultiLayerItem.h" #include "GUI/Model/Item/MaterialItems.h" -#include "GUI/Model/Model/SampleModel.h" #include "GUI/Model/To/DomainSimulationBuilder.h" #include "GUI/Support/Data/SimulationOptionsItem.h" #include "GUI/View/FromDomain/GUIObjectBuilder.h" diff --git a/Tests/Unit/GUI/TestMapperForItem.cpp b/Tests/Unit/GUI/TestMapperForItem.cpp index 472fa8bc1f1c63287c675d4d0ce01cde25ffd446..c6f763243458235e2776293446747de39291a214 100644 --- a/Tests/Unit/GUI/TestMapperForItem.cpp +++ b/Tests/Unit/GUI/TestMapperForItem.cpp @@ -11,7 +11,6 @@ public: Widget() : m_onPropertyChangeCount(0) , m_onChildPropertyChangeCount(0) - , m_onParentChangeCount(0) , m_onChildrenChangeCount(0) , m_onAboutToRemoveChild(0) { @@ -21,7 +20,6 @@ public: { m_onPropertyChangeCount = 0; m_onChildPropertyChangeCount = 0; - m_onParentChangeCount = 0; m_onChildrenChangeCount = 0; m_onAboutToRemoveChild = 0; m_reported_items.clear(); @@ -39,8 +37,6 @@ public: mapper->setOnChildPropertyChange( [this](SessionItem* item, QString name) { onChildPropertyChange(item, name); }, caller); - mapper->setOnParentChange([this](SessionItem* parent) { onParentChange(parent); }, caller); - mapper->setOnChildrenChange([this](SessionItem*) { onChildrenChange(); }, caller); mapper->setOnAboutToRemoveChild([this](SessionItem* item) { onAboutToRemoveChild(item); }, @@ -60,12 +56,6 @@ public: m_onChildPropertyChangeCount++; } - void onParentChange(SessionItem* item) - { - m_reported_items.append(item); - m_onParentChangeCount++; - } - void onChildrenChange() { m_onChildrenChangeCount++; } void unsubscribe(ModelMapper* mapper) { mapper->unsubscribe(this); } @@ -78,7 +68,6 @@ public: int m_onPropertyChangeCount; int m_onChildPropertyChangeCount; - int m_onParentChangeCount; int m_onChildrenChangeCount; int m_onAboutToRemoveChild; QList<SessionItem*> m_reported_items; @@ -110,7 +99,6 @@ TEST_F(TestMapperForItem, initialCondition) Widget w; EXPECT_EQ(w.m_onPropertyChangeCount, 0); EXPECT_EQ(w.m_onChildPropertyChangeCount, 0); - EXPECT_EQ(w.m_onParentChangeCount, 0); EXPECT_EQ(w.m_onChildrenChangeCount, 0); EXPECT_TRUE(w.m_reported_items.isEmpty()); EXPECT_TRUE(w.m_reported_names.isEmpty()); diff --git a/Tests/Unit/GUI/TestParaCrystalItems.cpp b/Tests/Unit/GUI/TestParaCrystalItems.cpp index 23fd72064fa646e7fa93c6af1cd0b5e9bfcd65f3..acf90e9de744ab2ee78786f0b464db1bf59477e3 100644 --- a/Tests/Unit/GUI/TestParaCrystalItems.cpp +++ b/Tests/Unit/GUI/TestParaCrystalItems.cpp @@ -5,7 +5,6 @@ #include "GUI/Model/Item/LayerItem.h" #include "GUI/Model/Item/MultiLayerItem.h" #include "GUI/Model/Item/ParticleLayoutItem.h" -#include "GUI/Model/Model/SampleModel.h" #include "GUI/View/FromDomain/FromDomain.h" #include "Sample/Aggregate/Interference2DParaCrystal.h" #include "Tests/GTestWrapper/google_test.h" diff --git a/Tests/Unit/GUI/TestRealSpaceBuilderUtils.cpp b/Tests/Unit/GUI/TestRealSpaceBuilderUtils.cpp index d433e3bbe0bb7c188dcd4f283708ba234c96927b..368ec54792ad1972f8b2e56b9c870ee5b6e002d6 100644 --- a/Tests/Unit/GUI/TestRealSpaceBuilderUtils.cpp +++ b/Tests/Unit/GUI/TestRealSpaceBuilderUtils.cpp @@ -4,7 +4,6 @@ #include "GUI/Model/Item/ParticleLayoutItem.h" #include "GUI/Model/Model/ApplicationModels.h" #include "GUI/Model/Item/MaterialItems.h" -#include "GUI/Model/Model/SampleModel.h" #include "GUI/View/Realspace/Particle3DContainer.h" #include "GUI/View/Realspace/RealSpaceBuilder.h" #include "GUI/View/Realspace/RealSpaceBuilderUtils.h" diff --git a/Tests/Unit/GUI/TestSessionModel.cpp b/Tests/Unit/GUI/TestSessionModel.cpp index 4e67ec69c0f0458fc5783c834886bd3030ba5b51..f4f3d31ede14f8d72c3d09d773f87062e59c1c37 100644 --- a/Tests/Unit/GUI/TestSessionModel.cpp +++ b/Tests/Unit/GUI/TestSessionModel.cpp @@ -5,7 +5,6 @@ #include "GUI/Model/Item/MaskItems.h" #include "GUI/Model/Item/MultiLayerItem.h" #include "GUI/Model/Model/JobModel.h" -#include "GUI/Model/Model/SampleModel.h" #include "GUI/Support/Data/SessionItemTags.h" #include "Tests/GTestWrapper/google_test.h" #include <QSignalSpy> diff --git a/Tests/Unit/GUI/TestSessionXML.cpp b/Tests/Unit/GUI/TestSessionXML.cpp index 6afb04e462ce241dbcd1d7651f35d685970d24b4..60825f63f03b938dbaf69091c55c5d788146f327 100644 --- a/Tests/Unit/GUI/TestSessionXML.cpp +++ b/Tests/Unit/GUI/TestSessionXML.cpp @@ -9,7 +9,6 @@ #include "GUI/Model/Item/ParticleLayoutItem.h" #include "GUI/Model/Item/RectangularDetectorItem.h" #include "GUI/Model/Model/JobModel.h" -#include "GUI/Model/Model/SampleModel.h" #include "GUI/Model/Model/SessionModel.h" #include "GUI/Model/Model/SessionXML.h" #include "GUI/Model/XML/Serializer.h"