BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
BeamItems.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/Model/Device/BeamItems.h
6 //! @brief Defines BeamItem hierarchy
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 
15 #ifndef BORNAGAIN_GUI_MODEL_DEVICE_BEAMITEMS_H
16 #define BORNAGAIN_GUI_MODEL_DEVICE_BEAMITEMS_H
17 
24 #include <functional>
25 #include <heinz/Vectors3D.h>
26 
27 class BasicAxisItem;
28 class Beam;
30 class BeamWavelengthItem;
31 class FootprintItem;
32 class IAxis;
33 
34 class BeamItem {
35 public:
36  virtual ~BeamItem() = default;
37 
38  virtual void serialize(Streamer& s);
39 
40  DOUBLE_PROPERTY(intensity, Intensity);
41 
42  double wavelength() const;
43  void setWavelength(double value);
45 
46  virtual double getInclinationAngle() const = 0;
47  virtual void setInclinationAngle(double value);
49 
50  double getAzimuthalAngle() const;
51  void setAzimuthalAngle(double value);
53 
54  std::unique_ptr<Beam> createBeam() const;
55 
56 protected:
57  BeamItem();
58 
59  template <typename T>
60  void initWavelength();
61  template <typename T>
62  void initInclinationAngle();
63 
64  std::unique_ptr<BeamWavelengthItem> m_wavelengthItem;
65  std::unique_ptr<BeamAzimuthalAngleItem> m_azimuthalAngleItem;
66  std::unique_ptr<BeamDistributionItem> m_inclinationAngleItem;
67 };
68 
69 class SpecularBeamItem : public BeamItem {
70 public:
71  explicit SpecularBeamItem(const InstrumentItem* owningInstrument);
72  void serialize(Streamer& s) override;
73 
74  double getInclinationAngle() const override;
75  void setInclinationAngle(double value) override;
78 
79  FootprintItem* footprint() const;
81  void setGaussianFootprint(double value);
82  void setSquareFootprint(double value);
84  template <typename T>
86 
87  void updateToData(const IAxis& axis, QString units);
88  void updateWavelength();
89 
90 private:
92 };
93 
94 class GISASBeamItem : public BeamItem {
95 public:
96  GISASBeamItem();
97 
98  double getInclinationAngle() const override;
99 
100  //! Explicitly set a getter function for the inclination angle.
101  //!
102  //! If a getter is set, it overrides the behavior in getInclinationAngle().
103  //! Helpful if the angle can't be determined from the internal beam parameters, but from
104  //! external information.
105  void setInclinationAngleGetter(std::function<double()> getter);
106 
107  std::function<double()> m_inclinationAngleGetter;
108 };
109 
110 #endif // BORNAGAIN_GUI_MODEL_DEVICE_BEAMITEMS_H
Defines class BeamAngleItems.
Defines class BeamWavelengthItem.
Defines class SelectionDescriptor.
Defines class SelectionProperty.
Defines class SessionItem.
Declares the class SpecularBeamInclinationItem.
The BeamDistributionItem handles wavelength, inclination and azimuthal parameter distribution for Bea...
virtual BeamDistributionItem * inclinationAngleItem() const
Definition: BeamItems.cpp:77
std::unique_ptr< Beam > createBeam() const
Definition: BeamItems.cpp:97
void initInclinationAngle()
Definition: BeamItems.cpp:116
void setWavelength(double value)
Definition: BeamItems.cpp:62
DOUBLE_PROPERTY(intensity, Intensity)
virtual ~BeamItem()=default
std::unique_ptr< BeamDistributionItem > m_inclinationAngleItem
Definition: BeamItems.h:66
BeamAzimuthalAngleItem * azimuthalAngleItem() const
Definition: BeamItems.cpp:92
virtual void serialize(Streamer &s)
Definition: BeamItems.cpp:48
std::unique_ptr< BeamWavelengthItem > m_wavelengthItem
Definition: BeamItems.h:64
virtual void setInclinationAngle(double value)
Definition: BeamItems.cpp:72
void setAzimuthalAngle(double value)
Definition: BeamItems.cpp:87
double wavelength() const
Definition: BeamItems.cpp:57
virtual double getInclinationAngle() const =0
void initWavelength()
Definition: BeamItems.cpp:110
std::unique_ptr< BeamAzimuthalAngleItem > m_azimuthalAngleItem
Definition: BeamItems.h:65
double getAzimuthalAngle() const
Definition: BeamItems.cpp:82
BeamWavelengthItem * wavelengthItem() const
Definition: BeamItems.cpp:67
double getInclinationAngle() const override
Definition: BeamItems.cpp:214
void setInclinationAngleGetter(std::function< double()> getter)
Explicitly set a getter function for the inclination angle.
Definition: BeamItems.cpp:222
std::function< double()> m_inclinationAngleGetter
Definition: BeamItems.h:107
Abstract base class for instrument-specific item classes.
Describes a selection (various possibilities and the current one).
Base class for a GUI data item.
Definition: SessionItem.h:204
BeamInclinationAxisItem contains inclination angle axis for specular/off-specular simulations and als...
void setSquareFootprint(double value)
Definition: BeamItems.cpp:176
SelectionDescriptor< FootprintItem * > footprintSelection() const
Definition: BeamItems.cpp:166
SelectionProperty< FootprintItem * > m_footprint
Definition: BeamItems.h:91
void updateWavelength()
Definition: BeamItems.cpp:193
void setInclinationAngle(double value) override
Definition: BeamItems.cpp:144
FootprintItem * footprint() const
Definition: BeamItems.cpp:161
BasicAxisItem * inclinationAxis() const
Definition: BeamItems.cpp:156
void setGaussianFootprint(double value)
Definition: BeamItems.cpp:171
SpecularBeamItem(const InstrumentItem *owningInstrument)
Definition: BeamItems.cpp:124
SessionItem * footprintGroupItem() const
void updateToData(const IAxis &axis, QString units)
Definition: BeamItems.cpp:181
SpecularBeamInclinationItem * inclinationAngleItem() const override
Definition: BeamItems.cpp:151
double getInclinationAngle() const override
Definition: BeamItems.cpp:139
void serialize(Streamer &s) override
Definition: BeamItems.cpp:132
Supports serialization to or deserialization from QXmlStream.
Definition: Streamer.h:36