1
/***************************************************************************
2
* Copyright (c) 2005 Werner Mayer <werner.wm.mayer@gmx.de> *
4
* This file is part of the FreeCAD CAx development system. *
6
* This library is free software; you can redistribute it and/or *
7
* modify it under the terms of the GNU Library General Public *
8
* License as published by the Free Software Foundation; either *
9
* version 2 of the License, or (at your option) any later version. *
11
* This library is distributed in the hope that it will be useful, *
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14
* GNU Library General Public License for more details. *
16
* You should have received a copy of the GNU Library General Public *
17
* License along with this library; see the file COPYING.LIB. If not, *
18
* write to the Free Software Foundation, Inc., 59 Temple Place, *
19
* Suite 330, Boston, MA 02111-1307, USA *
21
***************************************************************************/
32
#include <Inventor/SbLinear.h>
33
#include <Inventor/SbVec2f.h>
42
class SbViewportRegion;
43
class SoMouseButtonEvent;
44
class SoLocation2Event;
45
class SoKeyboardEvent;
48
class View3DInventorViewer;
51
* The mouse model base class
52
* In derived classes you must implement the methods @ref initialize() and @ref terminate()
53
* For all drawing stuff you just have to reimplement the @ref draw() method.
54
* In general you need not to do anything else.
55
* \author Werner Mayer and J�rgen Riegel
57
class GuiExport AbstractMouseModel
60
enum { Continue=0, Restart=1, Finish=2, Cancel=3 };
63
virtual ~AbstractMouseModel(void){}
64
/// implement this in derived classes
65
virtual void initialize() = 0;
66
/// implement this in derived classes
67
virtual void terminate () = 0;
68
void grabMouseModel(Gui::View3DInventorViewer*);
69
void releaseMouseModel(void);
70
const std::vector<SbVec2f>& getPolygon() const { return _clPoly; }
71
SbBool isInner() const { return m_bInner; }
75
/** @name Mouse events*/
77
int handleEvent(const SoEvent * const ev, const SbViewportRegion& vp);
81
virtual int mouseButtonEvent( const SoMouseButtonEvent * const e, const QPoint& pos ){ return 0; };
82
virtual int locationEvent ( const SoLocation2Event * const e, const QPoint& pos ){ return 0; };
83
virtual int keyboardEvent ( const SoKeyboardEvent * const e ) { return 0; };
86
virtual void draw (){};
89
Gui::View3DInventorViewer*_pcView3D;
90
QCursor m_cPrevCursor;
97
std::vector<SbVec2f> _clPoly;
100
// -----------------------------------------------------------------------------------
103
* The standard model class
104
* \author J�rgen Riegel
106
class GuiExport BaseMouseModel : public AbstractMouseModel
110
virtual ~BaseMouseModel(){}
113
// -----------------------------------------------------------------------------------
116
* The poly picker mouse model class
118
* \author Werner Mayer
120
class GuiExport PolyPickerMouseModel : public BaseMouseModel
123
PolyPickerMouseModel();
124
virtual ~PolyPickerMouseModel();
126
/// set the new mouse cursor
127
virtual void initialize();
129
virtual void terminate();
132
virtual int mouseButtonEvent( const SoMouseButtonEvent * const e, const QPoint& pos );
133
virtual int locationEvent ( const SoLocation2Event * const e, const QPoint& pos );
134
virtual int keyboardEvent ( const SoKeyboardEvent * const e );
137
virtual void draw ();
138
virtual int popupMenu();
141
std::vector<QPoint> _cNodeVector;
142
int m_iRadius, m_iNodes;
146
// -----------------------------------------------------------------------------------
149
* The poly clip mouse model class
151
* \author Werner Mayer
153
class GuiExport PolyClipMouseModel : public PolyPickerMouseModel
156
PolyClipMouseModel();
157
virtual ~PolyClipMouseModel();
160
virtual int popupMenu();
163
// -----------------------------------------------------------------------------------
166
* The selection mouse model class
167
* Draws a rectangle for selection
168
* \author Werner Mayer
170
class GuiExport SelectionMouseModel : public BaseMouseModel
173
SelectionMouseModel();
174
virtual ~SelectionMouseModel();
177
virtual void initialize();
179
virtual void terminate();
182
virtual int mouseButtonEvent( const SoMouseButtonEvent * const e, const QPoint& pos );
183
virtual int locationEvent ( const SoLocation2Event * const e, const QPoint& pos );
184
virtual int keyboardEvent ( const SoKeyboardEvent * const e );
186
/// draw the rectangle
187
virtual void draw ();
193
// -----------------------------------------------------------------------------------
196
* The box zoom mouse model class
197
* Draws a rectangle for box zooming
198
* \author Werner Mayer
200
class GuiExport BoxZoomMouseModel : public SelectionMouseModel
204
~BoxZoomMouseModel();
210
#endif // MOUSEMODEL_H