00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef SO_GUI_ALGO_VIEWERS
00026 #define SO_GUI_ALGO_VIEWERS
00027
00029
00030
00031
00032
00033
00034
00036
00037 #include <Inventor/Gui/viewers/SoGuiConstrainedViewer.h>
00038 #include <Inventor/SbVec.h>
00039
00040 class SbProjector;
00041 class SoExtSelection;
00042 class SoFieldSensor;
00043 class SoMPEGRenderer;
00044 class SoNode;
00045 class SoSwitch;
00046 class SoAlarmSensor;
00047 class SbSphereSheetProjector;
00048
00088 class SoGuiAlgoViewers : public SoGuiConstrainedViewer
00089 {
00090 SO_FIELDCONTAINER_HEADER( SoGuiAlgoViewers );
00091
00092 public:
00093
00097 enum ViewerTypes
00098 {
00102 EXAMINER,
00106 PLANE,
00110 FLY,
00114 WALK,
00118 UNKNOWN
00119 };
00120
00122 enum DrawStyle
00123 {
00127 VIEW_AS_IS,
00131 VIEW_HIDDEN_LINE,
00135 VIEW_NO_TEXTURE,
00139 VIEW_LOW_COMPLEXITY,
00143 VIEW_LINE,
00147 VIEW_POINT,
00151 VIEW_BBOX,
00155 VIEW_LOW_RES_LINE,
00159 VIEW_LOW_RES_POINT,
00163 VIEW_SAME_AS_STILL
00164 };
00165
00167 enum DrawType
00168 {
00172 STILL,
00176 INTERACTIVE
00177 };
00178
00180 enum BufferType
00181 {
00185 BUFFER_SINGLE,
00189 BUFFER_DOUBLE,
00193 BUFFER_INTERACTIVE
00194 };
00195
00199 enum ProjectorsType
00200 {
00205 SPHERICAL,
00212 CYLINDRICAL
00213 };
00214
00218 enum ZoomingType
00219 {
00223 AUTOCENTER,
00228 GIVENPOSITION
00229 };
00230
00234 SoGuiAlgoViewers();
00235
00239 void setConstrained( SbBool constrained );
00240
00244 SbBool isConstrained() const;
00245
00249 void setViewerType( ViewerTypes vType );
00250
00254 SoGuiAlgoViewers::ViewerTypes getViewerType() const;
00255
00261 void resetRenderAction();
00262
00267 void setSheetProjectionType( const ProjectorsType &projType );
00268
00272 ProjectorsType getSheetProjectionType() const;
00273
00278 inline void setMouseAngularSpeed( double speedFactor ) { m_mouseAngularSpeed = speedFactor; }
00279
00283 inline double getMouseAngularSpeed( ) { return m_mouseAngularSpeed; }
00284
00289 void setZoomingType( const ZoomingType &zoomType );
00290
00296 ZoomingType getZoomingType() const;
00297
00301 virtual void setRotationTargetPosition( const SbVec3f &targetPos );
00302
00306 virtual void resetRotationTargetPosition( );
00307
00313 virtual bool getRotationTargetPosition( SbVec3f &targetPos );
00314
00319 virtual void getDefaultRotationTargetPosition( SbVec3f &targetPos );
00320
00322
00324
00332 virtual void setSceneGraph( SoNode* newScene );
00333
00337 virtual SoNode* getSceneGraph();
00338
00343 void enableShadows( bool onOrOff );
00344
00350 virtual void setCamera( SoCamera* newCamera );
00351
00355 SoCamera* getCamera();
00356
00366 virtual void setCameraType( SoType type );
00367
00372 SoType getCameraType();
00373
00383 virtual void toggleCameraType();
00384
00390 virtual void setPreserveCameraHeightAngle( SbBool flag );
00391
00397 virtual SbBool isCameraHeightAnglePreserved() const;
00398
00403 virtual void viewAll();
00404
00408 virtual void saveHomePosition();
00409
00413 virtual void resetToHomePosition();
00414
00421 virtual void setHeadlight( SbBool insertFlag );
00422
00426 SbBool isHeadlight();
00427
00431 SoDirectionalLight* getHeadlight();
00432
00481 virtual void setDrawStyle( DrawType type, DrawStyle style );
00482
00486 DrawStyle getDrawStyle( DrawType type );
00487
00492 virtual void setBufferingType( BufferType type );
00493
00497 BufferType getBufferingType();
00498
00512 virtual void setViewing( SbBool flag );
00513
00517 SbBool isViewing() const;
00518
00525 virtual void recomputeSceneSize();
00526
00535 virtual void setSeekMode( SbBool onOrOff );
00536
00540 SbBool isSeekMode();
00541
00545 virtual void adjustCameraClippingPlanes();
00546
00550 void setBoxSelectionMode( SbBool on );
00551
00555 SbBool isBoxSelection() const;
00556
00560 void setBoxDrawingMode( SbBool on );
00561
00565 SbBool isBoxDrawing() const;
00566
00572 void doBoxZoom( int x1, int y1, int x2, int y2 );
00573
00580 virtual void rollCamera( const SbVec2s& newLocator );
00581
00590 virtual void dollyCamera( const SbVec2s& newLocator );
00591
00596 virtual void dollyCamera( float dist );
00597
00605 virtual void reverseDollyCamera( const SbVec2s& newLocator );
00606
00614 virtual void panCamera( const SbVec2f& newLocator );
00615
00619 void doCameraAnimation();
00620
00624 virtual void rightWheelStart();
00625
00629 virtual void bottomWheelStart();
00630
00634 virtual void leftWheelStart();
00635
00643 virtual void bottomWheelMotion( float newVal );
00644
00652 virtual void leftWheelMotion( float newVal );
00653
00657 virtual void rightWheelMotion( float newVal );
00658
00662 virtual void mouseWheelMotion( float newVal );
00663
00668 void activatePanning();
00669
00677 void setStartMousePositionLocator( const SbVec2s& mousePosition );
00678
00682 SbVec2s getStartMousePositionLocator() const;
00683
00691 void setCurrentMousePositionLocator( const SbVec2s& mousePosition );
00692
00696 SbVec2s getCurrentMousePositionLocator() const;
00697
00705 void setPreviousMousePositionLocator( const SbVec2s& mousePosition );
00706
00710 SbVec2s getPreviousMousePositionLocator() const;
00711
00715 void setCameraPositionLocator( const SbVec3f& camPosition );
00716
00720 SbVec3f getCameraPositionLocator() const;
00721
00725 void setCameraFocalPlane( const SbPlane& focalPlane );
00726
00730 SbPlane getCameraFocalPlane() const;
00731
00738 void interactiveCountInc();
00739
00744 void interactiveCountDec();
00745
00749 void setPrevAnimTime( SbTime previous );
00750
00754 SbTime getPrevAnimTime() const;
00755
00759 virtual void computeSeekFinalOrientation();
00760
00768 virtual void setMPEGRecorder( SoMPEGRenderer* recorder );
00769
00773 virtual SoMPEGRenderer* getMPEGRecorder() const;
00774
00778 void viewX( bool reverse = false );
00779
00783 void viewY( bool reverse = false );
00784
00788 void viewZ( bool reverse = false );
00789
00794 SoNode* getSceneRoot();
00795
00797
00799
00806 virtual void spinCamera( const SbVec2f& newLocator );
00807
00819 virtual void spinConstrainedCamera( const SbVec2f& newLocator, int axisIndex );
00820
00824 void startSpinAnimation();
00825
00829 void stopSpinAnimation();
00830
00834 virtual void doSpinAnimation();
00835
00843 SbProjector* getSheetProjector() const;
00844
00849 SbSphereSheetProjector* getSphereSheetProjector() const;
00850
00854 void activateSpinning();
00855
00860 void rotateCamera( const SbRotation& rot );
00861
00871 void constrainCameraRotation( bool x = false, bool y = false, bool z = false );
00872
00874
00876
00881 void setPlane( const SbVec3f& newNormal, const SbVec3f& newRight );
00882
00884
00886
00890 void calculateMaxSpeed();
00891
00895 void changeMaxStraightSpeed( SbBool increase );
00896
00900 void setMinSpeed( float speed );
00901
00905 float getMinSpeed() const;
00906
00910 void setMaxSpeed( float speed );
00911
00915 float getMaxSpeed() const;
00916
00920 void setSpeedLimit( float limit );
00921
00925 float getSpeedLimit() const;
00926
00930 void setCurrentSpeed( float speed );
00931
00935 float getCurrentSpeed() const;
00936
00940 void setMaxStraightSpeed( float speed );
00941
00945 float getMaxStraightSpeed() const;
00946
00950 void setMaxSpeedInc( float increment );
00951
00955 float getMaxSpeedInc() const;
00956
00960 void startFlyAnimation();
00961
00965 void stopFlyAnimation();
00966
00970 void activateFlying();
00971
00973
00975
00978 enum WalkViewerMode
00979 {
00983 WALK_MODE,
00987 PAN_MODE
00988 };
00989
00993 void updateCameraFocalPoint();
00994
00998 void setWalkViewerAnimMode( WalkViewerMode mode );
00999
01003 SoGuiAlgoViewers::WalkViewerMode getWalkViewerAnimMode() const;
01004
01008 void startWalkAnimation();
01009
01013 void stopWalkAnimation();
01014
01019 void rotateCamera();
01020
01021 private:
01022
01023 void setMMode( int mode );
01024 int getMMode() const;
01025
01026
01027 int sheetProjProjectAndGetRotation( const SbVec2f& newLocator, SbRotation& rot );
01028
01029 private:
01030
01031 virtual ~SoGuiAlgoViewers();
01032
01033 SbProjector* makeSheetProjector( const ProjectorsType &mode );
01034
01035 private:
01036 static void spinAnimationSensorCB( void* v, SoSensor* sensor );
01037 static void constrainedAnimationSensorCB( void* v, SoSensor* sensor );
01038 static void setFocalPointFinishCallback( void* data, void* v );
01039 static void mouseWheelMotionAlarmSensorCB(void *data, SoSensor *sensor);
01040
01041 void rotateCameraAboutVwCenter( const SbRotation& rot );
01042 void rotateCameraWithRotTarget( const SbRotation& rot );
01043 void rotateCameraWithRotTargetCore( const SbRotation& rot );
01044 void rotateCameraWithRotTargetDec( const SbRotation& rot );
01045 void mouseWheelMotion_( float newVal, float &scaleFactor );
01046 void screenToFocalPlanePoint( const SbVec2s &pxPoint, SbVec3f &worldPoint, SbPlane *focPlane = NULL );
01047 void screenNormToFocalPlanePoint( const SbVec2f &normPoint, SbVec3f &worldPoint, SbPlane *fplane = NULL );
01048 void sheetProjProjectAndGetRotationCore( const SbVec2f& newLocator, SbRotation& rot );
01049
01050
01051 int m_mode;
01052 SbBool m_constrained;
01053 ViewerTypes m_vType;
01054 SbBool m_boxDrawing, m_boxSelection, m_firstActivation;
01055 SoExtSelection* m_selection;
01056 SoSwitch* m_selectionSwitch;
01057
01058 SbVec2s m_locator, m_prevPos, m_startPos;
01059
01060
01061 SoFieldSensor* m_seekAnimationSensor;
01062 SoFieldSensor* m_spinAnimationSensor;
01063 SoFieldSensor* m_walkAnimationSensor;
01064 SoFieldSensor* m_flyAnimationSensor;
01065
01066 SoAlarmSensor* m_mouseWheelMotionAlarmSensor;
01067
01068
01069 SbProjector* m_sheetProjector;
01070 ProjectorsType m_projectorType;
01071
01072 SbBool m_computeAverage;
01073 SbRotation m_averageRotation;
01074 SbRotation* m_rotBuffer;
01075 int m_firstIndex, m_lastIndex;
01076 SbVec3s m_constrainedAxis;
01077
01078
01079 SbVec3f m_locator3D;
01080 SbPlane m_focalplane;
01081
01082
01083 void computeTranslateValues();
01084 float m_transXspeed, m_transYspeed;
01085
01086
01087 float m_minSpeed, m_maxInc, m_speedLimit;
01088 float m_speed, m_maxSpeed, m_maxStraightSpeed;
01089 SbTime m_prevAnimTime;
01090
01091
01092 WalkViewerMode m_wvMode;
01093 SbBool m_walkAnimation;
01094
01095
01096 SbVec2f* m_lastRotStepLocator;
01097 double m_mouseAngularSpeed;
01098 ZoomingType m_zoomingType;
01099 SbVec3f *m_rotationTargetPosition;
01100 };
01101
01102 #endif // SO_GUI_ALGO_VIEWERS
01103
01104
01105