manipulatedCameraFrame.h
1 /****************************************************************************
2 
3  Copyright (C) 2002-2013 Gilles Debunne. All rights reserved.
4 
5  This file is part of the QGLViewer library version 2.5.2.
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_CAMERA_FRAME_H
24 #define QGLVIEWER_MANIPULATED_CAMERA_FRAME_H
25 
26 #include "manipulatedFrame.h"
27 
28 namespace qglviewer {
47 class QGLVIEWER_EXPORT ManipulatedCameraFrame : public ManipulatedFrame
48 {
49 #ifndef DOXYGEN
50  friend class Camera;
51  friend class ::QGLViewer;
52 #endif
53 
54  Q_OBJECT
55 
56 public:
60 
62  ManipulatedCameraFrame& operator=(const ManipulatedCameraFrame& mcf);
63 
66 public:
75  Vec pivotPoint() const { return pivotPoint_; }
77  void setPivotPoint(const Vec& point) { pivotPoint_ = point; }
78 
79 #ifndef DOXYGEN
80  Vec revolveAroundPoint() const { qWarning("revolveAroundPoint() is deprecated, use pivotPoint() instead"); return pivotPoint(); }
81  void setRevolveArountPoint(const Vec& point) { qWarning("setRevolveAroundPoint() is deprecated, use setPivotPoint() instead"); setPivotPoint(point); }
82 #endif
83 
84 
87 public:
106  bool rotatesAroundUpVector() const { return rotatesAroundUpVector_; }
110  void setRotatesAroundUpVector(bool constrained) { rotatesAroundUpVector_ = constrained; }
111 
120  bool zoomsOnPivotPoint() const { return zoomsOnPivotPoint_; }
124  void setZoomsOnPivotPoint(bool enabled) { zoomsOnPivotPoint_ = enabled; }
125 
126 private:
127 #ifndef DOXYGEN
128  void zoom(float delta, const Camera * const camera);
129 #endif
130 
131 
134 public Q_SLOTS:
139  void setFlySpeed(float speed) { flySpeed_ = speed; }
140 
145  void setSceneUpVector(const Vec& up) { sceneUpVector_ = up; }
146 
147 public:
156  float flySpeed() const { return flySpeed_; }
157 
171  Vec sceneUpVector() const { return sceneUpVector_; }
172 
173 #ifndef DOXYGEN
174  Vec flyUpVector() const;
175  void setFlyUpVector(const Vec& up);
176 #endif
177 
178 
181 protected:
182  virtual void mouseReleaseEvent(QMouseEvent* const event, Camera* const camera);
183  virtual void mouseMoveEvent (QMouseEvent* const event, Camera* const camera);
184  virtual void wheelEvent (QWheelEvent* const event, Camera* const camera);
186 
189 protected Q_SLOTS:
190  virtual void spin();
192 
195 public:
196  virtual QDomElement domElement(const QString& name, QDomDocument& document) const;
197 public Q_SLOTS:
198  virtual void initFromDOMElement(const QDomElement& element);
200 
201 #ifndef DOXYGEN
202 protected:
203  virtual void startAction(int ma, bool withConstraint=true); // int is really a QGLViewer::MouseAction
204 #endif
205 
206 private Q_SLOTS:
207  virtual void flyUpdate();
208 
209 private:
210  void updateSceneUpVector();
211  Quaternion turnQuaternion(int x, const Camera* const camera);
212  Quaternion pitchYawQuaternion(int x, int y, const Camera* const camera);
213 
214 private:
215  // Fly mode data
216  float flySpeed_;
217  float driveSpeed_;
218  Vec sceneUpVector_;
219  QTimer flyTimer_;
220 
221  bool rotatesAroundUpVector_;
222  // Inverse the direction of an horizontal mouse motion. Depends on the projected
223  // screen orientation of the vertical axis when the mouse button is pressed.
224  bool constrainedRotationIsReversed_;
225 
226  bool zoomsOnPivotPoint_;
227 
228  Vec pivotPoint_;
229 };
230 
231 } // namespace qglviewer
232 
233 #endif // QGLVIEWER_MANIPULATED_CAMERA_FRAME_H
The ManipulatedCameraFrame class represents a ManipulatedFrame with Camera specific mouse bindings...
A ManipulatedFrame is a Frame that can be rotated and translated using the mouse. ...
float flySpeed() const
Returns the fly speed, expressed in OpenGL units.
bool rotatesAroundUpVector() const
Returns true when the frame's rotation is constrained around the sceneUpVector(), and false otherwise...
Vec pivotPoint() const
Returns the point the ManipulatedCameraFrame pivot point, around which the camera rotates...
void setRotatesAroundUpVector(bool constrained)
Sets the value of rotatesAroundUpVector().
The Vec class represents 3D positions and 3D vectors.
Definition: vec.h:65
void setFlySpeed(float speed)
Sets the flySpeed(), defined in OpenGL units.
A perspective or orthographic camera.
Definition: camera.h:84
The Quaternion class represents 3D rotations and orientations.
Definition: quaternion.h:66
virtual ~ManipulatedCameraFrame()
Virtual destructor.
void setPivotPoint(const Vec &point)
Sets the pivotPoint(), defined in the world coordinate system.
void setZoomsOnPivotPoint(bool enabled)
Sets the value of zoomsOnPivotPoint().
Vec sceneUpVector() const
Returns the up vector of the scene, expressed in the world coordinate system.
bool zoomsOnPivotPoint() const
Returns whether or not the QGLViewer::ZOOM action zooms on the pivot point.
void setSceneUpVector(const Vec &up)
Sets the sceneUpVector(), defined in the world coordinate system.