BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
DistributionEditor.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/View/Instrument/DistributionEditor.h
6 //! @brief A widget for selecting a distribution and setting its parameters
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_VIEW_INSTRUMENT_DISTRIBUTIONEDITOR_H
16 #define BORNAGAIN_GUI_VIEW_INSTRUMENT_DISTRIBUTIONEDITOR_H
17 
18 #include "GUI/View/Tool/ID.h"
19 #include <QGroupBox>
20 
21 class QComboBox;
22 class QStackedLayout;
23 class DistributionForm;
25 class QFormLayout;
26 class DistributionPlot;
27 class DoubleSpinBox;
28 class ScientificSpinBox;
29 class QSpinBox;
30 class DoubleDescriptor;
31 class UIntDescriptor;
32 
33 #include <boost/numeric/interval.hpp>
34 
35 #include <map>
36 #include <optional>
37 
38 //! configuration to control how the user can enter a mean value
39 struct MeanConfig {
40  bool scientific; //!< whether to use a scientific number notation
41 };
42 
43 /// Widget for selecting a distribution (combo box) and input of the corresponding values
44 /// with respect to the given distribution (e.g. mean and deviation for gauss distribution)
45 
46 class DistributionSelector : public QWidget {
47  Q_OBJECT
48 
49 public:
50  /// \param mean_config controls how the mean value is shown and can be input.
51  /// If this parameter is \c nullopt then the mean value can not be input
52  /// and only symmetric distributions are provided
53  /// \pre ! mean_config && distributions == Distributions::Symmetric
54  /// (i.e. the combination of all distributions without mean input is currently not
55  /// supported)
56  DistributionSelector(std::optional<MeanConfig> mean_config,
57  GUI::ID::Distributions distributions, QWidget* parent,
59 
60  BeamDistributionItem* item() const;
62  void refresh();
63 
64 signals:
66 
67 private:
70  QSpinBox* createSpinBox(const UIntDescriptor& d);
71  void createMeanSpinBox(const DoubleDescriptor& d);
72 
73 private:
75  std::optional<MeanConfig> m_meanConfig;
77  QFormLayout* m_formLayout;
78  QComboBox* m_distributionCombo;
79 };
80 
81 
82 /// DistributionSelector as above but contained in a GroupBox with a title and a button
83 /// to open the distribution dialog
84 
85 class DistributionEditor : public QGroupBox {
86  Q_OBJECT
87 
88 public:
89  DistributionEditor(const QString& title, const std::optional<MeanConfig>& mean_config,
90  GUI::ID::Distributions distributions, QWidget* parent,
91  BeamDistributionItem* item);
92 
93  //! Update UI from data
94  void updateData();
95 
96 signals:
98 
99 private:
100  void updatePlot();
101 
104 };
105 
106 #endif // BORNAGAIN_GUI_VIEW_INSTRUMENT_DISTRIBUTIONEDITOR_H
Defines enum ViewId.
The BeamDistributionItem handles wavelength, inclination and azimuthal parameter distribution for Bea...
DistributionSelector as above but contained in a GroupBox with a title and a button to open the distr...
DistributionPlot * m_plot
void updateData()
Update UI from data.
DistributionSelector * m_selector
void distributionChanged()
DistributionEditor(const QString &title, const std::optional< MeanConfig > &mean_config, GUI::ID::Distributions distributions, QWidget *parent, BeamDistributionItem *item)
The DistributionPlot class plots 1d functions corresponding to domain's Distribution1D.
Widget for selecting a distribution (combo box) and input of the corresponding values with respect to...
BeamDistributionItem * m_item
DistributionSelector(std::optional< MeanConfig > mean_config, GUI::ID::Distributions distributions, QWidget *parent, BeamDistributionItem *item)
DoubleSpinBox * createSpinBox(const DoubleDescriptor &d)
GUI::ID::Distributions m_distributions
QComboBox * m_distributionCombo
GUI::ID::Distributions distributions() const
void createMeanSpinBox(const DoubleDescriptor &d)
BeamDistributionItem * item() const
QFormLayout * m_formLayout
std::optional< MeanConfig > m_meanConfig
Describes properties of a double value which are necessary to allow GUI representation,...
SpinBox for DoubleDescriptors, supporting units.
Definition: DoubleSpinBox.h:22
Describes properties of a uint value which are necessary to allow GUI representation,...
Distributions
Which distributions should be available in the selector.
Definition: ID.h:24
configuration to control how the user can enter a mean value
bool scientific
whether to use a scientific number notation