BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
MaterialEditorModel.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/View/MaterialEditor/MaterialEditorModel.h
6 //! @brief Defines class MaterialEditorModel
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_MATERIALEDITOR_MATERIALEDITORMODEL_H
16 #define BORNAGAIN_GUI_VIEW_MATERIALEDITOR_MATERIALEDITORMODEL_H
17 
18 #include <QAbstractItemModel>
19 
20 class MaterialItem;
21 class MaterialItems;
22 
23 //! Model for list of materials, used in MaterialEditorDialog.
24 //!
25 //! This model is also used for changing values of a material, therefore the list can be
26 //! updated accordingly.
27 class MaterialEditorModel : public QAbstractTableModel {
28 public:
30 
31  int rowCount(const QModelIndex& parent = QModelIndex()) const override;
32  int columnCount(const QModelIndex& parent = QModelIndex()) const override;
33  QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
34  QVariant headerData(int section, Qt::Orientation orientation,
35  int role = Qt::DisplayRole) const override;
36 
37  void setMaterialItemName(const QModelIndex& index, const QString& name);
38  void setColor(const QModelIndex& index, const QColor& color);
39  void setX(const QModelIndex& index, double value);
40  void setY(const QModelIndex& index, double value);
41  void setZ(const QModelIndex& index, double value);
42  void setDelta(const QModelIndex& index, double value);
43  void setBeta(const QModelIndex& index, double value);
44  void setRe(const QModelIndex& index, double value);
45  void setIm(const QModelIndex& index, double value);
46 
47  MaterialItem* materialFromIndex(const QModelIndex& index) const;
48  QModelIndex indexFromMaterial(const MaterialItem* m) const;
49  QModelIndex indexFromMaterial(const QString& identifier) const;
50 
51  QModelIndex first() const;
52 
53  MaterialItem* addRefractiveMaterial(const QString& name, double delta, double beta);
54  MaterialItem* addSLDMaterial(const QString& name, double sld, double abs_term);
55  MaterialItem* cloneMaterial(const QModelIndex& index);
56  void removeMaterial(const QModelIndex& index);
57 
58 private:
59  //! The columns in the header. PARAMETERS contains delta/beta or Re/Im.
61 
63 };
64 
65 
66 #endif // BORNAGAIN_GUI_VIEW_MATERIALEDITOR_MATERIALEDITORMODEL_H
Model for list of materials, used in MaterialEditorDialog.
MaterialItem * materialFromIndex(const QModelIndex &index) const
void setDelta(const QModelIndex &index, double value)
QModelIndex indexFromMaterial(const MaterialItem *m) const
MaterialItem * addRefractiveMaterial(const QString &name, double delta, double beta)
void setY(const QModelIndex &index, double value)
void setColor(const QModelIndex &index, const QColor &color)
void setRe(const QModelIndex &index, double value)
int rowCount(const QModelIndex &parent=QModelIndex()) const override
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
void setIm(const QModelIndex &index, double value)
MaterialItem * addSLDMaterial(const QString &name, double sld, double abs_term)
void setZ(const QModelIndex &index, double value)
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
void setX(const QModelIndex &index, double value)
MaterialItem * cloneMaterial(const QModelIndex &index)
MaterialEditorModel(MaterialItems *p)
void removeMaterial(const QModelIndex &index)
void setMaterialItemName(const QModelIndex &index, const QString &name)
QModelIndex first() const
MaterialItems * m_model
int columnCount(const QModelIndex &parent=QModelIndex()) const override
void setBeta(const QModelIndex &index, double value)
QString const & name(EShape k)
Definition: particles.cpp:20