BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
MaskEditorPropertyPanel.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/View/Mask/MaskEditorPropertyPanel.h
6 //! @brief Defines class MaskEditorPropertyPanel
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_MASK_MASKEDITORPROPERTYPANEL_H
16 #define BORNAGAIN_GUI_VIEW_MASK_MASKEDITORPROPERTYPANEL_H
17 
19 #include <QModelIndex>
20 #include <QWidget>
21 #include <functional>
22 
23 using std::function;
24 
25 class QListView;
26 class SessionModel;
27 class QItemSelection;
28 class QItemSelectionModel;
29 class IntensityDataItem;
31 class QFormLayout;
32 class DoubleDescriptor;
33 class MaskItem;
34 
35 //! Tool widget for MaskEditor
36 
37 class MaskEditorPropertyPanel : public QWidget {
38  Q_OBJECT
39 public:
40  MaskEditorPropertyPanel(QWidget* parent = nullptr);
41 
42  QSize sizeHint() const override;
43  QSize minimumSizeHint() const override;
44 
45  void setMaskContext(SessionModel* model, const QModelIndex& maskContainerIndex,
46  IntensityDataItem* intensityItem);
47 
48  void resetContext();
49  void setPanelHidden(bool hidden);
50  QItemSelectionModel* selectionModel();
51 
52 signals:
53  void itemContextMenuRequest(const QPoint& point);
54 
55 private slots:
56  void onSelectionChanged(const QItemSelection& selected, const QItemSelection&);
57  void onCustomContextMenuRequested(const QPoint& point);
58 
59 private:
60  //! Set the current mask and creates the UI to edit the mask's properties
61  void setCurrentMaskItem(MaskItem* maskItem);
62 
63  //! Add a spinbox to edit a mask's double value
65 
66  //! Add a checkbox to edit a mask's boolean value
67  void addMaskCheckBox(const QString& title, function<bool()> getter,
68  function<void(bool)> setter);
69 
70  //! Return the mask item for the given index. nullptr if index invalid or not pointing to a mask
71  //! item.
72  MaskItem* maskItemForIndex(const QModelIndex& index);
73 
74  //! Creates the UI to edit the current mask's properties
75  void createMaskEditorUI();
76 
77 private:
78  QListView* m_listView;
81  QModelIndex m_rootIndex;
83  QFormLayout* m_maskPropertiesLayout;
84  MaskItem* m_currentMaskItem; //!< the mask item whose properties shall be edited
86 };
87 
88 #endif // BORNAGAIN_GUI_VIEW_MASK_MASKEDITORPROPERTYPANEL_H
Defines class MaskEditorFlags.
Describes properties of a double value which are necessary to allow GUI representation,...
Widget to edit properties of an IntensityDataItem.
Tool widget for MaskEditor.
void addMaskSpinBox(DoubleDescriptor d)
Add a spinbox to edit a mask's double value.
void setPanelHidden(bool hidden)
Show/Hide panel. When panel is hidden, all property editors are disabled.
IntensityDataPropertyWidget * m_plotPropertyEditor
void onSelectionChanged(const QItemSelection &selected, const QItemSelection &)
QSize minimumSizeHint() const override
void addMaskCheckBox(const QString &title, function< bool()> getter, function< void(bool)> setter)
Add a checkbox to edit a mask's boolean value.
void itemContextMenuRequest(const QPoint &point)
IntensityDataItem * m_intensityDataItem
void setMaskContext(SessionModel *model, const QModelIndex &maskContainerIndex, IntensityDataItem *intensityItem)
void onCustomContextMenuRequested(const QPoint &point)
MaskItem * m_currentMaskItem
the mask item whose properties shall be edited
QItemSelectionModel * selectionModel()
QSize sizeHint() const override
void createMaskEditorUI()
Creates the UI to edit the current mask's properties.
MaskEditorPropertyPanel(QWidget *parent=nullptr)
MaskItem * maskItemForIndex(const QModelIndex &index)
Return the mask item for the given index. nullptr if index invalid or not pointing to a mask item.
void setCurrentMaskItem(MaskItem *maskItem)
Set the current mask and creates the UI to edit the mask's properties.
A base class for all mask items.
Definition: MaskItems.h:27
Base class for a GUI data collection. A collection is e.g. all real data (RealDataModel)....
Definition: SessionModel.h:42