~ubuntu-branches/ubuntu/trusty/libqglviewer/trusty

« back to all changes in this revision

Viewing changes to QGLViewer/manipulatedCameraFrame.h

  • Committer: Package Import Robot
  • Author(s): Anton Gladky
  • Date: 2013-12-28 14:57:47 UTC
  • mfrom: (7.1.5 sid)
  • Revision ID: package-import@ubuntu.com-20131228145747-qy7hqddvex3oti0c
Tags: 2.5.0-1
* [f80a053] Imported Upstream version 2.5.0
* [c07abbe] Use wrap-and-sort.
* [89d8250] Remove google adsense-scripts.
* [4224be5] Set Standards-Versions: 3.9.5. No changes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 
3
3
 Copyright (C) 2002-2013 Gilles Debunne. All rights reserved.
4
4
 
5
 
 This file is part of the QGLViewer library version 2.4.0.
 
5
 This file is part of the QGLViewer library version 2.5.0.
6
6
 
7
7
 http://www.libqglviewer.com - contact@libqglviewer.com
8
8
 
26
26
#include "manipulatedFrame.h"
27
27
 
28
28
namespace qglviewer {
29
 
  /*! \brief The ManipulatedCameraFrame class represents a ManipulatedFrame with Camera specific mouse bindings.
 
29
/*! \brief The ManipulatedCameraFrame class represents a ManipulatedFrame with Camera specific mouse bindings.
30
30
  \class ManipulatedCameraFrame manipulatedCameraFrame.h QGLViewer/manipulatedCameraFrame.h
31
31
 
32
32
  A ManipulatedCameraFrame is a specialization of a ManipulatedFrame, designed to be set as the
44
44
  See the <a href="../mouse.html">mouse page</a> for a description of the possible actions that can
45
45
  be performed using the mouse and their bindings.
46
46
  \nosubgrouping */
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:
57
 
    ManipulatedCameraFrame();
58
 
    /*! Virtual destructor. Empty. */
59
 
    virtual ~ManipulatedCameraFrame() {};
60
 
 
61
 
    ManipulatedCameraFrame(const ManipulatedCameraFrame& mcf);
62
 
    ManipulatedCameraFrame& operator=(const ManipulatedCameraFrame& mcf);
63
 
 
64
 
    /*! @name Revolve around point */
65
 
    //@{
66
 
  public:
67
 
    /*! Returns the point the ManipulatedCameraFrame revolves around when rotated.
68
 
 
69
 
    It is defined in the world coordinate system. Default value is (0,0,0).
70
 
 
71
 
    When the ManipulatedCameraFrame is associated to a Camera, Camera::revolveAroundPoint() also
72
 
    returns this value. This point can interactively be changed using the mouse (see
73
 
    QGLViewer::RAP_FROM_PIXEL and QGLViewer::RAP_IS_CENTER in the <a href="../mouse.html">mouse
74
 
    page</a>). */
75
 
    Vec revolveAroundPoint() const { return revolveAroundPoint_; }
76
 
    /*! Sets the revolveAroundPoint(), defined in the world coordinate system. */
77
 
    void setRevolveAroundPoint(const Vec& revolveAroundPoint) { revolveAroundPoint_ = revolveAroundPoint; }
78
 
    //@}
79
 
 
80
 
    /*! @name Fly parameters */
81
 
    //@{
82
 
  public Q_SLOTS:
83
 
    /*! Sets the flySpeed(), defined in OpenGL units.
84
 
 
85
 
    Default value is 0.0, but it is modified according to the QGLViewer::sceneRadius() when the
86
 
    ManipulatedCameraFrame is set as the Camera::frame(). */
87
 
    void setFlySpeed(float speed) { flySpeed_ = speed; };
88
 
 
89
 
    /*! Sets the flyUpVector(), defined in the world coordinate system.
90
 
 
91
 
    Default value is (0,1,0), but it is updated by the Camera when set as its Camera::frame(). Use
92
 
    Camera::setUpVector() instead in that case. */
93
 
    void setFlyUpVector(const Vec& up) { flyUpVector_ = up; };
94
 
 
95
 
  public:
96
 
    /*! Returns the fly speed, expressed in OpenGL units.
97
 
 
98
 
    It corresponds to the incremental displacement that is periodically applied to the
99
 
    ManipulatedCameraFrame position when a QGLViewer::MOVE_FORWARD or QGLViewer::MOVE_BACKWARD
100
 
    QGLViewer::MouseAction is proceeded.
101
 
 
102
 
    \attention When the ManipulatedCameraFrame is set as the Camera::frame(), this value is set
103
 
    according to the QGLViewer::sceneRadius() by QGLViewer::setSceneRadius(). */
104
 
    float flySpeed() const { return flySpeed_; };
105
 
 
106
 
    /*! Returns the up vector used in fly mode, expressed in the world coordinate system.
107
 
 
108
 
    Fly mode corresponds to the QGLViewer::MOVE_FORWARD and QGLViewer::MOVE_BACKWARD
109
 
    QGLViewer::MouseAction bindings. In these modes, horizontal displacements of the mouse rotate
110
 
    the ManipulatedCameraFrame around this vector. Vertical displacements rotate always around the
111
 
    Camera \c X axis.
112
 
 
113
 
    Default value is (0,1,0), but it is updated by the Camera when set as its Camera::frame().
114
 
    Camera::setOrientation() and Camera::setUpVector()) modify this value and should be used
115
 
    instead. */
116
 
