BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
LayerItem.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/coregui/Models/LayerItem.cpp
6 //! @brief Implements class LayerItem
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 
17 
18 namespace {
19 const QString layer_nslices_tooltip = "Number of horizontal slices.\n"
20  "Used for Average Layer Material calculations \n"
21  "when corresponding simulation option is set.";
22 }
23 
24 const QString LayerItem::P_THICKNESS = QString::fromStdString("Thickness");
25 const QString LayerItem::P_ROUGHNESS = "Top roughness";
26 const QString LayerItem::P_MATERIAL = "Material";
27 const QString LayerItem::P_NSLICES = "Number of slices";
28 const QString LayerItem::T_LAYOUTS = "Layout tag";
29 
31 {
32  setToolTip("A layer with thickness and material");
35  .setToolTip("Thickness of a layer in nanometers");
36 
38  ->setToolTip("Material the layer is made of")
39  .setEditorType("ExtMaterialEditor");
40 
43  .setToolTip(layer_nslices_tooltip);
44 
45  addGroupProperty(P_ROUGHNESS, "Roughness")->setToolTip("Roughness of top interface");
46 
47  registerTag(T_LAYOUTS, 0, -1, QStringList() << "ParticleLayout");
49 
50  mapper()->setOnParentChange([this](SessionItem* new_parent) { updateAppearance(new_parent); });
51 }
52 
53 QVector<SessionItem*> LayerItem::materialPropertyItems()
54 {
55  QVector<SessionItem*> result;
56  if (auto property = getItem(LayerItem::P_MATERIAL))
57  result.push_back(property);
58  for (auto layout : getItems(LayerItem::T_LAYOUTS))
59  result.append(MaterialItemUtils::materialPropertyItems(layout));
60  return result;
61 }
62 
64 {
65  if (!new_parent) {
66  if (parent() && parent()->modelType() == "MultiLayer") {
67  // we are about to be removed from MultiLayer
70  }
71  }
72 }
Defines class LayerItem.
Defines class MaterialItemUtils.
static const QString T_LAYOUTS
Definition: LayerItem.h:26
static const QString P_MATERIAL
Definition: LayerItem.h:24
static const QString P_THICKNESS
Definition: LayerItem.h:22
static const QString P_ROUGHNESS
Definition: LayerItem.h:23
QVector< SessionItem * > materialPropertyItems()
Definition: LayerItem.cpp:53
static const QString P_NSLICES
Definition: LayerItem.h:25
void updateAppearance(SessionItem *new_parent)
Definition: LayerItem.cpp:63
void setOnParentChange(std::function< void(SessionItem *)> f, const void *caller=0)
Calls back when parent has changed, reports newParent.
Definition: ModelMapper.cpp:60
static RealLimits lowerLimited(double bound_value)
Creates an object bounded from the left.
Definition: RealLimits.cpp:105
SessionItem * addProperty(const QString &name, const QVariant &variant)
Add new property item and register new tag.
bool registerTag(const QString &name, int min=0, int max=-1, QStringList modelTypes={})
Add new tag to this item with given name, min, max and types.
QVector< SessionItem * > getItems(const QString &tag="") const
Returns vector of all items of given tag.
SessionItem & setEditorType(const QString &editorType)
SessionItem * addGroupProperty(const QString &groupTag, const QString &groupType)
Creates new group item and register new tag, returns GroupItem.
ModelMapper * mapper()
Returns the current model mapper of this item. Creates new one if necessary.
SessionItem * parent() const
Returns parent of this item.
Definition: SessionItem.cpp:73
void setDefaultTag(const QString &tag)
Set default tag.
SessionItem & setToolTip(const QString &tooltip)
QString modelType() const
Get model type.
void setEnabled(bool enabled)
SessionItem * getItem(const QString &tag="", int row=0) const
Returns item in given row of given tag.
SessionItem & setLimits(const RealLimits &value)
QVector< SessionItem * > materialPropertyItems(SessionItem *item)
Gather material property items from a given item.
ExternalProperty defaultMaterialProperty()