Skip to content
Snippets Groups Projects
SampleEditorController.h 4.91 KiB
Newer Older
//  ************************************************************************************************
//
//  BornAgain: simulate and fit reflection and scattering
//
//! @file      GUI/View/Sample/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_SAMPLE_SAMPLEEDITORCONTROLLER_H
#define BORNAGAIN_GUI_VIEW_SAMPLE_SAMPLEEDITORCONTROLLER_H
#include "GUI/Model/Sample/ParticlesCatalog.h"
Wuttke, Joachim's avatar
Wuttke, Joachim committed
#include <QObject>
class CompoundItem;
class ISelectionForm;
class InterferenceForm;
class InterferenceItem;
class Item3D;
class ItemWithMaterial;
class ItemWithParticles;
class LatticeTypeSelectionForm;
class MesocrystalForm;
class ParticleLayoutItem;
Wuttke, Joachim's avatar
Wuttke, Joachim committed
class PolyForm;
Wuttke, Joachim's avatar
Wuttke, Joachim committed
class SampleForm;
class SampleItem;

//! Class to modify a sample from the layer oriented sample editor.
//!
Wuttke, Joachim's avatar
Wuttke, Joachim committed
//! Use this class to modify the sample model. It takes care of notifications.
//! It operates on one SampleItem.
Wuttke, Joachim's avatar
Wuttke, Joachim committed
//!
//! Originally, it also supported undo/redo (never completed, withdrawn in release 22).

class SampleEditorController : public QObject {
    Q_OBJECT
public:
Wuttke, Joachim's avatar
Wuttke, Joachim committed
    SampleEditorController(SampleItem* 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 setSampleForm(SampleForm* view);

    //! The item on which this controller operates.
    SampleItem* sampleItem() const { return m_sample_item; }
    //! The materials of the current document
    void addLayerItem(LayerItem* before);
    QColor findColor(size_t atIndex);
    void onLayerAdded(LayerItem* layer);
Mikhail Svechnikov's avatar
Mikhail Svechnikov committed
    void duplicateLayerItem(const LayerItem* layer);
    void removeLayerItem(LayerItem* layer);
    void onLayoutAdded(LayerForm* layerForm, ParticleLayoutItem* layout);
    void addLayoutItem(LayerForm* layerForm);
    void duplicateLayoutItem(LayerForm* layerForm, ParticleLayoutItem* layout);
Mikhail Svechnikov's avatar
Mikhail Svechnikov committed
    void removeLayoutItem(LayerForm* layerForm, ParticleLayoutItem* layout);
Mikhail Svechnikov's avatar
Mikhail Svechnikov committed
    void onParticleLayoutAdded(ParticleLayoutItem* layout, ItemWithParticles* newItem);
    void addParticleLayoutItem(ParticleLayoutItem* layout, ParticlesCatalog::Type type);
    void addParticleLayoutItem(ParticleLayoutItem* layout, FormfactorCatalog::Type type);
Mikhail Svechnikov's avatar
Mikhail Svechnikov committed
    ParticleLayoutItem* parentLayoutItem(ItemWithParticles* item);
Mikhail Svechnikov's avatar
Mikhail Svechnikov committed
    void onParticleCompoundAdded(CompoundItem* composition, ItemWithParticles* newItem);
    void addCompoundItem(CompoundItem* composition, ParticlesCatalog::Type type);
    void addCompoundItem(CompoundItem* composition, FormfactorCatalog::Type type);
Mikhail Svechnikov's avatar
Mikhail Svechnikov committed
    CompoundItem* parentCompoundItem(ItemWithParticles* item);

    void duplicateItemWithParticles(ItemWithParticles* item);
    void removeParticle(ItemWithParticles* item);

    void setCoreFormfactor(CoreAndShellForm* widget, FormfactorCatalog::Type type);
    void setShellFormfactor(CoreAndShellForm* widget, FormfactorCatalog::Type type);
    void setMesocrystalBasis(MesocrystalForm* widget, ParticlesCatalog::Type type);
    void setMesocrystalBasis(MesocrystalForm* widget, FormfactorCatalog::Type type);
    void selectInterference(InterferenceForm* widget, int newIndex);
Wuttke, Joachim's avatar
Wuttke, Joachim committed
    void setIntegrateOverXi(LatticeTypeSelectionForm* widget, bool value);
Wuttke, Joachim's avatar
Wuttke, Joachim committed
    void setDouble(double value, DoubleProperty& d);

    void selectMaterial(ItemWithMaterial* item, const QString& newMaterialIdentifier);
Wuttke, Joachim's avatar
Wuttke, Joachim committed
    void setMaterialValue(ItemWithMaterial* item, double value, DoubleProperty& 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).
Wuttke, Joachim's avatar
Wuttke, Joachim committed
    void setDensityRelatedValue(InterferenceItem* interferenceItem, double value,
    void onStoppedToMoveLayer(QWidget* widgetToMove, QWidget* moveAboveThisWidget);

    void requestViewInRealspace(Item3D* item);
    void aboutToRemoveItem(Item3D* item);
    void modified();
    ItemWithParticles* createAndInitItem(FormfactorCatalog::Type formFactorType) const;
    ItemWithParticles* createAndInitItem(ParticlesCatalog::Type itemType) const;
    SampleItem* m_sample_item;
    SampleForm* m_sample_form;
#endif // BORNAGAIN_GUI_VIEW_SAMPLE_SAMPLEEDITORCONTROLLER_H