diff --git a/GUI/View/SampleDesigner/CompoundForm.cpp b/GUI/View/SampleDesigner/CompoundForm.cpp index 0977fbc7204b58f35851c370522f1cd214e576c4..d084a245ebeb564796e917382c298216e74e18f7 100644 --- a/GUI/View/SampleDesigner/CompoundForm.cpp +++ b/GUI/View/SampleDesigner/CompoundForm.cpp @@ -22,57 +22,56 @@ #include <QAction> #include <QPushButton> -CompoundForm::CompoundForm(QWidget* parent, CompoundItem* compositionItem, - SampleEditorController* ec, bool allowRemove) +CompoundForm::CompoundForm(QWidget* parent, CompoundItem* compoundItem, SampleEditorController* ec, + bool allowRemove) : QGroupBox(parent) - , m_compositionItem(compositionItem) + , m_compositionItem(compoundItem) , m_ec(ec) { setTitle("Composition of particles"); FormLayouter layouter(this, ec); layouter.setContentsMargins(30, 6, 0, 0); - layouter.addVector(compositionItem->position(), false); - layouter.addSelection(compositionItem->rotationSelection()); - layouter.addValue(compositionItem->abundance()); + layouter.addVector(compoundItem->position(), false); + layouter.addSelection(compoundItem->rotationSelection()); + layouter.addValue(compoundItem->abundance()); - for (auto* particle : compositionItem->itemsWithParticles()) + for (auto* particle : compoundItem->itemsWithParticles()) layouter.addRow( LayerEditorUtil::createWidgetForItemWithParticles(this, particle, false, ec)); auto* btn = LayerEditorUtil::createAddParticleButton( - this, [=](FormFactorItemCatalog::Type type) { ec->addCompoundItem(compositionItem, type); }, - [=](ItemWithParticlesCatalog::Type type) { ec->addCompoundItem(compositionItem, type); }); + this, [=](FormFactorItemCatalog::Type type) { ec->addCompoundItem(compoundItem, type); }, + [=](ItemWithParticlesCatalog::Type type) { ec->addCompoundItem(compoundItem, type); }); m_structureEditingWidgets << btn; layouter.addStructureEditingRow(btn); auto* collapser = GroupBoxCollapser::installIntoGroupBox(this); - collapser->setExpanded(compositionItem->isExpandCompound()); + collapser->setExpanded(compoundItem->isExpandCompound()); connect(collapser, &GroupBoxCollapser::toggled, this, - [compositionItem](bool b) { compositionItem->setExpandCompound(b); }); + [compoundItem](bool b) { compoundItem->setExpandCompound(b); }); // top right corner actions // show in real space { auto* showInRealspaceAction = ActionFactory::createShowInRealspaceAction( this, "particle composition", - [ec, compositionItem] { ec->requestViewInRealspace(compositionItem); }); + [ec, compoundItem] { ec->requestViewInRealspace(compoundItem); }); collapser->addAction(showInRealspaceAction); } // duplicate { - m_duplicateAction = ActionFactory::createDuplicateAction( - this, "particle composition", - [ec, compositionItem] { ec->duplicateItemWithParticles(compositionItem); }); + m_duplicateAction = + ActionFactory::createDuplicateAction(this, "particle composition", [ec, compoundItem] { + ec->duplicateItemWithParticles(compoundItem); + }); collapser->addAction(m_duplicateAction); } // remove { - m_removeAction = - ActionFactory::createRemoveAction(this, "particle composition", [ec, compositionItem] { - ec->removeParticle(compositionItem); - }); + m_removeAction = ActionFactory::createRemoveAction( + this, "particle composition", [ec, compoundItem] { ec->removeParticle(compoundItem); }); if (allowRemove) collapser->addAction(m_removeAction); } diff --git a/GUI/View/SampleDesigner/CompoundForm.h b/GUI/View/SampleDesigner/CompoundForm.h index 980f9d9a3828a10c45474c0e967b4fd032b46163..ab3528da381d96136d421e62a42f45b06fee4c6f 100644 --- a/GUI/View/SampleDesigner/CompoundForm.h +++ b/GUI/View/SampleDesigner/CompoundForm.h @@ -26,7 +26,7 @@ class SampleEditorController; class CompoundForm : public QGroupBox { Q_OBJECT public: - CompoundForm(QWidget* parent, CompoundItem* compositionItem, SampleEditorController* ec, + CompoundForm(QWidget* parent, CompoundItem* compoundItem, SampleEditorController* ec, bool allowRemove = true); ~CompoundForm(); diff --git a/GUI/View/SampleDesigner/CoreAndShellForm.cpp b/GUI/View/SampleDesigner/CoreAndShellForm.cpp index 3ecde15292729db0ef662b41f8cc18afbd729765..a6c50386c8d377298bd0fa0366a2c3c702b1c77a 100644 --- a/GUI/View/SampleDesigner/CoreAndShellForm.cpp +++ b/GUI/View/SampleDesigner/CoreAndShellForm.cpp @@ -50,18 +50,18 @@ QComboBox* createFormFactorCombo(QWidget* parent, FormFactorItem* current) } // namespace -CoreAndShellForm::CoreAndShellForm(QWidget* parent, CoreAndShellItem* item, +CoreAndShellForm::CoreAndShellForm(QWidget* parent, CoreAndShellItem* coreShellItem, SampleEditorController* ec, bool allowRemove) : QGroupBox(parent) - , m_item(item) + , m_item(coreShellItem) , m_ec(ec) { setTitle("Core/shell particle"); FormLayouter layouter(this, ec); layouter.setContentsMargins(30, 6, 0, 0); - layouter.addVector(item->position(), false); - layouter.addSelection(item->rotationSelection()); - layouter.addValue(item->abundance()); + layouter.addVector(coreShellItem->position(), false); + layouter.addSelection(coreShellItem->rotationSelection()); + layouter.addValue(coreShellItem->abundance()); // - core { @@ -71,8 +71,9 @@ CoreAndShellForm::CoreAndShellForm(QWidget* parent, CoreAndShellItem* item, core.layouter = std::make_unique<FormLayouter>(coreParticleGroup, ec); core.formfactorCombo = createFormFactorCombo( - coreParticleGroup, - item->coreItem() != nullptr ? item->coreItem()->formFactorItem() : nullptr); + coreParticleGroup, coreShellItem->coreItem() != nullptr + ? coreShellItem->coreItem()->formFactorItem() + : nullptr); connect(core.formfactorCombo, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &CoreAndShellForm::onCoreComboChanged); core.layouter->addRow("Form factor:", core.formfactorCombo); @@ -83,9 +84,9 @@ CoreAndShellForm::CoreAndShellForm(QWidget* parent, CoreAndShellItem* item, connect(showInRealspaceAction, &QAction::triggered, this, &CoreAndShellForm::showCoreInRealspace); core.collapser->addAction(showInRealspaceAction); - core.collapser->setExpanded(item->isExpandCore()); + core.collapser->setExpanded(coreShellItem->isExpandCore()); connect(core.collapser, &GroupBoxCollapser::toggled, this, - [item](bool b) { item->setExpandCore(b); }); + [coreShellItem](bool b) { coreShellItem->setExpandCore(b); }); createCoreWidgets(); @@ -98,15 +99,16 @@ CoreAndShellForm::CoreAndShellForm(QWidget* parent, CoreAndShellItem* item, shellParticleGroup->setObjectName("Particle"); shell.layouter = std::make_unique<FormLayouter>(shellParticleGroup, ec); shell.formfactorCombo = createFormFactorCombo( - shellParticleGroup, - item->shellItem() != nullptr ? item->shellItem()->formFactorItem() : nullptr); + shellParticleGroup, coreShellItem->shellItem() != nullptr + ? coreShellItem->shellItem()->formFactorItem() + : nullptr); connect(shell.formfactorCombo, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &CoreAndShellForm::onShellComboChanged); shell.layouter->addRow("Form factor:", shell.formfactorCombo); shell.collapser = GroupBoxCollapser::installIntoGroupBox(shellParticleGroup); - shell.collapser->setExpanded(item->isExpandShell()); + shell.collapser->setExpanded(coreShellItem->isExpandShell()); connect(shell.collapser, &GroupBoxCollapser::toggled, this, - [item](bool b) { item->setExpandShell(b); }); + [coreShellItem](bool b) { coreShellItem->setExpandShell(b); }); auto* showInRealspaceAction = ActionFactory::createShowInRealspaceAction(this, "shell particle"); @@ -120,27 +122,32 @@ CoreAndShellForm::CoreAndShellForm(QWidget* parent, CoreAndShellItem* item, } auto* mainCollapser = GroupBoxCollapser::installIntoGroupBox(this); - mainCollapser->setExpanded(item->isExpandMain()); + mainCollapser->setExpanded(coreShellItem->isExpandMain()); connect(mainCollapser, &GroupBoxCollapser::toggled, this, - [item](bool b) { item->setExpandMain(b); }); + [coreShellItem](bool b) { coreShellItem->setExpandMain(b); }); // top right corner actions // show in real space { auto* showInRealspaceAction = ActionFactory::createShowInRealspaceAction( - this, "core/shell particle", [ec, item] { ec->requestViewInRealspace(item); }); + this, "core/shell particle", + [ec, coreShellItem] { ec->requestViewInRealspace(coreShellItem); }); mainCollapser->addAction(showInRealspaceAction); } // duplicate { - m_duplicateAction = ActionFactory::createDuplicateAction( - this, "core/shell particle", [ec, item] { ec->duplicateItemWithParticles(item); }); + m_duplicateAction = + ActionFactory::createDuplicateAction(this, "core/shell particle", [ec, coreShellItem] { + ec->duplicateItemWithParticles(coreShellItem); + }); mainCollapser->addAction(m_duplicateAction); } // remove { - m_removeAction = ActionFactory::createRemoveAction( - this, "core/shell particle", [ec, item] { ec->removeParticle(item); }); + m_removeAction = + ActionFactory::createRemoveAction(this, "core/shell particle", [ec, coreShellItem] { + ec->removeParticle(coreShellItem); + }); if (allowRemove) mainCollapser->addAction(m_removeAction); } diff --git a/GUI/View/SampleDesigner/CoreAndShellForm.h b/GUI/View/SampleDesigner/CoreAndShellForm.h index 5512fb8d2ce7c7bd277c4ba9e52c7cc7960a01b9..4f7599f1e9e32ffb69d8127c49be2da531490f61 100644 --- a/GUI/View/SampleDesigner/CoreAndShellForm.h +++ b/GUI/View/SampleDesigner/CoreAndShellForm.h @@ -28,7 +28,7 @@ class SampleEditorController; class CoreAndShellForm : public QGroupBox { Q_OBJECT public: - CoreAndShellForm(QWidget* parent, CoreAndShellItem* item, SampleEditorController* ec, + CoreAndShellForm(QWidget* parent, CoreAndShellItem* coreShellItem, SampleEditorController* ec, bool allowRemove = true); void enableStructureEditing(bool b); diff --git a/GUI/View/SampleDesigner/LayerForm.cpp b/GUI/View/SampleDesigner/LayerForm.cpp index 7fc91f68b25b7a3514ad27cc0c627b64b5b5e0ab..2db98e290b5844dc054f6f7578f06256de5020df 100644 --- a/GUI/View/SampleDesigner/LayerForm.cpp +++ b/GUI/View/SampleDesigner/LayerForm.cpp @@ -29,18 +29,18 @@ #include <QPushButton> #include <memory> -LayerForm::LayerForm(QWidget* parent, LayerItem* layer, SampleEditorController* ec) +LayerForm::LayerForm(QWidget* parent, LayerItem* layerItem, SampleEditorController* ec) : QGroupBox(parent) - , m_layer(layer) + , m_layer(layerItem) , m_ec(ec) { setTitle(m_layer->layerName()); m_layouter = std::make_unique<FormLayouter>(this, ec); m_layouter->setContentsMargins(6, 6, 0, 6); m_collapser = GroupBoxCollapser::installIntoGroupBox(this, false); - m_collapser->setExpanded(layer->isExpandLayer()); + m_collapser->setExpanded(layerItem->isExpandLayer()); connect(m_collapser, &GroupBoxCollapser::toggled, this, - [layer](bool b) { layer->setExpandLayer(b); }); + [layerItem](bool b) { layerItem->setExpandLayer(b); }); // top right corner actions // choose color @@ -58,8 +58,8 @@ LayerForm::LayerForm(QWidget* parent, LayerItem* layer, SampleEditorController* QPixmap p(64, 64); p.fill(col); auto* ca = menu->addAction(QIcon(p), ""); - connect(ca, &QAction::triggered, [this, layer, col]() { - layer->setColor(col); + connect(ca, &QAction::triggered, [this, layerItem, col]() { + layerItem->setColor(col); updateColor(); }); } @@ -78,26 +78,26 @@ LayerForm::LayerForm(QWidget* parent, LayerItem* layer, SampleEditorController* // show in real space { auto* showInRealspaceAction = ActionFactory::createShowInRealspaceAction( - this, "layer", [ec, layer] { ec->requestViewInRealspace(layer); }); + this, "layer", [ec, layerItem] { ec->requestViewInRealspace(layerItem); }); m_collapser->addAction(showInRealspaceAction); } // duplicate { m_duplicateAction = ActionFactory::createDuplicateAction( - this, "layer", [ec, layer] { ec->duplicateLayerItem(layer); }); + this, "layer", [ec, layerItem] { ec->duplicateLayerItem(layerItem); }); m_collapser->addAction(m_duplicateAction); } // remove { m_removeAction = ActionFactory::createRemoveAction( - this, "layer", [ec, layer] { ec->removeLayerItem(layer); }); + this, "layer", [ec, layerItem] { ec->removeLayerItem(layerItem); }); m_collapser->addAction(m_removeAction); } QColor bckgroundCol = m_layer->color(); setStyleSheet("QGroupBox {background-color: " + bckgroundCol.name(QColor::HexRgb) + "}"); - m_layouter->addRow("Material:", new MaterialInplaceForm(this, layer, ec)); + m_layouter->addRow("Material:", new MaterialInplaceForm(this, layerItem, ec)); m_thicknessRow = m_layouter->addValue(m_layer->thickness()); m_layouter->addRow("Number of slices:", @@ -114,7 +114,7 @@ LayerForm::LayerForm(QWidget* parent, LayerItem* layer, SampleEditorController* m_roughnessRow = m_layouter->addSelection(m_layer->roughnessSelection()); // -- layouts - for (auto* layout : layer->layoutItems()) + for (auto* layout : layerItem->layoutItems()) m_layouter->addRow(new ParticleLayoutForm(this, layout, ec)); // -- Button for adding a new layout diff --git a/GUI/View/SampleDesigner/LayerForm.h b/GUI/View/SampleDesigner/LayerForm.h index 9732aa88ad82399a9d3de0baecdbf919a2cdb124..fed2e0c4115a33c1f57afe881f5a2c0b555a43e4 100644 --- a/GUI/View/SampleDesigner/LayerForm.h +++ b/GUI/View/SampleDesigner/LayerForm.h @@ -26,7 +26,7 @@ class WidgetMoverButton; class LayerForm : public QGroupBox { Q_OBJECT public: - LayerForm(QWidget* parent, LayerItem* layer, SampleEditorController* ec); + LayerForm(QWidget* parent, LayerItem* layerItem, SampleEditorController* ec); void enableStructureEditing(bool b); void updateLayerPositionDependentElements(); diff --git a/GUI/View/SampleDesigner/MesocrystalForm.cpp b/GUI/View/SampleDesigner/MesocrystalForm.cpp index ff1e3fb1e7f44413b90c5790a37e2270578b2259..ab540901a2eb98ae43eab33851d0adb33ca6b238 100644 --- a/GUI/View/SampleDesigner/MesocrystalForm.cpp +++ b/GUI/View/SampleDesigner/MesocrystalForm.cpp @@ -22,10 +22,10 @@ #include "GUI/View/Tool/GroupBoxCollapser.h" #include <QAction> -MesocrystalForm::MesocrystalForm(QWidget* parent, MesocrystalItem* item, SampleEditorController* ec, - bool allowRemove) +MesocrystalForm::MesocrystalForm(QWidget* parent, MesocrystalItem* mesocrystalItem, + SampleEditorController* ec, bool allowRemove) : QGroupBox(parent) - , m_item(item) + , m_item(mesocrystalItem) , m_ec(ec) { setTitle("Meso crystal"); @@ -33,43 +33,47 @@ MesocrystalForm::MesocrystalForm(QWidget* parent, MesocrystalItem* item, SampleE FormLayouter layouter(this, ec); m_layout = layouter.layout(); layouter.setContentsMargins(30, 6, 0, 0); - layouter.addVector(item->position(), false); - layouter.addSelection(item->rotationSelection()); - layouter.addValue(item->abundance()); - layouter.addVector(item->vectorA(), false); - layouter.addVector(item->vectorB(), false); - layouter.addVector(item->vectorC(), false); + layouter.addVector(mesocrystalItem->position(), false); + layouter.addSelection(mesocrystalItem->rotationSelection()); + layouter.addValue(mesocrystalItem->abundance()); + layouter.addVector(mesocrystalItem->vectorA(), false); + layouter.addVector(mesocrystalItem->vectorB(), false); + layouter.addVector(mesocrystalItem->vectorC(), false); - layouter.addSelection(item->outerShapeSelection()); + layouter.addSelection(mesocrystalItem->outerShapeSelection()); - m_basisCombo = createBasisCombo(this, item->basisItem()); + m_basisCombo = createBasisCombo(this, mesocrystalItem->basisItem()); connect(m_basisCombo, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &MesocrystalForm::onBasisComboChanged); m_rowOfBasisTypeCombo = layouter.addRow("Basis type", m_basisCombo); createBasisWidgets(); auto* collapser = GroupBoxCollapser::installIntoGroupBox(this); - collapser->setExpanded(item->isExpandMesocrystal()); + collapser->setExpanded(mesocrystalItem->isExpandMesocrystal()); connect(collapser, &GroupBoxCollapser::toggled, this, - [item](bool b) { item->setExpandMesocrystal(b); }); + [mesocrystalItem](bool b) { mesocrystalItem->setExpandMesocrystal(b); }); // top right corner actions // show in real space { - auto* showInRealspaceAction = ActionFactory::createShowInRealspaceAction( - this, "meso crystal", [ec, item] { ec->requestViewInRealspace(item); }); + auto* showInRealspaceAction = + ActionFactory::createShowInRealspaceAction(this, "meso crystal", [ec, mesocrystalItem] { + ec->requestViewInRealspace(mesocrystalItem); + }); collapser->addAction(showInRealspaceAction); } // duplicate { - m_duplicateAction = ActionFactory::createDuplicateAction( - this, "meso crystal", [ec, item] { ec->duplicateItemWithParticles(item); }); + m_duplicateAction = + ActionFactory::createDuplicateAction(this, "meso crystal", [ec, mesocrystalItem] { + ec->duplicateItemWithParticles(mesocrystalItem); + }); collapser->addAction(m_duplicateAction); } // remove { m_removeAction = ActionFactory::createRemoveAction( - this, "meso crystal", [ec, item] { ec->removeParticle(item); }); + this, "meso crystal", [ec, mesocrystalItem] { ec->removeParticle(mesocrystalItem); }); if (allowRemove) collapser->addAction(m_removeAction); } diff --git a/GUI/View/SampleDesigner/MesocrystalForm.h b/GUI/View/SampleDesigner/MesocrystalForm.h index d51d13729344d523ab048d84f25dfc5ec42256b1..153d303f8ec1ce5c00b5e24cdc7c93f25f13c502 100644 --- a/GUI/View/SampleDesigner/MesocrystalForm.h +++ b/GUI/View/SampleDesigner/MesocrystalForm.h @@ -27,7 +27,7 @@ class ItemWithParticles; class MesocrystalForm : public QGroupBox { Q_OBJECT public: - MesocrystalForm(QWidget* parent, MesocrystalItem* item, SampleEditorController* ec, + MesocrystalForm(QWidget* parent, MesocrystalItem* mesocrystalItem, SampleEditorController* ec, bool allowRemove = true); void enableStructureEditing(bool b); diff --git a/GUI/View/SampleDesigner/ParticleForm.cpp b/GUI/View/SampleDesigner/ParticleForm.cpp index 3ccacda65a3057c44619a61679eeca4e81506dac..a650923b16f6e8159770bfc2bd96e1988d2f4feb 100644 --- a/GUI/View/SampleDesigner/ParticleForm.cpp +++ b/GUI/View/SampleDesigner/ParticleForm.cpp @@ -22,43 +22,43 @@ #include "GUI/View/Tool/GroupBoxCollapser.h" #include <QAction> -ParticleForm::ParticleForm(QWidget* parent, ParticleItem* particle, bool allowAbundance, +ParticleForm::ParticleForm(QWidget* parent, ParticleItem* particleItem, bool allowAbundance, SampleEditorController* ec, bool allowRemove) : QGroupBox(parent) { - const QString formfactor = FormFactorItemCatalog::menuEntry(particle->formFactorItem()); + const QString formfactor = FormFactorItemCatalog::menuEntry(particleItem->formFactorItem()); setTitle("Particle (" + formfactor + ")"); FormLayouter layouter(this, ec); - layouter.addRow("Material", new MaterialInplaceForm(this, particle, ec)); - layouter.addGroupOfValues("Geometry", particle->formFactorItem()->geometryProperties()); - layouter.addVector(particle->position(), false); - layouter.addSelection(particle->rotationSelection()); + layouter.addRow("Material", new MaterialInplaceForm(this, particleItem, ec)); + layouter.addGroupOfValues("Geometry", particleItem->formFactorItem()->geometryProperties()); + layouter.addVector(particleItem->position(), false); + layouter.addSelection(particleItem->rotationSelection()); if (allowAbundance) - layouter.addValue(particle->abundance()); + layouter.addValue(particleItem->abundance()); auto* collapser = GroupBoxCollapser::installIntoGroupBox(this); - collapser->setExpanded(particle->isExpandParticle()); + collapser->setExpanded(particleItem->isExpandParticle()); connect(collapser, &GroupBoxCollapser::toggled, this, - [particle](bool b) { particle->setExpandParticle(b); }); + [particleItem](bool b) { particleItem->setExpandParticle(b); }); // top right corner actions // show in real space { auto* showInRealspaceAction = ActionFactory::createShowInRealspaceAction( - this, "particle", [ec, particle] { ec->requestViewInRealspace(particle); }); + this, "particle", [ec, particleItem] { ec->requestViewInRealspace(particleItem); }); collapser->addAction(showInRealspaceAction); } // duplicate { m_duplicateAction = ActionFactory::createDuplicateAction( - this, "particle", [ec, particle] { ec->duplicateItemWithParticles(particle); }); + this, "particle", [ec, particleItem] { ec->duplicateItemWithParticles(particleItem); }); collapser->addAction(m_duplicateAction); } // remove { m_removeAction = ActionFactory::createRemoveAction( - this, "particle", [ec, particle] { ec->removeParticle(particle); }); + this, "particle", [ec, particleItem] { ec->removeParticle(particleItem); }); if (allowRemove) collapser->addAction(m_removeAction); } diff --git a/GUI/View/SampleDesigner/ParticleForm.h b/GUI/View/SampleDesigner/ParticleForm.h index 9ae41d080e42577bd998f50080ddc652ebfc13e6..82c584f92bf48f6ee48b876c8c5d556475b7f5cd 100644 --- a/GUI/View/SampleDesigner/ParticleForm.h +++ b/GUI/View/SampleDesigner/ParticleForm.h @@ -24,7 +24,7 @@ class SampleEditorController; class ParticleForm : public QGroupBox { Q_OBJECT public: - ParticleForm(QWidget* parent, ParticleItem* particle, bool allowAbundance, + ParticleForm(QWidget* parent, ParticleItem* particleItem, bool allowAbundance, SampleEditorController* ec, bool allowRemove = true); void enableStructureEditing(bool b); diff --git a/GUI/View/SampleDesigner/ParticleLayoutForm.cpp b/GUI/View/SampleDesigner/ParticleLayoutForm.cpp index ba37d8bed126b72c23fdbf19b9448e3e15cab9a9..f78c0fad91f24230f6052e341c6e890ce5a87cb9 100644 --- a/GUI/View/SampleDesigner/ParticleLayoutForm.cpp +++ b/GUI/View/SampleDesigner/ParticleLayoutForm.cpp @@ -28,10 +28,10 @@ #include <QAction> #include <QPushButton> -ParticleLayoutForm::ParticleLayoutForm(LayerForm* form, ParticleLayoutItem* layout, +ParticleLayoutForm::ParticleLayoutForm(LayerForm* form, ParticleLayoutItem* pLayoutItem, SampleEditorController* ec) : QGroupBox(form) - , m_layoutItem(layout) + , m_layoutItem(pLayoutItem) , m_ec(ec) { FormLayouter layouter(this, ec); @@ -40,40 +40,47 @@ ParticleLayoutForm::ParticleLayoutForm(LayerForm* form, ParticleLayoutItem* layo m_totalDensitySpinBox = layouter.widgetAt<DoubleSpinBox*>(rowOfTotalDensity, QFormLayout::FieldRole); ASSERT(m_totalDensitySpinBox); - layouter.addRow(new InterferenceForm(this, layout, ec)); + layouter.addRow(new InterferenceForm(this, pLayoutItem, ec)); for (auto* particle : m_layoutItem->itemsWithParticles()) layouter.addRow( LayerEditorUtil::createWidgetForItemWithParticles(this, particle, true, ec)); auto* btn = LayerEditorUtil::createAddParticleButton( - this, [=](FormFactorItemCatalog::Type type) { ec->addParticleLayoutItem(layout, type); }, - [=](ItemWithParticlesCatalog::Type type) { ec->addParticleLayoutItem(layout, type); }); + this, + [=](FormFactorItemCatalog::Type type) { ec->addParticleLayoutItem(pLayoutItem, type); }, + [=](ItemWithParticlesCatalog::Type type) { ec->addParticleLayoutItem(pLayoutItem, type); }); m_structureEditingWidgets << btn; layouter.addStructureEditingRow(btn); m_collapser = GroupBoxCollapser::installIntoGroupBox(this); - m_collapser->setExpanded(layout->isExpandLayout()); + m_collapser->setExpanded(pLayoutItem->isExpandLayout()); connect(m_collapser, &GroupBoxCollapser::toggled, this, - [layout](bool b) { layout->setExpandLayout(b); }); + [pLayoutItem](bool b) { pLayoutItem->setExpandLayout(b); }); // top right corner actions // show in real space { - auto* showInRealspaceAction = ActionFactory::createShowInRealspaceAction( - this, "particle layout", [ec, layout] { ec->requestViewInRealspace(layout); }); + auto* showInRealspaceAction = + ActionFactory::createShowInRealspaceAction(this, "particle layout", [ec, pLayoutItem] { + ec->requestViewInRealspace(pLayoutItem); + }); m_collapser->addAction(showInRealspaceAction); } // duplicate { - m_duplicateAction = ActionFactory::createDuplicateAction( - this, "particle layout", [ec, layout, form] { ec->duplicateLayoutItem(form, layout); }); + m_duplicateAction = + ActionFactory::createDuplicateAction(this, "particle layout", [ec, pLayoutItem, form] { + ec->duplicateLayoutItem(form, pLayoutItem); + }); m_collapser->addAction(m_duplicateAction); } // remove { - m_removeAction = ActionFactory::createRemoveAction( - this, "particle layout", [ec, layout, form] { ec->removeLayoutItem(form, layout); }); + m_removeAction = + ActionFactory::createRemoveAction(this, "particle layout", [ec, pLayoutItem, form] { + ec->removeLayoutItem(form, pLayoutItem); + }); m_collapser->addAction(m_removeAction); } diff --git a/GUI/View/SampleDesigner/ParticleLayoutForm.h b/GUI/View/SampleDesigner/ParticleLayoutForm.h index 73953a59840d81c9f7e25b8a749343071ea635f4..ca0940a1aa8a42de57c09b19dc771abeacb49f3c 100644 --- a/GUI/View/SampleDesigner/ParticleLayoutForm.h +++ b/GUI/View/SampleDesigner/ParticleLayoutForm.h @@ -31,7 +31,8 @@ class SampleEditorController; class ParticleLayoutForm : public QGroupBox { Q_OBJECT public: - ParticleLayoutForm(LayerForm* form, ParticleLayoutItem* layoutItem, SampleEditorController* ec); + ParticleLayoutForm(LayerForm* form, ParticleLayoutItem* pLayoutItem, + SampleEditorController* ec); void enableStructureEditing(bool b); ParticleLayoutItem* layoutItem() const; diff --git a/GUI/View/SampleDesigner/SampleEditorController.cpp b/GUI/View/SampleDesigner/SampleEditorController.cpp index 9ef53953dd84d194711adb1834314ca1da0577b9..deac9b1f9f9f110c7fb750a5d41f3f05afd93cf5 100644 --- a/GUI/View/SampleDesigner/SampleEditorController.cpp +++ b/GUI/View/SampleDesigner/SampleEditorController.cpp @@ -129,21 +129,21 @@ void SampleEditorController::addLayerItemFromUndo(int atIndex) onLayerAdded(layer); } -void SampleEditorController::duplicateLayerItem(const LayerItem* layerItem) +void SampleEditorController::duplicateLayerItem(const LayerItem* layer) { - int at_index = m_sampleItem->layerItems().indexOf(layerItem) + 1; - QColor color = findColor(at_index); // before adding layer + int atIndex = m_sampleItem->layerItems().indexOf(layer) + 1; + QColor color = findColor(atIndex); // before adding layer - LayerItem* new_layer = m_sampleItem->createLayerItemAt(at_index); - GUI::Util::copyContents(layerItem, new_layer); - new_layer->setColor(color); + LayerItem* newLayer = m_sampleItem->createLayerItemAt(atIndex); + GUI::Util::copyContents(layer, newLayer); + newLayer->setColor(color); - onLayerAdded(new_layer); + onLayerAdded(newLayer); } -void SampleEditorController::removeLayerItem(LayerItem* layerItem) +void SampleEditorController::removeLayerItem(LayerItem* layer) { - m_undoStack.push(new CommandRemoveLayer(this, layerItem)); + m_undoStack.push(new CommandRemoveLayer(this, layer)); } void SampleEditorController::removeLayerItemFromUndo(int atIndex) @@ -169,32 +169,31 @@ void SampleEditorController::onLayoutAdded(LayerForm* layerForm, ParticleLayoutI void SampleEditorController::addLayoutItem(LayerForm* layerForm) { - auto* newLayoutItem = layerForm->layerItem()->addLayoutItem(); - onLayoutAdded(layerForm, newLayoutItem); + auto* newLayout = layerForm->layerItem()->addLayoutItem(); + onLayoutAdded(layerForm, newLayout); } void SampleEditorController::duplicateLayoutItem(LayerForm* layerForm, ParticleLayoutItem* layout) { - auto* newLayoutItem = layerForm->layerItem()->addLayoutItem(); - GUI::Util::copyContents(layout, newLayoutItem); - onLayoutAdded(layerForm, newLayoutItem); + auto* newLayout = layerForm->layerItem()->addLayoutItem(); + GUI::Util::copyContents(layout, newLayout); + onLayoutAdded(layerForm, newLayout); } -void SampleEditorController::removeLayoutItem(LayerForm* layerItemWidget, - ParticleLayoutItem* layout) +void SampleEditorController::removeLayoutItem(LayerForm* layerForm, ParticleLayoutItem* layout) { emit aboutToRemoveItem(layout); - layerItemWidget->onAboutToRemoveLayout(layout); - layerItemWidget->layerItem()->removeLayoutItem(layout); + layerForm->onAboutToRemoveLayout(layout); + layerForm->layerItem()->removeLayoutItem(layout); - for (auto* layoutForms : layerItemWidget->findChildren<ParticleLayoutForm*>()) - layoutForms->updateTitle(layerItemWidget->layerItem()); + for (auto* layoutForm : layerForm->findChildren<ParticleLayoutForm*>()) + layoutForm->updateTitle(layerForm->layerItem()); emit modified(); } void SampleEditorController::onParticleLayoutAdded(ParticleLayoutItem* layout, - ItemWithParticles* new_item) + ItemWithParticles* newItem) { emit modified(); @@ -202,7 +201,7 @@ void SampleEditorController::onParticleLayoutAdded(ParticleLayoutItem* layout, ASSERT(m_sampleForm); for (auto* w : m_sampleForm->findChildren<ParticleLayoutForm*>()) if (w->layoutItem() == layout) - w->onParticleAdded(new_item); + w->onParticleAdded(newItem); m_sampleForm->updateUnits(); } @@ -228,10 +227,10 @@ void SampleEditorController::duplicateItemWithParticles(ItemWithParticles* item) auto* newItem = createAndInitItem(type); GUI::Util::copyContents(item, newItem); - if (ParticleLayoutItem* parent_layout = parentLayout(item)) { + if (ParticleLayoutItem* parent_layout = parentLayoutItem(item)) { parent_layout->addItemWithParticleSelection(newItem); onParticleLayoutAdded(parent_layout, newItem); - } else if (CompoundItem* parent_compound = parentCompound(item)) { + } else if (CompoundItem* parent_compound = parentCompoundItem(item)) { parent_compound->addItemWithParticleSelection(newItem); onParticleCompoundAdded(parent_compound, newItem); } else @@ -239,7 +238,7 @@ void SampleEditorController::duplicateItemWithParticles(ItemWithParticles* item) } void SampleEditorController::onParticleCompoundAdded(CompoundItem* composition, - ItemWithParticles* new_item) + ItemWithParticles* newItem) { emit modified(); @@ -247,7 +246,7 @@ void SampleEditorController::onParticleCompoundAdded(CompoundItem* composition, ASSERT(m_sampleForm); for (auto* c : m_sampleForm->findChildren<CompoundForm*>()) if (c->compositionItem() == composition) - c->onParticleAdded(new_item); + c->onParticleAdded(newItem); m_sampleForm->updateUnits(); } @@ -326,7 +325,7 @@ void SampleEditorController::setShellFormFactor(CoreAndShellForm* widget, emit modified(); } -ParticleLayoutItem* SampleEditorController::parentLayout(ItemWithParticles* item) +ParticleLayoutItem* SampleEditorController::parentLayoutItem(ItemWithParticles* item) { for (auto* layoutForm : m_sampleForm->findChildren<ParticleLayoutForm*>()) if (layoutForm->layoutItem()->itemsWithParticles().contains(item)) @@ -334,11 +333,11 @@ ParticleLayoutItem* SampleEditorController::parentLayout(ItemWithParticles* item return nullptr; } -CompoundItem* SampleEditorController::parentCompound(ItemWithParticles* item) +CompoundItem* SampleEditorController::parentCompoundItem(ItemWithParticles* item) { - for (auto* layoutForm : m_sampleForm->findChildren<CompoundForm*>()) - if (layoutForm->compositionItem()->itemsWithParticles().contains(item)) - return layoutForm->compositionItem(); + for (auto* compoundForm : m_sampleForm->findChildren<CompoundForm*>()) + if (compoundForm->compositionItem()->itemsWithParticles().contains(item)) + return compoundForm->compositionItem(); return nullptr; } diff --git a/GUI/View/SampleDesigner/SampleEditorController.h b/GUI/View/SampleDesigner/SampleEditorController.h index fa1d9e6cacb21e6ba3f652f29132a9bcc8d4c45d..7f747e542be8b4c314d451c0e0c9a31c2d288eb2 100644 --- a/GUI/View/SampleDesigner/SampleEditorController.h +++ b/GUI/View/SampleDesigner/SampleEditorController.h @@ -75,24 +75,24 @@ public: QColor findColor(int atIndex); void onLayerAdded(LayerItem* layer); void addLayerItemFromUndo(int atIndex); - void duplicateLayerItem(const LayerItem* layerItem); - void removeLayerItem(LayerItem* layerItem); + void duplicateLayerItem(const LayerItem* layer); + void removeLayerItem(LayerItem* layer); void removeLayerItemFromUndo(int atIndex); void onLayoutAdded(LayerForm* layerForm, ParticleLayoutItem* layout); void addLayoutItem(LayerForm* layerForm); void duplicateLayoutItem(LayerForm* layerForm, ParticleLayoutItem* layout); - void removeLayoutItem(LayerForm* layerItem, ParticleLayoutItem* layout); + void removeLayoutItem(LayerForm* layerForm, ParticleLayoutItem* layout); - void onParticleLayoutAdded(ParticleLayoutItem* layout, ItemWithParticles* new_item); + void onParticleLayoutAdded(ParticleLayoutItem* layout, ItemWithParticles* newItem); void addParticleLayoutItem(ParticleLayoutItem* layout, ItemWithParticlesCatalog::Type type); void addParticleLayoutItem(ParticleLayoutItem* layout, FormFactorItemCatalog::Type t); - ParticleLayoutItem* parentLayout(ItemWithParticles* item); + ParticleLayoutItem* parentLayoutItem(ItemWithParticles* item); - void onParticleCompoundAdded(CompoundItem* composition, ItemWithParticles* new_item); + void onParticleCompoundAdded(CompoundItem* composition, ItemWithParticles* newItem); void addCompoundItem(CompoundItem* composition, ItemWithParticlesCatalog::Type type); void addCompoundItem(CompoundItem* composition, FormFactorItemCatalog::Type type); - CompoundItem* parentCompound(ItemWithParticles* item); + CompoundItem* parentCompoundItem(ItemWithParticles* item); void duplicateItemWithParticles(ItemWithParticles* item); void removeParticle(ItemWithParticles* item);