diff --git a/GUI/Models/DomainObjectBuilder.cpp b/GUI/Models/DomainObjectBuilder.cpp index 5081deeb48d4ab6286b0afae6ee42ccdbd8ea967..60d69e09415b8ff36f6881e3151de442e09b8eef 100644 --- a/GUI/Models/DomainObjectBuilder.cpp +++ b/GUI/Models/DomainObjectBuilder.cpp @@ -27,9 +27,8 @@ GUI::Model::DomainObjectBuilder::buildMultiLayer(const MultiLayerItem& multilaye auto P_multilayer = GUI::Transform::ToDomain::createMultiLayer(multilayer_item); for (LayerItem* child : multilayer_item.childrenOfType<LayerItem>()) { auto P_layer = buildLayer(*child); - auto roughnessItem = child->roughness(); - ASSERT(roughnessItem); - auto P_roughness = GUI::Transform::ToDomain::createLayerRoughness(*roughnessItem); + const auto roughness = child->roughness().currentItem(); + auto P_roughness = GUI::Transform::ToDomain::createLayerRoughness(roughness); if (P_layer) { if (P_roughness) P_multilayer->addLayerWithTopRoughness(*P_layer, *P_roughness); diff --git a/GUI/Models/InterferenceItems.cpp b/GUI/Models/InterferenceItems.cpp index 5ece284558dfecbf03cfd3d69cd31ea1ba1f2c6e..762d6cb5bab1e657e0e42be2012f511c5cbc3f73 100644 --- a/GUI/Models/InterferenceItems.cpp +++ b/GUI/Models/InterferenceItems.cpp @@ -14,6 +14,7 @@ #include "GUI/Models/InterferenceItems.h" #include "Base/Const/Units.h" +#include "GUI/Models/ComboProperty.h" #include "GUI/Models/DoubleDescriptor.h" #include "GUI/Models/FTDecayFunctionItems.h" #include "GUI/Models/FTDistributionItems.h" @@ -86,6 +87,11 @@ DoubleDescriptor Interference1DLatticeItem::rotationAngle() const return d; } +SelectionDescriptor<FTDecayFunction1DItem*> Interference1DLatticeItem::decayFunction() const +{ + return SelectionDescriptor<FTDecayFunction1DItem*>(item<GroupItem>(P_DECAY_FUNCTION)); +} + // --------------------------------------------------------------------------------------------- // Lattice2DItem* Interference2DAbstractLatticeItem::latticeType() const @@ -424,3 +430,9 @@ DoubleDescriptor InterferenceRadialParaCrystalItem::kappa() const { return DoubleDescriptor(getItem(P_KAPPA), Unit::unitless); } + +SelectionDescriptor<FTDistribution1DItem*> +InterferenceRadialParaCrystalItem::probabilityDistribution() const +{ + return SelectionDescriptor<FTDistribution1DItem*>(item<GroupItem>(P_PDF)); +} diff --git a/GUI/Models/InterferenceItems.h b/GUI/Models/InterferenceItems.h index b079d5a20e1c23f2444fceae0b07f5619beaed28..d808544e9fef39856db72c1a4488af7ed67fc49e 100644 --- a/GUI/Models/InterferenceItems.h +++ b/GUI/Models/InterferenceItems.h @@ -15,6 +15,7 @@ #ifndef BORNAGAIN_GUI_MODELS_INTERFERENCEITEMS_H #define BORNAGAIN_GUI_MODELS_INTERFERENCEITEMS_H +#include "GUI/Models/SelectionDescriptor.h" #include "GUI/Models/SessionGraphicsItem.h" class FTDecayFunction1DItem; @@ -55,6 +56,7 @@ public: DoubleDescriptor rotationAngle() const; template <typename T> T* setDecayFunctionType(); + SelectionDescriptor<FTDecayFunction1DItem*> decayFunction() const; }; class Interference2DAbstractLatticeItem : public InterferenceItem { @@ -167,7 +169,7 @@ public: DoubleDescriptor dampingLength() const; DoubleDescriptor domainSize() const; DoubleDescriptor kappa() const; - + SelectionDescriptor<FTDistribution1DItem*> probabilityDistribution() const; template <typename T> T* setPDFType(); }; diff --git a/GUI/Models/ItemWithParticles.cpp b/GUI/Models/ItemWithParticles.cpp index 3b9543c97f67db6b318446d691899230a3a37d78..f6e33af1a068c9bfa2120f5242720a93b0188370 100644 --- a/GUI/Models/ItemWithParticles.cpp +++ b/GUI/Models/ItemWithParticles.cpp @@ -60,6 +60,12 @@ void ItemWithParticles::setTransformation(RotationItem* transformation) model()->moveItem(transformation, this, -1, T_TRANSFORMATION); } +RotationItem* ItemWithParticles::rotationItem() const +{ + auto* transformationItem = dynamic_cast<TransformationItem*>(getItem(T_TRANSFORMATION)); + return transformationItem ? transformationItem->rotationItem() : nullptr; +} + bool ItemWithParticles::isTransformationTagName(const QString& name) { return name == T_TRANSFORMATION; @@ -67,8 +73,49 @@ bool ItemWithParticles::isTransformationTagName(const QString& name) Transform3D ItemWithParticles::rotation() const { - const auto item = dynamic_cast<TransformationItem*>(getItem(T_TRANSFORMATION)); - return item ? item->rotationItem()->rotation() : Transform3D(); + const auto item = rotationItem(); + return item ? item->rotation() : Transform3D(); +} + +SelectionDescriptor<RotationItem*> ItemWithParticles::rotationMethod() +{ + SelectionDescriptor<RotationItem*> d; + + // we need a special filling for this selection descriptor (not just from a GroupItem), since + // the rotation is stored in a TransformationItem instance, which can be present or not. + + static QVector<QPair<QString, QString>> map = {{"None", ""}, + {"X axis Rotation", XRotationItem::M_TYPE}, + {"Y axis Rotation", YRotationItem::M_TYPE}, + {"Z axis Rotation", ZRotationItem::M_TYPE}, + {"Euler Rotation", EulerRotationItem::M_TYPE}}; + + d.label = "Rotation"; + + for (auto [title, type] : map) + d.options << title; + + d.currentItem = [=]() -> RotationItem* { return rotationItem(); }; + + d.setCurrentIndex = [=](int current) { + if (auto item = getItem(T_TRANSFORMATION)) + model()->removeItem(item); + if (current > 0) + createTransformationItem()->setRotationType(map[current].second); + }; + + d.currentIndex = [=]() { + auto item = rotationItem(); + if (item == nullptr) + return 0; + for (int i = 1; i < map.size(); i++) + if (map[i].second == item->modelType()) + return i; + + return 0; + }; + + return d; } ItemWithParticles::ItemWithParticles(const QString& model_type, const QString& abundance_tooltip, diff --git a/GUI/Models/ItemWithParticles.h b/GUI/Models/ItemWithParticles.h index 0bb1fcc5760848a09bdfffe297759df7589d687c..3ee3a69acbf0758aa9ba517e4d0024d40cb367d1 100644 --- a/GUI/Models/ItemWithParticles.h +++ b/GUI/Models/ItemWithParticles.h @@ -16,6 +16,7 @@ #define BORNAGAIN_GUI_MODELS_ITEMWITHPARTICLES_H #include "Base/Vector/Vectors3D.h" +#include "GUI/Models/SelectionDescriptor.h" #include "GUI/Models/SessionGraphicsItem.h" class RotationItem; @@ -45,6 +46,9 @@ public: //! Returns identity transformation if no rotation is defined at all Transform3D rotation() const; + //! Returns selection descriptor for rotation methods. + SelectionDescriptor<RotationItem*> rotationMethod(); + protected: ItemWithParticles(const QString& model_type, const QString& abundance_tooltip, const QString& position_tooltip); @@ -53,6 +57,10 @@ protected: private: virtual bool isShellParticle() const; + + //! Convenience method to return a rotation item from the contained transformation item. + //! nullptr, if no transformation item defined. + RotationItem* rotationItem() const; }; #endif // BORNAGAIN_GUI_MODELS_ITEMWITHPARTICLES_H diff --git a/GUI/Models/LayerItem.cpp b/GUI/Models/LayerItem.cpp index c71b057e60da55528fb89f1c23c74a92f0cd59d9..e41af63646274542a5bc8ecc4738ff8ebee034e2 100644 --- a/GUI/Models/LayerItem.cpp +++ b/GUI/Models/LayerItem.cpp @@ -19,8 +19,11 @@ #include "GUI/Models/MaterialItemUtils.h" #include "GUI/Models/MultiLayerItem.h" #include "GUI/Models/ParticleLayoutItem.h" +#include "GUI/Models/SelectionDescriptor.h" #include "GUI/Models/UIntDescriptor.h" +using std::function; + namespace { const QString layer_nslices_tooltip = "Number of horizontal slices.\n" "Used for Average Layer Material calculations \n" @@ -76,9 +79,24 @@ bool LayerItem::isThicknessPropertyName(const QString& name) return name == P_THICKNESS; } -SessionItem* LayerItem::roughness() const +void LayerItem::setThicknessEnabled(bool enabled) { - return getGroupItem(P_ROUGHNESS); + getItem(P_THICKNESS)->setEnabled(enabled); +} + +SelectionDescriptor<std::variant<LayerZeroRoughnessItem*, LayerBasicRoughnessItem*>> +LayerItem::roughness() +{ + SelectionDescriptor<std::variant<LayerZeroRoughnessItem*, LayerBasicRoughnessItem*>> d( + item<GroupItem>(P_ROUGHNESS)); + + d.currentItem = [=]() -> std::variant<LayerZeroRoughnessItem*, LayerBasicRoughnessItem*> { + if (auto r = dynamic_cast<LayerBasicRoughnessItem*>(getGroupItem(P_ROUGHNESS))) + return {r}; + return {dynamic_cast<LayerZeroRoughnessItem*>(getGroupItem(P_ROUGHNESS))}; + }; + + return d; } SessionItem* LayerItem::roughnessItem() const @@ -86,12 +104,16 @@ SessionItem* LayerItem::roughnessItem() const return getItem(P_ROUGHNESS); } +void LayerItem::setRoughnessEnabled(bool enabled) +{ + getItem(P_ROUGHNESS)->setEnabled(enabled); +} + UIntDescriptor LayerItem::numSlices() const { return UIntDescriptor(getItem(P_NSLICES), Unit::unitless); } - QVector<ParticleLayoutItem*> LayerItem::layouts() const { return items<ParticleLayoutItem>(T_LAYOUTS); diff --git a/GUI/Models/LayerItem.h b/GUI/Models/LayerItem.h index a52d171241bd83e8aded8b400da955523d8fa730..64dcf035bb5728dc00171e3f2702af87f3357d1e 100644 --- a/GUI/Models/LayerItem.h +++ b/GUI/Models/LayerItem.h @@ -16,6 +16,8 @@ #define BORNAGAIN_GUI_MODELS_LAYERITEM_H #include "GUI/Models/ItemWithMaterial.h" +#include "GUI/Models/SelectionDescriptor.h" +#include <variant> class LayerZeroRoughnessItem; class LayerBasicRoughnessItem; @@ -37,13 +39,14 @@ public: QVector<ItemWithMaterial*> itemsWithMaterial(); - SessionItem* thicknessItem() const; DoubleDescriptor thickness() const; static bool isThicknessPropertyName(const QString& name); + void setThicknessEnabled(bool enabled); template <typename T> T* setRoughnessType(); - SessionItem* roughness() const; - SessionItem* roughnessItem() const; + SelectionDescriptor<std::variant<LayerZeroRoughnessItem*, LayerBasicRoughnessItem*>> + roughness(); + void setRoughnessEnabled(bool enabled); UIntDescriptor numSlices() const; @@ -52,6 +55,14 @@ public: private: void updateAppearance(SessionItem* new_parent); + + // -- Only for testing + friend class TestMultiLayerItem_test_twoLayerSystem_Test; + friend class TestMultiLayerItem_test_threeLayerSystem_Test; + friend class TestMultiLayerItem_test_movingMiddleLayerOnTop_Test; + friend class TestModelUtils_test_iterateIf_Test; + SessionItem* thicknessItem() const; + SessionItem* roughnessItem() const; }; template <typename T> T* LayerItem::setRoughnessType() diff --git a/GUI/Models/MesoCrystalItem.cpp b/GUI/Models/MesoCrystalItem.cpp index 1911a94092ac8325216414cd14e7376d3cd42a04..707f21a3b55f30c12488dc701c40c693e777846d 100644 --- a/GUI/Models/MesoCrystalItem.cpp +++ b/GUI/Models/MesoCrystalItem.cpp @@ -125,6 +125,11 @@ std::unique_ptr<IFormFactor> MesoCrystalItem::getOuterShape() const return ff_item.createFormFactor(); } +SelectionDescriptor<FormFactorItem*> MesoCrystalItem::outerShape() +{ + return SelectionDescriptor<FormFactorItem*>(item<GroupItem>(P_OUTER_SHAPE)); +} + ItemWithParticles* MesoCrystalItem::basisParticle() const { return dynamic_cast<ItemWithParticles*>(getItem(T_BASIS_PARTICLE)); diff --git a/GUI/Models/MesoCrystalItem.h b/GUI/Models/MesoCrystalItem.h index efa6164e96732f1f1485cc7fc662090d6638a633..59c84c858c3c698bebef6a417a8f93d354096071 100644 --- a/GUI/Models/MesoCrystalItem.h +++ b/GUI/Models/MesoCrystalItem.h @@ -17,6 +17,7 @@ #include "Base/Vector/Vectors3D.h" #include "GUI/Models/ItemWithParticles.h" +#include "GUI/Models/SelectionDescriptor.h" #include "Sample/Lattice/Lattice3D.h" class FormFactorItem; @@ -46,6 +47,9 @@ public: std::unique_ptr<IFormFactor> getOuterShape() const; template <typename T> T* setOuterShapeType(); + SelectionDescriptor<FormFactorItem*> outerShape(); + + ItemWithParticles* basisParticle() const; void setVectorA(const R3& vector_a); diff --git a/GUI/Models/MultiLayerItem.cpp b/GUI/Models/MultiLayerItem.cpp index 3b145963655fa99098ce06358957566e0cb21cae..58a5f6decd2a02528569f9fe1732c6fe6cd88d45 100644 --- a/GUI/Models/MultiLayerItem.cpp +++ b/GUI/Models/MultiLayerItem.cpp @@ -120,16 +120,12 @@ void MultiLayerItem::updateLayers() { QVector<LayerItem*> list = childrenOfType<LayerItem>(); for (auto it = list.begin(); it != list.end(); ++it) { - if (it == list.begin()) - (*it)->roughnessItem()->setEnabled(false); - else - (*it)->roughnessItem()->setEnabled(true); + (*it)->setRoughnessEnabled(it != list.begin()); if (it == list.begin() || it == (list.end() - 1)) { - (*it)->thicknessItem()->setEnabled(false); + (*it)->setThicknessEnabled(false); (*it)->thickness().set(0.0); - } else { - (*it)->thicknessItem()->setEnabled(true); - } + } else + (*it)->setThicknessEnabled(true); } } diff --git a/GUI/Models/SelectionDescriptor.h b/GUI/Models/SelectionDescriptor.h new file mode 100644 index 0000000000000000000000000000000000000000..abd9a9b76a02ebc099daa72310f120e84034999f --- /dev/null +++ b/GUI/Models/SelectionDescriptor.h @@ -0,0 +1,76 @@ +// ************************************************************************************************ +// +// BornAgain: simulate and fit reflection and scattering +// +//! @file GUI/Models/SelectionDescriptor.h +//! @brief Defines class SelectionDescriptor +//! +//! @homepage http://www.bornagainproject.org +//! @license GNU General Public License v3 or higher (see COPYING) +//! @copyright Forschungszentrum Jülich GmbH 2021 +//! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS) +// +// ************************************************************************************************ + +#ifndef BORNAGAIN_GUI_MODELS_SELECTIONDESCRIPTOR_H +#define BORNAGAIN_GUI_MODELS_SELECTIONDESCRIPTOR_H + +#include "GUI/Models/ComboProperty.h" +#include "GUI/Models/GroupItem.h" +#include <QString> +#include <QStringList> +#include <functional> + +using std::function; + +//! Describes a selection (various possibilities and the current one). +//! +//! Usually a selection is presented as a combo box. +//! Right now with SessionModel still in place, in most cases a selection changes the current item +//! of a group item, i.e. it changes the class of a certain child item (e.g. +//! XRotationItem*/YRotationItem*/...). +//! +//! The template parameter defines the type of the current item. This can be a pointer to a common +//! base class (like RotationItem*), but it also can be a std::variant<...>, which is useful if +//! no dedicated common base class exists (like for the roughness items LayerZeroRoughnessItem and +//! LayerBasicRoughnessItem). +//! +//! By using this class, the underlying data scheme is hidden from the user of the data. This e.g. +//! eases SessionItem migration. The underlying implementation can be a GroupItem, a simple pointer +//! member, a std::variant or any other construction to define a selection. +template <typename T> class SelectionDescriptor { +public: + SelectionDescriptor() = default; + + //! Initialize the members by means of a GroupItem. + //! + //! currentItem can only be initialized if the template parameter is a pointer (like + //! RotationItem*). If it is e.g. a std::variant<>, the currentItem has to be initialized by the + //! caller. Only for easier migration. Should be removed after SessionItem refactoring. + explicit SelectionDescriptor(GroupItem* item) + { + label = item->displayName(); + options = item->value().value<ComboProperty>().getValues(); + setCurrentIndex = [=](int index) { + ComboProperty comboProperty = item->value().value<ComboProperty>(); + + if (comboProperty.currentIndex() != index) { + comboProperty.setCurrentIndex(index); + item->setValue(QVariant::fromValue<ComboProperty>(comboProperty)); + } + }; + currentIndex = [=] { return item->value().value<ComboProperty>().currentIndex(); }; + + if constexpr (std::is_pointer<T>::value) + currentItem = [=] { return dynamic_cast<T>(item->currentItem()); }; + } + + QString label; //!< A label text (short, no trailing colon) + QString tooltip; //!< Tooltip text + QStringList options; //!< List of options, usually presented as combo entries + function<void(int)> setCurrentIndex; //!< Function to set currently selected option + function<int()> currentIndex; //!< Function to get currently selected option + function<T()> currentItem; //!< Function to get currently selected item +}; + +#endif // BORNAGAIN_GUI_MODELS_SELECTIONDESCRIPTOR_H diff --git a/GUI/Models/TransformToDomain.cpp b/GUI/Models/TransformToDomain.cpp index 2497dcefc8491ca0a73e41f0fb546a4b778577f6..cb318a42205a74667ab639c2a35e9a512791cc15 100644 --- a/GUI/Models/TransformToDomain.cpp +++ b/GUI/Models/TransformToDomain.cpp @@ -81,14 +81,13 @@ std::unique_ptr<Layer> GUI::Transform::ToDomain::createLayer(const LayerItem& it return P_layer; } -std::unique_ptr<LayerRoughness> -GUI::Transform::ToDomain::createLayerRoughness(const SessionItem& roughnessItem) +std::unique_ptr<LayerRoughness> GUI::Transform::ToDomain::createLayerRoughness( + const std::variant<LayerZeroRoughnessItem*, LayerBasicRoughnessItem*>& roughness) { - if (roughnessItem.modelType() == LayerZeroRoughnessItem::M_TYPE) + if (std::holds_alternative<LayerZeroRoughnessItem*>(roughness)) return nullptr; - if (roughnessItem.modelType() == LayerBasicRoughnessItem::M_TYPE) { - const LayerBasicRoughnessItem& basicRoughnessItem = - dynamic_cast<const LayerBasicRoughnessItem&>(roughnessItem); + if (std::holds_alternative<LayerBasicRoughnessItem*>(roughness)) { + const auto& basicRoughnessItem = *std::get<LayerBasicRoughnessItem*>(roughness); return std::make_unique<LayerRoughness>(basicRoughnessItem.sigma(), basicRoughnessItem.hurst(), basicRoughnessItem.lateralCorrelationLength()); diff --git a/GUI/Models/TransformToDomain.h b/GUI/Models/TransformToDomain.h index 7aee184daee0b7e034f1a35a8e68b917c42a19db..3fb7d07909727a5d6f6f6ed5a06f6d0bbf64f365 100644 --- a/GUI/Models/TransformToDomain.h +++ b/GUI/Models/TransformToDomain.h @@ -25,6 +25,7 @@ #include "Sample/Multilayer/MultiLayer.h" #include "Sample/Particle/IParticle.h" #include <memory> +#include <variant> class AlphaScan; class BeamDistributionItem; @@ -39,13 +40,16 @@ class MultiLayerItem; class ParticleLayoutItem; class SessionItem; class ISimulation; +class LayerZeroRoughnessItem; +class LayerBasicRoughnessItem; namespace GUI::Transform::ToDomain { std::unique_ptr<Material> createDomainMaterial(const ItemWithMaterial& item); std::unique_ptr<IParticle> createIParticle(const SessionItem& item); std::unique_ptr<Layer> createLayer(const LayerItem& item); -std::unique_ptr<LayerRoughness> createLayerRoughness(const SessionItem& item); +std::unique_ptr<LayerRoughness> createLayerRoughness( + const std::variant<LayerZeroRoughnessItem*, LayerBasicRoughnessItem*>& roughness); std::unique_ptr<MultiLayer> createMultiLayer(const MultiLayerItem& item); std::unique_ptr<ParticleLayout> createParticleLayout(const ParticleLayoutItem& item); diff --git a/GUI/Models/TransformationItem.cpp b/GUI/Models/TransformationItem.cpp index 213abba38967284634eb7ad7074120ee356ce181..79ccf7a54b9deeeeb606c18f4c7559e628950337 100644 --- a/GUI/Models/TransformationItem.cpp +++ b/GUI/Models/TransformationItem.cpp @@ -34,3 +34,8 @@ RotationItem* TransformationItem::rotationItem() const { return dynamic_cast<RotationItem*>(getGroupItem(P_ROT)); } + +void TransformationItem::setRotationType(const QString& modelType) +{ + setGroupProperty(P_ROT, modelType); +} diff --git a/GUI/Models/TransformationItem.h b/GUI/Models/TransformationItem.h index 9f088f780d6ae1ce81d6ba49d02462d976627f44..77a4746c86e84ba5c6b04950f6dd0dfcb8128e71 100644 --- a/GUI/Models/TransformationItem.h +++ b/GUI/Models/TransformationItem.h @@ -30,6 +30,7 @@ public: RotationItem* rotationItem() const; template <typename T> T* setRotationType(); + void setRotationType(const QString& modelType); }; diff --git a/Tests/Unit/GUI/TestLayerRoughnessItems.cpp b/Tests/Unit/GUI/TestLayerRoughnessItems.cpp index d148f6cb27d5fb286d010c139182c930badbcfc2..ea1cf2facfcb70558eb8d79256c60dd718455e96 100644 --- a/Tests/Unit/GUI/TestLayerRoughnessItems.cpp +++ b/Tests/Unit/GUI/TestLayerRoughnessItems.cpp @@ -14,13 +14,13 @@ TEST_F(TestLayerRoughnessItems, test_LayerRoughnessToDomain) roughnessItem.hurst().set(20.0); roughnessItem.lateralCorrelationLength().set(30.0); - auto P_roughness = GUI::Transform::ToDomain::createLayerRoughness(roughnessItem); + auto P_roughness = GUI::Transform::ToDomain::createLayerRoughness(&roughnessItem); EXPECT_EQ(P_roughness->getSigma(), roughnessItem.sigma()); EXPECT_EQ(P_roughness->getHurstParameter(), roughnessItem.hurst()); EXPECT_EQ(P_roughness->getLatteralCorrLength(), roughnessItem.lateralCorrelationLength()); LayerZeroRoughnessItem zeroRoughnessItem; - EXPECT_TRUE(GUI::Transform::ToDomain::createLayerRoughness(zeroRoughnessItem) == nullptr); + EXPECT_TRUE(GUI::Transform::ToDomain::createLayerRoughness(&zeroRoughnessItem) == nullptr); } TEST_F(TestLayerRoughnessItems, test_LayerRoughnessFromDomain) diff --git a/Tests/Unit/GUI/TestMultiLayerItem.cpp b/Tests/Unit/GUI/TestMultiLayerItem.cpp index b17c91a8135deed77841bf042a3f5be7d59ee38b..5ac15848e5e3964f58e085ee2256db5627cae324 100644 --- a/Tests/Unit/GUI/TestMultiLayerItem.cpp +++ b/Tests/Unit/GUI/TestMultiLayerItem.cpp @@ -33,8 +33,8 @@ TEST_F(TestMultiLayerItem, test_twoLayerSystem) EXPECT_TRUE(bottom->roughnessItem()->isEnabled()); // Default roughness should be "LayerZeroRoughness" - EXPECT_EQ(top->roughness()->modelType(), LayerZeroRoughnessItem::M_TYPE); - EXPECT_EQ(bottom->roughness()->modelType(), LayerZeroRoughnessItem::M_TYPE); + EXPECT_TRUE(std::holds_alternative<LayerZeroRoughnessItem*>(top->roughness().currentItem())); + EXPECT_TRUE(std::holds_alternative<LayerZeroRoughnessItem*>(bottom->roughness().currentItem())); } //! Testing layer appearance (enabled, disabled) in a MultiLayer made of three default layers. @@ -66,9 +66,9 @@ TEST_F(TestMultiLayerItem, test_threeLayerSystem) EXPECT_TRUE(bottom->roughnessItem()->isEnabled()); // Default roughness should be "LayerZeroRoughness" - EXPECT_EQ(top->roughness()->modelType(), LayerZeroRoughnessItem::M_TYPE); - EXPECT_EQ(middle->roughness()->modelType(), LayerZeroRoughnessItem::M_TYPE); - EXPECT_EQ(bottom->roughness()->modelType(), LayerZeroRoughnessItem::M_TYPE); + EXPECT_TRUE(std::holds_alternative<LayerZeroRoughnessItem*>(top->roughness().currentItem())); + EXPECT_TRUE(std::holds_alternative<LayerZeroRoughnessItem*>(middle->roughness().currentItem())); + EXPECT_TRUE(std::holds_alternative<LayerZeroRoughnessItem*>(bottom->roughness().currentItem())); } //! Testing middle layer appearance when it is moved to the top.