00001 /*======================================================================= 00002 * Copyright 1991-1996, Silicon Graphics, Inc. 00003 * ALL RIGHTS RESERVED 00004 * 00005 * UNPUBLISHED -- Rights reserved under the copyright laws of the United 00006 * States. Use of a copyright notice is precautionary only and does not 00007 * imply publication or disclosure. 00008 * 00009 * U.S. GOVERNMENT RESTRICTED RIGHTS LEGEND: 00010 * Use, duplication or disclosure by the Government is subject to restrictions 00011 * as set forth in FAR 52.227.19(c)(2) or subparagraph (c)(1)(ii) of the Rights 00012 * in Technical Data and Computer Software clause at DFARS 252.227-7013 and/or 00013 * in similar or successor clauses in the FAR, or the DOD or NASA FAR 00014 * Supplement. Contractor/manufacturer is Silicon Graphics, Inc., 00015 * 2011 N. Shoreline Blvd. Mountain View, CA 94039-7311. 00016 * 00017 * THE CONTENT OF THIS WORK CONTAINS CONFIDENTIAL AND PROPRIETARY 00018 * INFORMATION OF SILICON GRAPHICS, INC. ANY DUPLICATION, MODIFICATION, 00019 * DISTRIBUTION, OR DISCLOSURE IN ANY FORM, IN WHOLE, OR IN PART, IS STRICTLY 00020 * PROHIBITED WITHOUT THE PRIOR EXPRESS WRITTEN PERMISSION OF SILICON 00021 * GRAPHICS, INC. 00022 **=======================================================================*/ 00023 /*======================================================================= 00024 ** Author : Alain Dumesny (MMM yyyy) 00025 **=======================================================================*/ 00026 /*======================================================================= 00027 *** THE CONTENT OF THIS WORK IS PROPRIETARY TO FEI S.A.S, (FEI S.A.S.), *** 00028 *** AND IS DISTRIBUTED UNDER A LICENSE AGREEMENT. *** 00029 *** *** 00030 *** REPRODUCTION, DISCLOSURE, OR USE, IN WHOLE OR IN PART, OTHER THAN AS *** 00031 *** SPECIFIED IN THE LICENSE ARE NOT TO BE UNDERTAKEN EXCEPT WITH PRIOR *** 00032 *** WRITTEN AUTHORIZATION OF FEI S.A.S. *** 00033 *** *** 00034 *** RESTRICTED RIGHTS LEGEND *** 00035 *** USE, DUPLICATION, OR DISCLOSURE BY THE GOVERNMENT OF THE CONTENT OF THIS *** 00036 *** WORK OR RELATED DOCUMENTATION IS SUBJECT TO RESTRICTIONS AS SET FORTH IN *** 00037 *** SUBPARAGRAPH (C)(1) OF THE COMMERCIAL COMPUTER SOFTWARE RESTRICTED RIGHT *** 00038 *** CLAUSE AT FAR 52.227-19 OR SUBPARAGRAPH (C)(1)(II) OF THE RIGHTS IN *** 00039 *** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 52.227-7013. *** 00040 *** *** 00041 *** COPYRIGHT (C) 1996-2020 BY FEI S.A.S, *** 00042 *** BORDEAUX, FRANCE *** 00043 *** ALL RIGHTS RESERVED *** 00044 **=======================================================================*/ 00045 /*======================================================================= 00046 ** Modified by : VSG (MMM YYYY) 00047 **=======================================================================*/ 00048 00049 00050 #ifdef SOQT 00051 # include <Inventor/Qt/viewers/SoQtWalkViewer.h> 00052 #elif defined _WIN32 00053 # include <Inventor/Win/viewers/SoWinWalkViewer.h> 00054 #else // _WIN32 00055 00056 #ifndef _SO_XT_WALK_VIEWER_ 00057 #define _SO_XT_WALK_VIEWER_ 00058 00059 #include <Inventor/Xt/viewers/SoXtConstrainedViewer.h> 00060 #include <Inventor/SbLinear.h> 00061 #include <Inventor/SbTime.h> 00062 #include <Inventor/Gui/viewers/SoGuiWalkViewer.h> 00063 00064 class SoFieldSensor; 00065 00067 // 00068 // Class: SoXtWalkViewer 00069 // 00070 // Walk Viewer - changes the camera position by simulating the constrain 00071 // on someone walking. The up direction is kept at all times, and the camera 00072 // is moved keeping the eye level the same, regardless of whether the person 00073 // is looking down or up (looking direction is constrained to 180 degree). 00074 // 00075 // 00076 // Keys used by this viewer: 00077 // ------------------------- 00078 // 00079 // Left Mouse: walk mode. Click down and move up/down for fowards/backwards 00080 // motion. Move right and left for turning. Speed increases 00081 // exponentially with the distance from the mouse-down origin. 00082 // 00083 // Middle Mouse: 00084 // Ctrl + Left Mouse: Translate up, down, left and right. 00085 // 00086 // Ctrl + Middle Mouse: tilt the camera up/down and right/left. This 00087 // allows you to look around while stopped. 00088 // 00089 // <s> + click: Alternative to the Seek button. Press (but do not hold down) 00090 // the <s> key, then click on a target object. 00091 // 00092 // <U> + click: Press (but do not hold down) the <U> key, then 00093 // click on a target object to set the "up" direction to the surface 00094 // normal. By default +y is the "up" direction. 00095 // 00096 // Right Mouse: Open the popup menu. 00097 // 00099 00170 class SoXtWalkViewer : public SoXtConstrainedViewer { 00171 public: 00172 00177 SoXtWalkViewer( SoWidget parent = NULL, 00178 const char* name = NULL, 00179 SbBool buildInsideParent = TRUE, 00180 SoXtFullViewer::BuildFlag flag = SoXtFullViewer::BUILD_ALL, 00181 SoXtViewer::Type type = SoXtViewer::BROWSER ); 00185 ~SoXtWalkViewer(); 00186 00187 // 00188 // redefine these to add Walk viewer functionality 00189 // 00190 virtual void setViewing( SbBool onOrOff ); 00191 virtual void setCamera( SoCamera *cam ); 00192 virtual void setCursorEnabled( SbBool onOrOff ); 00193 virtual void setSeekMode( SbBool onOrOff ); 00194 00195 // This is redefined to prevent the camera type from being changed 00196 virtual void setCameraType( SoType type ); 00197 00201 void setViewerSpeed( float speed ) { m_guiWalkViewer->setViewerSpeed( speed ); } 00202 00206 float getViewerSpeed() const { return m_guiWalkViewer->getViewerSpeed(); } 00207 00208 private: 00209 00210 SoGuiWalkViewer* getGuiWalkViewer() const; 00211 00212 // This constructor takes a boolean whether to build the widget now. 00213 // Subclasses can pass FALSE, then call SoXtWalkViewer::buildWidget() 00214 // when they are ready for it to be built. 00215 private: 00216 SoXtWalkViewer( SoWidget parent, 00217 const char* name, 00218 SbBool buildInsideParent, 00219 SoXtFullViewer::BuildFlag flag, 00220 SoXtViewer::Type type, 00221 SbBool buildNow, 00222 SbBool sync = TRUE ); 00223 00224 private: 00225 // redefine these 00226 virtual SbString getDefaultWidgetName() const; 00227 virtual SbString getDefaultTitle() const; 00228 virtual SbString getDefaultIconTitle() const; 00229 00230 // redefine those routines to do viewer specific stuff 00231 virtual void processEvent( XAnyEvent* anyevent ); 00232 virtual void actualRedraw(); 00233 virtual void rightWheelMotion( float ); 00234 00235 // redefine this to add the extra thumbwheel on the left side 00236 virtual SoWidget buildLeftTrim( SoWidget parent ); 00237 00238 // add viewer preference stuff 00239 virtual void createPrefSheet(); 00240 00241 // Define this to bring the viewer help card 00242 virtual void openViewerHelpCard(); 00243 00244 virtual void updateCursor(); 00245 private: 00246 SoGuiWalkViewer* m_guiWalkViewer; 00247 00248 // viewer state variables 00249 Cursor walkCursor, panCursor, tiltCursor, seekCursor, upCursor; 00250 00251 // extra decoration vars 00252 int heightWheelVal; 00253 static void heightWheelCB( SoWidget w, SoXtWalkViewer* p, XtPointer* d ); 00254 00255 SbTime prevAnimTime; 00256 00257 void updateViewerMode( unsigned int state ); 00258 void switchMode( int newMode ); 00259 void defineCursors(); 00260 00261 // this is called by both constructors 00262 void constructorCommon( SbBool buildNow ); 00263 }; 00264 00265 #endif /* _SO_XT_WALK_VIEWER_ */ 00266 00267 #endif // _WIN32 00268 00269 00270