1 // Copyright (C) 2007-2023 CEA, EDF, OPEN CASCADE
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #ifndef OCCVIEWER_VIEWSKETCHER_H
21 #define OCCVIEWER_VIEWSKETCHER_H
23 #include "OCCViewer.h"
29 class OCCViewer_ViewWindow;
34 class QtxRectRubberBand;
35 class QtxPolyRubberBand;
36 class QtxCircleRubberBand;
39 #pragma warning ( disable:4251 )
43 \class OCCViewer_ViewSketcher
46 class OCCVIEWER_EXPORT OCCViewer_ViewSketcher : public QObject
51 enum { Neutral, Accept, Reject };
54 OCCViewer_ViewSketcher( OCCViewer_ViewWindow*, int );
55 virtual ~OCCViewer_ViewSketcher();
60 int buttonState() const;
61 bool isHasShift() const;
68 void setSketchButton( int );
70 virtual bool isDefault() const;
71 virtual bool eventFilter( QObject*, QEvent* );
73 virtual void setSketcherMode(int) {}
74 virtual int sketcherMode() const { return 0; }
77 void onDrawViewPort();
80 enum SketchState { Debut, EnTrain, Fin };
81 virtual bool onKey( QKeyEvent* );
82 virtual void onMouse( QMouseEvent* );
83 virtual void onSketch( SketchState ) = 0;
84 virtual void onActivate();
85 virtual void onDeactivate();
89 OCCViewer_ViewWindow* mypViewWindow;
93 QCursor mySavedCursor;
94 QPoint myStart, myCurr;
100 \class OCCViewer_RectSketcher
103 class OCCVIEWER_EXPORT OCCViewer_RectSketcher : public OCCViewer_ViewSketcher
106 OCCViewer_RectSketcher( OCCViewer_ViewWindow*, int );
107 virtual ~OCCViewer_RectSketcher();
110 virtual bool onKey( QKeyEvent* );
111 virtual void onMouse( QMouseEvent* );
112 virtual void onSketch( SketchState );
113 virtual void onActivate();
114 virtual void onDeactivate();
116 QtxRectRubberBand* mypRectRB;
120 \class OCCViewer_PolygonSketcher
123 class OCCVIEWER_EXPORT OCCViewer_PolygonSketcher : public OCCViewer_ViewSketcher
126 enum SketchMode { Poligone, Circle };
128 OCCViewer_PolygonSketcher( OCCViewer_ViewWindow*, int );
129 virtual ~OCCViewer_PolygonSketcher();
131 virtual void setSketcherMode(int theMode);
132 virtual int sketcherMode() const {
137 virtual bool onKey( QKeyEvent* );
138 virtual void onMouse( QMouseEvent* );
139 virtual void onSketch( SketchState );
140 virtual void onActivate();
141 virtual void onDeactivate();
144 bool isValid( const QPolygon*, const QPoint& ) const;
145 bool isIntersect( const QPoint&, const QPoint&,
146 const QPoint&, const QPoint& ) const;
155 QtxPolyRubberBand* mypPolyRB;
156 QtxCircleRubberBand* mypCircleRB;
162 #pragma warning( default:4251 )