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 #if 1 SoDEPRECATED
01041 SbBool setFullSceneAntialiasing( SbBool enable,
01042 float quality = -1.f,
01043 int filterMask = SoFullSceneAntialiasing::ALL );
01044 SoDEPRECATED
01049 SbBool isFullSceneAntialiasingEnabled() const;
01050 SoDEPRECATED
01055 SbBool getFullSceneAntialiasing( float& quality, int& filterMask ) const;
01056 SoDEPRECATED
01061 SbBool isFullSceneAntialiasingAvailable();
01062 SoDEPRECATED
01068 SbBool isFullSceneAntialiasingHQAvailable();
01069 SoDEPRECATED
01076 SbBool setFullSceneAntialiasingHQ( SbBool enable );
01077 SoDEPRECATED
01082 SbBool isFullSceneAntialiasingHQEnabled() const;
01083 SoDEPRECATED
01088 int getFullSceneAntialiasingMaxSamples() const;
01089
01090 #endif
01092 private:
01093
01094 void setMMode( int mode );
01095 int getMMode() const;
01096
01097
01098 int sheetProjProjectAndGetRotation( const SbVec2f& newLocator, SbRotation& rot );
01099
01100 private:
01101
01102 virtual ~SoGuiAlgoViewers();
01103
01104 SbProjector* makeSheetProjector( const ProjectorsType &mode );
01105
01106 private:
01107 static void spinAnimationSensorCB( void* v, SoSensor* sensor );
01108 static void constrainedAnimationSensorCB( void* v, SoSensor* sensor );
01109 static void setFocalPointFinishCallback( void* data, void* v );
01110 static void mouseWheelMotionAlarmSensorCB(void *data, SoSensor *sensor);
01111
01112 void rotateCameraAboutVwCenter( const SbRotation& rot );
01113 void rotateCameraWithRotTarget( const SbRotation& rot );
01114 void rotateCameraWithRotTargetCore( const SbRotation& rot );
01115 void rotateCameraWithRotTargetDec( const SbRotation& rot );
01116 void mouseWheelMotion_( float newVal, float &scaleFactor );
01117 void screenToFocalPlanePoint( const SbVec2s &pxPoint, SbVec3f &worldPoint, SbPlane *focPlane = NULL );
01118 void screenNormToFocalPlanePoint( const SbVec2f &normPoint, SbVec3f &worldPoint, SbPlane *fplane = NULL );
01119 void sheetProjProjectAndGetRotationCore( const SbVec2f& newLocator, SbRotation& rot );
01120
01121
01122 int m_mode;
01123 SbBool m_constrained;
01124 ViewerTypes m_vType;
01125 SbBool m_boxDrawing, m_boxSelection, m_firstActivation;
01126 SoExtSelection* m_selection;
01127 SoSwitch* m_selectionSwitch;
01128
01129 SbVec2s m_locator, m_prevPos, m_startPos;
01130
01131
01132 SoFieldSensor* m_seekAnimationSensor;
01133 SoFieldSensor* m_spinAnimationSensor;
01134 SoFieldSensor* m_walkAnimationSensor;
01135 SoFieldSensor* m_flyAnimationSensor;
01136
01137 SoAlarmSensor* m_mouseWheelMotionAlarmSensor;
01138
01139
01140 SbProjector* m_sheetProjector;
01141 ProjectorsType m_projectorType;
01142
01143 SbBool m_computeAverage;
01144 SbRotation m_averageRotation;
01145 SbRotation* m_rotBuffer;
01146 int m_firstIndex, m_lastIndex;
01147 SbVec3s m_constrainedAxis;
01148
01149
01150 SbVec3f m_locator3D;
01151 SbPlane m_focalplane;
01152
01153
01154 void computeTranslateValues();
01155 float m_transXspeed, m_transYspeed;
01156
01157
01158 float m_minSpeed, m_maxInc, m_speedLimit;
01159 float m_speed, m_maxSpeed, m_maxStraightSpeed;
01160 SbTime m_prevAnimTime;
01161
01162
01163 WalkViewerMode m_wvMode;
01164 SbBool m_walkAnimation;
01165
01166
01167 SbVec2f* m_lastRotStepLocator;
01168 double m_mouseAngularSpeed;
01169 ZoomingType m_zoomingType;
01170 SbVec3f *m_rotationTargetPosition;
01171 };
01172
01173 #endif // SO_GUI_ALGO_VIEWERS
01174
01175
01176