BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
RealSpaceCanvas.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/coregui/Views/RealSpaceWidgets/RealSpaceCanvas.h
6 //! @brief Defines class RealSpaceCanvas
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_REALSPACEWIDGETS_REALSPACECANVAS_H
16 #define BORNAGAIN_GUI_COREGUI_VIEWS_REALSPACEWIDGETS_REALSPACECANVAS_H
17 
18 #include <QItemSelectionModel>
19 #include <QModelIndex>
20 #include <QWidget>
21 #include <memory>
22 
23 class SampleModel;
24 class RealSpaceView;
25 class RealSpaceModel;
26 class WarningSign;
27 
28 // Class for holding size and thickness information of layers
30 public:
31  SceneGeometry(double size = 100.0, double top_thickness = 25.0, double bottom_thickness = 25.0,
32  double min_thickness = 2.0)
33  {
34  l_size = size; // layer size
35  l_top_thickness = top_thickness; // top layer thickness
36  l_bottom_thickness = bottom_thickness; // bottom layer thickness
37  l_min_thickness = min_thickness; // minimum layer thickness
38  }
39 
40  double layer_size() const { return l_size; }
41  double layer_top_thickness() const { return l_top_thickness; }
42  double layer_bottom_thickness() const { return l_top_thickness; }
43  double layer_min_thickness() const { return l_min_thickness; }
44 
45  void set_layer_size(double size) { l_size = size; }
46  void set_layer_top_thickness(double top_thickness) { l_top_thickness = top_thickness; }
47  void set_layer_bottom_thickness(double bottom_thickness) { l_top_thickness = bottom_thickness; }
48 
49 private:
50  double l_size;
54 };
55 
56 //! Provides 3D object generation for RealSpaceWidget.
57 class RealSpaceCanvas : public QWidget {
58  Q_OBJECT
59 
60 public:
61  RealSpaceCanvas(QWidget* parent = nullptr);
63 
64  void setModel(SampleModel* sampleModel = nullptr,
65  QItemSelectionModel* selectionModel = nullptr);
66 
67 public slots:
68  void onSelectionChanged(const QItemSelection&, const QItemSelection&);
69  void updateToSelection();
70 
71  void onDefaultViewAction();
72  void onSideViewAction();
73  void onTopViewAction();
74  void onLockViewAction(bool view_locked);
75  void onChangeLayerSizeAction(double layer_size_scale);
76  void onSavePictureAction();
77  void onRowsAboutToBeRemoved(const QModelIndex& parent, int first, int last);
78 
79 private slots:
80  void onDataChanged(const QModelIndex& index);
81  void updateScene();
82  void resetScene();
83 
84  void defaultView();
85  void sideView();
86  void topView();
87 
88 private:
89  void setConnected(SampleModel* model, bool makeConnected);
90 
92  QModelIndex m_currentSelection;
94  std::unique_ptr<RealSpaceModel> m_realSpaceModel;
95  QItemSelectionModel* m_selectionModel;
97  std::unique_ptr<SceneGeometry> m_sceneGeometry;
99  void savePicture(const QPixmap& pixmap);
100 };
101 
102 #endif // BORNAGAIN_GUI_COREGUI_VIEWS_REALSPACEWIDGETS_REALSPACECANVAS_H
Provides 3D object generation for RealSpaceWidget.
QItemSelectionModel * m_selectionModel
void onSelectionChanged(const QItemSelection &, const QItemSelection &)
std::unique_ptr< RealSpaceModel > m_realSpaceModel
QModelIndex m_currentSelection
void setModel(SampleModel *sampleModel=nullptr, QItemSelectionModel *selectionModel=nullptr)
void onLockViewAction(bool view_locked)
WarningSign * m_warningSign
void onDataChanged(const QModelIndex &index)
std::unique_ptr< SceneGeometry > m_sceneGeometry
void onChangeLayerSizeAction(double layer_size_scale)
RealSpaceView * m_view
RealSpaceCanvas(QWidget *parent=nullptr)
void onRowsAboutToBeRemoved(const QModelIndex &parent, int first, int last)
SampleModel * m_sampleModel
void savePicture(const QPixmap &pixmap)
void setConnected(SampleModel *model, bool makeConnected)
Contains 3D view.
Definition: RealSpaceView.h:29
Main model to hold sample items.
Definition: SampleModel.h:24
void set_layer_top_thickness(double top_thickness)
double l_bottom_thickness
double layer_top_thickness() const
double l_min_thickness
SceneGeometry(double size=100.0, double top_thickness=25.0, double bottom_thickness=25.0, double min_thickness=2.0)
double layer_min_thickness() const
double layer_bottom_thickness() const
void set_layer_bottom_thickness(double bottom_thickness)
void set_layer_size(double size)
double l_top_thickness
double layer_size() const
The WarningSign controls appearance of WarningSignWidget on top of parent widget.
Definition: WarningSign.h:25