BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
BeamWavelengthItem.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/coregui/Models/BeamWavelengthItem.cpp
6 //! @brief Implements class BeamWavelengthItem
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 
16 
17 namespace {
18 const double default_wl = 0.1;
19 }
20 
21 BeamWavelengthItem::BeamWavelengthItem(const QString& model_type, const QString& distribution_group)
22  : BeamDistributionItem(model_type, m_show_mean)
23 {
24  register_distribution_group(distribution_group);
25 
27  valueItem->setLimits(RealLimits::positive());
28  valueItem->setDecimals(4);
29  valueItem->setValue(default_wl);
30  valueItem->setEditorType("ScientificSpinBox");
31 
33 }
34 
35 //! Returns wavelength. In the case of distribution applied, returns its mean.
36 
38 {
40 }
41 
43  : BeamWavelengthItem("SpecularBeamWavelength", "Symmetric distribution group")
44 {
45 }
46 
48 {
49  SessionItem* valueItem =
51  if (!limits.isInRange(wavelength())) {
52  const double new_value =
53  limits.isLimited() ? (limits.upperLimit() - limits.lowerLimit()) / 2. : default_wl;
54  valueItem->setValue(new_value);
55  }
56  valueItem->setLimits(limits);
57 }
Defines class BeamWavelengthItem.
The BeamDistributionItem handles wavelength, inclination and azimuthal parameter distribution for Bea...
void initDistributionItem(bool show_mean)
Propagates the value and limits stored in DistributionNone type into alls distributions.
static const QString P_DISTRIBUTION
void register_distribution_group(const QString &group_type)
virtual double meanValue() const
Returns mean value of the distribution.
static const bool m_show_mean
double wavelength() const
Returns wavelength. In the case of distribution applied, returns its mean.
BeamWavelengthItem(const QString &model_type="BeamWavelength", const QString &distribution_group="Distribution extended group")
Limits for a real fit parameter.
Definition: RealLimits.h:24
bool isLimited() const
Definition: RealLimits.cpp:199
static RealLimits positive()
Creates an object which can have only positive values (>0., zero is not included)
Definition: RealLimits.cpp:110
bool isInRange(double value) const
returns true if proposed value is in limits range
Definition: RealLimits.cpp:96
double upperLimit() const
Returns upper limit.
Definition: RealLimits.cpp:62
double lowerLimit() const
Returns lower limit.
Definition: RealLimits.cpp:40
SessionItem & setDecimals(int n)
SessionItem * getGroupItem(const QString &groupName) const
Access subitem of group item.
SessionItem & setEditorType(const QString &editorType)
bool setValue(QVariant value)
Set value, ensure that variant types match.
RealLimits limits() const
SessionItem * getItem(const QString &tag="", int row=0) const
Returns item in given row of given tag.
SessionItem & setLimits(const RealLimits &value)
void setToRange(const RealLimits &limits)
static const QString P_MEAN
std::string model_type
Definition: types.h:23