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

Description

Definition at line 36 of file LayerItem.h.

Inheritance diagram for LayerItem:
[legend]
Collaboration diagram for LayerItem:
[legend]

Public Member Functions

 LayerItem (const MaterialItems *materials)
 
ParticleLayoutItem * addLayout ()
 
void clearRoughness ()
 
QColor color () const
 
bool isBottomLayer () const
 
bool isTopLayer () const
 
QVector< ItemWithMaterial * > itemsWithMaterial ()
 
QVector< ItemWithParticles * > itemsWithParticles () const
 
QString layerName () const
 
QVector< ParticleLayoutItem * > layouts () const
 
QColor materialColor () const
 
QString materialIdentifier () const
 
MaterialItem * materialItem () const
 Returns the material item this item links to. More...
 
QString materialName () const
 
UIntDescriptor numSlices () const
 
void removeLayout (ParticleLayoutItem *layout)
 
SelectionDescriptor< LayerBasicRoughnessItem * > roughness ()
 
void serialize (Streamer &s)
 
void setBasicRoughness ()
 
void setColor (const QColor &color)
 
void setIsBottomLayer (bool b)
 
void setIsTopLayer (bool b)
 
void setLayerName (const QString &name)
 
void setMaterial (const MaterialItem *materialItem)
 Set the material this item shall use. Stores the identifier, not the pointer! More...
 
void setMaterial (const QString &materialIdentifier)
 Set the material this item shall use. Stores the given identifier, not a pointer to the material! More...
 
void setMaterialUndefined ()
 Set "no material defined". More...
 
DoubleDescriptor thickness () const
 

Protected Attributes

QString m_materialIdentifier
 
const MaterialItems * m_materialItems
 

Private Attributes

QColor m_color
 
bool m_isBottomLayer = false
 
bool m_isTopLayer = false
 
QVector< ParticleLayoutItem * > m_layouts
 
QString m_name
 
UIntProperty m_numSlices
 
DoubleProperty m_thickness
 
std::unique_ptr< LayerBasicRoughnessItem > m_topRoughness
 

Constructor & Destructor Documentation

◆ LayerItem()

LayerItem::LayerItem ( const MaterialItems *  materials)
explicit

Definition at line 55 of file LayerItem.cpp.

56  : ItemWithMaterial(materials)
57 {
58  m_thickness.init("Thickness", "Thickness of the layer", 0.0, Unit::nanometer, 3,
59  RealLimits::lowerLimited(0.0), "thickness");
60 
61  m_numSlices.init("Number of slices",
62  "Number of horizontal slices.\n"
63  "Used for Average Layer Material calculations \n"
64  "when corresponding simulation option is set.",
65  1, Unit::unitless, RealLimits::lowerLimited(0.0), "slices");
66 
67  m_name = "Layer";
68 }
@ unitless
@ nanometer
void init(const QString &label, const QString &tooltip, double value, const variant< QString, Unit > &unit, const QString &persistentTag)
ItemWithMaterial(const MaterialItems *materials)
Overhand the material list where the current material has to be searched for.
UIntProperty m_numSlices
Definition: LayerItem.h:71
DoubleProperty m_thickness
Definition: LayerItem.h:72
QString m_name
Definition: LayerItem.h:70
void init(const QString &label, const QString &tooltip, uint value, const variant< QString, Unit > &unit, const QString &persistentTag)

References DoubleProperty::init(), UIntProperty::init(), m_name, m_numSlices, m_thickness, nanometer, and unitless.

Here is the call graph for this function:

Member Function Documentation

◆ addLayout()

ParticleLayoutItem * LayerItem::addLayout ( )

Definition at line 141 of file LayerItem.cpp.

142 {
144  return m_layouts.back();
145 }
const MaterialItems * m_materialItems
QVector< ParticleLayoutItem * > m_layouts
Definition: LayerItem.h:76

References m_layouts, and ItemWithMaterial::m_materialItems.

Referenced by SampleEditorController::addLayout(), and GUI::Transform::FromCore::itemizeSample().

◆ clearRoughness()

