manipulatedFrame.h
Go to the documentation of this file.
00001 /****************************************************************************
00002 
00003  Copyright (C) 2002-2013 Gilles Debunne. All rights reserved.
00004 
00005  This file is part of the QGLViewer library version 2.4.0.
00006 
00007  http://www.libqglviewer.com - contact@libqglviewer.com
00008 
00009  This file may be used under the terms of the GNU General Public License 
00010  versions 2.0 or 3.0 as published by the Free Software Foundation and
00011  appearing in the LICENSE file included in the packaging of this file.
00012  In addition, as a special exception, Gilles Debunne gives you certain 
00013  additional rights, described in the file GPL_EXCEPTION in this package.
00014 
00015  libQGLViewer uses dual licensing. Commercial/proprietary software must
00016  purchase a libQGLViewer Commercial License.
00017 
00018  This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00019  WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
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_; // Should be a QGLViewer::MouseAction, but include loop
00274     Constraint* previousConstraint_; // When manipulation is without Contraint.
00275 
00276     virtual void startAction(int ma, bool withConstraint=true); // int is really a QGLViewer::MouseAction
00277     void computeMouseSpeed(const QMouseEvent* const e);
00278     int mouseOriginalDirection(const QMouseEvent* const e);
00279 
00280     // Previous mouse position (used for incremental updates) and mouse press position.
00281     QPoint prevPos_, pressPos_;
00282 #endif // DOXYGEN
00283 
00284   private:
00285     // Sensitivity
00286     float rotSensitivity_;
00287     float transSensitivity_;
00288     float spinningSensitivity_;
00289     float wheelSensitivity_;
00290 
00291     // Mouse speed and spinning
00292     QTime last_move_time;
00293     float mouseSpeed_;
00294     int delay_;
00295     bool isSpinning_;
00296     QTimer spinningTimer_;
00297     Quaternion spinningQuaternion_;
00298 
00299     // Whether the SCREEN_TRANS direction (horizontal or vertical) is fixed or not.
00300     bool dirIsFixed_;
00301 
00302     // MouseGrabber
00303     bool keepsGrabbingMouse_;
00304   };
00305 
00306 } // namespace qglviewer
00307 
00308 #endif // QGLVIEWER_MANIPULATED_FRAME_H


octovis
Author(s): Kai M. Wurm , Armin Hornung
autogenerated on Thu Feb 11 2016 23:51:20