// ************************************************************************************************ // // BornAgain: simulate and fit reflection and scattering // //! @file GUI/Views/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_VIEWS_SAMPLEDESIGNER_SAMPLEEDITORCONTROLLER_H #define BORNAGAIN_GUI_VIEWS_SAMPLEDESIGNER_SAMPLEEDITORCONTROLLER_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 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(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* multiLayerForm() const; //! The item on which this controller operates. MultiLayerItem* multiLayerItem() const; //! The contained undo stack. QUndoStack* undoStack(); void addLayer(LayerItem* before); void removeLayer(LayerItem* layerItem); void addLayout(LayerForm* layerItem); void removeLayout(LayerForm* layerItem, ParticleLayoutItem* layout); void addParticle(ParticleLayoutItem* layout, const QString& classname); void addParticle(ParticleCompositionItem* composition, const QString& classname); void setCoreFormFactor(ParticleCoreShellForm* widget, const QString& formFactorModelType); void setShellFormFactor(ParticleCoreShellForm* widget, const QString& formFactorModelType); void removeParticle(ItemWithParticles* item); void setMesoCrystalBasis(MesoCrystalForm* widget, const QString& classname); void selectInterference(ParticleLayoutItem* layoutItem, int newIndex); void setDouble(double newValue, DoubleDescriptor d); void setDoubleFromUndo(double newValue, const QString& path); void setInt(int newValue, UIntDescriptor d); void setCurrentIndex(SelectionContainerForm* widget, int index, const AbstractSelectionDescriptor& d); void selectMaterial(ItemWithMaterial* item, const QString& newMaterialIdentifier); void setMaterialValue(ItemWithMaterial* item, double newValue, DoubleDescriptor d); void onStartingToMoveLayer(); void onStoppedToMoveLayer(QWidget* widgetToMove, QWidget* moveAboveThisWidget); private: QUndoStack m_undoStack; MultiLayerItem* m_multiLayerItem; MultiLayerForm* m_multiLayerForm; }; #endif // BORNAGAIN_GUI_VIEWS_SAMPLEDESIGNER_SAMPLEEDITORCONTROLLER_H