mouseGrabber.h
Go to the documentation of this file.
1 /****************************************************************************
2 
3  Copyright (C) 2002-2013 Gilles Debunne. All rights reserved.
4 
5  This file is part of the QGLViewer library version 2.4.0.
6 
7  http://www.libqglviewer.com - contact@libqglviewer.com
8 
9  This file may be used under the terms of the GNU General Public License
10  versions 2.0 or 3.0 as published by the Free Software Foundation and
11  appearing in the LICENSE file included in the packaging of this file.
12  In addition, as a special exception, Gilles Debunne gives you certain
13  additional rights, described in the file GPL_EXCEPTION in this package.
14 
15  libQGLViewer uses dual licensing. Commercial/proprietary software must
16  purchase a libQGLViewer Commercial License.
17 
18  This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
19  WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
20 
21 *****************************************************************************/
22 
23 #ifndef QGLVIEWER_MOUSE_GRABBER_H
24 #define QGLVIEWER_MOUSE_GRABBER_H
25 
26 #include "config.h"
27 
28 #if QT_VERSION >= 0x040000
29 # include <QEvent>
30 #else
31 # include <qevent.h>
32 #endif
33 
34 class QGLViewer;
35 
36 namespace qglviewer {
37  class Camera;
38 
135  {
136 #ifndef DOXYGEN
137  friend class ::QGLViewer;
138 #endif
139 
140  public:
141  MouseGrabber();
143 #if QT_VERSION >= 0x040000
144  virtual ~MouseGrabber() { MouseGrabber::MouseGrabberPool_.removeAll(this); };
145 #else
146  virtual ~MouseGrabber() { MouseGrabber::MouseGrabberPool_.removeRef(this); };
147 #endif
148 
151  public:
182  virtual void checkIfGrabsMouse(int x, int y, const Camera* const camera) = 0;
183 
187  bool grabsMouse() const { return grabsMouse_; };
188 
189  protected:
191  void setGrabsMouse(bool grabs) { grabsMouse_ = grabs; };
193 
194 
197  public:
207 #if QT_VERSION >= 0x040000
208  static const QList<MouseGrabber*>& MouseGrabberPool() { return MouseGrabber::MouseGrabberPool_; };
209 #else
210 # if QT_VERSION >= 0x030000
211  static const QPtrList<MouseGrabber>& MouseGrabberPool() { return MouseGrabber::MouseGrabberPool_; };
212 # else
213  static const QList<MouseGrabber>& MouseGrabberPool() { return MouseGrabber::MouseGrabberPool_; };
214 # endif
215 #endif
216 
222 #if QT_VERSION >= 0x040000
223  bool isInMouseGrabberPool() const { return MouseGrabber::MouseGrabberPool_.contains(const_cast<MouseGrabber*>(this)); };
224 #else
225  bool isInMouseGrabberPool() const { return MouseGrabber::MouseGrabberPool_.findRef(this) != -1; };
226 #endif
227  void addInMouseGrabberPool();
228  void removeFromMouseGrabberPool();
229  void clearMouseGrabberPool(bool autoDelete=false);
231 
232 
235  protected:
251  virtual void mousePressEvent(QMouseEvent* const event, Camera* const camera) { Q_UNUSED(event) Q_UNUSED(camera) };
255  virtual void mouseDoubleClickEvent(QMouseEvent* const event, Camera* const camera) { Q_UNUSED(event) Q_UNUSED(camera) };
257  virtual void mouseReleaseEvent(QMouseEvent* const event, Camera* const camera) { Q_UNUSED(event) Q_UNUSED(camera) };
263  virtual void mouseMoveEvent(QMouseEvent* const event, Camera* const camera) { Q_UNUSED(event) Q_UNUSED(camera) };
267  virtual void wheelEvent(QWheelEvent* const event, Camera* const camera) { Q_UNUSED(event) Q_UNUSED(camera) };
269 
270  private:
271  // Copy constructor and opertor= are declared private and undefined
272  // Prevents everyone from trying to use them
273  MouseGrabber(const MouseGrabber&);
274  MouseGrabber& operator=(const MouseGrabber&);
275 
277 
278  // Q G L V i e w e r p o o l
279 #if QT_VERSION >= 0x040000
280  static QList<MouseGrabber*> MouseGrabberPool_;
281 #else
282  static QPtrList<MouseGrabber> MouseGrabberPool_;
283 #endif
284  };
285 
286 } // namespace qglviewer
287 
288 #endif // QGLVIEWER_MOUSE_GRABBER_H
virtual void mouseMoveEvent(QMouseEvent *const event, Camera *const camera)
Definition: mouseGrabber.h:263
bool isInMouseGrabberPool() const
Definition: mouseGrabber.h:225
void setGrabsMouse(bool grabs)
Definition: mouseGrabber.h:191
static QPtrList< MouseGrabber > MouseGrabberPool_
Definition: mouseGrabber.h:282
virtual void mouseReleaseEvent(QMouseEvent *const event, Camera *const camera)
Definition: mouseGrabber.h:257
Abstract class for objects that grab mouse focus in a QGLViewer.
Definition: mouseGrabber.h:134
bool grabsMouse() const
Definition: mouseGrabber.h:187
#define QGLVIEWER_EXPORT
Definition: config.h:75
virtual void mouseDoubleClickEvent(QMouseEvent *const event, Camera *const camera)
Definition: mouseGrabber.h:255
static const QList< MouseGrabber > & MouseGrabberPool()
Definition: mouseGrabber.h:213
A versatile 3D OpenGL viewer based on QGLWidget.
Definition: qglviewer.h:70
A perspective or orthographic camera.
Definition: camera.h:81
virtual void wheelEvent(QWheelEvent *const event, Camera *const camera)
Definition: mouseGrabber.h:267
virtual void mousePressEvent(QMouseEvent *const event, Camera *const camera)
Definition: mouseGrabber.h:251


octovis
Author(s): Kai M. Wurm , Armin Hornung
autogenerated on Mon Jun 10 2019 14:00:25