BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
MaterialPropertyController.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/coregui/Models/MaterialPropertyController.h
6 //! @brief Defines MaterialPropertyController class
7 //!
8 //! @homepage http://www.bornagainproject.org
9 //! @license GNU General Public License v3 or higher (see COPYING)
10 //! @copyright Forschungszentrum Jülich GmbH 2018
11 //! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************************************
14 
15 #ifndef BORNAGAIN_GUI_COREGUI_MODELS_MATERIALPROPERTYCONTROLLER_H
16 #define BORNAGAIN_GUI_COREGUI_MODELS_MATERIALPROPERTYCONTROLLER_H
17 
18 #include <QObject>
19 
20 class MaterialModel;
21 class SampleModel;
22 class SessionItem;
23 
24 //! Listens MaterialModel for changes in MaterialItems and then
25 //! updates MaterialProperties in all related items in SampleModel.
26 
27 class MaterialPropertyController : public QObject {
28  Q_OBJECT
29 public:
30  MaterialPropertyController(QObject* parent = nullptr);
31 
32  void setModels(MaterialModel* materialModel, SampleModel* sampleModel);
33 
34 public slots:
35  void onMaterialModelLoad();
36 
37 private slots:
38  void onMaterialDataChanged(const QModelIndex& topLeft, const QModelIndex&, const QVector<int>&);
39  void onMaterialRowsAboutToBeRemoved(const QModelIndex& parent, int first, int last);
40 
41 private:
42  QVector<SessionItem*> relatedSampleItems();
43 
46 };
47 
48 #endif // BORNAGAIN_GUI_COREGUI_MODELS_MATERIALPROPERTYCONTROLLER_H
Listens MaterialModel for changes in MaterialItems and then updates MaterialProperties in all related...
void setModels(MaterialModel *materialModel, SampleModel *sampleModel)
QVector< SessionItem * > relatedSampleItems()
Returns vector of SessionItems having MaterialProperty on board.
void onMaterialDataChanged(const QModelIndex &topLeft, const QModelIndex &, const QVector< int > &)
On MaterialItem change: updates corresponding MaterialProperty in sample items.
MaterialPropertyController(QObject *parent=nullptr)
void onMaterialRowsAboutToBeRemoved(const QModelIndex &parent, int first, int last)
On MaterialItem removal: updates corresponding MaterialProperty in sample items.
void onMaterialModelLoad()
Special case when original MaterialModel was fully rebuild from MaterialEditor.
Main model to hold sample items.
Definition: SampleModel.h:24