BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
MultiLayerItems.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/Model/Sample/MultiLayerItems.cpp
6 //! @brief Implements class MultiLayerItems
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 
19 #include <QApplication>
20 
22 {
23  qDeleteAll(m_samples);
24 }
25 
26 QVector<MultiLayerItem*> MultiLayerItems::sampleItems() const
27 {
28  return m_samples;
29 }
30 
32 {
33  m_samples << new MultiLayerItem();
34  return m_samples.back();
35 }
36 
38 {
39  m_samples << sample;
40 }
41 
43 {
44  m_samples.removeAll(sample);
45  delete sample;
46 }
47 
48 QStringList MultiLayerItems::sampleNames() const
49 {
50  QStringList existingNames;
51  for (const auto* item : m_samples)
52  existingNames << item->sampleName();
53  return existingNames;
54 }
55 
57 {
58  s.assertVersion(0);
59  Serialize::rwVector(s, "Multilayers", m_samples);
60 }
Defines abstract item with a material property.
Defines class MultiLayerItem.
Defines class MultiLayerItems.
Defines class Streamer.
void removeMultiLayer(MultiLayerItem *sample)
void serialize(Streamer &s)
QStringList sampleNames() const
QVector< MultiLayerItem * > m_samples
QVector< MultiLayerItem * > sampleItems() const
MultiLayerItem * addMultiLayer()
Adds a sample and returns the new item.
Supports serialization to or deserialization from QXmlStream.
Definition: Streamer.h:36
void assertVersion(unsigned expectedVersion) const
As reader, throws DeserializationException unless the expected version is read. As writer,...
Definition: Streamer.cpp:26
void rwVector(Streamer &s, const QString &tag, QVector< T > &vec, Args... argsForConstructor)
Serializes a list of items of known and fixed type. Passes optional arguments to the constructor.
Definition: Serialize.h:93