BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
MultiLayerItem.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/coregui/Models/MultiLayerItem.cpp
6 //! @brief Implements class MultiLayerItem
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 
20 namespace {
21 const QString external_field_tooltip = "External field (A/m)";
22 }
23 
25  QString::fromStdString("CrossCorrelationLength");
26 const QString MultiLayerItem::P_EXTERNAL_FIELD = "ExternalField";
27 const QString MultiLayerItem::T_LAYERS = "Layer tag";
28 
30 {
31  setToolTip("A multilayer to hold stack of layers");
32  setItemName("MultiLayer");
33 
35  ->setDecimals(5)
36  .setToolTip("Cross correlation length of roughnesses \n"
37  "between interfaces in nanometers");
38  addProperty<VectorItem>(P_EXTERNAL_FIELD)->setToolTip(external_field_tooltip);
39 
40  registerTag(T_LAYERS, 0, -1, QStringList() << "Layer");
42 
45 
47 }
48 
50 {
51  QVector<SessionItem*> result;
52  for (auto layer_item : getItems(T_LAYERS))
53  result.append(static_cast<LayerItem*>(layer_item)->materialPropertyItems());
54  return result;
55 }
56 
58 {
59  QVector<SessionItem*> list = getChildrenOfType("Layer");
60  for (auto it = list.begin(); it != list.end(); ++it) {
61  if (it == list.begin())
62  (*it)->getItem(LayerItem::P_ROUGHNESS)->setEnabled(false);
63  else
64  (*it)->getItem(LayerItem::P_ROUGHNESS)->setEnabled(true);
65 
66  if (it == list.begin() || it == (list.end() - 1)) {
67  (*it)->getItem(LayerItem::P_THICKNESS)->setEnabled(false);
68  (*it)->setItemValue(LayerItem::P_THICKNESS, 0.0);
69  } else {
70  (*it)->getItem(LayerItem::P_THICKNESS)->setEnabled(true);
71  }
72  }
73 }
Defines class LayerItem.
Defines class MultiLayerItem.
Defines interface IParameterTranslator and subclasses.
Defines class VectorItem.
static const QString P_THICKNESS
Definition: LayerItem.h:22
static const QString P_ROUGHNESS
Definition: LayerItem.h:23
void setOnChildrenChange(std::function< void(SessionItem *)> f, const void *caller=0)
Calls back when number of children has changed, reports newChild.
Definition: ModelMapper.cpp:68
QVector< SessionItem * > materialPropertyItems()
static const QString P_CROSS_CORR_LENGTH
static const QString T_LAYERS
static const QString P_EXTERNAL_FIELD
void setItemName(const QString &name)
Set item name, add property if necessary.
SessionItem * addProperty(const QString &name, const QVariant &variant)
Add new property item and register new tag.
SessionItem & setDecimals(int n)
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.
ModelMapper * mapper()
Returns the current model mapper of this item. Creates new one if necessary.
void setDefaultTag(const QString &tag)
Set default tag.
void addTranslator(const IPathTranslator &translator)
SessionItem & setToolTip(const QString &tooltip)
QVector< SessionItem * > getChildrenOfType(const QString &model_type) const
Returns a vector of all children of the given type.