diff --git a/GUI/Models/LayerItem.cpp b/GUI/Models/LayerItem.cpp index c71b057e60da55528fb89f1c23c74a92f0cd59d9..d4522cf60fd9e9f3fd997ba1e4cb2b6bac7f3e0f 100644 --- a/GUI/Models/LayerItem.cpp +++ b/GUI/Models/LayerItem.cpp @@ -76,6 +76,11 @@ bool LayerItem::isThicknessPropertyName(const QString& name) return name == P_THICKNESS; } +void LayerItem::setThicknessEnabled(bool enabled) +{ + getItem(P_THICKNESS)->setEnabled(enabled); +} + SessionItem* LayerItem::roughness() const { return getGroupItem(P_ROUGHNESS); @@ -86,12 +91,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..d3b05014da73b9d7c6f2bced1e6e54f079051fb3 100644 --- a/GUI/Models/LayerItem.h +++ b/GUI/Models/LayerItem.h @@ -37,13 +37,13 @@ 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; + void setRoughnessEnabled(bool enabled); UIntDescriptor numSlices() const; @@ -52,6 +52,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/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); } }