manipulatedFrame.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_MANIPULATED_FRAME_H
24 #define QGLVIEWER_MANIPULATED_FRAME_H
25 
26 #include "frame.h"
27 #include "mouseGrabber.h"
28 #include "qglviewer.h"
29 
30 #include <QString>
31 #include <QTimer>
32 #include <QDateTime>
33 
34 namespace qglviewer {
96 {
97 #ifndef DOXYGEN
98  friend class Camera;
99  friend class ::QGLViewer;
100 #endif
101 
102  Q_OBJECT
103 
104 public:
107  virtual ~ManipulatedFrame() {}
108 
110  ManipulatedFrame& operator=(const ManipulatedFrame& mf);
111 
112 Q_SIGNALS:
124  void manipulated();
125 
136  void spun();
137 
140 public Q_SLOTS:
142  void setRotationSensitivity(qreal sensitivity) { rotationSensitivity_ = sensitivity; }
144  void setTranslationSensitivity(qreal sensitivity) { translationSensitivity_ = sensitivity; }
146  void setSpinningSensitivity(qreal sensitivity) { spinningSensitivity_ = sensitivity; }
148  void setWheelSensitivity(qreal sensitivity) { wheelSensitivity_ = sensitivity; }
150  void setZoomSensitivity(qreal sensitivity) { zoomSensitivity_ = sensitivity; }
151 
152 public:
161  qreal rotationSensitivity() const { return rotationSensitivity_; }
180  qreal translationSensitivity() const { return translationSensitivity_; }
192  qreal spinningSensitivity() const { return spinningSensitivity_; }
193 
201  qreal zoomSensitivity() const { return zoomSensitivity_; }
209  qreal wheelSensitivity() const { return wheelSensitivity_; }
211 
212 
215 public:
222  bool isSpinning() const { return isSpinning_; }
231  Quaternion spinningQuaternion() const { return spinningQuaternion_; }
232 public Q_SLOTS:
235  void setSpinningQuaternion(const Quaternion& spinningQuaternion) { spinningQuaternion_ = spinningQuaternion; }
236  virtual void startSpinning(int updateInterval);
239  virtual void stopSpinning() { spinningTimer_.stop(); isSpinning_ = false; }
240 protected Q_SLOTS:
241  virtual void spin();
242 private Q_SLOTS:
243  void spinUpdate();
245 
248 protected:
249  virtual void mousePressEvent (QMouseEvent* const event, Camera* const camera);
250  virtual void mouseMoveEvent (QMouseEvent* const event, Camera* const camera);
251  virtual void mouseReleaseEvent (QMouseEvent* const event, Camera* const camera);
252  virtual void mouseDoubleClickEvent(QMouseEvent* const event, Camera* const camera);
253  virtual void wheelEvent (QWheelEvent* const event, Camera* const camera);
255 
256 public:
259  bool isManipulated() const;
268  QGLViewer::MouseAction currentMouseAction() const { return action_; }
270 
273 public:
274  virtual void checkIfGrabsMouse(int x, int y, const Camera* const camera);
276 
279 public:
280  virtual QDomElement domElement(const QString& name, QDomDocument& document) const;
281 public Q_SLOTS:
282  virtual void initFromDOMElement(const QDomElement& element);
284 
285 #ifndef DOXYGEN
286 protected:
287  Quaternion deformedBallQuaternion(int x, int y, qreal cx, qreal cy, const Camera* const camera);
288 
290  Constraint* previousConstraint_; // When manipulation is without Contraint.
291 
292  virtual void startAction(int ma, bool withConstraint=true); // int is really a QGLViewer::MouseAction
293  void computeMouseSpeed(const QMouseEvent* const e);
294  int mouseOriginalDirection(const QMouseEvent* const e);
295 
298  qreal deltaWithPrevPos(QMouseEvent* const event, Camera* const camera) const;
300  qreal wheelDelta(const QWheelEvent* event) const;
301 
302  // Previous mouse position (used for incremental updates) and mouse press position.
303  QPoint prevPos_, pressPos_;
304 
305 private:
306  void zoom(qreal delta, const Camera * const camera);
307 
308 #endif // DOXYGEN
309 
310 private:
311  // Sensitivity
317 
318  // Mouse speed and spinning
320  qreal mouseSpeed_;
321  int delay_;
325 
326  // Whether the SCREEN_TRANS direction (horizontal or vertical) is fixed or not.
328 
329  // MouseGrabber
331 };
332 
333 } // namespace qglviewer
334 
335 #endif // QGLVIEWER_MANIPULATED_FRAME_H
A ManipulatedFrame is a Frame that can be rotated and translated using the mouse. ...
QGLViewer::MouseAction currentMouseAction() const
void setZoomSensitivity(qreal sensitivity)
void setRotationSensitivity(qreal sensitivity)
void setWheelSensitivity(qreal sensitivity)
void setSpinningSensitivity(qreal sensitivity)
Abstract class for objects that grab mouse focus in a QGLViewer.
Definition: mouseGrabber.h:130
#define QGLVIEWER_EXPORT
void setSpinningQuaternion(const Quaternion &spinningQuaternion)
QGLViewer::MouseAction action_
A perspective or orthographic camera.
Definition: camera.h:84
qreal translationSensitivity() const
The Quaternion class represents 3D rotations and orientations.
Definition: quaternion.h:66
The Frame class represents a coordinate system, defined by a position and an orientation.
Definition: frame.h:121
Quaternion spinningQuaternion() const
An interface class for Frame constraints.
Definition: constraint.h:117
void setTranslationSensitivity(qreal sensitivity)


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