BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
MaterialItems.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/Model/Sample/MaterialItems.h
6 //! @brief Defines class MaterialItems
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_MODEL_SAMPLE_MATERIALITEMS_H
16 #define BORNAGAIN_GUI_MODEL_SAMPLE_MATERIALITEMS_H
17 
18 #include <QObject>
19 #include <QVector>
20 
21 class MaterialItem;
22 class Streamer;
23 
24 class MaterialItems : public QObject {
25  Q_OBJECT
26 
27 public:
28  explicit MaterialItems(QObject* parent = nullptr);
30 
31  void clear();
32 
33  //! Add the material and take ownership of it.
34  void addMaterial(MaterialItem* material);
35 
36  MaterialItems* createCopy() const;
37 
38  MaterialItem* addRefractiveMaterial(const QString& name, double delta, double beta);
39  MaterialItem* addSLDMaterial(const QString& name, double sld, double abs_term);
40 
41  MaterialItem* materialFromName(const QString& name) const;
42  MaterialItem* materialFromIdentifier(const QString& identifier) const;
43 
44  //! Inserts a copy of the given material and returns the newly inserted item.
45  //!
46  //! The copy will have a different material identifier and a different name.
47  MaterialItem* insertCopy(const MaterialItem& material);
48 
49  const QVector<MaterialItem*>& materialItems() const;
50 
52 
53  void removeMaterial(const QString& identifier);
54  void removeMaterial(MaterialItem* materialItem);
55 
56  void serialize(Streamer& s);
57 
58  //! Copies the complete content, emitting signals for existing and changed materials
59  void initFrom(const MaterialItems& from);
60 
61  //! Compares for complete equality (same material identifiers, same order of materials,...)
62  bool operator==(const MaterialItems& other) const;
63  bool operator!=(const MaterialItems& other) const;
64 
65 signals:
67  void materialChanged(MaterialItem* materialItem);
68 
69 private:
70  //! Add the material and take ownership of it.
71  //!
72  //! In the given flag the signal "materialAddedOrRemoved" can be suppressed.
73  void addMaterial(MaterialItem* material, bool signalAdding);
74 
75 private:
76  QVector<MaterialItem*> m_materialItems; //!< all materials (owned by this class)
77 };
78 
79 #endif // BORNAGAIN_GUI_MODEL_SAMPLE_MATERIALITEMS_H
@ other
The unit has no enum value defined in here (e.g. when defined as an explicit string)
void addMaterial(MaterialItem *material)
Add the material and take ownership of it.
MaterialItem * addRefractiveMaterial(const QString &name, double delta, double beta)
MaterialItem * materialFromIdentifier(const QString &identifier) const
MaterialItem * defaultMaterial() const
void materialAddedOrRemoved()
void initFrom(const MaterialItems &from)
Copies the complete content, emitting signals for existing and changed materials.
MaterialItem * addSLDMaterial(const QString &name, double sld, double abs_term)
QVector< MaterialItem * > m_materialItems
all materials (owned by this class)
Definition: MaterialItems.h:76
void removeMaterial(const QString &identifier)
MaterialItems(QObject *parent=nullptr)
MaterialItems * createCopy() const
MaterialItem * insertCopy(const MaterialItem &material)
Inserts a copy of the given material and returns the newly inserted item.
bool operator==(const MaterialItems &other) const
Compares for complete equality (same material identifiers, same order of materials,...
const QVector< MaterialItem * > & materialItems() const
void materialChanged(MaterialItem *materialItem)
MaterialItem * materialFromName(const QString &name) const
bool operator!=(const MaterialItems &other) const
void serialize(Streamer &s)
Supports serialization to or deserialization from QXmlStream.
Definition: Streamer.h:36
QString const & name(EShape k)
Definition: particles.cpp:20