39 #include "Sample/HardParticle/Cylinder.h"
43 , m_sampleForm(nullptr)
44 , m_document(document)
77 unusedColors.removeAll(l->color());
78 if (!unusedColors.isEmpty())
79 color = unusedColors.first();
83 QMap<QString, int> usage;
85 usage[l->color().name()] += 1;
89 sortedByUsage.begin(), sortedByUsage.end(),
90 [&](
const QColor& a,
const QColor& b) { return usage[a.name()] < usage[b.name()]; });
99 for (
const auto& col : sortedByUsage)
100 if (col != above && col != below) {
119 if (c->layerItem() == layer)
130 layoutForms->updateTitle(layerItemWidget->
layerItem());
157 layoutForms->updateTitle(layerItemWidget->
layerItem());
173 if (w->layoutItem() == layoutItem)
174 w->onParticleAdded(newParticle);
189 if (w->layoutItem() == layoutItem)
190 w->onParticleAdded(newItem);
205 if (c->compositionItem() == compositionItem)
206 c->onParticleAdded(newItem);
221 if (c->compositionItem() == compositionItem)
222 c->onParticleAdded(newParticle);
231 newParticle->setMaterial(
materialItems()->defaultMaterial());
262 if (particleCoreShell->core() ==
nullptr)
276 if (particleCoreShell->shell() ==
nullptr)
290 if (layoutForm->layoutItem()->particles().contains(itemToRemove)) {
291 layoutForm->onAboutToRemoveParticle(itemToRemove);
294 layoutForm->layoutItem()->removeParticle(itemToRemove);
300 if (c->compositionItem()->particles().contains(itemToRemove)) {
301 c->onAboutToRemoveParticle(itemToRemove);
304 c->compositionItem()->removeParticle(itemToRemove);
323 if (s->valueDescriptor().path() == path) {
335 QSignalBlocker b(spinBox);
338 spinBox->selectAll();
374 const QString& newMaterialIdentifier)
381 if (c->layerItem() == item)
396 if (c->itemWithMaterial() != item
410 if (c->layoutItem()->interference() == interferenceItem) {
411 c->updateDensityValue();
423 QWidget* moveAboveThisWidget)
428 auto* itemToMove =
dynamic_cast<LayerForm*
>(widgetToMove)->layerItem();
429 auto* moveBeforeThisItem =
430 moveAboveThisLayerForm !=
nullptr ? moveAboveThisLayerForm->
layerItem() :
nullptr;
480 QWidget* parent = widget->parentWidget();
482 parent = parent->parentWidget();
485 particleLayoutForm->updateDensityEnabling();
486 particleLayoutForm->updateDensityValue();
Defines class DoubleSpinBox.
Defines InterferenceItems's classes.
Defines class MaterialItems.
Defines class MesoCrystalItem.
Defines class MultiLayerItem.
Defines class ParticleCompositionForm.
Defines class ParticleCompositionItem.
Defines class ParticleCoreShellForm.
Defines class ParticleCoreShellItem.
Defines class ParticleItem.
Defines class ParticleLayoutForm.
Defines class ParticleLayoutItem.
Defines class ProjectDocument.
Defines command classes for LayerOrientedSampleEditor.
Defines class SampleEditorController.
Defines class UIntDescriptor.
Abstract base class for SelectionDescriptor to ease referencing.
virtual void setCurrentIndex(int newIndex) const =0
Set currently selected option.
Command to add a layer to a sample.
Command to change a double value.
Command to remove a layer from a sample.
Describes properties of a double value which are necessary to allow GUI representation,...
QString label
A label text (short, no trailing colon)
function< void(double)> set
function to set the value
function< double()> get
function to get the current value
function< QString()> path
Path describing this value. Used e.g. for undo/redo.
SpinBox for DoubleDescriptors, supporting units.
const DoubleDescriptor & valueDescriptor() const
The descriptor on which this spinbox operates.
void setBaseValue(double baseValue)
Set the base value (unit is the one of the contained descriptor).
void setXiIntegration(bool xiIntegration)
QString materialIdentifier() const
void setMaterial(const MaterialItem *materialItem)
Set the material this item shall use. Stores the identifier, not the pointer!
static ItemWithParticles * create(Type type, const MaterialItems *materials)
Creates the item of the given type.
ParticleLayoutItem * addLayout()
void setColor(const QColor &color)
void removeLayout(ParticleLayoutItem *layout)
void setBasis(ItemWithParticles *basis)
ItemWithParticles * basisParticle() const
void setDescription(const QString &description)
LayerItem * addLayer(int index=-1)
Creates and inserts a layer at given index.
MaterialItems & materialItems()
void setSampleName(const QString &name)
void removeLayer(LayerItem *item)
QVector< LayerItem * > layers() const
void moveLayer(LayerItem *item, LayerItem *beforeThisLayer)
Form for editing a particle composition.
void addParticle(ItemWithParticles *particle)
Form for editing a core/shell particle.
ParticleCoreShellItem * coreShellItem() const
void createShellWidgets()
ParticleItem * createShell(const MaterialItems *materials)
ParticleItem * createCore(const MaterialItems *materials)
void setFormFactor(FormFactorItem *p)
Form for editing a particle layout.
void addParticle(ItemWithParticles *particle)
SelectionDescriptor< InterferenceItem * > interference() const
Project document class handles all data related to the opened project (sample, job,...
void setInt(int newValue, UIntDescriptor d)
void setMesoCrystalBasis(MesoCrystalForm *widget, ItemWithParticlesCatalog::Type type)
void setCoreFormFactor(ParticleCoreShellForm *widget, FormFactorItemCatalog::Type type)
ProjectDocument * projectDocument() const
The current document.
void removeLayout(LayerForm *layerItem, ParticleLayoutItem *layout)
MultiLayerItem * sampleItem() const
The item on which this controller operates.
void setMultiLayerForm(MultiLayerForm *view)
Set the current form.
void addLayer(LayerItem *before)
ItemWithParticles * createAndInitParticle(FormFactorItemCatalog::Type formFactorType) const
QUndoStack * undoStack()
The contained undo stack.
void setSampleDescription(const QString &description)
void setCurrentIndex(AbstractSelectionContainerForm *widget, int index, const AbstractSelectionDescriptor &d)
void setDouble(double newValue, DoubleDescriptor d)
MaterialItems * materialItems() const
The materials of the current document.
void addParticle(ParticleLayoutItem *layout, ItemWithParticlesCatalog::Type type)
void addLayerFromUndo(int atIndex)
void onStoppedToMoveLayer(QWidget *widgetToMove, QWidget *moveAboveThisWidget)
void setIntegrateOverXi(LatticeTypeSelectionForm *widget, bool newValue)
void onStartingToMoveLayer()
MultiLayerForm * sampleForm() const
The current form.
void addLayout(LayerForm *layerItem)
void selectMaterial(ItemWithMaterial *item, const QString &newMaterialIdentifier)
void setDensityRelatedValue(InterferenceItem *interferenceItem, double newValue, DoubleDescriptor d)
Set an interference function's value which affects the total particle density of the containing parti...
void setShellFormFactor(ParticleCoreShellForm *widget, FormFactorItemCatalog::Type type)
MultiLayerItem * m_sampleItem
MultiLayerForm * m_sampleForm
void aboutToRemoveItem(SampleItem item)
void setDoubleFromUndo(double newValue, const QString &path)
void removeLayer(LayerItem *layerItem)
ProjectDocument * m_document
void setSampleName(const QString &name)
SampleEditorController(ProjectDocument *document, MultiLayerItem *multi)
void removeLayerFromUndo(int atIndex)
void setMaterialValue(ItemWithMaterial *item, double newValue, DoubleDescriptor d)
void selectInterference(InterferenceForm *widget, int newIndex)
void removeParticle(ItemWithParticles *item)
Describes properties of a uint value which are necessary to allow GUI representation,...
function< void(uint)> set
function to set the value
QString const & name(EShape k)
QList< QColor > predefinedLayerColors()