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-2023 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/SoQtFlyViewer.h> 00052 #elif defined _WIN32 00053 # include <Inventor/Win/viewers/SoWinFlyViewer.h> 00054 #else // _WIN32 00055 00056 #ifndef _SO_XT_FLY_VIEWER_ 00057 #define _SO_XT_FLY_VIEWER_ 00058 00059 #include <Inventor/Xt/viewers/SoXtConstrainedViewer.h> 00060 #include <Inventor/SbLinear.h> 00061 #include <Inventor/SbTime.h> 00062 #include <Inventor/Gui/viewers/SoGuiFlyViewer.h> 00063 00064 class SoFieldSensor; 00065 00067 // 00068 // Class: SoXtFlyViewer 00069 // 00070 // 00071 // Keys used by this viewer: 00072 // ------------------------- 00073 // 00074 // Left Mouse: Click to increase speed. 00075 // 00076 // <s> + Left Mouse: Alternative to the Seek button. Press (but do not 00077 // hold down) the <s> key, then click on a target object. 00078 // 00079 // <U> + Left Mouse: Press (but do not hold down) the <U> key, then 00080 // click on a target object to set the "up" direction to the surface normal. 00081 // By default +y is the "up" direction. 00082 // 00083 // Middle Mouse: Click to decrease speed. 00084 // 00085 // Left and Middle Mouse: Click boths simultaneously to stop. 00086 // 00087 // Ctrl: Hold the key down to temporary stop and rotate the viewpoint. 00088 // 00089 // Right Mouse: Open the popup menu. 00090 // 00092 00169 class SoXtFlyViewer : public SoXtConstrainedViewer 00170 { 00171 public: 00172 00177 SoXtFlyViewer( 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 ); 00182 00186 ~SoXtFlyViewer(); 00187 00188 // redefine these to add fly viewer functionality 00189 virtual void setViewing( SbBool onOrOff ); 00190 virtual void resetToHomePosition(); 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 00198 // set/get minimum speed in word coodinate / second 00199 // default value is 0, meaning the minimum speed is computed according to scene graph extent 00200 void setMinSpeed( float speed ); 00201 float getMinSpeed(); 00202 00203 // set/get speed multiplier. default value is 1.5 00204 void setSpeedMultiplier( float speedInc ); 00205 float getSpeedMultiplier(); 00206 00207 private: 00208 00209 SoGuiFlyViewer* getGuiFlyViewer() const; 00210 00211 // This constructor takes a boolean whether to build the widget now. 00212 // Subclasses can pass FALSE, then call SoXtFlyViewer::buildWidget() 00213 // when they are ready for it to be built. 00214 private: 00215 SoXtFlyViewer( 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 newVal ); 00233 00234 // add viewer preference stuff 00235 virtual void createPrefSheet(); 00236 00237 // Define this to bring the viewer help card 00238 virtual void openViewerHelpCard(); 00239 00240 private: 00241 // viewer state variables 00242 Cursor viewerCursor, seekCursor, upCursor; 00243 SbRotation camStartOrientation; 00244 00245 // preference sheet stuff 00246 SoWidget createFlyPrefSheetGuts( SoWidget parent ); 00247 static void incPrefSheetButtonCB( SoWidget w, SoXtFlyViewer* v, void* data); 00248 static void decPrefSheetButtonCB( SoWidget w, SoXtFlyViewer* v, void* data ); 00249 00250 void defineCursors(); 00251 void switchMode( int newMode ); 00252 void changeMaxStraightSpeed( SbBool increase ); 00253 00254 // this is called by both constructors 00255 void constructorCommon( SbBool buildNow ); 00256 00257 SoGuiFlyViewer* m_guiFlyViewer; 00258 }; 00259 00260 #endif /* _SO_XT_FLY_VIEWER_ */ 00261 00262 #endif // _WIN32 00263 00264 00265