Main Page | Namespace List | Class Hierarchy | Compound List | File List | Compound Members | File Members | Related Pages

manipulatedFrame.h

Go to the documentation of this file.
00001 /****************************************************************************
00002 
00003  This file is part of the QGLViewer library
00004  Copyright (C) 2002-2004  Gilles Debunne (Gilles.Debunne@imag.fr)
00005  Version 1.3.5 Release 8. Packaged on Monday December 22, 2003.
00006 
00007  http://www-imagis.imag.fr/Membres/Gilles.Debunne/CODE/QGLViewer
00008 
00009  libQGLViewer is free software; you can redistribute it and/or modify
00010  it under the terms of the GNU General Public License as published by
00011  the Free Software Foundation; either version 2 of the License, or
00012  (at your option) any later version.
00013 
00014  libQGLViewer is distributed in the hope that it will be useful,
00015  but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  GNU General Public License for more details.
00018 
00019  You should have received a copy of the GNU General Public License
00020  along with libQGLViewer; if not, write to the Free Software
00021  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00022 
00023 *****************************************************************************/
00024 
00025 #ifndef QGLVIEWER_MANIPULATED_FRAME_H
00026 #define QGLVIEWER_MANIPULATED_FRAME_H
00027 
00028 #include <qstring.h>
00029 #include <qtimer.h>
00030 #include <qdatetime.h>
00031 
00032 #include "spinningFrame.h"
00033 #include "mouseGrabber.h"
00034 
00035 class QGLViewer;
00036 
00037 namespace qglviewer {
00038 
00095   class QGLVIEWER_EXPORT ManipulatedFrame : public SpinningFrame, public MouseGrabber
00096   {
00097 #ifndef DOXYGEN
00098     friend class Camera;
00099     friend class ::QGLViewer;
00100 #endif
00101 
00102     Q_OBJECT
00103 
00104   public:
00105     ManipulatedFrame();
00107     virtual ~ManipulatedFrame() {};
00108     
00109     signals:
00125     void manipulated();
00126 
00129   public slots:
00131     void setRotationSensitivity(const float s) { rotSensitivity_ = s; };
00145     void setTranslationSensitivity(const float s) { transSensitivity_ = s; };
00146 
00148     void setSpinningSensitivity(const float s) { spinningSensitivity_ = s; };
00149   public:
00151     float rotationSensitivity() const { return rotSensitivity_; };
00153     float translationSensitivity() const { return transSensitivity_; };
00158     float spinningSensitivity() const { return spinningSensitivity_; };
00160     
00161   public:
00166     bool isManipulated() const { return action_ != NO_ACTION; };
00168 
00169   public:
00172     virtual QDomElement domElement(const QString& name, QDomDocument& doc) const;
00173     virtual void initFromDOMElement(const QDomElement& de);
00175     
00178   protected:
00179     virtual void mousePressEvent(QMouseEvent* const, Camera* const);
00180     virtual void mouseReleaseEvent(QMouseEvent* const, Camera* const);
00181     virtual void mouseMoveEvent(QMouseEvent* const, const Camera* const);
00182     virtual void wheelEvent(QWheelEvent* const, const Camera* const camera);
00184 
00187     void checkIfGrabsMouse(int x, int y, const Camera* const camera); 
00189 
00190   protected:
00191     Quaternion quaternionFromDeformedBall(const int x, const int y, const float cx, const float cy, const Camera* const camera);
00192 
00193   public:
00194     // P o s s i b l e   a c t i o n s
00195     enum MouseMotion { NO_ACTION,
00196                ROTATE, ZOOM, TRANSLATE,
00197                MOVE_FORWARD, LOOK_AROUND, MOVE_BACKWARD,
00198                SCREEN_ROTATE, SCREEN_ROTATE_BOTTOM,
00199                SCREEN_TRANSLATE, ZOOM_ON_REGION };
00200     //#CONNECTION# QGLViewer::setMouseBinding
00201     
00202   protected:    
00203     MouseMotion action_;
00204     bool withConstraint_;
00205 
00206     virtual void startAction(MouseMotion ma, bool withConstraint=true);
00207     void computeMouseSpeed(const QMouseEvent* const e);    
00208     int mouseOriginalDirection(const QMouseEvent* const e);
00209 
00210     // Previous mouse position, used for incremental updates.
00211     int prevX_,  prevY_;
00212     // Mouse press position
00213     int pressX_, pressY_;  
00214     
00215   private:
00216     // Copy constructor and opertor= are declared private and undefined
00217     // Prevents everyone from trying to use them
00218     ManipulatedFrame(const ManipulatedFrame& mf);
00219     ManipulatedFrame& operator=(const ManipulatedFrame& mf);
00220 
00221     // Sensitivity
00222     float rotSensitivity_;
00223     float transSensitivity_;
00224     float spinningSensitivity_;
00225   
00226     // Mouse speed and spinning
00227     QTime last_move_time;
00228     float mouseSpeed_; 
00229     int delay_; 
00230 
00231     // Whether the SCREEN_TRANS direction (horizontal or vertical) is fixed or not.
00232     bool dirIsFixed_;
00233 
00234     // MouseGrabber
00235     bool keepsGrabbingMouse_;
00236   };
00237 
00238 } // namespace qglviewer
00239 
00240 #endif // QGLVIEWER_MANIPULATED_FRAME_H

Generated on Fri Feb 27 12:01:39 2004 for Glitch by doxygen 1.3.2