Open Inventor Release 2024.1.1
 
Loading...
Searching...
No Matches
SoGuiAlgoViewers.h
1/*=======================================================================
2 *** THE CONTENT OF THIS WORK IS PROPRIETARY TO FEI S.A.S, (FEI S.A.S.), ***
3 *** AND IS DISTRIBUTED UNDER A LICENSE AGREEMENT. ***
4 *** ***
5 *** REPRODUCTION, DISCLOSURE, OR USE, IN WHOLE OR IN PART, OTHER THAN AS ***
6 *** SPECIFIED IN THE LICENSE ARE NOT TO BE UNDERTAKEN EXCEPT WITH PRIOR ***
7 *** WRITTEN AUTHORIZATION OF FEI S.A.S. ***
8 *** ***
9 *** RESTRICTED RIGHTS LEGEND ***
10 *** USE, DUPLICATION, OR DISCLOSURE BY THE GOVERNMENT OF THE CONTENT OF THIS ***
11 *** WORK OR RELATED DOCUMENTATION IS SUBJECT TO RESTRICTIONS AS SET FORTH IN ***
12 *** SUBPARAGRAPH (C)(1) OF THE COMMERCIAL COMPUTER SOFTWARE RESTRICTED RIGHT ***
13 *** CLAUSE AT FAR 52.227-19 OR SUBPARAGRAPH (C)(1)(II) OF THE RIGHTS IN ***
14 *** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 52.227-7013. ***
15 *** ***
16 *** COPYRIGHT (C) 1996-2020 BY FEI S.A.S, ***
17 *** BORDEAUX, FRANCE ***
18 *** ALL RIGHTS RESERVED ***
19**=======================================================================*/
20/*=======================================================================
21** Author : Tristan MEHAMLI (Dec 2008)
22**=======================================================================*/
23
24
25#ifndef SO_GUI_ALGO_VIEWERS
26#define SO_GUI_ALGO_VIEWERS
27
29//
30// Class: SoGuiAlgoViewers
31//
32// Provides common and specific algorithms for viewers.
33//
34//
36
37#include <Inventor/Gui/viewers/SoGuiConstrainedViewer.h>
38#include <Inventor/SbVec.h>
39
40class SbProjector;
41class SoExtSelection;
42class SoFieldSensor;
43class SoMPEGRenderer;
44class SoNode;
45class SoSwitch;
46class SoAlarmSensor;
48
89{
90 SO_FIELDCONTAINER_HEADER( SoGuiAlgoViewers );
91
92public:
93
120
165
178
195
214
230
235
239 void setConstrained( SbBool constrained );
240
245
250
255
262
267 void setSheetProjectionType( const ProjectorsType &projType );
268
273
278 inline void setMouseAngularSpeed( double speedFactor ) { m_mouseAngularSpeed = speedFactor; }
279
283 inline double getMouseAngularSpeed( ) { return m_mouseAngularSpeed; }
284
289 void setZoomingType( const ZoomingType &zoomType );
290
297
301 virtual void setRotationTargetPosition( const SbVec3f &targetPos );
302
307
313 virtual bool getRotationTargetPosition( SbVec3f &targetPos );
314
319 virtual void getDefaultRotationTargetPosition( SbVec3f &targetPos );
320
322 //* Common algorithms *//
324
332 virtual void setSceneGraph( SoNode* newScene );
333
338
343 void enableShadows( bool onOrOff );
344
350 virtual void setCamera( SoCamera* newCamera );
351
356
366 virtual void setCameraType( SoType type );
367
373
383 virtual void toggleCameraType();
384
391
398
403 virtual void viewAll();
404
408 virtual void saveHomePosition();
409
413 virtual void resetToHomePosition();
414
421 virtual void setHeadlight( SbBool insertFlag );
422
427
432
481 virtual void setDrawStyle( DrawType type, DrawStyle style );
482
487
492 virtual void setBufferingType( BufferType type );
493
498
512 virtual void setViewing( SbBool flag );
513
518
525 virtual void recomputeSceneSize();
526
535 virtual void setSeekMode( SbBool onOrOff );
536
541
546
551
556
561
566
572 void doBoxZoom( int x1, int y1, int x2, int y2 );
573
580 virtual void rollCamera( const SbVec2s& newLocator );
581
590 virtual void dollyCamera( const SbVec2s& newLocator );
591
596 virtual void dollyCamera( float dist );
597
605 virtual void reverseDollyCamera( const SbVec2s& newLocator );
606
614 virtual void panCamera( const SbVec2f& newLocator );
615
620
624 virtual void rightWheelStart();
625
629 virtual void bottomWheelStart();
630
634 virtual void leftWheelStart();
635
643 virtual void bottomWheelMotion( float newVal );
644
652 virtual void leftWheelMotion( float newVal );
653
657 virtual void rightWheelMotion( float newVal );
658
662 virtual void mouseWheelMotion( float newVal );
663
669
677 void setStartMousePositionLocator( const SbVec2s& mousePosition );
678
683
691 void setCurrentMousePositionLocator( const SbVec2s& mousePosition );
692
697
705 void setPreviousMousePositionLocator( const SbVec2s& mousePosition );
706
711
715 void setCameraPositionLocator( const SbVec3f& camPosition );
716
721
725 void setCameraFocalPlane( const SbPlane& focalPlane );
726
731
739
745
749 void setPrevAnimTime( SbTime previous );
750
755
760
768 virtual void setMPEGRecorder( SoMPEGRenderer* recorder );
769
774
778 void viewX( bool reverse = false );
779
783 void viewY( bool reverse = false );
784
788 void viewZ( bool reverse = false );
789
795
797 //* Examiner algorithms *//
799
806 virtual void spinCamera( const SbVec2f& newLocator );
807
819 virtual void spinConstrainedCamera( const SbVec2f& newLocator, int axisIndex );
820
825
830
834 virtual void doSpinAnimation();
835
844
850
855
860 void rotateCamera( const SbRotation& rot );
861
871 void constrainCameraRotation( bool x = false, bool y = false, bool z = false );
872
874 //* Plane algorithms *//
876
881 void setPlane( const SbVec3f& newNormal, const SbVec3f& newRight );
882
884 //* Fly algorithms *//
886
891
896
900 void setMinSpeed( float speed );
901
905 float getMinSpeed() const;
906
910 void setMaxSpeed( float speed );
911
915 float getMaxSpeed() const;
916
920 void setSpeedLimit( float limit );
921
925 float getSpeedLimit() const;
926
930 void setCurrentSpeed( float speed );
931
935 float getCurrentSpeed() const;
936
940 void setMaxStraightSpeed( float speed );
941
945 float getMaxStraightSpeed() const;
946
950 void setMaxSpeedInc( float increment );
951
955 float getMaxSpeedInc() const;
956
961
966
971
973 //* Walk algorithms *//
975
989
994
999
1004
1009
1014
1020
1021private:
1022
1023 void setMMode( int mode );
1024 int getMMode() const;
1025
1026 // Utility method to project and get rotation on SheetProjector at once
1027 int sheetProjProjectAndGetRotation( const SbVec2f& newLocator, SbRotation& rot );
1028
1029private:
1030 // Destructor.
1031 virtual ~SoGuiAlgoViewers();
1032
1033 SbProjector* makeSheetProjector( const ProjectorsType &mode );
1034
1035private:
1036 static void spinAnimationSensorCB( void* v, SoSensor* sensor ); // Examiner
1037 static void constrainedAnimationSensorCB( void* v, SoSensor* sensor ); // Fly and walk
1038 static void setFocalPointFinishCallback( void* data, void* v ); // Walk viewer only
1039 static void mouseWheelMotionAlarmSensorCB(void *data, SoSensor *sensor); // mouse wheel motion
1040
1041 void rotateCameraAboutVwCenter( const SbRotation& rot );
1042 void rotateCameraWithRotTarget( const SbRotation& rot );
1043 void rotateCameraWithRotTargetCore( const SbRotation& rot );
1044 void rotateCameraWithRotTargetDec( const SbRotation& rot );
1045 void mouseWheelMotion_( float newVal, float &scaleFactor );
1046 void screenToFocalPlanePoint( const SbVec2s &pxPoint, SbVec3f &worldPoint, SbPlane *focPlane = NULL );
1047 void screenNormToFocalPlanePoint( const SbVec2f &normPoint, SbVec3f &worldPoint, SbPlane *fplane = NULL );
1048 void sheetProjProjectAndGetRotationCore( const SbVec2f& newLocator, SbRotation& rot );
1049
1050
1051 int m_mode;
1052 SbBool m_constrained; // Used to determine whether the algorithm to use is for constrained viewers.
1053 ViewerTypes m_vType; // Current viewer type.
1054 SbBool m_boxDrawing, m_boxSelection, m_firstActivation;
1055 SoExtSelection* m_selection;
1056 SoSwitch* m_selectionSwitch;
1057
1058 SbVec2s m_locator, m_prevPos, m_startPos; // mouse position
1059
1060 // Sensors for animations
1061 SoFieldSensor* m_seekAnimationSensor;
1062 SoFieldSensor* m_spinAnimationSensor;
1063 SoFieldSensor* m_walkAnimationSensor;
1064 SoFieldSensor* m_flyAnimationSensor;
1065
1066 SoAlarmSensor* m_mouseWheelMotionAlarmSensor;
1067
1068 // variables used for spinning animation
1069 SbProjector* m_sheetProjector;
1070 ProjectorsType m_projectorType;
1071
1072 SbBool m_computeAverage;
1073 SbRotation m_averageRotation;
1074 SbRotation* m_rotBuffer;
1075 int m_firstIndex, m_lastIndex;
1076 SbVec3s m_constrainedAxis;
1077
1078 // Camera translation vars.
1079 SbVec3f m_locator3D;
1080 SbPlane m_focalplane;
1081
1082 // Plane viewer.
1083 void computeTranslateValues();
1084 float m_transXspeed, m_transYspeed;
1085
1086 // Fly viewer.
1087 float m_minSpeed, m_maxInc, m_speedLimit;
1088 float m_speed, m_maxSpeed, m_maxStraightSpeed;
1089 SbTime m_prevAnimTime;
1090
1091 // Walk viewer.
1092 WalkViewerMode m_wvMode;
1093 SbBool m_walkAnimation;
1094
1095 // Rotation temp data
1096 SbVec2f* m_lastRotStepLocator; // during the projection and get rotation
1097 double m_mouseAngularSpeed;
1098 ZoomingType m_zoomingType;
1099 SbVec3f *m_rotationTargetPosition;
1100};
1101
1102#endif // SO_GUI_ALGO_VIEWERS
1103
1104
Oriented plane in 3D.
Definition SbPlane.h:64
Base class for representing projectors.
Definition SbProjector.h:85
Class for representing a rotation.
Definition SbRotation.h:126
Sphere-sheet projector.
Class for representation of a time.
Definition SbTime.h:91
2D vector class.
Definition SbVec.h:76
2D vector class.
Definition SbVec.h:700
3D vector class.
Definition SbVec.h:932
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> 3D vector class.
Definition SbVec.h:1797
Triggers a delegate once sometime in the future.
Abstract base class for camera nodes.
Definition SoCamera.h:188
Node representing a directional light source.
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Selection node t...
Sensor class that can be attached to Open Inventor fields.
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Common algorithm...
virtual void recomputeSceneSize()
This can be used to let the viewer know that the scene graph has changed so that the viewer can recom...
virtual void rollCamera(const SbVec2s &newLocator)
Rolls the camera based on cursor motion.
virtual void adjustCameraClippingPlanes()
Auto clipping routine.
void interactiveCountInc()
Invokes the start viewing callbacks.
SbProjector * getSheetProjector() const
Returns the sheet projector.
SbBool isHeadlight()
Returns TRUE if the headlight is on.
virtual void setPreserveCameraHeightAngle(SbBool flag)
If TRUE, an SoPerspectiveCamera's heightAngle is preserved if the camera is changed to an SoOrthograp...
void startFlyAnimation()
Starts the walk animation.
SbVec2s getPreviousMousePositionLocator() const
Returns the previous mouse position in pixels.
SbVec2s getCurrentMousePositionLocator() const
Returns the current mouse position in pixels.
void setBoxSelectionMode(SbBool on)
Sets box selection mode.
ViewerTypes
Viewer type flags.
@ EXAMINER
Algorithms for examiner viewer.
@ PLANE
Algorithms for plane viewer.
@ WALK
Algorithms for walk viewer.
@ FLY
Algorithms for fly viewer.
@ UNKNOWN
Unknown: default value.
virtual void resetToHomePosition()
Restores the camera values.
DrawType
List of possible drawing types.
@ INTERACTIVE
Applies to rendering while interactive viewing.
@ STILL
Applies to static rendering.
void updateCameraFocalPoint()
Updates focal distance.
float getCurrentSpeed() const
Returns the current speed.
SoDirectionalLight * getHeadlight()
Returns the headlight node.
void resetRenderAction()
This method resets the render action cache.
void setBoxDrawingMode(SbBool on)
Sets box drawing mode.
void setMaxSpeedInc(float increment)
Sets maximum speed multiplier.
virtual void bottomWheelStart()
Initializes bottom thumb wheel.
void doCameraAnimation()
Does camera animation for constrained viewers.
virtual void computeSeekFinalOrientation()
Keeps the same camera rotation when seeking.
ZoomingType
List of possible zooming modes.
@ GIVENPOSITION
Uses as the zooming center a point provided by the application through the setCurrentMousePositionLoc...
@ AUTOCENTER
Around the viewport center.
void setSheetProjectionType(const ProjectorsType &projType)
Specifies the sheet projection to use for rotations.
void setMaxSpeed(float speed)
Sets the maximum speed.
float getSpeedLimit() const
Returns the speed limit.
virtual SoMPEGRenderer * getMPEGRecorder() const
Returns the recorder used for MPEG encoding.
virtual void doSpinAnimation()
Rotate the camera for spin animation.
virtual SoNode * getSceneGraph()
Returns the scene graph to render.
virtual void reverseDollyCamera(const SbVec2s &newLocator)
Same as dollyCamera but reversed.
SoGuiAlgoViewers::ViewerTypes getViewerType() const
Returns the current viewer type.
void activateSpinning()
Set sphere sheet starting point and resets the animation queue.
double getMouseAngularSpeed()
Returns the factor used to scale the rotation speed while interactively rotating the camera.
SbBool isConstrained() const
Returns TRUE if algorithms for constrained viewers are used.
SoGuiAlgoViewers::WalkViewerMode getWalkViewerAnimMode() const
Returns the current mode for the walk viewer camera animation.
virtual void spinConstrainedCamera(const SbVec2f &newLocator, int axisIndex)
Spin the camera based on cursor motion but constrained to rotation around one axis.
BufferType getBufferingType()
Returns the current buffering type in the main view.
SbPlane getCameraFocalPlane() const
Returns the camera focal position.
SbVec3f getCameraPositionLocator() const
Returns the camera position.
virtual void mouseWheelMotion(float newVal)
Makes the camera to zoom based on mouse wheel motion.
ProjectorsType
List of possible projection modes for the virtual trackball.
@ SPHERICAL
Spherical rotation (the classic Open Inventor algorithm).
@ CYLINDRICAL
Cylindrical rotation.
void setMaxStraightSpeed(float speed)
Sets the maximum straight speed.
virtual void setBufferingType(BufferType type)
Sets the current buffering type in the main view (default BUFFER_DOUBLE).
void startWalkAnimation()
Starts the walk animation.
void setPrevAnimTime(SbTime previous)
Sets the previous animation time.
ProjectorsType getSheetProjectionType() const
Returns the sheet projection used for rotations.
void setViewerType(ViewerTypes vType)
Sets the type of viewer used for the algorithms.
void stopWalkAnimation()
Stops the walk animation.
virtual void setViewing(SbBool flag)
Sets whether the viewer is turned on or off.
void viewZ(bool reverse=false)
Selects sagittal view.
void rotateCamera(const SbRotation &rot)
Rotates the camera around focal point by given incremental rotation (Given rotation is concatenated o...
SbBool isBoxSelection() const
Returns TRUE if box selection mode is enabled.
float getMaxSpeedInc() const
Returns maximum speed multiplier.
virtual void resetRotationTargetPosition()
Reset target position to default rotation around "focal point".
SoNode * getSceneRoot()
Returns the scene root of the viewer (drawstyle, camera and headlight + user scene graph) or the user...
void setPreviousMousePositionLocator(const SbVec2s &mousePosition)
Sets the previous mouse position.
void setConstrained(SbBool constrained)
Specifies whether algorithms for constrained viewers should be used.
virtual void setSeekMode(SbBool onOrOff)
Set the viewer into/out of seek mode (default OFF).
void calculateMaxSpeed()
Calculates the maximum speed of the animation.
void setCameraFocalPlane(const SbPlane &focalPlane)
Sets the camera focal plane.
void setWalkViewerAnimMode(WalkViewerMode mode)
Sets the camera animation for walk viewers regarding the mode.
float getMaxSpeed() const
Returns the maximum speed.
virtual void viewAll()
Changes the camera position to view the entire scene (the camera zoom or orientation isn't changed).
void viewY(bool reverse=false)
Selects frontal view.
virtual void setHeadlight(SbBool insertFlag)
Turns the headlight on/off (default on).
void setCurrentSpeed(float speed)
Sets the current speed.
DrawStyle getDrawStyle(DrawType type)
Returns the current drawing style in the main view.
float getMinSpeed() const
Returns the minimum speed.
virtual bool getRotationTargetPosition(SbVec3f &targetPos)
Query the camera target position for rotations.
void setPlane(const SbVec3f &newNormal, const SbVec3f &newRight)
Moves the camera to be aligned with the given plane.
virtual void setSceneGraph(SoNode *newScene)
Sets the scene graph to render.
void setStartMousePositionLocator(const SbVec2s &mousePosition)
Sets the mouse start position.
void enableShadows(bool onOrOff)
Adds an SoShadowGroup after the headlight and enables it if true.
virtual SbBool isCameraHeightAnglePreserved() const
Queries whether the SoPerspectiveCamera's heightAngle is preserved if the camera is changed to an SoO...
WalkViewerMode
Walk viewer mode flags.
@ PAN_MODE
Panning mode.
@ WALK_MODE
Walking mode (default).
void interactiveCountDec()
Invokes the finish viewing callbacks.
virtual void panCamera(const SbVec2f &newLocator)
Pans the camera based on cursor motion.
void changeMaxStraightSpeed(SbBool increase)
Computes the maximum straight speed.
virtual void setRotationTargetPosition(const SbVec3f &targetPos)
Sets the camera target position for rotations.
SbBool isViewing() const
Returns TRUE if the viewer is in viewing mode.
void viewX(bool reverse=false)
Selects axial view.
float getMaxStraightSpeed() const
Returns the maximum straight speed.
SoCamera * getCamera()
Gets the edited camera.
void stopSpinAnimation()
Stops the spin animation.
void constrainCameraRotation(bool x=false, bool y=false, bool z=false)
Constrains the camera to spin around the specified axis.
void activateFlying()
Initializes flying animation.
void startSpinAnimation()
Starts the spin animation.
SbBool isBoxDrawing() const
Returns TRUE if box drawing mode is enabled.
virtual void dollyCamera(const SbVec2s &newLocator)
Moves the camera on the z axis based on cursor motion.
virtual void spinCamera(const SbVec2f &newLocator)
Spins the camera based on cursor motion.
virtual void bottomWheelMotion(float newVal)
Examiner and constrained viewers: Rotates the camera based on bottom wheel motion.
void setSpeedLimit(float limit)
Sets the speed limit.
virtual void leftWheelStart()
Initializes left thumb wheel.
void stopFlyAnimation()
Stops the walk animation.
SoType getCameraType()
Gets the camera type that will be created by the viewer if no cameras are found in the scene graph (s...
virtual void rightWheelMotion(float newVal)
Makes the camera to zoom based on right wheel motion.
virtual void saveHomePosition()
Saves the camera values.
SbVec2s getStartMousePositionLocator() const
Returns the mouse start position in pixels.
ZoomingType getZoomingType() const
Returns the zooming algorithm.
virtual void dollyCamera(float dist)
Moves the camera forward by the given amount.
void setZoomingType(const ZoomingType &zoomType)
Specifies the zooming algorithm to use.
BufferType
List of different buffering types.
@ BUFFER_SINGLE
Single buffer.
@ BUFFER_INTERACTIVE
Double buffer while interactive viewing.
@ BUFFER_DOUBLE
Double buffer.
virtual void toggleCameraType()
This routine will toggle the current camera from perspective to orthographic, and from orthographic b...
virtual void getDefaultRotationTargetPosition(SbVec3f &targetPos)
Gets the default camera target position for rotations.
void setCameraPositionLocator(const SbVec3f &camPosition)
Sets the camera position.
void setMinSpeed(float speed)
Sets the minimum speed.
virtual void setCameraType(SoType type)
Sets the camera type that will be created by the viewer if no cameras are found in the scene graph (s...
void setMouseAngularSpeed(double speedFactor)
Specifies the factor used to scale the rotation speed while interactively rotating the camera.
SbTime getPrevAnimTime() const
Returns the previous animation time.
virtual void leftWheelMotion(float newVal)
Examiner and constrained viewers: Rotates the camera based on left wheel motion.
void doBoxZoom(int x1, int y1, int x2, int y2)
Zooms to the region delimited by the box.
SbSphereSheetProjector * getSphereSheetProjector() const
Returns the sphere sheet projector and NULL if the current projection is not spherical.
void activatePanning()
Updates camera position when panning is actived.
DrawStyle
List of possible drawing styles.
@ VIEW_LOW_COMPLEXITY
Render low complexity and no texture.
@ VIEW_SAME_AS_STILL
Forces the INTERACTIVE draw style to match STILL.
@ VIEW_LINE
Wireframe draw style.
@ VIEW_BBOX
Bounding box draw style.
@ VIEW_LOW_RES_LINE
Low complexity wireframe + no depth clearing.
@ VIEW_POINT
Point draw style.
@ VIEW_NO_TEXTURE
Render without textures.
@ VIEW_HIDDEN_LINE
Render only the frontmost lines.
@ VIEW_LOW_RES_POINT
Low complexity point + no depth clearing.
SbBool isSeekMode()
Returns TRUE if viewer is in seek mode.
virtual void rightWheelStart()
Initializes right thumb wheel.
void rotateCamera()
Rotates the camera around focal point by given incremental rotation (Given rotation is concatenated o...
SoGuiAlgoViewers()
Constructor.
virtual void setMPEGRecorder(SoMPEGRenderer *recorder)
Sets the recorder used for MPEG encoding.
void setCurrentMousePositionLocator(const SbVec2s &mousePosition)
Sets the current mouse position.
virtual void setCamera(SoCamera *newCamera)
Sets the edited camera.
virtual void setDrawStyle(DrawType type, DrawStyle style)
Sets the current drawing style in the main view.
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Base class for g...
Abstract base class for all database nodes.
Definition SoNode.h:145
Abstract base class for Open Inventor sensors.
Definition SoSensor.h:100
Group node that traverses one chosen child.
Definition SoSwitch.h:179
Stores runtime type information.
Definition SoType.h:98
int SbBool
Boolean type.
Definition SbBase.h:87