Open Inventor Release 2024.1.3
 
Loading...
Searching...
No Matches
SoWinExaminerViewer.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-2023 BY FEI S.A.S, ***
17 *** BORDEAUX, FRANCE ***
18 *** ALL RIGHTS RESERVED ***
19**=======================================================================*/
20/*=======================================================================
21** Author : VSG (MMM YYYY)
22**=======================================================================*/
23
24
25
26#ifndef _SO_WIN_EXAMINER_VIEWER_
27#define _SO_WIN_EXAMINER_VIEWER_
28
29#include <Inventor/Win/SoWinBeginStrict.h>
30
31#include <Inventor/Win/viewers/SoWinFullViewer.h>
32#include <Inventor/events/SoMouseButtonEvent.h>
33#include <Inventor/Gui/viewers/SoGuiExaminerViewer.h>
34
35// classes used
37class SoFieldSensor;
38class SoSeparator;
39class SoSwitch;
40class SoTranslation;
41class SoScale;
42class SoWinBitmapButton;
43
45//
46// Class: SoWinExaminerViewer
47//
48// Examiner viewer - allows the user to change the camera position
49// by spinning a sphere in front of the viewpoint.
50//
51//
52// Keys used by this viewer:
53// -------------------------
54//
55// Left Mouse: Tumbles the virtual trackball.
56//
57// Middle Mouse:
58// Ctrl + Left Mouse: Translate up, down, left and right.
59//
60// Ctrl + Middle Mouse:
61// Left + Middle Mouse: Dolly in and out (gets closer to and further
62// away from the object).
63//
64// Shift + Ctrl + Left Mouse: Dolly in and out (same as Left + Middle
65// behavior but added by VSG to support the
66// standard Microsoft 2-button mouse).
67//
68// <s> + click: Alternative to the Seek button. Press (but do not hold
69// down) the <s> key, then click on a target object.
70//
71// Right Mouse: Open the popup menu.
72//
74
188{
189
190 public:
191
224
249
258 SoWinExaminerViewer( SoWidget parent = NULL,
259 const char* name = NULL,
260 SbBool buildInsideParent = TRUE,
267
274 void setViewingMode( ViewingMode viewingMode ) ;
275
280 { return (ViewingMode)m_guiExamViewer->getViewingMode(); }
281
294
299 { return m_constrainedMode; }
300
302 // Constrained viewer.
316 {
317 public:
321 void setViewer(SoWinViewer* viewer) { m_viewer = viewer; }
322
326 virtual void apply() const = 0;
327
328 private:
329 SoWinViewer* m_viewer;
330 };
331
349 {
350 private:
354 void apply() const;
355 };
356
370 {
371 private:
375 void apply() const;
376 };
377
392 {
393 private:
397 void apply() const;
398 };
399
413 {
414 private:
418 void apply() const;
419 };
420
434 {
435 private:
439 void apply() const;
440 };
441
455 {
456 private:
460 void apply() const;
461 };
462
476 {
477 private:
481 void apply() const;
482 };
483
497 {
498 private:
502 void apply() const;
503 };
504
518 {
519 private:
523 void apply() const;
524 };
525
540 {
541 private:
545 void apply() const;
546 };
547
562 {
563 private:
567 void apply() const;
568 };
569
583 {
584 private:
588 void apply() const;
589 };
590
601 virtual void addFunctionKeyBinding( SoKeyboardEvent::Key key, const SoViewingFunction* viewingFunc );
602
607
657 virtual void addViewingMouseBinding( SoKeyboardEvent::Key* keys = NULL,
658 int numKey = 0,
659 SoMouseButtonEvent::Button *mouseBtn = NULL,
660 int numMouseBtn = 0,
661 const SoViewingFunction *viewingFunc = NULL );
669 int numKeys = 0,
670 SoMouseButtonEvent::Button* mouseBtn = NULL,
671 int numMouseBtn = 0 );
672
673 // End Constrained viewer.
674
676 // Defines the list of functions that supports this viewer.
678
684
688 SbBool isFeedbackVisible() const { return m_guiExamViewer->isFeedbackVisible(); }
689
693 void setFeedbackSize( int newSize );
694
698 int getFeedbackSize() const { return m_guiExamViewer->getFeedbackSize(); }
699
708
712 SbBool isAnimationEnabled() { return m_guiExamViewer->isAnimationEnabled(); }
713
718
722 SbBool isAnimating() { return m_guiExamViewer->isAnimating(); }
723
724 // redefine these to add Examiner viewer functionality
725 virtual void viewAll();
726 virtual void resetToHomePosition();
727 virtual void setCamera( SoCamera* cam );
728 virtual void setViewing( SbBool onOrOff );
729 virtual void setCursorEnabled( SbBool onOrOff );
730 virtual void setSeekMode( SbBool onOrOff );
731
742 virtual void activateSpinning( const SbVec2s& newLocator );
743
754 virtual void activatePanning( const SbVec2s& newLocator );
755
766 virtual void activateDolly( const SbVec2s& newLocator );
767
778 virtual void activateRoll( const SbVec2s& newLocator );
779
786 virtual void rollCamera( const SbVec2s &newLocator );
787
794 virtual void spinCamera( const SbVec2f &newLocator );
795
806 virtual void spinConstrainedCamera( const SbVec2f& newLocator, int axisIndex );
807
816 virtual void dollyCamera( const SbVec2s &newLocator );
817
824 virtual void reverseDollyCamera( const SbVec2s& newLocator );
825
832 virtual void panCamera( const SbVec2f& newLocator );
833
834 private:
835
836 SoGuiExaminerViewer* getGuiExaminerViewer() const;
837
838 private:
839
844 virtual void rotateCamera( const SbRotation& rot );
845
855 void constrainCameraRotation( bool x = false, bool y = false, bool z = false );
856
857 private:
858
859 // This constructor takes a boolean whether to build the widget now.
860 // Subclasses can pass FALSE, then call SoWinExaminerViewer::buildWidget()
861 // when they are ready for it to be built.
862 SoEXTENDER
863 SoWinExaminerViewer( SoWidget parent,
864 const char* name,
865 SbBool buildInsideParent,
867 SoWinViewer::Type type,
868 SbBool buildNow,
869 SbBool sync = TRUE );
870
871 // redefine these
872 virtual SbString getDefaultWidgetName() const;
873 virtual SbString getDefaultTitle() const;
874 virtual SbString getDefaultIconTitle() const;
875
876 // redefine those routines to do viewer specific stuff
877 virtual void processEvent( XAnyEvent* anyevent );
878 virtual void actualRedraw();
879
880 // Get X resources for the widget.
881 SoWidget buildWidget( SoWidget parent );
882
883 // Define those thumb wheels to rotate the object
884 virtual void bottomWheelMotion( float newVal );
885 virtual void leftWheelMotion( float newVal );
886 virtual void rightWheelMotion( float newVal );
887 virtual void mouseWheelMotion( float newVal );
888
889 // redefine those routines to also stop animation if any
890 virtual void bottomWheelStart();
891 virtual void leftWheelStart();
892
893 // add viewer preference stuff
894 virtual void createPrefSheet();
895
896 // add some viewer buttons
897 virtual void createViewerButtons( SoWidget parent );
898
899 // build examiner viewer specific popup menu
900 // Note: Examiner viewer uses a slightly different popup menu
901 // resource that has two more items in the preferences submenu.
902 virtual void buildPopupMenu();
903
904 // Define this to bring the viewer help card
905 virtual void openViewerHelpCard();
906
907 // It's a long story, but since we can't attach callbacks to a window
908 // quite like we can to an Xt widget, it makes more sense for the
909 // subclass viewer to handle the buttons it knows about then pass
910 // the rest back up to SoWinFullViewer.
911 //
912 // So WINxx this function must be virtual and protected, not private.
913 virtual void pushButtonCB( SoWidget w, int id, void* data );
914
915 virtual void doSpinAnimation();
916
917 virtual void updateCursor();
918
919 private:
920 SoGuiExaminerViewer* m_guiExamViewer; // Implementation class for SoXxExaminerViewer
921
922 // Viewer state variables
923 SoGuiExaminerViewer::ViewingSpinType m_viewingSpinType;
924 ConstrainedViewingMode m_constrainedMode; // Constrained viewing type
925
926 SbBool firstBuild; // set FALSE after buildWidget called once
927
928 // point of rotation feedback vars
929 static char* geometryBuffer;
930
931 // variables used for doing spinning animation
932 long lastMotionTime;
933 static void visibilityChangeCB( void* pt, SbBool visible );
934
935 private:
936
937 // viewer state variables
938 int m_mouseReady;
939 SbBool m_viewingOnOffFlag;
940
941 int m_prevFlag;
942
943 // Members used to return in the previous mode after using binding function:
944 // Set to true when a binding function start.
945 SbBool m_needToBeReset;
946 // Viewer mode before launching binding function.
947 int m_prevCursorMode;
948
949 void updateViewerMode( unsigned int state );
950 void switchMode( int newMode );
951 void setViewerMode();
952
953 // push button vars and callbacks
954 SoWinBitmapButton* buttonList[10];
955 static void camPushCB( SoWidget w, SoWinExaminerViewer* v, void* data );
956
957 // this is called by both constructors
958 void constructorCommon( SbBool buildNow );
959
960 // Utility function called from processEvent
961 void processPopupItem( int item );
962};
963
964#include <Inventor/Win/SoWinEndStrict.h>
965
966#endif /* _SO_WIN_EXAMINER_VIEWER_ */
967
Class for representing a rotation.
Definition SbRotation.h:126
Sphere-sheet projector.
Class for smart character strings.
Definition SbString.h:202
2D vector class.
Definition SbVec.h:76
2D vector class.
Definition SbVec.h:700
Abstract base class for camera nodes.
Definition SoCamera.h:188
Sensor class that can be attached to Open Inventor fields.
Key
The keyboard keys.
Node representing a 3D geometric scaling.
Definition SoScale.h:96
Group node that saves and restores traversal state.
Group node that traverses one chosen child.
Definition SoSwitch.h:179
Node representing a 3D translation.
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Viewing Function...
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Viewing Function...
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Viewing Function...
void setViewer(SoWinViewer *viewer)
Sets the viewer that the function applies to.
virtual void apply() const =0
Applies this manipulation to a specified combination of key and mouse button.
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Viewing Function...
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Viewing Function...
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Viewing Function...
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Viewing Function...
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Viewing Function...
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Viewing Function...
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Viewing Function...
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Viewing Function...
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Viewing Function...
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Viewing Function...
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Viewer component...
ConstrainedViewingMode
Constrained viewing mode.
@ CONSTRAINED_VIEWING_MODE_Z
Constrains camera rotation around Z axis.
@ CONSTRAINED_VIEWING_MODE_Y
Constrains camera rotation around Y axis.
@ CONSTRAINED_VIEWING_MODE_X
Constrains camera rotation around X axis.
@ NONE
No axis constraints.
virtual void activateDolly(const SbVec2s &newLocator)
Sets the start locator for dolly camera animation.
virtual void dollyCamera(const SbVec2s &newLocator)
Move the camera on the z axis based on cursor motion.
ViewingMode getViewingMode() const
Gets the current viewing mode.
virtual void addViewingMouseBinding(SoKeyboardEvent::Key *keys=NULL, int numKey=0, SoMouseButtonEvent::Button *mouseBtn=NULL, int numMouseBtn=0, const SoViewingFunction *viewingFunc=NULL)
Adds a new mouse binding to the viewer.
int getFeedbackSize() const
Returns the point of rotation feedback size in pixels.
virtual void setSeekMode(SbBool onOrOff)
Externally set the viewer into/out off seek mode (default OFF).
virtual void viewAll()
Changes the camera position to view the entire scene (the camera zoom or orientation isn't changed).
virtual void reverseDollyCamera(const SbVec2s &newLocator)
Same as dollyCamera but reversed.
virtual void setCursorEnabled(SbBool onOrOff)
Sets whether the viewer is allowed to change the cursor over the renderArea window.
void setFeedbackSize(int newSize)
Sets the point of rotation feedback size in pixels (default 20 pix).
virtual void resetToHomePosition()
Restores the camera values.
ConstrainedViewingMode getConstrainedViewingMode() const
Returns the current constrained viewing mode.
SoWinExaminerViewer(SoWidget parent=NULL, const char *name=NULL, SbBool buildInsideParent=TRUE, SoWinFullViewer::BuildFlag flag=SoWinFullViewer::BUILD_ALL, SoWinViewer::Type type=SoWinViewer::BROWSER)
Constructor which specifies the viewer type.
SbBool isAnimationEnabled()
Returns whether spin animation is enabled.
virtual void activateRoll(const SbVec2s &newLocator)
Sets the start locator for roll camera animation.
@ VIEWING_MODE_ZOOM
Dolly/Zoom (move forward and backward) to get closer to or further away from the point of interest.
@ VIEWING_MODE_SPIN_CONSTRAINED
Same as VIEWING_MODE_SPIN but add also constrained camera rotation.
@ VIEWING_MODE_PAN
Translate the camera in the viewer plane.
@ VIEWING_MODE_SPIN
Rotate the camera around the point of interest.
void setViewingMode(ViewingMode viewingMode)
Sets the viewing mode.
virtual void addFunctionKeyBinding(SoKeyboardEvent::Key key, const SoViewingFunction *viewingFunc)
Adds a new function key binding to the viewer.
void setAnimationEnabled(SbBool onOrOff)
Enables/disables the spin animation feature of the viewer (enabled by default).
virtual void activateSpinning(const SbVec2s &newLocator)
Sets the start locator for spin camera animation.
SbBool isAnimating()
Queries if the viewer is currently animating.
virtual void spinCamera(const SbVec2f &newLocator)
Spin the camera based on cursor motion.
virtual void activatePanning(const SbVec2s &newLocator)
Sets the start locator for pan camera animation.
void setFeedbackVisibility(SbBool onOrOff)
Shows/hides the point of rotation feedback, which only appears while in viewing mode (default is off)...
virtual void removeViewingMouseBinding(SoKeyboardEvent::Key *keys=NULL, int numKeys=0, SoMouseButtonEvent::Button *mouseBtn=NULL, int numMouseBtn=0)
Removes a mouse binding (if it exists).
virtual void rollCamera(const SbVec2s &newLocator)
Roll the camera based on cursor motion.
void setConstrainedViewingMode(ConstrainedViewingMode mode)
Sets the constrained viewing mode.
void stopAnimating()
Stops animation, if it is occurring.
virtual void panCamera(const SbVec2f &newLocator)
Pans the camera based on cursor motion.
virtual void removeFunctionKeyBinding(SoKeyboardEvent::Key functionKey)
Removes the specified function key binding (if it exists).
SbBool isFeedbackVisible() const
Returns the rotation feedback flag.
~SoWinExaminerViewer()
Destructor.
virtual void spinConstrainedCamera(const SbVec2f &newLocator, int axisIndex)
Spin the constrained camera based on cursor motion.
virtual void setViewing(SbBool onOrOff)
Sets whether the viewer is turned on or off.
virtual void setCamera(SoCamera *cam)
Sets the camera that will be controlled by the viewer.
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Base viewer clas...
BuildFlag
This specifies what should be build by default in the constructor.
@ BUILD_ALL
Build everything by default.
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Viewer component...
Type
An EDITOR viewer will create a camera under the user supplied scene graph (specified in setSceneGraph...
@ BROWSER
Camera views scene, but is not added to scene.
int SbBool
Boolean type.
Definition SbBase.h:87