void LayerItem::clearRoughness ( )

Definition at line 126 of file LayerItem.cpp.

127 {
128  m_topRoughness.reset();
129 }
std::unique_ptr< LayerBasicRoughnessItem > m_topRoughness
Definition: LayerItem.h:77

References m_topRoughness.

Referenced by roughness().

◆ color()

QColor LayerItem::color ( ) const

Definition at line 153 of file LayerItem.cpp.

154 {
155  return m_color;
156 }
QColor m_color
Definition: LayerItem.h:73

References m_color.

Referenced by LayerForm::LayerForm(), setColor(), and LayerForm::updateColor().

◆ isBottomLayer()

bool LayerItem::isBottomLayer ( ) const

Definition at line 178 of file LayerItem.cpp.

179 {
180  return m_isBottomLayer;
181 }
bool m_isBottomLayer
Definition: LayerItem.h:75

References m_isBottomLayer.

Referenced by GUI::View::TransformTo3D::visualLayerThickness().

◆ isTopLayer()

bool LayerItem::isTopLayer ( ) const

Definition at line 168 of file LayerItem.cpp.

169 {
170  return m_isTopLayer;
171 }
bool m_isTopLayer
Definition: LayerItem.h:74

References m_isTopLayer.

Referenced by GUI::View::TransformTo3D::visualLayerThickness().

◆ itemsWithMaterial()

QVector< ItemWithMaterial * > LayerItem::itemsWithMaterial ( )

Definition at line 80 of file LayerItem.cpp.

81 {
82  QVector<ItemWithMaterial*> result;
83  result.push_back(this);
84  for (auto* layout : layouts())
85  result.append(layoutItemsWithMaterial(layout));
86  return result;
87 }
QVector< ParticleLayoutItem * > layouts() const
Definition: LayerItem.cpp:136

References layouts().

Here is the call graph for this function:

◆ itemsWithParticles()

QVector< ItemWithParticles * > LayerItem::itemsWithParticles ( ) const

Definition at line 89 of file LayerItem.cpp.

90 {
91  QVector<ItemWithParticles*> result;
92  for (auto* layout : layouts())
93  result << layout->containedItemsWithParticles();
94  return result;
95 }

References ParticleLayoutItem::containedItemsWithParticles(), and layouts().

Here is the call graph for this function:

◆ layerName()

QString LayerItem::layerName ( ) const

Definition at line 75 of file LayerItem.cpp.

76 {
77  return m_name;
78 }

References m_name.

Referenced by LayerForm::LayerForm(), and SampleValidator::validateInterferences().

◆ layouts()

◆ materialColor()

QColor ItemWithMaterial::materialColor ( ) const
inherited

Definition at line 42 of file ItemWithMaterial.cpp.

43 {
44  ASSERT(materialItem());
45  return materialItem()->color();
46 }
MaterialItem * materialItem() const
Returns the material item this item links to.
QColor color() const

References MaterialItem::color(), and ItemWithMaterial::materialItem().

Referenced by GUI::View::TransformTo3D::createLayer().

Here is the call graph for this function:

◆ materialIdentifier()

QString ItemWithMaterial::materialIdentifier ( ) const
inherited

◆ materialItem()

MaterialItem * ItemWithMaterial::materialItem ( ) const
inherited

Returns the material item this item links to.

Definition at line 59 of file ItemWithMaterial.cpp.

60 {
61  if (materialIdentifier().isEmpty())
62  return nullptr;
63 
65 }
QString materialIdentifier() const
MaterialItem * materialFromIdentifier(const QString &identifier) const

References ItemWithMaterial::m_materialItems, MaterialItems::materialFromIdentifier(), and ItemWithMaterial::materialIdentifier().

Referenced by ParticleItem::createParticle(), MaterialInplaceForm::createWidgets(), ItemWithMaterial::materialColor(), ItemWithMaterial::materialName(), MaterialInplaceForm::selectMaterial(), and ItemWithMaterial::setMaterial().

Here is the call graph for this function:

◆ materialName()

QString ItemWithMaterial::materialName ( ) const
inherited

