BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
RoughnessTranslator Class Reference
Inheritance diagram for RoughnessTranslator:
[legend]
Collaboration diagram for RoughnessTranslator:
[legend]

Public Member Functions

 RoughnessTranslator (const SessionItem *p_parent)
 Converts "/Layer1/LayerBasicRoughness/Sigma" into "/LayerInterface0/LayerBasicRoughness/Sigma". More...
 
 ~RoughnessTranslator () override
 
RoughnessTranslatorclone () const override
 
QStringList translate (const QStringList &list) const override
 

Private Member Functions

int getLayerIndex (QString layerName) const
 Extract layer index from the string "Layer11". More...
 
int numberOfLayers () const
 

Private Attributes

const SessionItemm_parent
 

Detailed Description

Definition at line 77 of file ParameterTranslators.h.

Constructor & Destructor Documentation

◆ RoughnessTranslator()

RoughnessTranslator::RoughnessTranslator ( const SessionItem p_parent)

Converts "/Layer1/LayerBasicRoughness/Sigma" into "/LayerInterface0/LayerBasicRoughness/Sigma".

Definition at line 92 of file ParameterTranslators.cpp.

92 : m_parent(p_parent) {}
const SessionItem * m_parent

Referenced by clone().

◆ ~RoughnessTranslator()

RoughnessTranslator::~RoughnessTranslator ( )
inlineoverride

Definition at line 80 of file ParameterTranslators.h.

80 {}

Member Function Documentation

◆ clone()

RoughnessTranslator * RoughnessTranslator::clone ( ) const
overridevirtual

Implements IPathTranslator.

Definition at line 94 of file ParameterTranslators.cpp.

95 {
96  return new RoughnessTranslator(m_parent);
97 }
RoughnessTranslator(const SessionItem *p_parent)
Converts "/Layer1/LayerBasicRoughness/Sigma" into "/LayerInterface0/LayerBasicRoughness/Sigma".

References RoughnessTranslator(), and m_parent.

Here is the call graph for this function:

◆ getLayerIndex()

int RoughnessTranslator::getLayerIndex ( QString  layerName) const
private

Extract layer index from the string "Layer11".

Definition at line 119 of file ParameterTranslators.cpp.

120 {
121  layerName.remove("Layer");
122  bool ok(true);
123  int layerIndex = layerName.toInt(&ok);
124  if (!ok)
125  throw GUIHelpers::Error("RoughnessTranslator::getLayerIndex() -> Error. Can't parse.");
126  return layerIndex;
127 }

Referenced by translate().

◆ numberOfLayers()

int RoughnessTranslator::numberOfLayers ( ) const
private

Definition at line 129 of file ParameterTranslators.cpp.

130 {
131  QVector<SessionItem*> list = m_parent->getChildrenOfType("Layer");
132  return list.size();
133 }
QVector< SessionItem * > getChildrenOfType(const QString &model_type) const
Returns a vector of all children of the given type.

References SessionItem::getChildrenOfType(), and m_parent.

Referenced by translate().

Here is the call graph for this function:

◆ translate()

QStringList RoughnessTranslator::translate ( const QStringList &  list) const
overridevirtual

Implements IPathTranslator.

Definition at line 99 of file ParameterTranslators.cpp.

100 {
101  if (list.empty())
102  return {};
103 
104  if (!list.back().contains("Layer") || !expectedRoughnessPars.contains(list.front()))
105  return list;
106 
107  QStringList result = list;
108 
109  QString layerName = result.takeLast();
110  int layerIndex = getLayerIndex(layerName);
111  QString postfix = numberOfLayers() == 2 ? QString() : QString::number(layerIndex - 1);
112 
113  result.push_back(QString::fromStdString("LayerInterface") + postfix);
114  return result;
115 }
int getLayerIndex(QString layerName) const
Extract layer index from the string "Layer11".

References getLayerIndex(), and numberOfLayers().

Here is the call graph for this function:

Member Data Documentation

◆ m_parent

const SessionItem* RoughnessTranslator::m_parent
private

Definition at line 89 of file ParameterTranslators.h.

Referenced by clone(), and numberOfLayers().


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