BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
AxisProperty.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/Model/Descriptor/AxisProperty.cpp
6 //! @brief Implements class AxisProperty
7 //!
8 //! @homepage http://www.bornagainproject.org
9 //! @license GNU General Public License v3 or higher (see COPYING)
10 //! @copyright Forschungszentrum Jülich GmbH 2022
11 //! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************************************
14 
16 #include "Base/Util/Assert.h"
18 
19 void AxisProperty::initNbins(const QString& label, const QString& tooltip, uint n,
20  const variant<QString, Unit>& unit)
21 {
22  m_nbins.init(label, tooltip, n, unit, "nbins");
23 }
24 
25 
26 void AxisProperty::initMin(const QString& label, const QString& tooltip, double value,
27  const variant<QString, Unit>& unit, const RealLimits& limits,
28  uint decimals)
29 {
30  m_min.init(label, tooltip, value, unit, decimals, limits, "min");
31 }
32 
33 void AxisProperty::initMax(const QString& label, const QString& tooltip, double value,
34  const variant<QString, Unit>& unit, const RealLimits& limits,
35  uint decimals)
36 {
37  m_max.init(label, tooltip, value, unit, decimals, limits, "max");
38 }
39 
40 std::unique_ptr<FixedBinAxis> AxisProperty::createAxis(double scaleFactor) const
41 {
42  return std::make_unique<FixedBinAxis>(std::string(), m_nbins, m_min * scaleFactor,
43  m_max * scaleFactor);
44 }
45 
46 void AxisProperty::rwAxisProperty(Streamer& s, const QString& tag)
47 {
48  s.start(tag);
49  s.assertVersion(0);
50  Serialize::rwProperty(s, m_nbins);
51  Serialize::rwProperty(s, m_min);
52  Serialize::rwProperty(s, m_max);
53  s.finish(tag);
54 }
Defines class AxisProperty.
Defines class Streamer.
void rwAxisProperty(Streamer &s, const QString &tag)
void initNbins(const QString &label, const QString &tooltip, uint n=100, const variant< QString, Unit > &unit="nbins")
void initMin(const QString &label, const QString &tooltip, double value, const variant< QString, Unit > &unit, const RealLimits &limits=RealLimits::nonnegative(), uint decimals=3)
std::unique_ptr< FixedBinAxis > createAxis(double scaleFactor) const
Creates an axis with empty title.
void initMax(const QString &label, const QString &tooltip, double value, const variant< QString, Unit > &unit, const RealLimits &limits=RealLimits::nonnegative(), uint decimals=3)
Supports serialization to or deserialization from QXmlStream.
Definition: Streamer.h:36
void start(const QString &tag)
Definition: Streamer.cpp:82
void finish(const QString &tag)
Definition: Streamer.cpp:90
void assertVersion(unsigned expectedVersion) const
As reader, throws DeserializationException unless the expected version is read. As writer,...
Definition: Streamer.cpp:26
void rwProperty(Streamer &s, DoubleProperty &d)