Version: 8.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
OCCViewer_ViewSketcher.h
Go to the documentation of this file.
1 // Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 
20 #ifndef OCCVIEWER_VIEWSKETCHER_H
21 #define OCCVIEWER_VIEWSKETCHER_H
22 
23 #include "OCCViewer.h"
24 
25 #include <QObject>
26 #include <QCursor>
27 #include <QSize>
28 
30 class QKeyEvent;
31 class QMouseEvent;
32 class QPolygon;
33 
34 class QtxRectRubberBand;
35 class QtxPolyRubberBand;
36 
37 #ifdef WIN32
38 #pragma warning ( disable:4251 )
39 #endif
40 
46 {
47  Q_OBJECT
48 
49 public:
50  enum { Neutral, Accept, Reject };
51 
52 public:
54  virtual ~OCCViewer_ViewSketcher();
55 
56 public:
57  int type() const;
58  int result() const;
59  int buttonState() const;
60  bool isHasShift() const;
61  void* data() const;
62 
63  void activate();
64  void deactivate();
65 
66  int sketchButton();
67  void setSketchButton( int );
68 
69  virtual bool isDefault() const;
70  virtual bool eventFilter( QObject*, QEvent* );
71 
72 private slots:
73  void onDrawViewPort();
74 
75 protected:
76  enum SketchState { Debut, EnTrain, Fin };
77  virtual bool onKey( QKeyEvent* );
78  virtual void onMouse( QMouseEvent* );
79  virtual void onSketch( SketchState ) = 0;
80  virtual void onActivate();
81  virtual void onDeactivate();
82 
83 protected:
86  int myType;
87  void* mypData;
88  int myResult;
89  QCursor mySavedCursor;
90  QPoint myStart, myCurr;
92  bool myHasShift;
93 };
94 
100 {
101 public:
103  virtual ~OCCViewer_RectSketcher();
104 
105 protected:
106  virtual bool onKey( QKeyEvent* );
107  virtual void onMouse( QMouseEvent* );
108  virtual void onSketch( SketchState );
109  virtual void onActivate();
110  virtual void onDeactivate();
111  private:
113 };
114 
120 {
121 public:
123  virtual ~OCCViewer_PolygonSketcher();
124 
125 protected:
126  virtual bool onKey( QKeyEvent* );
127  virtual void onMouse( QMouseEvent* );
128  virtual void onSketch( SketchState );
129  virtual void onActivate();
130  virtual void onDeactivate();
131 
132 private:
133  bool isValid( const QPolygon*, const QPoint& ) const;
134  bool isIntersect( const QPoint&, const QPoint&,
135  const QPoint&, const QPoint& ) const;
136 
137 private:
138  bool myDbl;
139  QSize myToler;
140  QPolygon* mypPoints;
143 
145 };
146 
147 #ifdef WIN32
148 #pragma warning( default:4251 )
149 #endif
150 
151 #endif