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 00169 class SoXtWalkViewer : public SoXtConstrainedViewer { 00170 public: 00171 00176 SoXtWalkViewer( SoWidget parent = NULL, 00177 const char* name = NULL, 00178 SbBool buildInsideParent = TRUE, 00179 SoXtFullViewer::BuildFlag flag = SoXtFullViewer::BUILD_ALL, 00180 SoXtViewer::Type type = SoXtViewer::BROWSER ); 00184 ~SoXtWalkViewer(); 00185 00186 // 00187 // redefine these to add Walk viewer functionality 00188 // 00189 virtual void setViewing( SbBool onOrOff ); 00190 virtual void setCamera( SoCamera *cam ); 00191 virtual void setCursorEnabled( SbBool onOrOff ); 00192 virtual void setSeekMode( SbBool onOrOff ); 00193 00194 // This is redefined to prevent the camera type from being changed 00195 virtual void setCameraType( SoType type ); 00196 00200 void setViewerSpeed( float speed ) { m_guiWalkViewer->setViewerSpeed( speed ); } 00201 00205 float getViewerSpeed() const { return m_guiWalkViewer->getViewerSpeed(); } 00206 00207 private: 00208 00209 SoGuiWalkViewer* getGuiWalkViewer() const; 00210 00211 // This constructor takes a boolean whether to build the widget now. 00212 // Subclasses can pass FALSE, then call SoXtWalkViewer::buildWidget() 00213 // when they are ready for it to be built. 00214 private: 00215 SoXtWalkViewer( SoWidget parent, 00216 const char* name, 00217 SbBool buildInsideParent, 00218 SoXtFullViewer::BuildFlag flag, 00219 SoXtViewer::Type type, 00220 SbBool buildNow, 00221 SbBool sync = TRUE ); 00222 00223 private: 00224 // redefine these 00225 virtual SbString getDefaultWidgetName() const; 00226 virtual SbString getDefaultTitle() const; 00227 virtual SbString getDefaultIconTitle() const; 00228 00229 // redefine those routines to do viewer specific stuff 00230 virtual void processEvent( XAnyEvent* anyevent ); 00231 virtual void actualRedraw(); 00232 virtual void rightWheelMotion( float ); 00233 00234 // redefine this to add the extra thumbwheel on the left side 00235 virtual SoWidget buildLeftTrim( SoWidget parent ); 00236 00237 // add viewer preference stuff 00238 virtual void createPrefSheet(); 00239 00240 // Define this to bring the viewer help card 00241 virtual void openViewerHelpCard(); 00242 00243 virtual void updateCursor(); 00244 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