Open Inventor Release 2024.1.3
 
Loading...
Searching...
No Matches
SoXtWalkViewer.h
1/*=======================================================================
2 * Copyright 1991-1996, Silicon Graphics, Inc.
3 * ALL RIGHTS RESERVED
4 *
5 * UNPUBLISHED -- Rights reserved under the copyright laws of the United
6 * States. Use of a copyright notice is precautionary only and does not
7 * imply publication or disclosure.
8 *
9 * U.S. GOVERNMENT RESTRICTED RIGHTS LEGEND:
10 * Use, duplication or disclosure by the Government is subject to restrictions
11 * as set forth in FAR 52.227.19(c)(2) or subparagraph (c)(1)(ii) of the Rights
12 * in Technical Data and Computer Software clause at DFARS 252.227-7013 and/or
13 * in similar or successor clauses in the FAR, or the DOD or NASA FAR
14 * Supplement. Contractor/manufacturer is Silicon Graphics, Inc.,
15 * 2011 N. Shoreline Blvd. Mountain View, CA 94039-7311.
16 *
17 * THE CONTENT OF THIS WORK CONTAINS CONFIDENTIAL AND PROPRIETARY
18 * INFORMATION OF SILICON GRAPHICS, INC. ANY DUPLICATION, MODIFICATION,
19 * DISTRIBUTION, OR DISCLOSURE IN ANY FORM, IN WHOLE, OR IN PART, IS STRICTLY
20 * PROHIBITED WITHOUT THE PRIOR EXPRESS WRITTEN PERMISSION OF SILICON
21 * GRAPHICS, INC.
22**=======================================================================*/
23/*=======================================================================
24** Author : Alain Dumesny (MMM yyyy)
25**=======================================================================*/
26/*=======================================================================
27 *** THE CONTENT OF THIS WORK IS PROPRIETARY TO FEI S.A.S, (FEI S.A.S.), ***
28 *** AND IS DISTRIBUTED UNDER A LICENSE AGREEMENT. ***
29 *** ***
30 *** REPRODUCTION, DISCLOSURE, OR USE, IN WHOLE OR IN PART, OTHER THAN AS ***
31 *** SPECIFIED IN THE LICENSE ARE NOT TO BE UNDERTAKEN EXCEPT WITH PRIOR ***
32 *** WRITTEN AUTHORIZATION OF FEI S.A.S. ***
33 *** ***
34 *** RESTRICTED RIGHTS LEGEND ***
35 *** USE, DUPLICATION, OR DISCLOSURE BY THE GOVERNMENT OF THE CONTENT OF THIS ***
36 *** WORK OR RELATED DOCUMENTATION IS SUBJECT TO RESTRICTIONS AS SET FORTH IN ***
37 *** SUBPARAGRAPH (C)(1) OF THE COMMERCIAL COMPUTER SOFTWARE RESTRICTED RIGHT ***
38 *** CLAUSE AT FAR 52.227-19 OR SUBPARAGRAPH (C)(1)(II) OF THE RIGHTS IN ***
39 *** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 52.227-7013. ***
40 *** ***
41 *** COPYRIGHT (C) 1996-2020 BY FEI S.A.S, ***
42 *** BORDEAUX, FRANCE ***
43 *** ALL RIGHTS RESERVED ***
44**=======================================================================*/
45/*=======================================================================
46** Modified by : VSG (MMM YYYY)
47**=======================================================================*/
48
49
50#ifdef SOQT
51# include <Inventor/Qt/viewers/SoQtWalkViewer.h>
52#elif defined _WIN32
53# include <Inventor/Win/viewers/SoWinWalkViewer.h>
54#else // _WIN32
55
56#ifndef _SO_XT_WALK_VIEWER_
57#define _SO_XT_WALK_VIEWER_
58
59#include <Inventor/Xt/viewers/SoXtConstrainedViewer.h>
60#include <Inventor/SbLinear.h>
61#include <Inventor/SbTime.h>
62#include <Inventor/Gui/viewers/SoGuiWalkViewer.h>
63
64class SoFieldSensor;
65
67//
68// Class: SoXtWalkViewer
69//
70// Walk Viewer - changes the camera position by simulating the constrain
71// on someone walking. The up direction is kept at all times, and the camera
72// is moved keeping the eye level the same, regardless of whether the person
73// is looking down or up (looking direction is constrained to 180 degree).
74//
75//
76// Keys used by this viewer:
77// -------------------------
78//
79// Left Mouse: walk mode. Click down and move up/down for fowards/backwards
80// motion. Move right and left for turning. Speed increases
81// exponentially with the distance from the mouse-down origin.
82//
83// Middle Mouse:
84// Ctrl + Left Mouse: Translate up, down, left and right.
85//
86// Ctrl + Middle Mouse: tilt the camera up/down and right/left. This
87// allows you to look around while stopped.
88//
89// <s> + click: Alternative to the Seek button. Press (but do not hold down)
90// the <s> key, then click on a target object.
91//
92// <U> + click: Press (but do not hold down) the <U> key, then
93// click on a target object to set the "up" direction to the surface
94// normal. By default +y is the "up" direction.
95//
96// Right Mouse: Open the popup menu.
97//
99
170 public:
171
176 SoXtWalkViewer( SoWidget parent = NULL,
177 const char* name = NULL,
178 SbBool buildInsideParent = TRUE,
179 SoXtFullViewer::BuildFlag flag = SoXtFullViewer::BUILD_ALL,
180 SoXtViewer::Type type = SoXtViewer::BROWSER );
185
186 //
187 // redefine these to add Walk viewer functionality
188 //
189 virtual void setViewing( SbBool onOrOff );
190 virtual void setCamera( SoCamera *cam );
191 virtual void setCursorEnabled( SbBool onOrOff );
192 virtual void setSeekMode( SbBool onOrOff );
193
194 // This is redefined to prevent the camera type from being changed
195 virtual void setCameraType( SoType type );
196
200 void setViewerSpeed( float speed ) { m_guiWalkViewer->setViewerSpeed( speed ); }
201
205 float getViewerSpeed() const { return m_guiWalkViewer->getViewerSpeed(); }
206
207 private:
208
209 SoGuiWalkViewer* getGuiWalkViewer() const;
210
211 // This constructor takes a boolean whether to build the widget now.
212 // Subclasses can pass FALSE, then call SoXtWalkViewer::buildWidget()
213 // when they are ready for it to be built.
214 private:
215 SoXtWalkViewer( SoWidget parent,
216 const char* name,
217 SbBool buildInsideParent,
218 SoXtFullViewer::BuildFlag flag,
219 SoXtViewer::Type type,
220 SbBool buildNow,
221 SbBool sync = TRUE );
222
223 private:
224 // redefine these
225 virtual SbString getDefaultWidgetName() const;
226 virtual SbString getDefaultTitle() const;
227 virtual SbString getDefaultIconTitle() const;
228
229 // redefine those routines to do viewer specific stuff
230 virtual void processEvent( XAnyEvent* anyevent );
231 virtual void actualRedraw();
232 virtual void rightWheelMotion( float );
233
234 // redefine this to add the extra thumbwheel on the left side
235 virtual SoWidget buildLeftTrim( SoWidget parent );
236
237 // add viewer preference stuff
238 virtual void createPrefSheet();
239
240 // Define this to bring the viewer help card
241 virtual void openViewerHelpCard();
242
243 virtual void updateCursor();
244
245 private:
246 SoGuiWalkViewer* m_guiWalkViewer;
247
248 // viewer state variables
249 Cursor walkCursor, panCursor, tiltCursor, seekCursor, upCursor;
250
251 // extra decoration vars
252 int heightWheelVal;
253 static void heightWheelCB( SoWidget w, SoXtWalkViewer* p, XtPointer* d );
254
255 SbTime prevAnimTime;
256
257 void updateViewerMode( unsigned int state );
258 void switchMode( int newMode );
259 void defineCursors();
260
261 // this is called by both constructors
262 void constructorCommon( SbBool buildNow );
263};
264
265#endif /* _SO_XT_WALK_VIEWER_ */
266
267#endif // _WIN32
268
269
Class for smart character strings.
Definition SbString.h:202
Class for representation of a time.
Definition SbTime.h:91
Abstract base class for camera nodes.
Definition SoCamera.h:188
Sensor class that can be attached to Open Inventor fields.
Stores runtime type information.
Definition SoType.h:98
Base viewer class which adds camera constraints given a world up direction.
Viewer component which moves the camera in a plane.
SoXtWalkViewer(SoWidget parent=NULL, const char *name=NULL, SbBool buildInsideParent=TRUE, SoXtFullViewer::BuildFlag flag=SoXtFullViewer::BUILD_ALL, SoXtViewer::Type type=SoXtViewer::BROWSER)
Constructor which specifies the viewer type.
~SoXtWalkViewer()
Destructor.
virtual void setSeekMode(SbBool onOrOff)
Externally set the viewer into/out off seek mode (default OFF).
virtual void setCamera(SoCamera *cam)
Sets the edited camera.
virtual void setViewing(SbBool onOrOff)
Sets whether the viewer is turned on or off.
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 setViewerSpeed(float speed)
Set viewer speed multiplier (default is 1)
float getViewerSpeed() const
Get viewer speed multiplier.
virtual void setCursorEnabled(SbBool onOrOff)
Sets whether the viewer is allowed to change the cursor over the renderArea window.
int SbBool
Boolean type.
Definition SbBase.h:87
void * XtPointer
Definition SoQtDef.h:122