BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
MaskGraphicsView.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/View/Mask/MaskGraphicsView.h
6 //! @brief Defines class MaskGraphicsView
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_MASKGRAPHICSVIEW_H
16 #define BORNAGAIN_GUI_VIEW_MASK_MASKGRAPHICSVIEW_H
17 
19 #include <QGraphicsView>
20 
21 class QWheelEvent;
22 class MaskGraphicsProxy;
23 
24 //! Graphics view for MaskEditorCanvas
25 
26 class MaskGraphicsView : public QGraphicsView {
27  Q_OBJECT
28 public:
29  MaskGraphicsView(QGraphicsScene* scene, QWidget* parent = nullptr);
30  QSize sizeHint() const override { return QSize(512, 512); }
31  QSize minimumSizeHint() const override { return QSize(128, 128); }
32 
33 public slots:
34  void onResetViewRequest();
35 
36  void updateSize(const QSize& newSize);
37 
38 signals:
39  void changeActivityRequest(MaskEditorFlags::Activity);
41 
42 protected:
43  void wheelEvent(QWheelEvent* event) override;
44  void resizeEvent(QResizeEvent* event) override;
45  void keyPressEvent(QKeyEvent* event) override;
46  void keyReleaseEvent(QKeyEvent* event) override;
47 
48 private:
49  bool isControlButtonIsPressed(QWheelEvent* event);
50  void cancelCurrentDrawing();
51 
52  void setZoomValue(double zoom_value);
53  void decreazeZoomValue();
54  void increazeZoomValue();
55 
57 };
58 
59 #endif // BORNAGAIN_GUI_VIEW_MASK_MASKGRAPHICSVIEW_H
Defines class MaskEditorFlags.
Graphics proxy to place QWidget inside QGraphicsScene, used by MaskEditorCanvas.
Graphics view for MaskEditorCanvas.
void wheelEvent(QWheelEvent *event) override
void changeActivityRequest(MaskEditorFlags::Activity)
void setZoomValue(double zoom_value)
void updateSize(const QSize &newSize)
void resizeEvent(QResizeEvent *event) override
On resize event changes scene size and MaskGraphicsProxy so they would get the size of viewport.
bool isControlButtonIsPressed(QWheelEvent *event)
QSize minimumSizeHint() const override
MaskGraphicsView(QGraphicsScene *scene, QWidget *parent=nullptr)
void keyReleaseEvent(QKeyEvent *event) override
void deleteSelectedRequest()
void keyPressEvent(QKeyEvent *event) override
QSize sizeHint() const override
void onResetViewRequest()
Reset given view to original zoom state. Also asks graphics scene to do the same with color map.