// ************************************************************************************************ // // BornAgain: simulate and fit reflection and scattering // //! @file GUI/View/SampleDesigner/SampleEditorController.h //! @brief Defines class SampleEditorController //! //! @homepage http://www.bornagainproject.org //! @license GNU General Public License v3 or higher (see COPYING) //! @copyright Forschungszentrum Jülich GmbH 2021 //! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS) // // ************************************************************************************************ #ifndef BORNAGAIN_GUI_VIEW_SAMPLEDESIGNER_SAMPLEEDITORCONTROLLER_H #define BORNAGAIN_GUI_VIEW_SAMPLEDESIGNER_SAMPLEEDITORCONTROLLER_H #include "GUI/Model/CatSample/FormFactorItemCatalog.h" #include "GUI/Model/CatSample/ItemWithParticlesCatalog.h" #include "GUI/Model/Sample/SampleItem.h" #include <QUndoStack> class MultiLayerItem; class MultiLayerForm; class LayerItem; class ParticleLayoutItem; class ParticleCoreShellForm; class ItemWithParticles; class MesocrystalForm; class LayerForm; class ParticleCompositionItem; class DoubleDescriptor; class UIntDescriptor; class ItemWithMaterial; class SelectionContainerForm; class AbstractSelectionDescriptor; class InterferenceForm; class SessionItem; class InterferenceItem; class AbstractSelectionContainerForm; class LatticeTypeSelectionForm; class MaterialItems; class ProjectDocument; //! Class to modify a sample from the layer oriented sample editor. //! //! Use this class to modify the sample model. It takes care of notifications and creating undo/redo //! commands. //! It operates on one MultiLayerItem (which is a sample). class SampleEditorController : public QObject { Q_OBJECT public: SampleEditorController(ProjectDocument* document, MultiLayerItem* multi); //! Set the current form. //! //! The form can change e.g. when a different sample gets the current one //! in the layer editor. Also nullptr is allowed. void setMultiLayerForm(MultiLayerForm* view); //! The current form. MultiLayerForm* sampleForm() const; //! The item on which this controller operates. MultiLayerItem* sampleItem() const; //! The contained undo stack. QUndoStack* undoStack(); //! The materials of the current document MaterialItems* materialItems() const; //! The current document ProjectDocument* projectDocument() const; void addLayer(LayerItem* before); void addLayerFromUndo(int atIndex); void removeLayer(LayerItem* layerItem); void removeLayerFromUndo(int atIndex); void addLayout(LayerForm* layerItem); void removeLayout(LayerForm* layerItem, ParticleLayoutItem* layout); void addParticle(ParticleLayoutItem* layout, ItemWithParticlesCatalog::Type type); void addParticle(ParticleLayoutItem* layout, FormFactorItemCatalog::Type t); void addParticle(ParticleCompositionItem* composition, ItemWithParticlesCatalog::Type type); 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 setMesocrystalBasis(MesocrystalForm* widget, ItemWithParticlesCatalog::Type type); void setMesocrystalBasis(MesocrystalForm* widget, FormFactorItemCatalog::Type type); void selectInterference(InterferenceForm* widget, int newIndex); void setIntegrateOverXi(LatticeTypeSelectionForm* widget, bool newValue); void setDouble(double newValue, DoubleDescriptor d); void setDoubleFromUndo(double newValue, const QString& path); void setInt(int newValue, UIntDescriptor d); void setCurrentIndex(AbstractSelectionContainerForm* widget, int index, const AbstractSelectionDescriptor& d); void selectMaterial(ItemWithMaterial* item, const QString& newMaterialIdentifier); void setMaterialValue(ItemWithMaterial* item, double newValue, DoubleDescriptor d); //! Set an interference function's value which affects the total particle density of the //! containing particle layout. //! //! Some values in interference settings affect the total density in the particle layout which //! contains this interference function. Call this method to provide all the related updating //! (data & UI). void setDensityRelatedValue(InterferenceItem* interferenceItem, double newValue, DoubleDescriptor d); void onStartingToMoveLayer(); void onStoppedToMoveLayer(QWidget* widgetToMove, QWidget* moveAboveThisWidget); void setSampleName(const QString& name); void setSampleDescription(const QString& description); signals: void requestViewInRealSpace(SampleItem item); void aboutToRemoveItem(SampleItem item); void modified(); private: ItemWithParticles* createAndInitParticle(FormFactorItemCatalog::Type formFactorType) const; ItemWithParticles* createAndInitParticle(ItemWithParticlesCatalog::Type itemType) const; private: QUndoStack m_undoStack; MultiLayerItem* m_sampleItem; MultiLayerForm* m_sampleForm; ProjectDocument* m_document; }; #endif // BORNAGAIN_GUI_VIEW_SAMPLEDESIGNER_SAMPLEEDITORCONTROLLER_H