Image Component Library (ICL)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
SceneMouseHandler.h
Go to the documentation of this file.
00001 /********************************************************************
00002 **                Image Component Library (ICL)                    **
00003 **                                                                 **
00004 ** Copyright (C) 2006-2013 CITEC, University of Bielefeld          **
00005 **                         Neuroinformatics Group                  **
00006 ** Website: www.iclcv.org and                                      **
00007 **          http://opensource.cit-ec.de/projects/icl               **
00008 **                                                                 **
00009 ** File   : ICLGeom/src/ICLGeom/SceneMouseHandler.h                **
00010 ** Module : ICLGeom                                                **
00011 ** Authors: Christof Elbrechter, Erik Weitnauer, Daniel Dornbusch  **
00012 **                                                                 **
00013 **                                                                 **
00014 ** GNU LESSER GENERAL PUBLIC LICENSE                               **
00015 ** This file may be used under the terms of the GNU Lesser General **
00016 ** Public License version 3.0 as published by the                  **
00017 **                                                                 **
00018 ** Free Software Foundation and appearing in the file LICENSE.LGPL **
00019 ** included in the packaging of this file.  Please review the      **
00020 ** following information to ensure the license requirements will   **
00021 ** be met: http://www.gnu.org/licenses/lgpl-3.0.txt                **
00022 **                                                                 **
00023 ** The development of this software was supported by the           **
00024 ** Excellence Cluster EXC 277 Cognitive Interaction Technology.    **
00025 ** The Excellence Cluster EXC 277 is a grant of the Deutsche       **
00026 ** Forschungsgemeinschaft (DFG) in the context of the German       **
00027 ** Excellence Initiative.                                          **
00028 **                                                                 **
00029 ********************************************************************/
00030 
00031 #pragma once
00032 
00033 #if !defined(ICL_HAVE_OPENGL) || !defined(ICL_HAVE_QT)
00034   #ifdef WIN32
00035 #pragma WARNING("this header must not be included if ICL_HAVE_OPENGL or ICL_HAVE_QT is not defined")
00036   #else
00037     #warning "this header must not be included if ICL_HAVE_OPENGL or ICL_HAVE_QT is not defined"
00038   #endif
00039 #else
00040 
00041 
00042 #include <ICLUtils/CompatMacros.h>
00043 #include <ICLGeom/Camera.h>
00044 #include <ICLQt/MouseHandler.h>
00045 
00046 namespace icl{
00047 
00049   namespace qt{
00050     class GUI;
00051   }
00054   namespace geom{
00055     
00057 
00064     typedef void (*MouseActionCallback)(const qt::MouseEvent&,const utils::Point32f&,
00065                                         const utils::Point32f&,Camera&,void* );
00066     
00067     
00069     class Scene;
00070     
00071     
00073     struct MouseMappingTableEntry{
00075       MouseActionCallback mMouseAction;
00076       
00078       void* mData;
00079     };
00080     
00081     
00083     struct MouseSensitivities{
00085       float mTranslation;
00086       
00088       float mRotation;
00089       
00091       float mMouse;
00092       
00094       float mWheel;
00095     };
00096     
00097     
00099     enum MouseSensitivitiesModifier{
00100       LowMouseSensitivity    = 0,
00101       NormalMouseSensitivity = 1,
00102       HighMouseSensitivity   = 2,
00103       MAX_MOUSE_SENSITIVITY  = HighMouseSensitivity
00104     };
00105     
00106     
00108         
00135     class SceneMouseHandler : public qt::MouseHandler{
00136       protected:
00137       
00139 
00145       MouseMappingTableEntry mMouseMappingTable[qt::MAX_MOUSE_EVENT + 1][2][2][2][2][2][2];
00146       
00148       MouseSensitivities mMouseSensitivities[MAX_MOUSE_SENSITIVITY + 1];
00149       
00151       Camera mCameraBackup;
00152       
00154       utils::Point32f mAnchor;
00155       
00157       Scene* mParentScene;
00158       
00160       int mCameraIndex;
00161       
00163       int mKeyboardModifiersBackup;
00164       
00166       qt::GUI *mGUI;
00167       
00168       public:
00169       
00171 
00174       ICLGeom_API SceneMouseHandler(const int pCameraIndex, Scene* pParentScene );
00175       
00177 
00178       SceneMouseHandler(const SceneMouseHandler& pSceneMouseHandler){
00179         *this = pSceneMouseHandler;
00180       }
00181 
00183       ICLGeom_API ~SceneMouseHandler();
00184       
00186       ICLGeom_API SceneMouseHandler& operator=(const SceneMouseHandler& pSceneMouseHandler);
00187       
00189       void setParentScene(Scene* pParentScene){
00190         mParentScene = pParentScene;
00191       }
00192       
00194       Scene* getParentScene(){
00195         return mParentScene;
00196       }
00197       
00199 
00205       ICLGeom_API void setSensitivities(const float pTranslation, const float pRotation = 1.0,
00206                             const float pMouse = 1.0, const float pWheel = 0.001,
00207                             const float pModifier = 10.0 );
00208       
00209 
00211 
00212       MouseSensitivities getSensitivities(MouseSensitivitiesModifier pMouseSensitivitiesModifier){
00213         return mMouseSensitivities[pMouseSensitivitiesModifier];
00214       };
00215       
00216       
00218 
00220       void setCameraIndex(const int pCameraIndex){
00221         mCameraIndex = pCameraIndex;
00222       }
00223       
00224       
00226 
00227       int getCameraIndex(){
00228         return mCameraIndex;
00229       }
00230 
00231 
00233 
00234       ICLGeom_API virtual void setMouseMappings();
00235       
00236       
00238 
00247       ICLGeom_API void setMouseMapping(const qt::MouseEventType pMouseEventType,
00248                            const bool pLeftMouseButton,
00249                            const bool pMiddleMouseButton,
00250                            const bool pRightMouseButton,
00251                            const bool pShift,
00252                            const bool pControl,
00253                            const bool pAlt,
00254                            MouseActionCallback pMouseActionCallback,
00255                            void* pData=0);
00256 
00257 
00259 
00269       ICLGeom_API static void freeView(const qt::MouseEvent &pMouseEvent,
00270                            const utils::Point32f &pCurrentMousePosition,
00271                            const utils::Point32f &pDeltaMousePosition,
00272                            Camera &pCamera, void *pData,
00273                            bool pInverseX, bool pInverseY);
00274 
00275 
00277 
00284       static void freeView(const qt::MouseEvent &pMouseEvent,
00285                            const utils::Point32f &pCurrentMousePosition,
00286                            const utils::Point32f &pDeltaMousePosition,
00287                            Camera &pCamera, void *pData){
00288         freeView( pMouseEvent, pCurrentMousePosition, pDeltaMousePosition, pCamera, pData, false, false );
00289       }
00290       
00291       
00293 
00300       static void freeViewInverseMouseX(const qt::MouseEvent &pMouseEvent,
00301                                         const utils::Point32f &pCurrentMousePosition,
00302                                         const utils::Point32f &pDeltaMousePosition,
00303                                         Camera &pCamera, void *pData){
00304         freeView( pMouseEvent, pCurrentMousePosition, pDeltaMousePosition, pCamera, pData, true, false );
00305       }
00306 
00307 
00309 
00316       static void freeViewInverseMouseY(const qt::MouseEvent &pMouseEvent,
00317                                         const utils::Point32f &pCurrentMousePosition,
00318                                         const utils::Point32f &pDeltaMousePosition,
00319                                         Camera &pCamera, void *pData){
00320         freeView( pMouseEvent, pCurrentMousePosition, pDeltaMousePosition, pCamera, pData, false, true );
00321       }
00322       
00323       
00325 
00333       static void freeViewInverseBoth(const qt::MouseEvent &pMouseEvent,
00334                                       const utils::Point32f &pCurrentMousePosition,
00335                                       const utils::Point32f &pDeltaMousePosition,
00336                                       Camera &pCamera, void *pData){
00337         freeView( pMouseEvent, pCurrentMousePosition, pDeltaMousePosition, pCamera, pData, true, true );
00338       }
00339       
00340       
00342 
00349       ICLGeom_API static void rotateAroundOrigin(const qt::MouseEvent &pMouseEvent,
00350                                      const utils::Point32f &pCurrentMousePosition,
00351                                      const utils::Point32f &pDeltaMousePosition,
00352                                      Camera &pCamera, void *pData);
00353       
00355 
00362       ICLGeom_API static void strafe(const qt::MouseEvent &pMouseEvent,
00363                          const utils::Point32f &pCurrentMousePosition,
00364                          const utils::Point32f &pDeltaMousePosition,
00365                          Camera &pCamera, void *pData);
00366       
00368 
00375       ICLGeom_API static void rollAndDistance(const qt::MouseEvent &pMouseEvent,
00376                                   const utils::Point32f &pCurrentMousePosition,
00377                                   const utils::Point32f &pDeltaMousePosition,
00378                                   Camera &pCamera, void *pData);
00379       
00380       
00382 
00383       ICLGeom_API virtual void process(const qt::MouseEvent &pMouseEvent);
00384     };
00385     
00386   } // namespace geom
00387 }
00388 
00389 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines