BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
reallimits.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // qt-mvvm: Model-view-view-model framework for large GUI applications
4 //
5 //! @file mvvm/model/mvvm/utils/reallimits.h
6 //! @brief Defines class CLASS?
7 //!
8 //! @homepage http://www.bornagainproject.org
9 //! @license GNU General Public License v3 or higher (see COPYING)
10 //! @copyright Forschungszentrum Jülich GmbH 2020
11 //! @authors Gennady Pospelov et al, Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************************************
14 
15 #ifndef BORNAGAIN_MVVM_MODEL_MVVM_UTILS_REALLIMITS_H
16 #define BORNAGAIN_MVVM_MODEL_MVVM_UTILS_REALLIMITS_H
17 
18 #include "mvvm/model_export.h"
19 
20 namespace ModelView {
21 
22 //! Limits for double.
23 //! @ingroup fitting
24 
25 class MVVM_MODEL_EXPORT RealLimits {
26 public:
27  RealLimits();
28 
29  //! Creates an object bounded from the left
30  static RealLimits lowerLimited(double bound_value);
31 
32  //! Creates an object which can have only positive values (>0., zero is not included)
33  static RealLimits positive();
34 
35  //! Creates an object which can have only positive values with 0. included
36  static RealLimits nonnegative();
37 
38  //! Creates an object bounded from the right
39  static RealLimits upperLimited(double bound_value);
40 
41  //! Creates an object bounded from the left and right
42  static RealLimits limited(double left_bound_value, double right_bound_value);
43 
44  //! Creates an object withoud bounds (default)
45  static RealLimits limitless();
46 
47  //! if has lower limit
48  bool hasLowerLimit() const;
49 
50  //! Returns lower limit
51  double lowerLimit() const;
52 
53  //! if has upper limit
54  bool hasUpperLimit() const;
55 
56  //! Returns upper limit
57  double upperLimit() const;
58 
59  //! if has lower and upper limit
60  bool hasLowerAndUpperLimits() const;
61 
62  //! returns true if proposed value is in limits range
63  bool isInRange(double value) const;
64 
65  bool operator==(const RealLimits& other) const;
66  bool operator!=(const RealLimits& other) const;
67  bool operator<(const RealLimits& other) const;
68 
69  bool isLimitless() const;
70  bool isPositive() const;
71  bool isNonnegative() const;
72  bool isLowerLimited() const;
73  bool isUpperLimited() const;
74  bool isLimited() const;
75 
76 protected:
77  RealLimits(bool has_lower_limit, bool has_upper_limit, double lower_limit, double upper_limit);
78 
79  bool m_has_lower_limit; //! parameter has lower bound
80  bool m_has_upper_limit; //! parameter has upper bound
81  double m_lower_limit; //! minimum allowed value
82  double m_upper_limit; //! maximum allowed value
83 };
84 
85 } // namespace ModelView
86 
87 #endif // BORNAGAIN_MVVM_MODEL_MVVM_UTILS_REALLIMITS_H
bool operator<(const CumulativeValue &lhs, const CumulativeValue &rhs)
bool operator!=(const Material &left, const Material &right)
Comparison operator for material wrapper (inequality check)
Definition: Material.cpp:126
bool operator==(const Material &left, const Material &right)
Comparison operator for material wrapper (equality check)
Definition: Material.cpp:113
Limits for double.
Definition: reallimits.h:25
double m_lower_limit
parameter has upper bound
Definition: reallimits.h:81
bool m_has_upper_limit
parameter has lower bound
Definition: reallimits.h:80
double m_upper_limit
minimum allowed value
Definition: reallimits.h:82
materialitems.h Collection of materials to populate MaterialModel.