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