Image Component Library (ICL)
SceneMouseHandler.h
Go to the documentation of this file.
1 /********************************************************************
2 ** Image Component Library (ICL) **
3 ** **
4 ** Copyright (C) 2006-2013 CITEC, University of Bielefeld **
5 ** Neuroinformatics Group **
6 ** Website: www.iclcv.org and **
7 ** http://opensource.cit-ec.de/projects/icl **
8 ** **
9 ** File : ICLGeom/src/ICLGeom/SceneMouseHandler.h **
10 ** Module : ICLGeom **
11 ** Authors: Christof Elbrechter, Erik Weitnauer, Daniel Dornbusch **
12 ** **
13 ** **
14 ** GNU LESSER GENERAL PUBLIC LICENSE **
15 ** This file may be used under the terms of the GNU Lesser General **
16 ** Public License version 3.0 as published by the **
17 ** **
18 ** Free Software Foundation and appearing in the file LICENSE.LGPL **
19 ** included in the packaging of this file. Please review the **
20 ** following information to ensure the license requirements will **
21 ** be met: http://www.gnu.org/licenses/lgpl-3.0.txt **
22 ** **
23 ** The development of this software was supported by the **
24 ** Excellence Cluster EXC 277 Cognitive Interaction Technology. **
25 ** The Excellence Cluster EXC 277 is a grant of the Deutsche **
26 ** Forschungsgemeinschaft (DFG) in the context of the German **
27 ** Excellence Initiative. **
28 ** **
29 ********************************************************************/
30 
31 #pragma once
32 
33 #if !defined(ICL_HAVE_OPENGL) || !defined(ICL_HAVE_QT)
34  #ifdef WIN32
35 #pragma WARNING("this header must not be included if ICL_HAVE_OPENGL or ICL_HAVE_QT is not defined")
36  #else
37  #warning "this header must not be included if ICL_HAVE_OPENGL or ICL_HAVE_QT is not defined"
38  #endif
39 #else
40 
41 
42 #include <ICLUtils/CompatMacros.h>
43 #include <ICLGeom/Camera.h>
44 #include <ICLQt/MouseHandler.h>
45 
46 namespace icl{
47 
49  namespace qt{
50  class GUI;
51  }
54  namespace geom{
55 
57  class Scene;
58 
60 
68  typedef void (*MouseActionCallback)(const qt::MouseEvent&,const utils::Point32f&,
69  const utils::Point32f&,Camera&,Scene&,void* );
70 
71 
72 
77 
79  void* mData;
80  };
81 
82 
86  float mTranslation;
87 
89  float mRotation;
90 
92  float mMouse;
93 
95  float mWheel;
96  };
97 
98 
105  };
106 
107 
109 
137  protected:
138 
140 
147 
150 
153 
156 
159 
162 
165 
168 
169  public:
170 
172 
175  ICLGeom_API SceneMouseHandler(const int pCameraIndex, Scene* pParentScene );
176 
178 
179  SceneMouseHandler(const SceneMouseHandler& pSceneMouseHandler){
180  *this = pSceneMouseHandler;
181  }
182 
185 
187  ICLGeom_API SceneMouseHandler& operator=(const SceneMouseHandler& pSceneMouseHandler);
188 
190  void setParentScene(Scene* pParentScene){
191  mParentScene = pParentScene;
192  }
193 
196  return mParentScene;
197  }
198 
200 
206  ICLGeom_API void setSensitivities(const float pTranslation, const float pRotation = 1.0,
207  const float pMouse = 1.0, const float pWheel = 0.001,
208  const float pModifier = 10.0 );
209 
210 
212 
214  return mMouseSensitivities[pMouseSensitivitiesModifier];
215  };
216 
217 
219 
221  void setCameraIndex(const int pCameraIndex){
222  mCameraIndex = pCameraIndex;
223  }
224 
225 
227 
229  return mCameraIndex;
230  }
231 
232 
234 
235  ICLGeom_API virtual void setMouseMappings();
236 
237 
239 
248  ICLGeom_API void setMouseMapping(const qt::MouseEventType pMouseEventType,
249  const bool pLeftMouseButton,
250  const bool pMiddleMouseButton,
251  const bool pRightMouseButton,
252  const bool pShift,
253  const bool pControl,
254  const bool pAlt,
255  MouseActionCallback pMouseActionCallback,
256  void* pData=0);
257 
258 
260 
270  ICLGeom_API static void freeView(const qt::MouseEvent &pMouseEvent,
271  const utils::Point32f &pCurrentMousePosition,
272  const utils::Point32f &pDeltaMousePosition,
273  Camera &pCamera, Scene &pScene, void *pData,
274  bool pInverseX, bool pInverseY);
275 
276 
278 
285  static void freeView(const qt::MouseEvent &pMouseEvent,
286  const utils::Point32f &pCurrentMousePosition,
287  const utils::Point32f &pDeltaMousePosition,
288  Camera &pCamera, Scene &pScene, void *pData){
289  freeView( pMouseEvent, pCurrentMousePosition, pDeltaMousePosition, pCamera, pScene, pData, false, false );
290  }
291 
292 
294 
301  static void freeViewInverseMouseX(const qt::MouseEvent &pMouseEvent,
302  const utils::Point32f &pCurrentMousePosition,
303  const utils::Point32f &pDeltaMousePosition,
304  Camera &pCamera, Scene &pScene, void *pData){
305  freeView( pMouseEvent, pCurrentMousePosition, pDeltaMousePosition, pCamera, pScene, pData, true, false );
306  }
307 
308 
310 
317  static void freeViewInverseMouseY(const qt::MouseEvent &pMouseEvent,
318  const utils::Point32f &pCurrentMousePosition,
319  const utils::Point32f &pDeltaMousePosition,
320  Camera &pCamera, Scene &pScene, void *pData){
321  freeView( pMouseEvent, pCurrentMousePosition, pDeltaMousePosition, pCamera, pScene, pData, false, true );
322  }
323 
324 
326 
334  static void freeViewInverseBoth(const qt::MouseEvent &pMouseEvent,
335  const utils::Point32f &pCurrentMousePosition,
336  const utils::Point32f &pDeltaMousePosition,
337  Camera &pCamera, Scene &pScene, void *pData){
338  freeView( pMouseEvent, pCurrentMousePosition, pDeltaMousePosition, pCamera, pScene, pData, true, true );
339  }
340 
341 
343 
350  ICLGeom_API static void rotateAroundOrigin(const qt::MouseEvent &pMouseEvent,
351  const utils::Point32f &pCurrentMousePosition,
352  const utils::Point32f &pDeltaMousePosition,
353  Camera &pCamera, Scene &pScene, void *pData);
354 
356 
363  ICLGeom_API static void strafe(const qt::MouseEvent &pMouseEvent,
364  const utils::Point32f &pCurrentMousePosition,
365  const utils::Point32f &pDeltaMousePosition,
366  Camera &pCamera, Scene &pScene, void *pData);
367 
369 
376  ICLGeom_API static void rollAndDistance(const qt::MouseEvent &pMouseEvent,
377  const utils::Point32f &pCurrentMousePosition,
378  const utils::Point32f &pDeltaMousePosition,
379  Camera &pCamera, Scene &pScene, void *pData);
380 
382 
387  ICLGeom_API static void placeCursor(const qt::MouseEvent &pMouseEvent,
388  const utils::Point32f &pCurrentMousePosition,
389  const utils::Point32f &pDeltaMousePosition,
390  Camera &pCamera, Scene &pScene, void *pData);
391 
392 
394 
395  ICLGeom_API virtual void process(const qt::MouseEvent &pMouseEvent);
396  };
397 
398  } // namespace geom
399 }
400 
401 #endif
static void freeViewInverseMouseY(const qt::MouseEvent &pMouseEvent, const utils::Point32f &pCurrentMousePosition, const utils::Point32f &pDeltaMousePosition, Camera &pCamera, Scene &pScene, void *pData)
Free view with inversed y-axis.
Definition: SceneMouseHandler.h:317
Definition: SceneMouseHandler.h:101
float mMouse
sensitivity of mouse movements (e.g. 1.0)
Definition: SceneMouseHandler.h:92
void setParentScene(Scene *pParentScene)
Set parent scene.
Definition: SceneMouseHandler.h:190
Class providing a mouse handler for class scene.
Definition: SceneMouseHandler.h:136
undocument this line if you encounter any issues!
Definition: Any.h:37
Scene * getParentScene()
Get parent scene.
Definition: SceneMouseHandler.h:195
Main Class of ICL's GUI creation framework.
Definition: GUI.h:60
Camera mCameraBackup
backup of old camera
Definition: SceneMouseHandler.h:152
static ICLGeom_API void placeCursor(const qt::MouseEvent &pMouseEvent, const utils::Point32f &pCurrentMousePosition, const utils::Point32f &pDeltaMousePosition, Camera &pCamera, Scene &pScene, void *pData)
Place the cursor for rotational Origin.
int getCameraIndex()
Get camera index.
Definition: SceneMouseHandler.h:228
int mKeyboardModifiersBackup
backup of old keyboard modifiers
Definition: SceneMouseHandler.h:164
static ICLGeom_API void rotateAroundOrigin(const qt::MouseEvent &pMouseEvent, const utils::Point32f &pCurrentMousePosition, const utils::Point32f &pDeltaMousePosition, Camera &pCamera, Scene &pScene, void *pData)
Rotate around origin and correct camera orientation.
MouseEventType
list of supported mouse event types
Definition: MouseEvent.h:48
static void freeView(const qt::MouseEvent &pMouseEvent, const utils::Point32f &pCurrentMousePosition, const utils::Point32f &pDeltaMousePosition, Camera &pCamera, Scene &pScene, void *pData)
Free view with normal axes.
Definition: SceneMouseHandler.h:285
#define ICLGeom_API
Definition: CompatMacros.h:179
SceneMouseHandler(const SceneMouseHandler &pSceneMouseHandler)
Copy constructor.
Definition: SceneMouseHandler.h:179
Scene * mParentScene
pointer to parent scene
Definition: SceneMouseHandler.h:158
static ICLGeom_API void rollAndDistance(const qt::MouseEvent &pMouseEvent, const utils::Point32f &pCurrentMousePosition, const utils::Point32f &pDeltaMousePosition, Camera &pCamera, Scene &pScene, void *pData)
Roll and distance (camera movement forward and backward).
mouse mapping table entry
Definition: SceneMouseHandler.h:74
utils::Point32f mAnchor
starting mouse position for dragging
Definition: SceneMouseHandler.h:155
static ICLGeom_API void strafe(const qt::MouseEvent &pMouseEvent, const utils::Point32f &pCurrentMousePosition, const utils::Point32f &pDeltaMousePosition, Camera &pCamera, Scene &pScene, void *pData)
Strafe (camera movement up, down, left, right).
Camera class.
Definition: Camera.h:132
virtual ICLGeom_API void setMouseMappings()
Set mouse mappings.
static ICLGeom_API void freeView(const qt::MouseEvent &pMouseEvent, const utils::Point32f &pCurrentMousePosition, const utils::Point32f &pDeltaMousePosition, Camera &pCamera, Scene &pScene, void *pData, bool pInverseX, bool pInverseY)
Free view.
ICLGeom_API ~SceneMouseHandler()
Destructor.
Scene Implementation that is used to handle a list of objects and cameras.
Definition: Scene.h:138
Definition: SceneMouseHandler.h:103
static void freeViewInverseBoth(const qt::MouseEvent &pMouseEvent, const utils::Point32f &pCurrentMousePosition, const utils::Point32f &pDeltaMousePosition, Camera &pCamera, Scene &pScene, void *pData)
Free view with inversed axes.
Definition: SceneMouseHandler.h:334
Definition: SceneMouseHandler.h:102
MouseEvent Handler.
Definition: MouseHandler.h:92
void * mData
pointer to additional data
Definition: SceneMouseHandler.h:79
Single precission 3D Vectors Point class of the ICL.
Definition: Point32f.h:41
Definition: SceneMouseHandler.h:104
int mCameraIndex
index of camera in scene
Definition: SceneMouseHandler.h:161
highest enum value (enum value count = MAX_MOUSE_EVENT + 1)
Definition: MouseEvent.h:56
Provided by interface MouseGrabber.
Definition: MouseEvent.h:86
MouseSensitivities getSensitivities(MouseSensitivitiesModifier pMouseSensitivitiesModifier)
Get mouse and wheel sensitivities (low, normal, high).
Definition: SceneMouseHandler.h:213
float mWheel
sensitivity of mouse wheel (e.g. 0.001)
Definition: SceneMouseHandler.h:95
ICLGeom_API void setSensitivities(const float pTranslation, const float pRotation=1.0, const float pMouse=1.0, const float pWheel=0.001, const float pModifier=10.0)
Set mouse & wheel sensitivities, modifier factor and factors for rotation and translation.
virtual ICLGeom_API void process(const qt::MouseEvent &pMouseEvent)
Process mouse event using mouse mapping table.
MouseMappingTableEntry mMouseMappingTable[qt::MAX_MOUSE_EVENT+1][2][2][2][2][2][2]
Mouse mapping table:
Definition: SceneMouseHandler.h:146
void setCameraIndex(const int pCameraIndex)
Set camera index.
Definition: SceneMouseHandler.h:221
qt::GUI * mGUI
GUI for the adaption of scene properties.
Definition: SceneMouseHandler.h:167
MouseActionCallback mMouseAction
pointer to mouse action function
Definition: SceneMouseHandler.h:76
void(* MouseActionCallback)(const qt::MouseEvent &, const utils::Point32f &, const utils::Point32f &, Camera &, Scene &, void *)
Mouse action function pointer.
Definition: SceneMouseHandler.h:68
MouseSensitivitiesModifier
mouse sensitivities modifier
Definition: SceneMouseHandler.h:100
MouseSensitivities mMouseSensitivities[MAX_MOUSE_SENSITIVITY+1]
mouse sensitivities
Definition: SceneMouseHandler.h:149
float mRotation
sensitivity factor for rotations (e.g. 1.0)
Definition: SceneMouseHandler.h:89
float mTranslation
sensitivity factor for translation (e.g. mParentScene->getMaxSceneDim())
Definition: SceneMouseHandler.h:86
mouse sensitivities
Definition: SceneMouseHandler.h:84
ICLGeom_API SceneMouseHandler(const int pCameraIndex, Scene *pParentScene)
Constructor.
static void freeViewInverseMouseX(const qt::MouseEvent &pMouseEvent, const utils::Point32f &pCurrentMousePosition, const utils::Point32f &pDeltaMousePosition, Camera &pCamera, Scene &pScene, void *pData)
Free view with inversed x-axis.
Definition: SceneMouseHandler.h:301
ICLGeom_API SceneMouseHandler & operator=(const SceneMouseHandler &pSceneMouseHandler)
Assignment operator.
ICLGeom_API void setMouseMapping(const qt::MouseEventType pMouseEventType, const bool pLeftMouseButton, const bool pMiddleMouseButton, const bool pRightMouseButton, const bool pShift, const bool pControl, const bool pAlt, MouseActionCallback pMouseActionCallback, void *pData=0)
Set one mouse mapping.