Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef QGLVIEWER_MANIPULATED_FRAME_H
00024 #define QGLVIEWER_MANIPULATED_FRAME_H
00025
00026 #include "frame.h"
00027 #include "mouseGrabber.h"
00028
00029 #if QT_VERSION >= 0x040000
00030 # include <QString>
00031 # include <QTimer>
00032 # include <QDateTime>
00033 #else
00034 # include <qstring.h>
00035 # include <qtimer.h>
00036 # include <qdatetime.h>
00037 #endif
00038
00039 namespace qglviewer {
00100 class QGLVIEWER_EXPORT ManipulatedFrame : public Frame, public MouseGrabber
00101 {
00102 #ifndef DOXYGEN
00103 friend class Camera;
00104 friend class ::QGLViewer;
00105 #endif
00106
00107 Q_OBJECT
00108
00109 public:
00110 ManipulatedFrame();
00112 virtual ~ManipulatedFrame() {};
00113
00114 ManipulatedFrame(const ManipulatedFrame& mf);
00115 ManipulatedFrame& operator=(const ManipulatedFrame& mf);
00116
00117 Q_SIGNALS:
00129 void manipulated();
00130
00141 void spun();
00142
00145 public Q_SLOTS:
00147 void setRotationSensitivity(float sensitivity) { rotSensitivity_ = sensitivity; };
00149 void setTranslationSensitivity(float sensitivity) { transSensitivity_ = sensitivity; };
00151 void setSpinningSensitivity(float sensitivity) { spinningSensitivity_ = sensitivity; };
00153 void setWheelSensitivity(float sensitivity) { wheelSensitivity_ = sensitivity; };
00154 public:
00163 float rotationSensitivity() const { return rotSensitivity_; };
00182 float translationSensitivity() const { return transSensitivity_; };
00194 float spinningSensitivity() const { return spinningSensitivity_; };
00202 float wheelSensitivity() const { return wheelSensitivity_; };
00204
00205
00208 public:
00215 bool isSpinning() const { return isSpinning_; };
00224 Quaternion spinningQuaternion() const { return spinningQuaternion_; }
00225 public Q_SLOTS:
00228 void setSpinningQuaternion(const Quaternion& spinningQuaternion) { spinningQuaternion_ = spinningQuaternion; }
00229 virtual void startSpinning(int updateInterval);
00232 virtual void stopSpinning() { spinningTimer_.stop(); isSpinning_ = false; };
00233 protected Q_SLOTS:
00234 virtual void spin();
00235 private Q_SLOTS:
00236 void spinUpdate();
00238
00241 protected:
00242 virtual void mousePressEvent (QMouseEvent* const event, Camera* const camera);
00243 virtual void mouseMoveEvent (QMouseEvent* const event, Camera* const camera);
00244 virtual void mouseReleaseEvent (QMouseEvent* const event, Camera* const camera);
00245 virtual void mouseDoubleClickEvent(QMouseEvent* const event, Camera* const camera);
00246 virtual void wheelEvent (QWheelEvent* const event, Camera* const camera);
00248
00249 public:
00252 bool isManipulated() const;
00254
00257 public:
00258 virtual void checkIfGrabsMouse(int x, int y, const Camera* const camera);
00260
00263 public:
00264 virtual QDomElement domElement(const QString& name, QDomDocument& document) const;
00265 public Q_SLOTS:
00266 virtual void initFromDOMElement(const QDomElement& element);
00268
00269 #ifndef DOXYGEN
00270 protected:
00271 Quaternion deformedBallQuaternion(int x, int y, float cx, float cy, const Camera* const camera);
00272
00273 int action_;
00274 Constraint* previousConstraint_;
00275
00276 virtual void startAction(int ma, bool withConstraint=true);
00277 void computeMouseSpeed(const QMouseEvent* const e);
00278 int mouseOriginalDirection(const QMouseEvent* const e);
00279
00280
00281 QPoint prevPos_, pressPos_;
00282 #endif // DOXYGEN
00283
00284 private:
00285
00286 float rotSensitivity_;
00287 float transSensitivity_;
00288 float spinningSensitivity_;
00289 float wheelSensitivity_;
00290
00291
00292 QTime last_move_time;
00293 float mouseSpeed_;
00294 int delay_;
00295 bool isSpinning_;
00296 QTimer spinningTimer_;
00297 Quaternion spinningQuaternion_;
00298
00299
00300 bool dirIsFixed_;
00301
00302
00303 bool keepsGrabbingMouse_;
00304 };
00305
00306 }
00307
00308 #endif // QGLVIEWER_MANIPULATED_FRAME_H