00001 /*======================================================================= 00002 *** THE CONTENT OF THIS WORK IS PROPRIETARY TO FEI S.A.S, (FEI S.A.S.), *** 00003 *** AND IS DISTRIBUTED UNDER A LICENSE AGREEMENT. *** 00004 *** *** 00005 *** REPRODUCTION, DISCLOSURE, OR USE, IN WHOLE OR IN PART, OTHER THAN AS *** 00006 *** SPECIFIED IN THE LICENSE ARE NOT TO BE UNDERTAKEN EXCEPT WITH PRIOR *** 00007 *** WRITTEN AUTHORIZATION OF FEI S.A.S. *** 00008 *** *** 00009 *** RESTRICTED RIGHTS LEGEND *** 00010 *** USE, DUPLICATION, OR DISCLOSURE BY THE GOVERNMENT OF THE CONTENT OF THIS *** 00011 *** WORK OR RELATED DOCUMENTATION IS SUBJECT TO RESTRICTIONS AS SET FORTH IN *** 00012 *** SUBPARAGRAPH (C)(1) OF THE COMMERCIAL COMPUTER SOFTWARE RESTRICTED RIGHT *** 00013 *** CLAUSE AT FAR 52.227-19 OR SUBPARAGRAPH (C)(1)(II) OF THE RIGHTS IN *** 00014 *** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 52.227-7013. *** 00015 *** *** 00016 *** COPYRIGHT (C) 1996-2020 BY FEI S.A.S, *** 00017 *** BORDEAUX, FRANCE *** 00018 *** ALL RIGHTS RESERVED *** 00019 **=======================================================================*/ 00020 /*======================================================================= 00021 ** Author : VSG (MMM YYYY) 00022 **=======================================================================*/ 00023 00024 00025 00026 #ifndef _SO_WIN_CONSTRAINED_VIEWER_ 00027 #define _SO_WIN_CONSTRAINED_VIEWER_ 00028 00029 #include <Inventor/Win/SoWinBeginStrict.h> 00030 00031 #include <Inventor/Win/viewers/SoWinFullViewer.h> 00032 #include <Inventor/SbBox.h> 00033 00034 #include <Inventor/Gui/viewers/SoGuiConstrainedViewer.h> 00035 00037 // 00038 // Class: SoWinConstrainedViewer 00039 // 00041 00064 class SoWinConstrainedViewer : public SoWinFullViewer 00065 { 00066 public: 00067 00073 void setUpDirection( const SbVec3f& newUpDirection ); 00074 00078 SbVec3f getUpDirection() { return m_guiConstViewer->getUpDirection(); } 00079 00080 // 00081 // redefine these to add constrained viewer functionality 00082 // 00083 virtual void setCamera( SoCamera *newCam ); 00084 virtual void saveHomePosition(); 00085 virtual void resetToHomePosition(); 00086 virtual void recomputeSceneSize(); 00087 00088 private: 00089 00090 SoGuiConstrainedViewer* getGuiConstrainedViewer() const; 00091 00092 SoWinConstrainedViewer( SoWidget parent, 00093 const char* name, 00094 SbBool buildInsideParent, 00095 SoWinFullViewer::BuildFlag flag, 00096 SoWinViewer::Type type, 00097 SbBool buildNow, 00098 SbBool sync = TRUE ); 00099 00100 // Retro compatibility only 00101 SbVec3f upDirection; 00102 float sceneHeight, sceneSize; 00103 00104 private: 00105 00106 SoWinConstrainedViewer( SoWidget parent, 00107 const char* name, 00108 SbBool buildInsideParent, 00109 SoWinFullViewer::BuildFlag flag, 00110 SoWinViewer::Type type, 00111 SbBool buildNow, 00112 SbBool sync, 00113 SoGuiConstrainedViewer* guiConstViewer ); 00114 00115 ~SoWinConstrainedViewer(); 00116 00117 // Tilts the camera, restraining it to 180 degree rotation from the 00118 // up direction. A positive angle tilts the camera up. 00119 virtual void tiltCamera( float deltaAngle ); 00120 00121 // Moves the camera forward by the given amount 00122 virtual void dollyCamera( float dist ); 00123 00124 // Redefine these to do constrained viewing tasks. 00125 // The bottom wheel rotates the camera around the up direction, the 00126 // left wheel tilts the camera up/down constraning to 180 degree from 00127 // the up direction. The right wheel moves the camera forward/backward 00128 // withough constrain (taking the scene size into account). 00129 virtual void bottomWheelMotion( float newVal ); 00130 virtual void leftWheelMotion( float newVal ); 00131 virtual void rightWheelMotion( float newVal ); 00132 virtual void mouseWheelMotion( float newVal ); 00133 00134 // This is called during a paste. 00135 // We redefine this to keep the right vector of the camera 00136 // in a parallel plane. 00137 virtual void changeCameraValues( SoCamera* newCamera ); 00138 00139 // this routine is called by subclasses to find and set the new 00140 // up direction given the current mouse position. If something is 00141 // picked, the normal to the object picked will be used to specify 00142 // the new up direction. 00143 void findUpDirection( const SbVec2s& mouseLocation ); 00144 00145 // this routine checks the camera orientation and makes sure that the 00146 // current right vector and the ideal right vector (cross between the 00147 // view vector and world up direction) are the same (i.e. no unwanted 00148 // roll), else it fixes it. This keeps the up direction valid. 00149 void checkForCameraUpConstrain(); 00150 00151 // Redefine this to keep the up vector when seeking 00152 virtual void computeSeekFinalOrientation(); 00153 00154 private: 00155 00156 void constructorCommon( SbBool buildNow ); 00157 00158 SoGuiConstrainedViewer* m_guiConstViewer; // Implementation class of SoXxConstrainedViewer 00159 }; 00160 00161 #include <Inventor/Win/SoWinEndStrict.h> 00162 00163 #endif /* _SO_WIN_CONSTRAINED_VIEWER_ */ 00164 00165