Open Inventor Release 2024.1.3
 
Loading...
Searching...
No Matches
SoGuiConstrainedViewer.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-2014 BY FEI S.A.S, ***
17 *** BORDEAUX, FRANCE ***
18 *** ALL RIGHTS RESERVED ***
19**=======================================================================*/
20/*=======================================================================
21** Author : T.MEHAMLI (Jun 2007)
22**=======================================================================*/
23
24#ifndef SO_GUI_CONSTRAINED_VIEWER
25#define SO_GUI_CONSTRAINED_VIEWER
26
28//
29// Class: SoGuiConstrainedViewer
30//
31// SoXXViewer implementation class
32//
33//
35
36#include <Inventor/Gui/viewers/SoGuiFullViewer.h>
37
38#ifndef HIDDEN_FROM_DOC
39 // Defines
40# define MIN_ANGLE ( 5*M_PI/180. ) // minimum angle between look at
41 // direction and up direction (in rad)
42#endif
43
44
46{
47#ifndef HIDDEN_FROM_DOC
48 SO_FIELDCONTAINER_HEADER( SoGuiConstrainedViewer );
49#endif
50
51private:
56
62 void setUpDirection( const SbVec3f& newUpDirection );
63
67 SbVec3f getUpDirection();
68
69 // Accessor and mutator for the member m_sceneSize;
70 void setSceneSize( float size );
71 float getSceneSize () const;
72
73 // Accessor and mutator for the member m_sceneHeight;
74 void setSceneHeight( float height );
75 float getSceneHeight () const;
76
77 // ----------------------- Extension usage -----------------------------------
78
79 //
80 // redefine these to add constrained viewer functionality
81 //
82 virtual void setCamera( SoCamera* newCam );
83 virtual void saveHomePosition();
84 virtual void resetToHomePosition();
85 virtual void recomputeSceneSize();
86
87 // Tilts the camera, restraining it to 180 degree rotation from the
88 // up direction. A positive angle tilts the camera up.
89 virtual void tiltCamera( float deltaAngle );
90
91 // Moves the camera forward by the given amount
92 virtual void dollyCamera( float dist );
93
94 // Redefine these to do constrained viewing tasks.
95 // The bottom wheel rotates the camera around the up direction, the
96 // left wheel tilts the camera up/down constraning to 180 degree from
97 // the up direction. The right wheel moves the camera forward/backward
98 // withough constrain (taking the scene size into account).
99 virtual void bottomWheelMotion( float newVal );
100 virtual void leftWheelMotion( float newVal );
101 virtual void rightWheelMotion( float newVal );
102 virtual void mouseWheelMotion( float newVal );
103
104 // This is called during a paste.
105 // We redefine this to keep the right vector of the camera
106 // in a parallel plane.
107 virtual void changeCameraValues( SoCamera* newCamera );
108
109 // this routine is called by subclasses to find and set the new
110 // up direction given the current mouse position. If something is
111 // picked, the normal to the object picked will be used to specify
112 // the new up direction.
113 void findUpDirection( const SbVec2s& mouseLocation );
114
115 // this routine checks the camera orientation and makes sure that the
116 // current right vector and the ideal right vector (cross between the
117 // view vector and world up direction) are the same (i.e. no unwanted
118 // roll), else it fixes it. This keeps the up direction valid.
119 void checkForCameraUpConstrain();
120
121 // Redefine this to keep the up vector when seeking
122 virtual void computeSeekFinalOrientation();
123
124private:
128 virtual ~SoGuiConstrainedViewer();
129
130 // ----------------------- Private usage -------------------------------------
131
132 private:
133
134 SbVec3f m_origUpDirection; // used to save/reset
135 SbVec3f m_upDirection;
136 float m_sceneHeight;
137
138 float m_sceneSize;
139};
140
141#endif // SO_GUI_CONSTRAINED_VIEWER
142
2D vector class.
Definition SbVec.h:700
3D vector class.
Definition SbVec.h:932
Abstract base class for camera nodes.
Definition SoCamera.h:188