BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
ParameterTuningDelegate.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/coregui/Views/JobWidgets/ParameterTuningDelegate.h
6 //! @brief Defines class ParameterTuningDelegate
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_COREGUI_VIEWS_JOBWIDGETS_PARAMETERTUNINGDELEGATE_H
16 #define BORNAGAIN_GUI_COREGUI_VIEWS_JOBWIDGETS_PARAMETERTUNINGDELEGATE_H
17 
18 #include "Fit/Param/RealLimits.h"
19 #include <QItemDelegate>
20 #include <memory>
21 
22 class QDoubleSpinBox;
23 class QHBoxLayout;
24 class ParameterItem;
25 class ScientificSpinBox;
26 class SessionItem;
27 
28 class ParameterTuningDelegate : public QItemDelegate {
29  Q_OBJECT
30 
31 public:
32  class TuningData {
33  public:
34  TuningData();
35  void setRangeFactor(double range_factor);
36  void setItemLimits(const RealLimits& item_limits);
37  int value_to_slider(double value);
38  double slider_to_value(int slider);
39  double step() const;
40  int m_smin;
41  int m_smax;
42  double m_rmin;
43  double m_rmax;
46  };
47 
48  ParameterTuningDelegate(QObject* parent = 0);
50 
51  QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& /* index */) const
52  {
53  return QSize(option.rect.width(), 25);
54  }
55 
56  void paint(QPainter* painter, const QStyleOptionViewItem& option,
57  const QModelIndex& index) const;
58  QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option,
59  const QModelIndex& index) const;
60  void setEditorData(QWidget* editor, const QModelIndex& index) const;
61  void setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const;
62  void setSliderRangeFactor(double value);
63 
64  void setValueColumn(int valueColumn) { m_valueColumn = valueColumn; }
65 
66  void setReadOnly(bool isReadOnly);
67 
68 signals:
70 
71 private slots:
72  void sliderValueChanged(int position);
73  void editorValueChanged(double value);
74 
75 private:
76  void updateSlider(double value) const;
77  void emitSignals(double value);
78 
80  mutable QSlider* m_slider;
82  mutable QWidget* m_contentWidget;
83  mutable QHBoxLayout* m_contentLayout;
87 };
88 
89 #endif // BORNAGAIN_GUI_COREGUI_VIEWS_JOBWIDGETS_PARAMETERTUNINGDELEGATE_H
Defines class RealLimits.
The ParameterItem class represent a tuning value in a parameter tuning tree.
void setItemLimits(const RealLimits &item_limits)
void setReadOnly(bool isReadOnly)
void setValueColumn(int valueColumn)
void setEditorData(QWidget *editor, const QModelIndex &index) const
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
void setSliderRangeFactor(double value)
void updateSlider(double value) const
ScientificSpinBox * m_valueBox
ParameterTuningDelegate(QObject *parent=0)
QWidget * createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const
void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const
void currentLinkChanged(SessionItem *item)
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &) const
Limits for a real fit parameter.
Definition: RealLimits.h:24