BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
MultiLayerItem Class Reference

Description

Definition at line 31 of file MultiLayerItem.h.

Collaboration diagram for MultiLayerItem:
[legend]

Public Member Functions

 MultiLayerItem ()
 
LayerItemaddLayer (int index=-1)
 Creates and inserts a layer at given index. More...
 
void addStandardMaterials ()
 
DoubleDescriptor crossCorrLength () const
 
QString description () const
 
R3 externalField () const
 
VectorDescriptor externalFieldVector () const
 
void initFrom (const MultiLayerItem *other)
 
QVector< ItemWithMaterial * > itemsWithMaterial () const
 
QVector< LayerItem * > layers () const
 
MaterialItemsmaterialItems ()
 
const MaterialItemsmaterialItems () const
 
void moveLayer (LayerItem *item, LayerItem *beforeThisLayer)
 
void readContentFrom (QXmlStreamReader *reader)
 
void removeLayer (LayerItem *item)
 
QString sampleName () const
 
void serialize (Streamer &s)
 
void setDescription (const QString &description)
 
void setExternalField (const R3 &externalField)
 
void setSampleName (const QString &name)
 
void writeContentTo (QXmlStreamWriter *writer) const
 

Private Attributes

DoubleProperty m_crossCorrelationLength
 
QString m_description
 
VectorProperty m_externalField
 
QVector< LayerItem * > m_layers
 
MaterialItems m_materials
 
QString m_name
 

Constructor & Destructor Documentation

◆ MultiLayerItem()

MultiLayerItem::MultiLayerItem ( )

Definition at line 21 of file MultiLayerItem.cpp.

22 {
23  m_name = "Sample";
24  m_crossCorrelationLength.init("Cross-correlation length",
25  "Cross correlation length of roughnesses between interfaces", 0.0,
26  Unit::nanometer, 5, RealLimits::nonnegative(), "cross");
27  m_externalField.init("External field", "External field (A/m)", "A/m", "extField");
28 }
@ nanometer
void init(const QString &label, const QString &tooltip, double value, const variant< QString, Unit > &unit, const QString &persistentTag)
DoubleProperty m_crossCorrelationLength
VectorProperty m_externalField
void init(const QString &label, const QString &tooltip, const variant< QString, Unit > &unit, const QString &persistentTag)

References VectorProperty::init(), DoubleProperty::init(), m_crossCorrelationLength, m_externalField, m_name, and nanometer.

Here is the call graph for this function:

Member Function Documentation

◆ addLayer()

LayerItem * MultiLayerItem::addLayer ( int  index = -1)

Creates and inserts a layer at given index.

No properties etc. have been initialized, this has to be done by the caller If index = -1, create a layer at the end of the list.

Definition at line 96 of file MultiLayerItem.cpp.

97 {
98  if (index < 0)
99  index = m_layers.size();
100 
101  auto* layer = new LayerItem(&m_materials);
102  m_layers.insert(index, layer);
103  layer->setIsTopLayer(m_layers.first() == layer);
104  layer->setIsBottomLayer(m_layers.last() == layer);
105  return layer;
106 }
QVector< LayerItem * > m_layers
MaterialItems m_materials

References m_layers, and m_materials.

Referenced by SampleEditorController::addLayerFromUndo(), and CommandRemoveLayer::undo().

◆ addStandardMaterials()

void MultiLayerItem::addStandardMaterials ( )

Definition at line 43 of file MultiLayerItem.cpp.

44 {
45  m_materials.addRefractiveMaterial("Default", 1e-3, 1e-5);
46  m_materials.addRefractiveMaterial("Vacuum", 0.0, 0.0);
47  m_materials.addRefractiveMaterial("Particle", 6e-4, 2e-8);
48  m_materials.addRefractiveMaterial("Substrate", 6e-6, 2e-8);
49 }
MaterialItem * addRefractiveMaterial(const QString &name, double delta, double beta)

References MaterialItems::addRefractiveMaterial(), and m_materials.

Here is the call graph for this function:

◆ crossCorrLength()

DoubleDescriptor MultiLayerItem::crossCorrLength ( ) const

Definition at line 71 of file MultiLayerItem.cpp.

72 {
74 }

