BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
MaterialEditorDialog.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/View/MaterialEditor/MaterialEditorDialog.h
6 //! @brief Defines class MaterialEditorDialog
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_MATERIALEDITORDIALOG_H
16 #define BORNAGAIN_GUI_VIEW_MATERIALEDITOR_MATERIALEDITORDIALOG_H
17 
19 #include <QDialog>
20 #include <memory>
21 
22 class MaterialItem;
24 class MultiLayerItem;
25 
26 namespace Ui {
27 
29 }
30 
31 //! Dialog to select a material and also to edit the list of existing materials.
32 //! The dialog operates on a copy of the current materials. The original material store is only
33 //! updated if changes have been made and the dialog has been closed with OK.
34 //! Use this dialog only with the two static methods to edit the list, or to choose a material
35 class MaterialEditorDialog : public QDialog {
36  Q_OBJECT
37 
38 public:
39  //! Use this to choose a material. identifierOfPreviousMaterial is the material which should be
40  //! selected when opening the dialog. Returns the identifier of the newly selected material.
41  //! Returns an empty string, if the dialog is
42  //! cancelled.
43  static QString chooseMaterial(QWidget* parent, MultiLayerItem* sample,
44  const QString& identifierOfPreviousMaterial);
45 
46  //! Use this to edit the list of existing materials.
47  static void editMaterials(QWidget* parent, MultiLayerItem* sample);
48 
49 private:
50  MaterialEditorDialog(MultiLayerItem* sample, QWidget* parent = nullptr);
51  ~MaterialEditorDialog() override;
52 
53  //! updates original material model with the edited model
54  void accept() override;
55 
56  void addRefractiveMaterial();
57  void addSldMaterial();
58  void cloneCurrentMaterial();
59  void removeCurrentMaterial();
60 
61  void onSelectColor();
62  void updateActionEnabling();
63  void fill();
64  void setCurrentMaterial(const MaterialItem* m);
65  void setCurrentMaterial(const QString& identifier);
66  QModelIndex currentIndex() const;
68 
69  //! Returns the list of material identifiers of the materials currently used in the sample.
70  //! E.g. the material selected in a particle.
71  QStringList identifiersOfUsedMaterials() const;
72 
73 private:
74  MaterialItems m_tmpMaterialItems; //! Materials for working within this dialog
75 
78 
79  Ui::MaterialEditorDialog* m_ui;
80 
81  MaterialEditorModel* m_model; //! Model for the left list. Works on m_tmpMaterialItems
83 };
84 
85 #endif // BORNAGAIN_GUI_VIEW_MATERIALEDITOR_MATERIALEDITORDIALOG_H
Defines class MaterialItems.
Dialog to select a material and also to edit the list of existing materials. The dialog operates on a...
MaterialItems m_tmpMaterialItems
static QString chooseMaterial(QWidget *parent, MultiLayerItem *sample, const QString &identifierOfPreviousMaterial)
Use this to choose a material. identifierOfPreviousMaterial is the material which should be selected ...
QAction * m_cloneMaterialAction
Materials for working within this dialog.
void setCurrentMaterial(const MaterialItem *m)
MaterialEditorDialog(MultiLayerItem *sample, QWidget *parent=nullptr)
MaterialItem * currentMaterial()
Ui::MaterialEditorDialog * m_ui
QModelIndex currentIndex() const
MaterialEditorModel * m_model
MultiLayerItem * m_sample
Model for the left list. Works on m_tmpMaterialItems.
QStringList identifiersOfUsedMaterials() const
Returns the list of material identifiers of the materials currently used in the sample....
static void editMaterials(QWidget *parent, MultiLayerItem *sample)
Use this to edit the list of existing materials.
void accept() override
updates original material model with the edited model
Model for list of materials, used in MaterialEditorDialog.