    Vec flyUpVector() const { return flyUpVector_; };
117
 
    //@}
118
 
 
119
 
    /*! @name Mouse event handlers */
120
 
    //@{
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);
125
 
    //@}
126
 
 
127
 
    /*! @name Spinning */
128
 
    //@{
129
 
  protected Q_SLOTS:
130
 
    virtual void spin();
131
 
    //@}
132
 
 
133
 
    /*! @name XML representation */
134
 
    //@{
135
 
  public:
136
 
    virtual QDomElement domElement(const QString& name, QDomDocument& document) const;
137
 
  public Q_SLOTS:
138
 
    virtual void initFromDOMElement(const QDomElement& element);
139
 
    //@}
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
 
  };
 
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:
 
57
        ManipulatedCameraFrame();
 
58
        /*! Virtual destructor. Empty. */
 
59
        virtual ~ManipulatedCameraFrame() {}
 
60
 
 
61
        ManipulatedCameraFrame(const ManipulatedCameraFrame& mcf);
 
62
        ManipulatedCameraFrame& operator=(const ManipulatedCameraFrame& mcf);
 
63
 
 
64
        /*! @name Revolve around point */
 
65
        //@{
 
66
public:
 
67
        /*! Returns the point the ManipulatedCameraFrame revolves around when rotated.
 
68
 
 
69
        It is defined in the world coordinate system. Default value is (0,0,0).
 
70
 
 
71
        When the ManipulatedCameraFrame is associated to a Camera, Camera::revolveAroundPoint() also
 
72
        returns this value. This point can interactively be changed using the mouse (see
 
73
        QGLViewer::RAP_FROM_PIXEL and QGLViewer::RAP_IS_CENTER in the <a href="../mouse.html">mouse
 
74
        page</a>). */
 
75
        Vec revolveAroundPoint() const { return revolveAroundPoint_; }
 
76
        /*! Sets the revolveAroundPoint(), defined in the world coordinate system. */
 
77
        void setRevolveAroundPoint(const Vec& revolveAroundPoint) { revolveAroundPoint_ = revolveAroundPoint; }
 
78
        //@}
 
79
 
 
80
        /*! @name Fly parameters */
 
81
        //@{
 
82
public Q_SLOTS:
 
83
        /*! Sets the flySpeed(), defined in OpenGL units.
 
84
 
 
85
        Default value is 0.0, but it is modified according to the QGLViewer::sceneRadius() when the
 
86
        ManipulatedCameraFrame is set as the Camera::frame(). */
 
87
        void setFlySpeed(float speed) { flySpeed_ = speed; }
 
88
 
 
89
        /*! Sets the flyUpVector(), defined in the world coordinate system.
 
90
 
 
91
        Default value is (0,1,0), but it is updated by the Camera when set as its Camera::frame(). Use
 
92
        Camera::setUpVector() instead in that case. */
 
93
        void setFlyUpVector(const Vec& up) { flyUpVector_ = up; }
 
94
 
 
95
public:
 
96
        /*! Returns the fly speed, expressed in OpenGL units.
 
97
 
 
98
        It corresponds to the incremental displacement that is periodically applied to the
 
99
        ManipulatedCameraFrame position when a QGLViewer::MOVE_FORWARD or QGLViewer::MOVE_BACKWARD
 
100
        QGLViewer::MouseAction is proceeded.
 
101
 
 
102
        \attention When the ManipulatedCameraFrame is set as the Camera::frame(), this value is set
 
103
        according to the QGLViewer::sceneRadius() by QGLViewer::setSceneRadius(). */
 
104
        float flySpeed() const { return flySpeed_; }
 
105
 
 
106
        /*! Returns the up vector used in fly mode, expressed in the world coordinate system.
 
107
 
 
108
        Fly mode corresponds to the QGLViewer::MOVE_FORWARD and QGLViewer::MOVE_BACKWARD
 
109
        QGLViewer::MouseAction bindings. In these modes, horizontal displacements of the mouse rotate
 
110
        the ManipulatedCameraFrame around this vector. Vertical displacements rotate always around the
 
111
        Camera \c X axis.
 
112
 
 
113
        Default value is (0,1,0), but it is updated by the Camera when set as its Camera::frame().
 
114
        Camera::setOrientation() and Camera::setUpVector()) modify this value and should be used
 
115
        instead. */
 
116
        Vec flyUpVector() const { return flyUpVector_; }
 
117
        //@}
 
118
 
 
119
        /*! @name Mouse event handlers */
 
120
        //@{
 
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);
 
125
        //@}
 
126
 
 
127
        /*! @name Spinning */
 
128
        //@{
 
129
protected Q_SLOTS:
 
130
        virtual void spin();
 
131
        //@}
 
132
 
 
133
        /*! @name XML representation */
 
134
        //@{
 
135
public:
 
136
        virtual QDomElement domElement(const QString& name, QDomDocument& document) const;
 
137
public Q_SLOTS:
 
138
        virtual void initFromDOMElement(const QDomElement& element);
 
139
        //@}
 
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
163
 
164
164
} // namespace qglviewer
165
165