manipulatedCameraFrame.h
1 /****************************************************************************
2 
3  Copyright (C) 2002-2008 Gilles Debunne. All rights reserved.
4 
5  This file is part of the QGLViewer library version 2.3.10.
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 revolveAroundPoint() const { return revolveAroundPoint_; }
77  void setRevolveAroundPoint(const Vec& revolveAroundPoint) { revolveAroundPoint_ = revolveAroundPoint; }
79 
82  public Q_SLOTS:
87  void setFlySpeed(float speed) { flySpeed_ = speed; };
88 
93  void setFlyUpVector(const Vec& up) { flyUpVector_ = up; };
94 
95  public:
104  float flySpeed() const { return flySpeed_; };
105 
116  Vec flyUpVector() const { return flyUpVector_; };
118 
121  protected:
122  virtual void mouseReleaseEvent(QMouseEvent* const event, Camera* const camera);
123  virtual void mouseMoveEvent (QMouseEvent* const event, Camera* const camera);
124  virtual void wheelEvent (QWheelEvent* const event, Camera* const camera);
126 
129  protected Q_SLOTS:
130  virtual void spin();
132 
135  public:
136  virtual QDomElement domElement(const QString& name, QDomDocument& document) const;
137  public Q_SLOTS:
138  virtual void initFromDOMElement(const QDomElement& element);
140 
141 #ifndef DOXYGEN
142  protected:
143  virtual void startAction(int ma, bool withConstraint=true); // int is really a QGLViewer::MouseAction
144 #endif
145 
146  private Q_SLOTS:
147  virtual void flyUpdate();
148 
149  private:
150  void updateFlyUpVector();
151  Quaternion turnQuaternion(int x, const Camera* const camera);
152  Quaternion pitchYawQuaternion(int x, int y, const Camera* const camera);
153 
154  private:
155  // Fly mode data
156  float flySpeed_;
157  float driveSpeed_;
158  Vec flyUpVector_;
159  QTimer flyTimer_;
160 
161  Vec revolveAroundPoint_;
162  };
163 
164 } // namespace qglviewer
165 
166 #endif // QGLVIEWER_MANIPULATED_CAMERA_FRAME_H