References m_crossCorrelationLength.

Referenced by MultiLayerForm::MultiLayerForm(), and ParameterTreeBuilder::addSample().

◆ description()

QString MultiLayerItem::description ( ) const

Definition at line 61 of file MultiLayerItem.cpp.

62 {
63  return m_description;
64 }
QString m_description

References m_description.

Referenced by MultiLayerForm::MultiLayerForm(), and setDescription().

◆ externalField()

R3 MultiLayerItem::externalField ( ) const

Definition at line 76 of file MultiLayerItem.cpp.

77 {
78  return m_externalField;
79 }

References m_externalField.

Referenced by setExternalField().

◆ externalFieldVector()

VectorDescriptor MultiLayerItem::externalFieldVector ( ) const

Definition at line 86 of file MultiLayerItem.cpp.

87 {
88  return m_externalField;
89 }

References m_externalField.

Referenced by MultiLayerForm::MultiLayerForm(), and ParameterTreeBuilder::addSample().

◆ initFrom()

void MultiLayerItem::initFrom ( const MultiLayerItem other)

Definition at line 30 of file MultiLayerItem.cpp.

31 {
33 }
@ other
The unit has no enum value defined in here (e.g. when defined as an explicit string)
void copyContents(const T *source, T *dest)
Definition: Backup.h:46

References GUI::Util::copyContents(), and other.

Referenced by JobItem::copySampleIntoJob().

Here is the call graph for this function:

◆ itemsWithMaterial()

QVector< ItemWithMaterial * > MultiLayerItem::itemsWithMaterial ( ) const

Definition at line 35 of file MultiLayerItem.cpp.

36 {
37  QVector<ItemWithMaterial*> result;
38  for (auto* layer : m_layers)
39  result.append(layer->itemsWithMaterial());
40  return result;
41 }

References m_layers.

Referenced by MaterialEditorDialog::identifiersOfUsedMaterials().

◆ layers()

◆ materialItems() [1/2]

◆ materialItems() [2/2]

const MaterialItems & MultiLayerItem::materialItems ( ) const

Definition at line 163 of file MultiLayerItem.cpp.

164 {
165  return m_materials;
166 }

References m_materials.

◆ moveLayer()

void MultiLayerItem::moveLayer ( LayerItem item,
LayerItem beforeThisLayer 
)

Definition at line 119 of file MultiLayerItem.cpp.

120 {
121  m_layers.removeAll(layer);
122  int index = m_layers.size(); // move to end
123  if (beforeThisLayer != nullptr)
124  index = m_layers.indexOf(beforeThisLayer);
125  m_layers.insert(index, layer);
126  for (auto* l : m_layers) {
127  l->setIsTopLayer(m_layers.first() == l);
128  l->setIsBottomLayer(m_layers.last() == l);
129  }
130 }

References m_layers.

Referenced by SampleEditorController::onStoppedToMoveLayer().

◆ readContentFrom()

void MultiLayerItem::readContentFrom ( QXmlStreamReader *  reader)

Definition at line 138 of file MultiLayerItem.cpp.

139 {
140  Streamer s(reader);
141  serialize(s);
142 }
void serialize(Streamer &s)
Supports serialization to or deserialization from QXmlStream.
Definition: Streamer.h:36

References serialize().

Referenced by JobItem::readNonSessionItems().

Here is the call graph for this function:

◆ removeLayer()

void MultiLayerItem::removeLayer ( LayerItem item)

Definition at line 108 of file MultiLayerItem.cpp.

109 {
110  m_layers.removeAll(layer);
111  delete layer;
112 
113  if (!m_layers.isEmpty()) {
114  m_layers.first()->setIsTopLayer(true);
115  m_layers.last()->setIsBottomLayer(true);
116  }
117 }

References m_layers.

Referenced by SampleEditorController::removeLayerFromUndo().

◆ sampleName()

QString MultiLayerItem::sampleName ( ) const

Definition at line 51 of file MultiLayerItem.cpp.

52 {
53  return m_name;
54 }

References m_name.

Referenced by MultiLayerForm::MultiLayerForm(), and JobItem::sampleName().

◆ serialize()

void MultiLayerItem::serialize ( Streamer s)

