mouseGrabber.h
Go to the documentation of this file.
1 /****************************************************************************
2 
3  Copyright (C) 2002-2014 Gilles Debunne. All rights reserved.
4 
5  This file is part of the QGLViewer library version 2.6.3.
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 #include <QEvent>
29 
30 class QGLViewer;
31 
32 namespace qglviewer {
33 class Camera;
34 
131 {
132 #ifndef DOXYGEN
133  friend class ::QGLViewer;
134 #endif
135 
136 public:
137  MouseGrabber();
139  virtual ~MouseGrabber() { MouseGrabber::MouseGrabberPool_.removeAll(this); }
140 
143 public:
174  virtual void checkIfGrabsMouse(int x, int y, const Camera* const camera) = 0;
175 
179  bool grabsMouse() const { return grabsMouse_; }
180 
181 protected:
183  void setGrabsMouse(bool grabs) { grabsMouse_ = grabs; }
185 
186 
189 public:
199  static const QList<MouseGrabber*>& MouseGrabberPool() { return MouseGrabber::MouseGrabberPool_; }
200 
206  bool isInMouseGrabberPool() const { return MouseGrabber::MouseGrabberPool_.contains(const_cast<MouseGrabber*>(this)); }
207  void addInMouseGrabberPool();
208  void removeFromMouseGrabberPool();
209  void clearMouseGrabberPool(bool autoDelete=false);
211 
212 
215 protected:
231  virtual void mousePressEvent(QMouseEvent* const event, Camera* const camera) { Q_UNUSED(event); Q_UNUSED(camera); }
235  virtual void mouseDoubleClickEvent(QMouseEvent* const event, Camera* const camera) { Q_UNUSED(event); Q_UNUSED(camera); }
237  virtual void mouseReleaseEvent(QMouseEvent* const event, Camera* const camera) { Q_UNUSED(event); Q_UNUSED(camera); }
243  virtual void mouseMoveEvent(QMouseEvent* const event, Camera* const camera) { Q_UNUSED(event); Q_UNUSED(camera); }
247  virtual void wheelEvent(QWheelEvent* const event, Camera* const camera) { Q_UNUSED(event); Q_UNUSED(camera); }
249 
250 private:
251  // Copy constructor and opertor= are declared private and undefined
252  // Prevents everyone from trying to use them
253  MouseGrabber(const MouseGrabber&);
254  MouseGrabber& operator=(const MouseGrabber&);
255 
257 
258  // Q G L V i e w e r p o o l
259  static QList<MouseGrabber*> MouseGrabberPool_;
260 };
261 
262 } // namespace qglviewer
263 
264 #endif // QGLVIEWER_MOUSE_GRABBER_H
virtual void mouseMoveEvent(QMouseEvent *const event, Camera *const camera)
Definition: mouseGrabber.h:243
static QList< MouseGrabber * > MouseGrabberPool_
Definition: mouseGrabber.h:259
bool isInMouseGrabberPool() const
Definition: mouseGrabber.h:206
void setGrabsMouse(bool grabs)
Definition: mouseGrabber.h:183
virtual void mouseReleaseEvent(QMouseEvent *const event, Camera *const camera)
Definition: mouseGrabber.h:237
Abstract class for objects that grab mouse focus in a QGLViewer.
Definition: mouseGrabber.h:130
bool grabsMouse() const
Definition: mouseGrabber.h:179
#define QGLVIEWER_EXPORT
virtual void mouseDoubleClickEvent(QMouseEvent *const event, Camera *const camera)
Definition: mouseGrabber.h:235
A versatile 3D OpenGL viewer based on QGLWidget.
Definition: qglviewer.h:62
A perspective or orthographic camera.
Definition: camera.h:84
virtual void wheelEvent(QWheelEvent *const event, Camera *const camera)
Definition: mouseGrabber.h:247
static const QList< MouseGrabber * > & MouseGrabberPool()
Definition: mouseGrabber.h:199
virtual void mousePressEvent(QMouseEvent *const event, Camera *const camera)
Definition: mouseGrabber.h:231


octovis
Author(s): Kai M. Wurm , Armin Hornung
autogenerated on Wed Jun 5 2019 19:26:39