BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
SampleEditorController.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/View/SampleDesigner/SampleEditorController.h
6 //! @brief Defines class SampleEditorController
7 //!
8 //! @homepage http://www.bornagainproject.org
9 //! @license GNU General Public License v3 or higher (see COPYING)
10 //! @copyright Forschungszentrum Jülich GmbH 2021
11 //! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************************************
14 
15 #ifndef BORNAGAIN_GUI_VIEW_SAMPLEDESIGNER_SAMPLEEDITORCONTROLLER_H
16 #define BORNAGAIN_GUI_VIEW_SAMPLEDESIGNER_SAMPLEEDITORCONTROLLER_H
17 
21 #include <QUndoStack>
22 
23 class MultiLayerItem;
24 class MultiLayerForm;
25 class LayerItem;
26 class ParticleLayoutItem;
28 class ItemWithParticles;
29 class MesoCrystalForm;
30 class LayerForm;
32 class DoubleDescriptor;
33 class UIntDescriptor;
34 class ItemWithMaterial;
37 class InterferenceForm;
38 class SessionItem;
39 class InterferenceItem;
42 class MaterialItems;
43 class ProjectDocument;
44 
45 //! Class to modify a sample from the layer oriented sample editor.
46 //!
47 //! Use this class to modify the sample model. It takes care of notifications and creating undo/redo
48 //! commands.
49 //! It operates on one MultiLayerItem (which is a sample).
50 class SampleEditorController : public QObject {
51  Q_OBJECT
52 public:
54 
55  //! Set the current form.
56  //!
57  //! The form can change e.g. when a different sample gets the current one
58  //! in the layer editor. Also nullptr is allowed.
60 
61  //! The current form.
62  MultiLayerForm* sampleForm() const;
63 
64  //! The item on which this controller operates.
65  MultiLayerItem* sampleItem() const;
66 
67  //! The contained undo stack.
68  QUndoStack* undoStack();
69 
70  //! The materials of the current document
72 
73  //! The current document
75 
76  void addLayer(LayerItem* before);
77  void addLayerFromUndo(int atIndex);
78  void removeLayer(LayerItem* layerItem);
79  void removeLayerFromUndo(int atIndex);
80  void addLayout(LayerForm* layerItem);
81  void removeLayout(LayerForm* layerItem, ParticleLayoutItem* layout);
82 
92  void selectInterference(InterferenceForm* widget, int newIndex);
93  void setIntegrateOverXi(LatticeTypeSelectionForm* widget, bool newValue);
94 
95  void setDouble(double newValue, DoubleDescriptor d);
96  void setDoubleFromUndo(double newValue, const QString& path);
97  void setInt(int newValue, UIntDescriptor d);
98 
99  void setCurrentIndex(AbstractSelectionContainerForm* widget, int index,
100  const AbstractSelectionDescriptor& d);
101 
102  void selectMaterial(ItemWithMaterial* item, const QString& newMaterialIdentifier);
103  void setMaterialValue(ItemWithMaterial* item, double newValue, DoubleDescriptor d);
104 
105  //! Set an interference function's value which affects the total particle density of the
106  //! containing particle layout.
107  //!
108  //! Some values in interference settings affect the total density in the particle layout which
109  //! contains this interference function. Call this method to provide all the related updating
110  //! (data & UI).
111  void setDensityRelatedValue(InterferenceItem* interferenceItem, double newValue,
112  DoubleDescriptor d);
113 
114  void onStartingToMoveLayer();
115  void onStoppedToMoveLayer(QWidget* widgetToMove, QWidget* moveAboveThisWidget);
116 
117  void setSampleName(const QString& name);
118  void setSampleDescription(const QString& description);
119 
120 signals:
123  void modified();
124 
125 private:
128 
129 private:
130  QUndoStack m_undoStack;
134 };
135 
136 
137 #endif // BORNAGAIN_GUI_VIEW_SAMPLEDESIGNER_SAMPLEEDITORCONTROLLER_H
Defines class FormFactorItemCatalog.
Defines class ItemWithParticlesCatalog.
Defines class SampleItem.
Abstract widget base class to contain a selection, defined by a SelectionDescriptor.
Abstract base class for SelectionDescriptor to ease referencing.
Describes properties of a double value which are necessary to allow GUI representation,...
Form for editing interference functions.
Form for editing lattice type values.
Form for editing a layer.
Definition: LayerForm.h:29
Form for editing a mesocrystal.
Form to present/edit a MultiLayer (sample)
Form for editing a core/shell particle.
Project document class handles all data related to the opened project (sample, job,...
Class to modify a sample from the layer oriented sample editor.
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 requestViewInRealSpace(SampleItem item)
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)
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)
void aboutToRemoveItem(SampleItem item)
void setDoubleFromUndo(double newValue, const QString &path)
void removeLayer(LayerItem *layerItem)
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)
This can hold any item which belongs to a sample.
Definition: SampleItem.h:33
A widget to contain a selection, defined by a SelectionDescriptor.
Base class for a GUI data item.
Definition: SessionItem.h:204
Describes properties of a uint value which are necessary to allow GUI representation,...
QString const & name(EShape k)
Definition: particles.cpp:20