Definition at line 144 of file MultiLayerItem.cpp.

145 {
146  s.assertVersion(0);
147  Serialize::rwValue(s, "Name", m_name);
148  Serialize::rwValue(s, "Description", m_description);
151  Serialize::rwClass(s, "Materials", m_materials);
152  Serialize::rwVector(s, "Layers", m_layers, &m_materials);
153 
154  if (s.xmlReader()) {
155  // set non-stored infos
156  for (auto* l : m_layers) {
157  l->setIsTopLayer(m_layers.first() == l);
158  l->setIsBottomLayer(m_layers.last() == l);
159  }
160  }
161 }
QXmlStreamReader * xmlReader()
Returns stream reader or nullptr.
Definition: Streamer.h:48
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
void rwProperty(Streamer &s, DoubleProperty &d)
void rwValue(Streamer &s, const QString &tag, bool &val)
Definition: Serialize.cpp:19
void rwClass(Streamer &s, const QString &tag, T &t)
Serializes an item from a class that provides the function void serialize(Streamer&).
Definition: Serialize.h:77

References Streamer::assertVersion(), m_crossCorrelationLength, m_description, m_externalField, m_layers, m_materials, m_name, Serialize::rwClass(), Serialize::rwProperty(), Serialize::rwValue(), Serialize::rwVector(), and Streamer::xmlReader().

Referenced by readContentFrom(), and writeContentTo().

Here is the call graph for this function:

◆ setDescription()

void MultiLayerItem::setDescription ( const QString &  description)

Definition at line 66 of file MultiLayerItem.cpp.

67 {
69 }
QString description() const

References description(), and m_description.

Referenced by SampleListModel::setData(), and SampleEditorController::setSampleDescription().

Here is the call graph for this function:

◆ setExternalField()

void MultiLayerItem::setExternalField ( const R3 &  externalField)

Definition at line 81 of file MultiLayerItem.cpp.

82 {
84 }
R3 externalField() const
void set(const R3 &d)

References externalField(), m_externalField, and VectorProperty::set().

Here is the call graph for this function:

◆ setSampleName()

void MultiLayerItem::setSampleName ( const QString &  name)

Definition at line 56 of file MultiLayerItem.cpp.

57 {
58  m_name = name;
59 }
QString const & name(EShape k)
Definition: particles.cpp:20

References m_name, and GUI::RealSpace::Particles::name().

Referenced by SampleListModel::createSample(), SampleListModel::createSampleFromExamples(), SampleListModel::setData(), and SampleEditorController::setSampleName().

Here is the call graph for this function:

◆ writeContentTo()

void MultiLayerItem::writeContentTo ( QXmlStreamWriter *  writer) const

Definition at line 132 of file MultiLayerItem.cpp.

133 {
134  Streamer s(writer);
135  const_cast<MultiLayerItem*>(this)->serialize(s);
136 }

References serialize().

Referenced by JobItem::writeNonSessionItems().

Here is the call graph for this function:

Member Data Documentation

◆ m_crossCorrelationLength

DoubleProperty MultiLayerItem::m_crossCorrelationLength
private

Definition at line 74 of file MultiLayerItem.h.

Referenced by MultiLayerItem(), crossCorrLength(), and serialize().

◆ m_description

QString MultiLayerItem::m_description
private

Definition at line 73 of file MultiLayerItem.h.

Referenced by description(), serialize(), and setDescription().

◆ m_externalField

VectorProperty MultiLayerItem::m_externalField
private

◆ m_layers

QVector<LayerItem*> MultiLayerItem::m_layers
private

Definition at line 76 of file MultiLayerItem.h.

Referenced by addLayer(), itemsWithMaterial(), layers(), moveLayer(), removeLayer(), and serialize().

◆ m_materials

MaterialItems MultiLayerItem::m_materials
private

Definition at line 77 of file MultiLayerItem.h.

Referenced by addLayer(), addStandardMaterials(), materialItems(), and serialize().

◆ m_name

QString MultiLayerItem::m_name
private

Definition at line 72 of file MultiLayerItem.h.

Referenced by MultiLayerItem(), sampleName(), serialize(), and setSampleName().


The documentation for this class was generated from the following files: