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
00069 class VIEWERCOMPONENTS_API SceneInteractor : public SoSeparator
00070 {
00071 public:
00072
00074 SceneInteractor();
00075
00077 virtual ~SceneInteractor();
00078
00085 void adjustClippingPlanes( const SbViewportRegion &vpRegion );
00086
00091 void viewAll(const SbViewportRegion &viewport);
00092
00098 void viewAxis( const SbVec3f& direction, const SbVec3f& up );
00099
00103 SoCameraInteractor* getCameraInteractor();
00104
00108 SoCamera* getCamera() const;
00109
00113 enum CameraMode
00114 {
00115 PERSPECTIVE,
00116 ORTHOGRAPHIC
00117 };
00118
00122 virtual void setCameraMode(SceneInteractor::CameraMode mode);
00123
00127 SceneInteractor::CameraMode getCameraMode();
00128
00132 void enableHeadLight(bool enabled);
00133
00137 bool isHeadLightEnabled();
00138
00139 private:
00140 SoRef<SoEventCallback> m_eventCallBack;
00141 SoCameraInteractor* m_cameraInteractor;
00142
00143 virtual void mouseWheelMoved( SoMouseWheelEvent* wheelEvent, SoHandleEventAction* action );
00144 virtual void mouseMoved( SoLocation2Event* mouseEvent, SoHandleEventAction* action );
00145 virtual void mousePressed( SoMouseButtonEvent* mouseEvent, SoHandleEventAction* action );
00146 virtual void mouseReleased( SoMouseButtonEvent* mouseEvent, SoHandleEventAction* action );
00147 virtual void keyPressed( SoKeyboardEvent* keyEvent, SoHandleEventAction* action );
00148 virtual void keyReleased( SoKeyboardEvent* keyEvent, SoHandleEventAction* action );
00149 virtual void touch( SoTouchEvent* touchEvent, SoHandleEventAction* action );
00150 virtual void zoom( SoScaleGestureEvent* scaleEvent, SoHandleEventAction* action );
00151 virtual void rotate( SoRotateGestureEvent* rotateEvent, SoHandleEventAction* action );
00152 virtual void doubleTap(SoDoubleTapGestureEvent* doubleTapEvent, SoHandleEventAction* action);
00153 virtual void longTap(SoLongTapGestureEvent* longTapEvent, SoHandleEventAction* action);
00154
00155
00156 static void mouseMoveCB(void * userdata, SoEventCallback * node);
00157 static void mouseCB(void * userdata, SoEventCallback * node);
00158 static void keyboardCB(void * userdata, SoEventCallback * node);
00159 static void touchCB(void * userdata, SoEventCallback * node);
00160 static void zoomCB(void * userdata, SoEventCallback * node);
00161 static void rotateCB(void * userdata, SoEventCallback * node);
00162 static void doubleTapCB(void * userdata, SoEventCallback * node);
00163 static void longTapCB(void * userdata, SoEventCallback * node);
00164 static void wheelCB(void * userdata, SoEventCallback * node);
00165
00166 private:
00167 SoRef<SoRotation> m_headlightRot;
00168 SoRef<SoSwitch> m_cameraSwitch;
00169 SoRef<SoSwitch> m_headlightSwitch;
00170
00171 SoRef<SoCameraInteractor> m_perspInteractor;
00172 SoRef<SoCameraInteractor> m_orthoInteractor;
00173
00174 };
00175
00176 #endif // _SceneInteractor_
00177