00001 #ifndef _SceneInteractor_
00002 #define _SceneInteractor_
00003
00004 #include <Inventor/nodes/SoSeparator.h>
00005 #include <Inventor/nodes/SoSwitch.h>
00006 #include <Inventor/nodes/SoRotation.h>
00007 #include <Inventor/SbViewportRegion.h>
00008 #include <Inventor/ViewerComponents/SoCameraInteractor.h>
00009
00010 class SoMouseButtonEvent;
00011 class SoMouseWheelEvent;
00012 class SoKeyboardEvent;
00013 class SoLocation2Event;
00014 class SoScaleGestureEvent;
00015 class SoTouchEvent;
00016 class SoRotateGestureEvent;
00017 class SoDoubleTapGestureEvent;
00018 class SoLongTapGestureEvent;
00019 class SoCamera;
00020 class SoEventCallback;
00021
00070 class VIEWERCOMPONENTS_API SceneInteractor : public SoSeparator
00071 {
00072 public:
00073
00075 SceneInteractor();
00076
00078 virtual ~SceneInteractor();
00079
00086 void adjustClippingPlanes( const SbViewportRegion &vpRegion );
00087
00092 void viewAll(const SbViewportRegion &viewport);
00093
00099 void viewAxis( const SbVec3f& direction, const SbVec3f& up );
00100
00104 SoCameraInteractor* getCameraInteractor();
00105
00109 SoCamera* getCamera() const;
00110
00114 enum CameraMode
00115 {
00116 PERSPECTIVE,
00117 ORTHOGRAPHIC
00118 };
00119
00123 virtual void setCameraMode(SceneInteractor::CameraMode mode);
00124
00128 SceneInteractor::CameraMode getCameraMode();
00129
00133 void enableHeadLight(bool enabled);
00134
00138 bool isHeadLightEnabled();
00139
00140 private:
00141 SoRef<SoEventCallback> m_eventCallBack;
00142 SoCameraInteractor* m_cameraInteractor;
00143
00144 virtual void mouseWheelMoved( SoMouseWheelEvent* wheelEvent, SoHandleEventAction* action );
00145 virtual void mouseMoved( SoLocation2Event* mouseEvent, SoHandleEventAction* action );
00146 virtual void mousePressed( SoMouseButtonEvent* mouseEvent, SoHandleEventAction* action );
00147 virtual void mouseReleased( SoMouseButtonEvent* mouseEvent, SoHandleEventAction* action );
00148 virtual void keyPressed( SoKeyboardEvent* keyEvent, SoHandleEventAction* action );
00149 virtual void keyReleased( SoKeyboardEvent* keyEvent, SoHandleEventAction* action );
00150 virtual void touch( SoTouchEvent* touchEvent, SoHandleEventAction* action );
00151 virtual void zoom( SoScaleGestureEvent* scaleEvent, SoHandleEventAction* action );
00152 virtual void rotate( SoRotateGestureEvent* rotateEvent, SoHandleEventAction* action );
00153 virtual void doubleTap(SoDoubleTapGestureEvent* doubleTapEvent, SoHandleEventAction* action);
00154 virtual void longTap(SoLongTapGestureEvent* longTapEvent, SoHandleEventAction* action);
00155
00156
00157 static void mouseMoveCB(void * userdata, SoEventCallback * node);
00158 static void mouseCB(void * userdata, SoEventCallback * node);
00159 static void keyboardCB(void * userdata, SoEventCallback * node);
00160 static void touchCB(void * userdata, SoEventCallback * node);
00161 static void zoomCB(void * userdata, SoEventCallback * node);
00162 static void rotateCB(void * userdata, SoEventCallback * node);
00163 static void doubleTapCB(void * userdata, SoEventCallback * node);
00164 static void longTapCB(void * userdata, SoEventCallback * node);
00165 static void wheelCB(void * userdata, SoEventCallback * node);
00166
00167 private:
00168 SoRef<SoRotation> m_headlightRot;
00169 SoRef<SoSwitch> m_cameraSwitch;
00170 SoRef<SoSwitch> m_headlightSwitch;
00171
00172 SoRef<SoCameraInteractor> m_perspInteractor;
00173 SoRef<SoCameraInteractor> m_orthoInteractor;
00174
00175 };
00176
00177 #endif // _SceneInteractor_
00178