Definition at line 48 of file ItemWithMaterial.cpp.

49 {
50  ASSERT(materialItem());
51  return materialItem()->matItemName();
52 }
QString matItemName() const

References ItemWithMaterial::materialItem(), and MaterialItem::matItemName().

Referenced by LayerForm::updateTitle().

Here is the call graph for this function:

◆ numSlices()

UIntDescriptor LayerItem::numSlices ( ) const

Definition at line 131 of file LayerItem.cpp.

132 {
133  return m_numSlices;
134 }

References m_numSlices.

Referenced by LayerForm::LayerForm().

◆ removeLayout()

void LayerItem::removeLayout ( ParticleLayoutItem *  layout)

Definition at line 147 of file LayerItem.cpp.

148 {
149  m_layouts.removeAll(layout);
150  delete layout;
151 }

References m_layouts.

Referenced by SampleEditorController::removeLayout().

◆ roughness()

SelectionDescriptor< LayerBasicRoughnessItem * > LayerItem::roughness ( )

Definition at line 102 of file LayerItem.cpp.

103 {
105  d.label = "Top roughness";
106  d.tooltip = "Roughness of top interface";
107  d.options = QStringList{"No", "Basic"};
108 
109  d.currentIndexSetter = [=](int idx) {
110  if (idx == 0)
111  clearRoughness();
112  else
114  };
115 
116  d.currentIndexGetter = [=]() { return m_topRoughness ? 1 : 0; };
117  d.currentItem = [=] { return m_topRoughness.get(); };
118  return d;
119 }
void clearRoughness()
Definition: LayerItem.cpp:126
void setBasicRoughness()
Definition: LayerItem.cpp:121
Describes a selection (various possibilities and the current one).
function< int()> currentIndexGetter
Function to get currently selected option.
QString label
A label text (short, no trailing colon)
function< T()> currentItem
Function to get currently selected item.
function< void(int)> currentIndexSetter
Function to set currently selected option.
QStringList options
List of options, usually presented as combo entries.
QString tooltip
Tooltip text.

References clearRoughness(), SelectionDescriptor< T >::currentIndexGetter, SelectionDescriptor< T >::currentIndexSetter, SelectionDescriptor< T >::currentItem, SelectionDescriptor< T >::label, m_topRoughness, SelectionDescriptor< T >::options, setBasicRoughness(), and SelectionDescriptor< T >::tooltip.

Referenced by LayerForm::LayerForm().

Here is the call graph for this function:

◆ serialize()

void LayerItem::serialize ( Streamer &  s)

Definition at line 183 of file LayerItem.cpp.

184 {
185  s.assertVersion(0);
186  Serialize::rwValue(s, "Name", m_name);
187  Serialize::rwValue(s, "Color", m_color);
188  Serialize::rwValue(s, "MaterialIdentifier", m_materialIdentifier);
191  Serialize::rwOptional(s, "Roughness", m_topRoughness);
193 }
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 rwOptional(Streamer &s, const QString &tag, std::unique_ptr< ItemClass > &up, ArgsForConstructor... argsForConstructor)
Serializes an optional item of known type. Passes optional arguments to the constructor.
Definition: Serialize.h:142

References Streamer::assertVersion(), m_color, m_layouts, ItemWithMaterial::m_materialIdentifier, ItemWithMaterial::m_materialItems, m_name, m_numSlices, m_thickness, m_topRoughness, Serialize::rwOptional(), Serialize::rwProperty(), Serialize::rwValue(), and Serialize::rwVector().

Here is the call graph for this function:

◆ setBasicRoughness()

void LayerItem::setBasicRoughness ( )

Definition at line 121 of file LayerItem.cpp.

References m_topRoughness.

Referenced by roughness().

◆ setColor()

void LayerItem::setColor ( const QColor &  color)

Definition at line 158 of file LayerItem.cpp.

159 {
160  m_color = color;
161 }
QColor color() const
Definition: LayerItem.cpp:153

References color(), and m_color.

Referenced by LayerForm::LayerForm(), and SampleEditorController::addLayerFromUndo().

Here is the call graph for this function:

