Salome HOME
Issue #218 Disable stratch is expandable object is in the panel
[modules/shaper.git] / src / XGUI / XGUI_RubberBand.h
1 #ifndef XGUI_RubberBand_H
2 #define XGUI_RubberBand_H
3
4 #include "XGUI.h"
5 #include <QWidget>
6
7 /*!
8  \class XGUI_AbstractRubberBand
9  \ingroup GUI
10  \brief Analog of class QRubberBand with possibility of creation non-rectangular contour for selection.
11  
12  Currently this class does not support Style functionality in full.
13  */
14 class XGUI_EXPORT XGUI_AbstractRubberBand : public QWidget
15 {
16 Q_OBJECT
17  protected:
18   XGUI_AbstractRubberBand(QWidget*);
19
20  public:
21   virtual ~XGUI_AbstractRubberBand();
22
23   virtual void clearGeometry();
24
25   bool isClosed();
26
27  protected:
28   virtual void paintEvent(QPaintEvent*);
29   virtual void showEvent(QShowEvent*);
30   virtual void moveEvent(QMoveEvent*);
31   virtual void resizeEvent(QResizeEvent*);
32
33   virtual bool eventFilter(QObject*, QEvent*);
34
35   virtual void updateMask();
36
37  protected:
38   QPolygon myPoints;
39
40   bool myIsClosed;
41 };
42
43 /*!
44  \class XGUI_RectRubberBand
45  \ingroup GUI
46  \brief Analog of class QRubberBand with possibility of creation non-rectangular contour for selection.
47  
48  Redefinition for rectangular rubber band
49  */
50 class XGUI_RectRubberBand : public XGUI_AbstractRubberBand
51 {
52 Q_OBJECT
53
54  public:
55   XGUI_RectRubberBand(QWidget*);
56   virtual ~XGUI_RectRubberBand();
57
58   void initGeometry(const QRect&);
59   void setStartPoint(const QPoint&);
60   void setEndPoint(const QPoint&);
61
62   virtual void clearGeometry();
63 };
64
65 class XGUI_PolyRubberBand : public XGUI_AbstractRubberBand
66 {
67 Q_OBJECT
68
69  public:
70   XGUI_PolyRubberBand(QWidget*);
71   virtual ~XGUI_PolyRubberBand();
72
73   void initGeometry(const QPolygon&);
74   void initGeometry(const QPoint&);
75
76   void addNode(const QPoint&);
77   void replaceLastNode(const QPoint&);
78   void removeLastNode();
79
80   void setClosed(bool);
81 };
82
83 #endif