diff --git a/GUI/View/SampleDesigner/ParticleLayoutForm.cpp b/GUI/View/SampleDesigner/ParticleLayoutForm.cpp index 4e01452c3a5ff366cce283f531f6916eb0896ec0..6ee952899de0bed352f84c448f9ee0e9a46e68b9 100644 --- a/GUI/View/SampleDesigner/ParticleLayoutForm.cpp +++ b/GUI/View/SampleDesigner/ParticleLayoutForm.cpp @@ -15,6 +15,7 @@ #include "GUI/View/SampleDesigner/ParticleLayoutForm.h" #include "GUI/Model/Sample/InterferenceItems.h" #include "GUI/Model/Sample/ItemWithParticles.h" +#include "GUI/Model/Sample/LayerItem.h" #include "GUI/Model/Sample/ParticleLayoutItem.h" #include "GUI/Util/ActionFactory.h" #include "GUI/View/Edit/DoubleSpinBox.h" @@ -31,8 +32,6 @@ ParticleLayoutForm::ParticleLayoutForm(LayerForm* parent, ParticleLayoutItem* la SampleEditorController* ec) : QGroupBox(parent), m_layoutItem(layoutItem), m_ec(ec) { - setTitle(m_layoutItem->itemName()); - FormLayouter layouter(this, ec); layouter.setContentsMargins(30, 6, 0, 0); int rowOfTotalDensity = layouter.addValue(m_layoutItem->totalDensity()); @@ -57,12 +56,13 @@ ParticleLayoutForm::ParticleLayoutForm(LayerForm* parent, ParticleLayoutItem* la auto* showInRealSpaceAction = ActionFactory::createShowInRealSpaceAction( this, "particle layout", [=] { ec->requestViewInRealSpace(layoutItem); }); - auto* collapser = GroupBoxCollapser::installIntoGroupBox(this); - collapser->addAction(showInRealSpaceAction); - collapser->addAction(m_removeAction); + m_collapser = GroupBoxCollapser::installIntoGroupBox(this); + m_collapser->addAction(showInRealSpaceAction); + m_collapser->addAction(m_removeAction); m_layout = layouter.layout(); updateDensityEnabling(); + updateTitle(parent->layerItem()); } void ParticleLayoutForm::enableStructureEditing(bool b) @@ -115,3 +115,13 @@ void ParticleLayoutForm::updateDensityValue() { m_totalDensitySpinBox->updateValue(); } + +void ParticleLayoutForm::updateTitle(const LayerItem* layerItem) +{ + const auto layouts = layerItem->layouts(); + if (layouts.size() > 1) + m_collapser->setTitle("Particle layout " + + QString::number(layouts.indexOf(m_layoutItem) + 1)); + else + m_collapser->setTitle("Particle layout"); +} diff --git a/GUI/View/SampleDesigner/ParticleLayoutForm.h b/GUI/View/SampleDesigner/ParticleLayoutForm.h index b49067d7dc748ff7cb9ef5a4b4a1f660a3c1a23e..0ca24c3dc7131f8d31b369dd688b125fa6dc8149 100644 --- a/GUI/View/SampleDesigner/ParticleLayoutForm.h +++ b/GUI/View/SampleDesigner/ParticleLayoutForm.h @@ -26,6 +26,8 @@ class LayerForm; class SessionItem; class ItemWithParticles; class DoubleSpinBox; +class LayerItem; +class GroupBoxCollapser; //! Form for editing a particle layout class ParticleLayoutForm : public QGroupBox { @@ -50,6 +52,8 @@ public: //! This does not update any internal values, it only refreshes the shown value. void updateDensityValue(); + void updateTitle(const LayerItem* layerItem); + private: QFormLayout* m_layout; ParticleLayoutItem* m_layoutItem; @@ -57,6 +61,7 @@ private: SampleEditorController* m_ec; QList<QWidget*> m_structureEditingWidgets; DoubleSpinBox* m_totalDensitySpinBox; + GroupBoxCollapser* m_collapser; }; #endif // BORNAGAIN_GUI_VIEW_SAMPLEDESIGNER_PARTICLELAYOUTFORM_H diff --git a/GUI/View/SampleDesigner/SampleEditorController.cpp b/GUI/View/SampleDesigner/SampleEditorController.cpp index f644d7136cb5f391354d244150e03a7e73af24d6..3852fdb2c8d6c6e9012204237bd2baa73d2c05c0 100644 --- a/GUI/View/SampleDesigner/SampleEditorController.cpp +++ b/GUI/View/SampleDesigner/SampleEditorController.cpp @@ -111,6 +111,9 @@ void SampleEditorController::addLayout(LayerForm* layerItemWidget) auto* newLayoutItem = layerItemWidget->layerItem()->addLayout(); layerItemWidget->onLayoutAdded(newLayoutItem); m_multiLayerForm->updateUnits(); + + for (auto* layoutForms : layerItemWidget->findChildren<ParticleLayoutForm*>()) + layoutForms->updateTitle(layerItemWidget->layerItem()); } void SampleEditorController::removeLayer(LayerItem* layerItem) @@ -122,6 +125,9 @@ void SampleEditorController::removeLayout(LayerForm* layerItemWidget, ParticleLa { layerItemWidget->onAboutToRemoveLayout(layout); layerItemWidget->layerItem()->removeLayout(layout); + + for (auto* layoutForms : layerItemWidget->findChildren<ParticleLayoutForm*>()) + layoutForms->updateTitle(layerItemWidget->layerItem()); } void SampleEditorController::addParticle(ParticleLayoutItem* layoutItem, const QString& classname)