◆ setIsBottomLayer()

void LayerItem::setIsBottomLayer ( bool  b)

Definition at line 173 of file LayerItem.cpp.

174 {
175  m_isBottomLayer = b;
176 }

References m_isBottomLayer.

Referenced by GUI::Transform::FromCore::itemizeSample().

◆ setIsTopLayer()

void LayerItem::setIsTopLayer ( bool  b)

Definition at line 163 of file LayerItem.cpp.

164 {
165  m_isTopLayer = b;
166 }

References m_isTopLayer.

Referenced by GUI::Transform::FromCore::itemizeSample().

◆ setLayerName()

void LayerItem::setLayerName ( const QString &  name)

Definition at line 70 of file LayerItem.cpp.

71 {
72  m_name = name;
73 }
QString const & name(EShape k)
Definition: particles.cpp:20

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

Here is the call graph for this function:

◆ setMaterial() [1/2]

void ItemWithMaterial::setMaterial ( const MaterialItem *  materialItem)
inherited

Set the material this item shall use. Stores the identifier, not the pointer!

Definition at line 20 of file ItemWithMaterial.cpp.

21 {
23 }
QString identifier() const

References MaterialItem::identifier(), ItemWithMaterial::m_materialIdentifier, and ItemWithMaterial::materialItem().

Referenced by SampleEditorController::addLayerFromUndo(), GUI::Transform::FromCore::itemizeSample(), and SampleEditorController::selectMaterial().

Here is the call graph for this function:

◆ setMaterial() [2/2]

void ItemWithMaterial::setMaterial ( const QString &  materialIdentifier)
inherited

Set the material this item shall use. Stores the given identifier, not a pointer to the material!

Definition at line 25 of file ItemWithMaterial.cpp.

References ItemWithMaterial::m_materialIdentifier, and ItemWithMaterial::materialIdentifier().

Here is the call graph for this function:

◆ setMaterialUndefined()

void ItemWithMaterial::setMaterialUndefined ( )
inherited

Set "no material defined".

Definition at line 37 of file ItemWithMaterial.cpp.

38 {
39  m_materialIdentifier.clear();
40 }

References ItemWithMaterial::m_materialIdentifier.

◆ thickness()

DoubleDescriptor LayerItem::thickness ( ) const

Member Data Documentation

◆ m_color

QColor LayerItem::m_color
private

Definition at line 73 of file LayerItem.h.

Referenced by color(), serialize(), and setColor().

◆ m_isBottomLayer

bool LayerItem::m_isBottomLayer = false
private

Definition at line 75 of file LayerItem.h.

Referenced by isBottomLayer(), and setIsBottomLayer().

◆ m_isTopLayer

bool LayerItem::m_isTopLayer = false
private

Definition at line 74 of file LayerItem.h.

Referenced by isTopLayer(), and setIsTopLayer().

◆ m_layouts

QVector<ParticleLayoutItem*> LayerItem::m_layouts
private

Definition at line 76 of file LayerItem.h.

Referenced by addLayout(), layouts(), removeLayout(), and serialize().

◆ m_materialIdentifier

QString ItemWithMaterial::m_materialIdentifier
protectedinherited

◆ m_materialItems

const MaterialItems* ItemWithMaterial::m_materialItems
protectedinherited

◆ m_name

QString LayerItem::m_name
private

Definition at line 70 of file LayerItem.h.

Referenced by LayerItem(), layerName(), serialize(), and setLayerName().

◆ m_numSlices

UIntProperty LayerItem::m_numSlices
private

Definition at line 71 of file LayerItem.h.

Referenced by LayerItem(), numSlices(), and serialize().

◆ m_thickness

DoubleProperty LayerItem::m_thickness
private

Definition at line 72 of file LayerItem.h.

Referenced by LayerItem(), serialize(), and thickness().

◆ m_topRoughness

std::unique_ptr<LayerBasicRoughnessItem> LayerItem::m_topRoughness
private

Definition at line 77 of file LayerItem.h.

Referenced by clearRoughness(), roughness(), serialize(), and setBasicRoughness().


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