Skip to content
Snippets Groups Projects
Commit 7edf1305 authored by Matthias Puchner's avatar Matthias Puchner
Browse files

rm usage of SessionMode's modelType (to be continued)

parent eae864e9
No related branches found
No related tags found
1 merge request!570remove SessionModel/Item from SampleModel and all related items
...@@ -21,7 +21,6 @@ ...@@ -21,7 +21,6 @@
#include "GUI/Model/Sample/ParticleCompositionItem.h" #include "GUI/Model/Sample/ParticleCompositionItem.h"
#include "GUI/Model/Sample/ParticleCoreShellItem.h" #include "GUI/Model/Sample/ParticleCoreShellItem.h"
#include "GUI/Model/Sample/ParticleItem.h" #include "GUI/Model/Sample/ParticleItem.h"
#include "GUI/Model/Trafo/RotationItems.h"
#include "GUI/Model/Types/VectorDescriptor.h" #include "GUI/Model/Types/VectorDescriptor.h"
#include "GUI/View/Edit/DoubleSpinBox.h" #include "GUI/View/Edit/DoubleSpinBox.h"
#include "GUI/View/SampleDesigner/FormLayouter.h" #include "GUI/View/SampleDesigner/FormLayouter.h"
...@@ -215,8 +214,9 @@ QWidget* LayerEditorUtils::createWidgetForItemWithParticles(QWidget* parentWidge ...@@ -215,8 +214,9 @@ QWidget* LayerEditorUtils::createWidgetForItemWithParticles(QWidget* parentWidge
return nullptr; return nullptr;
} }
QPushButton* LayerEditorUtils::createAddParticleButton(QWidget* parentWidget, QPushButton* LayerEditorUtils::createAddParticleButton(
std::function<void(const QString&)> slot) QWidget* parentWidget, std::function<void(FormFactorItemCatalog::Type t)> slotAddFormFactor,
std::function<void(ItemWithParticlesCatalog::Type t)> slotAddParticle)
{ {
auto* btn = new QPushButton("Add particle", parentWidget); auto* btn = new QPushButton("Add particle", parentWidget);
...@@ -225,24 +225,31 @@ QPushButton* LayerEditorUtils::createAddParticleButton(QWidget* parentWidget, ...@@ -225,24 +225,31 @@ QPushButton* LayerEditorUtils::createAddParticleButton(QWidget* parentWidget,
const auto group = [&](const QString& title) { menuForEntries = menu->addMenu(title); }; const auto group = [&](const QString& title) { menuForEntries = menu->addMenu(title); };
const auto entry = [&](const QString& modelType) { group("Hard particles");
const auto ui = ItemCatalog::instance().uiInfo(modelType); for (const auto type : FormFactorItemCatalog::hardParticleTypes()) {
const auto ui = FormFactorItemCatalog::uiInfo(type);
QAction* a = menuForEntries->addAction(QIcon(ui.iconPath), ui.menuEntry); QAction* a = menuForEntries->addAction(QIcon(ui.iconPath), ui.menuEntry);
a->setToolTip(ui.description); a->setToolTip(ui.description);
QObject::connect(a, &QAction::triggered, [=]() { slot(modelType); }); QObject::connect(a, &QAction::triggered, [=]() { slotAddFormFactor(type); });
}; }
group("Hard particles");
for (const auto& modelType : ItemCatalog::formfactorHardParticleTypes())
entry(modelType);
group("Ripples"); group("Ripples");
for (const auto& modelType : ItemCatalog::formfactorRippleTypes()) for (const auto type : FormFactorItemCatalog::rippleTypes()) {
entry(modelType); const auto ui = FormFactorItemCatalog::uiInfo(type);
QAction* a = menuForEntries->addAction(QIcon(ui.iconPath), ui.menuEntry);
a->setToolTip(ui.description);
QObject::connect(a, &QAction::triggered, [=]() { slotAddFormFactor(type); });
}
group("Particle assemblies"); group("Particle assemblies");
for (const auto& modelType : ItemCatalog::particleAssemblyTypes()) for (const auto type :
entry(modelType); {ItemWithParticlesCatalog::Type::Composition, ItemWithParticlesCatalog::Type::CoreShell,
ItemWithParticlesCatalog::Type::MesoCrystal}) {
const auto ui = ItemWithParticlesCatalog::uiInfo(type);
QAction* a = menuForEntries->addAction(QIcon(ui.iconPath), ui.menuEntry);
a->setToolTip(ui.description);
QObject::connect(a, &QAction::triggered, [=]() { slotAddParticle(type); });
}
btn->setMenu(menu); btn->setMenu(menu);
......
...@@ -17,6 +17,8 @@ ...@@ -17,6 +17,8 @@
#include "GUI/Model/Types/DoubleDescriptor.h" #include "GUI/Model/Types/DoubleDescriptor.h"
#include "GUI/Model/Sample/FormFactorItemCatalog.h"
#include "GUI/Model/Sample/ItemWithParticlesCatalog.h"
#include <QColor> #include <QColor>
#include <QList> #include <QList>
#include <functional> #include <functional>
...@@ -85,8 +87,10 @@ QWidget* createWidgetForItemWithParticles(QWidget* parentWidget, ...@@ -85,8 +87,10 @@ QWidget* createWidgetForItemWithParticles(QWidget* parentWidget,
ItemWithParticles* itemWithParticles, bool allowAbundance, ItemWithParticles* itemWithParticles, bool allowAbundance,
SampleEditorController* ec, bool allowRemove = true); SampleEditorController* ec, bool allowRemove = true);
QPushButton* createAddParticleButton(QWidget* parentWidget, QPushButton*
std::function<void(const QString&)> slot); createAddParticleButton(QWidget* parentWidget,
std::function<void(FormFactorItemCatalog::Type t)> slotAddFormFactor,
std::function<void(ItemWithParticlesCatalog::Type t)> slotAddParticle);
QList<QColor> predefinedLayerColors(); QList<QColor> predefinedLayerColors();
......
...@@ -66,35 +66,39 @@ QComboBox* MesoCrystalForm::createBasisCombo(QWidget* parent, ItemWithParticles* ...@@ -66,35 +66,39 @@ QComboBox* MesoCrystalForm::createBasisCombo(QWidget* parent, ItemWithParticles*
WheelEventEater::install(combo); WheelEventEater::install(combo);
combo->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); combo->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
const auto modelTypes = ItemCatalog::formfactorHardParticleTypes() // #baMigration ++ implement basis combo
+ ItemCatalog::formfactorRippleTypes() // const auto modelTypes = ItemCatalog::formfactorHardParticleTypes()
+ ItemCatalog::particleAssemblyTypes(); // + ItemCatalog::formfactorRippleTypes()
// + ItemCatalog::particleAssemblyTypes(); //
combo->addItem("None", ""); // ParticleCoreShellItem::M_TYPE,
for (const auto& modelType : modelTypes) { // ParticleCompositionItem::M_TYPE,MesoCrystalItem::M_TYPE};
const auto ui = ItemCatalog::instance().uiInfo(modelType); //
combo->addItem(QIcon(ui.iconPath), ui.menuEntry, modelType); // combo->addItem("None", "");
} // for (const auto& modelType : modelTypes) {
// const auto ui = ItemCatalog::instance().uiInfo(modelType);
combo->setMaxVisibleItems(combo->count()); // combo->addItem(QIcon(ui.iconPath), ui.menuEntry, modelType);
// }
if (current == nullptr) //
combo->setCurrentIndex(0); // combo->setMaxVisibleItems(combo->count());
else if (auto* p = dynamic_cast<ParticleItem*>(current)) //
combo->setCurrentIndex(combo->findData(p->formfactor()->modelType())); // if (current == nullptr)
else // combo->setCurrentIndex(0);
combo->setCurrentIndex(combo->findData(current->modelType())); // else if (auto* p = dynamic_cast<ParticleItem*>(current))
// combo->setCurrentIndex(combo->findData(p->formfactor()->modelType()));
// else
// combo->setCurrentIndex(combo->findData(current->modelType()));
//
return combo; return combo;
} }
void MesoCrystalForm::onBasisComboChanged() void MesoCrystalForm::onBasisComboChanged()
{ {
while (m_layout->rowCount() > m_rowOfBasisTypeCombo + 1) // #baMigration ++ implement basis combo
m_layout->removeRow(m_rowOfBasisTypeCombo + 1); // while (m_layout->rowCount() > m_rowOfBasisTypeCombo + 1)
// m_layout->removeRow(m_rowOfBasisTypeCombo + 1);
const QString newClassName = m_basisCombo->currentData().toString(); //
m_ec->setMesoCrystalBasis(this, newClassName); // const QString newClassName = m_basisCombo->currentData().toString();
// m_ec->setMesoCrystalBasis(this, newClassName);
} }
void MesoCrystalForm::createBasisWidgets() void MesoCrystalForm::createBasisWidgets()
......
...@@ -33,14 +33,14 @@ CommandRemoveLayer::CommandRemoveLayer(SampleEditorController* ec, LayerItem* la ...@@ -33,14 +33,14 @@ CommandRemoveLayer::CommandRemoveLayer(SampleEditorController* ec, LayerItem* la
{ {
m_indexOfLayer = ec->multiLayerItem()->layers().indexOf(layerItem); m_indexOfLayer = ec->multiLayerItem()->layers().indexOf(layerItem);
m_layerItemBackup = m_backupModel.insertItem<LayerItem>(); // m_layerItemBackup = m_backupModel.insertItem<LayerItem>();
//
auto* source = layerItem; // auto* source = layerItem;
//
for (auto* child : source->children()) { // for (auto* child : source->children()) {
auto tag = source->tagFromItem(child); // auto tag = source->tagFromItem(child);
m_backupModel.copyItem(child, m_layerItemBackup, tag); // m_backupModel.copyItem(child, m_layerItemBackup, tag);
} // }
} }
void CommandRemoveLayer::redo() void CommandRemoveLayer::redo()
...@@ -55,21 +55,21 @@ void CommandRemoveLayer::redo() ...@@ -55,21 +55,21 @@ void CommandRemoveLayer::redo()
void CommandRemoveLayer::undo() void CommandRemoveLayer::undo()
{ {
if (m_indexOfLayer < m_ec->multiLayerItem()->layers().size()) // if (m_indexOfLayer < m_ec->multiLayerItem()->layers().size())
m_ec->multiLayerItem()->addLayer(m_indexOfLayer); // m_ec->multiLayerItem()->addLayer(m_indexOfLayer);
else // else
m_ec->multiLayerItem()->addLayer(-1); // m_ec->multiLayerItem()->addLayer(-1);
//
auto* restoredLayer = m_ec->multiLayerItem()->layers()[m_indexOfLayer]; // auto* restoredLayer = m_ec->multiLayerItem()->layers()[m_indexOfLayer];
restoredLayer->setMaterialModel(m_ec->materialModel()); // restoredLayer->setMaterialModel(m_ec->materialModel());
//
for (auto* child : m_layerItemBackup->children()) { // for (auto* child : m_layerItemBackup->children()) {
auto tag = m_layerItemBackup->tagFromItem(child); // auto tag = m_layerItemBackup->tagFromItem(child);
m_backupModel.copyItem(child, restoredLayer, tag); // m_backupModel.copyItem(child, restoredLayer, tag);
} // }
//
m_ec->multiLayerForm()->onLayerAdded(restoredLayer); // m_ec->multiLayerForm()->onLayerAdded(restoredLayer);
emit m_ec->modified(); // emit m_ec->modified();
} }
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include "GUI/View/SampleDesigner/SampleEditorController.h" #include "GUI/View/SampleDesigner/SampleEditorController.h"
#include "GUI/Model/Material/MaterialModel.h" #include "GUI/Model/Material/MaterialModel.h"
#include "GUI/Model/Project/ProjectDocument.h" #include "GUI/Model/Project/ProjectDocument.h"
#include "GUI/Model/Sample/FormFactorItemCatalog.h"
#include "GUI/Model/Sample/InterferenceItems.h" #include "GUI/Model/Sample/InterferenceItems.h"
#include "GUI/Model/Sample/LayerItem.h" #include "GUI/Model/Sample/LayerItem.h"
#include "GUI/Model/Sample/MesoCrystalItem.h" #include "GUI/Model/Sample/MesoCrystalItem.h"
...@@ -35,6 +36,7 @@ ...@@ -35,6 +36,7 @@
#include "GUI/View/SampleDesigner/ParticleCoreShellForm.h" #include "GUI/View/SampleDesigner/ParticleCoreShellForm.h"
#include "GUI/View/SampleDesigner/ParticleLayoutForm.h" #include "GUI/View/SampleDesigner/ParticleLayoutForm.h"
#include "GUI/View/SampleDesigner/SampleEditorCommands.h" #include "GUI/View/SampleDesigner/SampleEditorCommands.h"
#include "Sample/HardParticle/FormFactorCylinder.h"
SampleEditorController::SampleEditorController(ProjectDocument* document, MultiLayerItem* multi) SampleEditorController::SampleEditorController(ProjectDocument* document, MultiLayerItem* multi)
: m_multiLayerItem(multi), m_multiLayerForm(nullptr), m_document(document) : m_multiLayerItem(multi), m_multiLayerForm(nullptr), m_document(document)
...@@ -137,21 +139,37 @@ void SampleEditorController::removeLayout(LayerForm* layerItemWidget, ParticleLa ...@@ -137,21 +139,37 @@ void SampleEditorController::removeLayout(LayerForm* layerItemWidget, ParticleLa
emit modified(); emit modified();
} }
void SampleEditorController::addParticle(ParticleLayoutItem* layoutItem, const QString& classname) void SampleEditorController::addParticle(ParticleLayoutItem* layoutItem,
FormFactorItemCatalog::Type formFactorType)
{ {
SessionItem* newItem = nullptr; auto* newParticle = new ParticleItem();
if (ItemCatalog::isFormFactorModelType(classname)) { layoutItem->addParticle(newParticle);
auto* new_particle = layoutItem->model()->insertItem<ParticleItem>(layoutItem); newParticle->setMaterialModel(materialModel());
new_particle->setMaterialModel(materialModel()); newParticle->setFormFactor(FormFactorItemCatalog::create(formFactorType));
new_particle->setFormFactor(classname); newParticle->setMaterial(materialModel()->defaultMaterial());
new_particle->setMaterial(materialModel()->defaultMaterial());
newItem = new_particle; emit modified();
} else
newItem = layoutItem->model()->insertNewItem(classname, layoutItem); // search for particle layout widget for notification
ASSERT(m_multiLayerForm);
for (auto* w : m_multiLayerForm->findChildren<ParticleLayoutForm*>())
if (w->layoutItem() == layoutItem)
w->onParticleAdded(newParticle);
m_multiLayerForm->updateUnits();
}
void SampleEditorController::addParticle(ParticleLayoutItem* layoutItem,
ItemWithParticlesCatalog::Type type)
{
auto* newItem = ItemWithParticlesCatalog::create(type);
layoutItem->addParticle(newItem);
if (auto* cs = dynamic_cast<ParticleCoreShellItem*>(newItem)) { if (auto* cs = dynamic_cast<ParticleCoreShellItem*>(newItem)) {
cs->createCore(materialModel()); cs->createCore(materialModel());
cs->createShell(materialModel()); cs->createShell(materialModel());
cs->core()->setFormFactor(new CylinderItem());
cs->shell()->setFormFactor(new CylinderItem());
} }
emit modified(); emit modified();
...@@ -165,26 +183,20 @@ void SampleEditorController::addParticle(ParticleLayoutItem* layoutItem, const Q ...@@ -165,26 +183,20 @@ void SampleEditorController::addParticle(ParticleLayoutItem* layoutItem, const Q
} }
void SampleEditorController::addParticle(ParticleCompositionItem* compositionItem, void SampleEditorController::addParticle(ParticleCompositionItem* compositionItem,
const QString& classname) ItemWithParticlesCatalog::Type type)
{ {
SessionItem* newItem = nullptr; auto* newItem = ItemWithParticlesCatalog::create(type);
if (ItemCatalog::isFormFactorModelType(classname)) { compositionItem->addParticle(newItem);
auto* new_particle = compositionItem->model()->insertItem<ParticleItem>(compositionItem);
new_particle->setMaterialModel(materialModel());
new_particle->setFormFactor(classname);
new_particle->setMaterial(materialModel()->defaultMaterial());
newItem = new_particle;
} else {
newItem = compositionItem->model()->insertNewItem(classname, compositionItem);
if (auto* p = dynamic_cast<ItemWithMaterial*>(newItem)) { if (auto* p = dynamic_cast<ItemWithMaterial*>(newItem)) {
p->setMaterialModel(materialModel()); p->setMaterialModel(materialModel());
p->setMaterial(materialModel()->defaultMaterial()); p->setMaterial(materialModel()->defaultMaterial());
} }
}
if (auto* cs = dynamic_cast<ParticleCoreShellItem*>(newItem)) { if (auto* cs = dynamic_cast<ParticleCoreShellItem*>(newItem)) {
cs->createCore(materialModel()); cs->createCore(materialModel());
cs->createShell(materialModel()); cs->createShell(materialModel());
cs->core()->setFormFactor(new CylinderItem());
cs->shell()->setFormFactor(new CylinderItem());
} }
emit modified(); emit modified();
...@@ -197,39 +209,48 @@ void SampleEditorController::addParticle(ParticleCompositionItem* compositionIte ...@@ -197,39 +209,48 @@ void SampleEditorController::addParticle(ParticleCompositionItem* compositionIte
m_multiLayerForm->updateUnits(); m_multiLayerForm->updateUnits();
} }
void SampleEditorController::setCoreFormFactor(ParticleCoreShellForm* widget, void SampleEditorController::addParticle(ParticleCompositionItem* compositionItem,
const QString& formfactorModelType) FormFactorItemCatalog::Type formFactorType)
{ {
auto* particleCoreShell = widget->coreShellItem(); auto* newParticle = new ParticleItem();
compositionItem->addParticle(newParticle);
newParticle->setMaterialModel(materialModel());
newParticle->setFormFactor(FormFactorItemCatalog::create(formFactorType));
newParticle->setMaterial(materialModel()->defaultMaterial());
if (formfactorModelType.isEmpty()) { emit modified();
particleCoreShell->clearCore();
return; // search for composition widget for notification
ASSERT(m_multiLayerForm);
for (auto* c : m_multiLayerForm->findChildren<ParticleCompositionForm*>())
if (c->compositionItem() == compositionItem)
c->onParticleAdded(newParticle);
m_multiLayerForm->updateUnits();
} }
void SampleEditorController::setCoreFormFactor(ParticleCoreShellForm* widget,
FormFactorItemCatalog::Type type)
{
auto* particleCoreShell = widget->coreShellItem();
if (particleCoreShell->core() == nullptr) if (particleCoreShell->core() == nullptr)
particleCoreShell->createCore(materialModel()); particleCoreShell->createCore(materialModel());
particleCoreShell->core()->setFormFactor(formfactorModelType); particleCoreShell->core()->setFormFactor(FormFactorItemCatalog::create(type));
widget->createCoreWidgets(); widget->createCoreWidgets();
m_multiLayerForm->updateUnits(); m_multiLayerForm->updateUnits();
emit modified(); emit modified();
} }
void SampleEditorController::setShellFormFactor(ParticleCoreShellForm* widget, void SampleEditorController::setShellFormFactor(ParticleCoreShellForm* widget,
const QString& formfactorModelType) FormFactorItemCatalog::Type type)
{ {
auto* particleCoreShell = widget->coreShellItem(); auto* particleCoreShell = widget->coreShellItem();
if (formfactorModelType.isEmpty()) {
particleCoreShell->clearShell();
return;
}
if (particleCoreShell->shell() == nullptr) if (particleCoreShell->shell() == nullptr)
particleCoreShell->createShell(materialModel()); particleCoreShell->createShell(materialModel());
particleCoreShell->shell()->setFormFactor(formfactorModelType); particleCoreShell->shell()->setFormFactor(FormFactorItemCatalog::create(type));
widget->createShellWidgets(); widget->createShellWidgets();
m_multiLayerForm->updateUnits(); m_multiLayerForm->updateUnits();
emit modified(); emit modified();
...@@ -237,38 +258,39 @@ void SampleEditorController::setShellFormFactor(ParticleCoreShellForm* widget, ...@@ -237,38 +258,39 @@ void SampleEditorController::setShellFormFactor(ParticleCoreShellForm* widget,
void SampleEditorController::removeParticle(ItemWithParticles* item) void SampleEditorController::removeParticle(ItemWithParticles* item)
{ {
ASSERT(m_multiLayerForm); // #baMigration ++ implement removeParticle
// search for particle layout parent (the first which can be found) // ASSERT(m_multiLayerForm);
ParticleLayoutItem* layout = nullptr; // // search for particle layout parent (the first which can be found)
ParticleCompositionItem* composition = nullptr; // ParticleLayoutItem* layout = nullptr;
SessionItem* parent = item->parent(); // ParticleCompositionItem* composition = nullptr;
do { // SessionItem* parent = item->parent();
layout = dynamic_cast<ParticleLayoutItem*>(parent); // do {
composition = dynamic_cast<ParticleCompositionItem*>(parent); // layout = dynamic_cast<ParticleLayoutItem*>(parent);
parent = parent->parent(); // composition = dynamic_cast<ParticleCompositionItem*>(parent);
} while (parent && layout == nullptr && composition == nullptr); // parent = parent->parent();
// } while (parent && layout == nullptr && composition == nullptr);
if (layout != nullptr) { //
for (auto* c : m_multiLayerForm->findChildren<ParticleLayoutForm*>()) // if (layout != nullptr) {
if (c->layoutItem() == layout) // for (auto* c : m_multiLayerForm->findChildren<ParticleLayoutForm*>())
c->onAboutToRemoveParticle(item); // if (c->layoutItem() == layout)
// c->onAboutToRemoveParticle(item);
emit aboutToRemoveItem(item); //
layout->removeParticle(item); // emit aboutToRemoveItem(item);
emit modified(); // layout->removeParticle(item);
return; // emit modified();
} // return;
// }
if (composition != nullptr) { //
for (auto* c : m_multiLayerForm->findChildren<ParticleCompositionForm*>()) // if (composition != nullptr) {
if (c->compositionItem() == composition) // for (auto* c : m_multiLayerForm->findChildren<ParticleCompositionForm*>())
c->onAboutToRemoveParticle(item); // if (c->compositionItem() == composition)
// c->onAboutToRemoveParticle(item);
emit aboutToRemoveItem(item); //
composition->removeParticle(item); // emit aboutToRemoveItem(item);
emit modified(); // composition->removeParticle(item);
return; // emit modified();
} // return;
// }
} }
void SampleEditorController::setDouble(double newValue, DoubleDescriptor d) void SampleEditorController::setDouble(double newValue, DoubleDescriptor d)
...@@ -367,18 +389,19 @@ void SampleEditorController::setDensityRelatedValue(InterferenceItem* interferen ...@@ -367,18 +389,19 @@ void SampleEditorController::setDensityRelatedValue(InterferenceItem* interferen
{ {
setDouble(newValue, d); setDouble(newValue, d);
// #baMigration +++ implement this
// -- notify the containing particle layout about changed value // -- notify the containing particle layout about changed value
auto* particlelayoutItem = dynamic_cast<ParticleLayoutItem*>(interferenceItem->parent()); // auto* particlelayoutItem = dynamic_cast<ParticleLayoutItem*>(interferenceItem->parent());
if (!particlelayoutItem) // if (!particlelayoutItem)
return; // return;
//
// -- notify the containing particle layout UI about changed value // // -- notify the containing particle layout UI about changed value
ASSERT(m_multiLayerForm); // ASSERT(m_multiLayerForm);
for (auto* c : m_multiLayerForm->findChildren<ParticleLayoutForm*>()) // for (auto* c : m_multiLayerForm->findChildren<ParticleLayoutForm*>())
if (c->layoutItem() == particlelayoutItem) { // if (c->layoutItem() == particlelayoutItem) {
c->updateDensityValue(); // c->updateDensityValue();
break; // break;
} // }
} }
void SampleEditorController::onStartingToMoveLayer() void SampleEditorController::onStartingToMoveLayer()
...@@ -405,33 +428,24 @@ void SampleEditorController::onStoppedToMoveLayer(QWidget* widgetToMove, ...@@ -405,33 +428,24 @@ void SampleEditorController::onStoppedToMoveLayer(QWidget* widgetToMove,
emit modified(); emit modified();
} }
void SampleEditorController::setMesoCrystalBasis(MesoCrystalForm* widget, const QString& classname) void SampleEditorController::setMesoCrystalBasis(MesoCrystalForm* widget,
ItemWithParticlesCatalog::Type type)
{ {
auto* meso = widget->mesoCrystalItem(); auto* meso = widget->mesoCrystalItem();
meso->setBasis(ItemWithParticlesCatalog::create(type));
if (classname.isEmpty()) { widget->createBasisWidgets();
if (meso->basisParticle() != nullptr) { m_multiLayerForm->updateUnits();
emit aboutToRemoveItem(meso->basisParticle());
meso->model()->removeItem(meso->basisParticle());
emit modified(); emit modified();
} }
return;
}
if (classname == ParticleCompositionItem::M_TYPE) void SampleEditorController::setMesoCrystalBasis(MesoCrystalForm* widget,
meso->createBasis<ParticleCompositionItem>(); FormFactorItemCatalog::Type type)
else if (classname == MesoCrystalItem::M_TYPE) {
meso->createBasis<MesoCrystalItem>(); auto* meso = widget->mesoCrystalItem();
else if (classname == ParticleCoreShellItem::M_TYPE)
meso->createBasis<ParticleCoreShellItem>();
else if (ItemCatalog::isFormFactorModelType(classname)) {
auto* particle = dynamic_cast<ParticleItem*>(meso->basisParticle()); auto* particle = dynamic_cast<ParticleItem*>(meso->basisParticle());
if (particle == nullptr) if (particle == nullptr)
particle = meso->createBasis<ParticleItem>(); particle = meso->createBasis<ParticleItem>();
particle->setFormFactor(FormFactorItemCatalog::create(type));
particle->setFormFactor(classname);
}
widget->createBasisWidgets(); widget->createBasisWidgets();
m_multiLayerForm->updateUnits(); m_multiLayerForm->updateUnits();
emit modified(); emit modified();
......
...@@ -15,6 +15,8 @@ ...@@ -15,6 +15,8 @@
#ifndef BORNAGAIN_GUI_VIEW_SAMPLEDESIGNER_SAMPLEEDITORCONTROLLER_H #ifndef BORNAGAIN_GUI_VIEW_SAMPLEDESIGNER_SAMPLEEDITORCONTROLLER_H
#define BORNAGAIN_GUI_VIEW_SAMPLEDESIGNER_SAMPLEEDITORCONTROLLER_H #define BORNAGAIN_GUI_VIEW_SAMPLEDESIGNER_SAMPLEEDITORCONTROLLER_H
#include "GUI/Model/Sample/FormFactorItemCatalog.h"
#include "GUI/Model/Sample/ItemWithParticlesCatalog.h"
#include "GUI/Model/Sample/SampleItem.h" #include "GUI/Model/Sample/SampleItem.h"
#include <QUndoStack> #include <QUndoStack>
...@@ -76,12 +78,15 @@ public: ...@@ -76,12 +78,15 @@ public:
void addLayout(LayerForm* layerItem); void addLayout(LayerForm* layerItem);
void removeLayout(LayerForm* layerItem, ParticleLayoutItem* layout); void removeLayout(LayerForm* layerItem, ParticleLayoutItem* layout);
void addParticle(ParticleLayoutItem* layout, const QString& classname); void addParticle(ParticleLayoutItem* layout, ItemWithParticlesCatalog::Type type);
void addParticle(ParticleCompositionItem* composition, const QString& classname); void addParticle(ParticleLayoutItem* layout, FormFactorItemCatalog::Type t);
void setCoreFormFactor(ParticleCoreShellForm* widget, const QString& formfactorModelType); void addParticle(ParticleCompositionItem* composition, ItemWithParticlesCatalog::Type type);
void setShellFormFactor(ParticleCoreShellForm* widget, const QString& formfactorModelType); void addParticle(ParticleCompositionItem* composition, FormFactorItemCatalog::Type type);
void setCoreFormFactor(ParticleCoreShellForm* widget, FormFactorItemCatalog::Type type);
void setShellFormFactor(ParticleCoreShellForm* widget, FormFactorItemCatalog::Type type);
void removeParticle(ItemWithParticles* item); void removeParticle(ItemWithParticles* item);
void setMesoCrystalBasis(MesoCrystalForm* widget, const QString& classname); void setMesoCrystalBasis(MesoCrystalForm* widget, ItemWithParticlesCatalog::Type type);
void setMesoCrystalBasis(MesoCrystalForm* widget, FormFactorItemCatalog::Type type);
void selectInterference(InterferenceForm* widget, int newIndex); void selectInterference(InterferenceForm* widget, int newIndex);
void setIntegrateOverXi(LatticeTypeSelectionForm* widget, bool newValue); void setIntegrateOverXi(LatticeTypeSelectionForm* widget, bool newValue);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment