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-2014 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 00063 class SoWinConstrainedViewer : public SoWinFullViewer 00064 { 00065 public: 00066 00072 void setUpDirection( const SbVec3f& newUpDirection ); 00073 00077 SbVec3f getUpDirection() { return m_guiConstViewer->getUpDirection(); } 00078 00079 // 00080 // redefine these to add constrained viewer functionality 00081 // 00082 virtual void setCamera( SoCamera *newCam ); 00083 virtual void saveHomePosition(); 00084 virtual void resetToHomePosition(); 00085 virtual void recomputeSceneSize(); 00086 00087 private: 00088 00089 SoGuiConstrainedViewer* getGuiConstrainedViewer() const; 00090 00091 SoWinConstrainedViewer( SoWidget parent, 00092 const char* name, 00093 SbBool buildInsideParent, 00094 SoWinFullViewer::BuildFlag flag, 00095 SoWinViewer::Type type, 00096 SbBool buildNow, 00097 SbBool sync = TRUE ); 00098 00099 // Retro compatibility only 00100 SbVec3f upDirection; 00101 float sceneHeight, sceneSize; 00102 00103 private: 00104 00105 SoWinConstrainedViewer( SoWidget parent, 00106 const char* name, 00107 SbBool buildInsideParent, 00108 SoWinFullViewer::BuildFlag flag, 00109 SoWinViewer::Type type, 00110 SbBool buildNow, 00111 SbBool sync, 00112 SoGuiConstrainedViewer* guiConstViewer ); 00113 00114 ~SoWinConstrainedViewer(); 00115 00116 // Tilts the camera, restraining it to 180 degree rotation from the 00117 // up direction. A positive angle tilts the camera up. 00118 virtual void tiltCamera( float deltaAngle ); 00119 00120 // Moves the camera forward by the given amount 00121 virtual void dollyCamera( float dist ); 00122 00123 // Redefine these to do constrained viewing tasks. 00124 // The bottom wheel rotates the camera around the up direction, the 00125 // left wheel tilts the camera up/down constraning to 180 degree from 00126 // the up direction. The right wheel moves the camera forward/backward 00127 // withough constrain (taking the scene size into account). 00128 virtual void bottomWheelMotion( float newVal ); 00129 virtual void leftWheelMotion( float newVal ); 00130 virtual void rightWheelMotion( float newVal ); 00131 virtual void mouseWheelMotion( float newVal ); 00132 00133 // This is called during a paste. 00134 // We redefine this to keep the right vector of the camera 00135 // in a parallel plane. 00136 virtual void changeCameraValues( SoCamera* newCamera ); 00137 00138 // this routine is called by subclasses to find and set the new 00139 // up direction given the current mouse position. If something is 00140 // picked, the normal to the object picked will be used to specify 00141 // the new up direction. 00142 void findUpDirection( const SbVec2s& mouseLocation ); 00143 00144 // this routine checks the camera orientation and makes sure that the 00145 // current right vector and the ideal right vector (cross between the 00146 // view vector and world up direction) are the same (i.e. no unwanted 00147 // roll), else it fixes it. This keeps the up direction valid. 00148 void checkForCameraUpConstrain(); 00149 00150 // Redefine this to keep the up vector when seeking 00151 virtual void computeSeekFinalOrientation(); 00152 00153 private: 00154 00155 void constructorCommon( SbBool buildNow ); 00156 00157 SoGuiConstrainedViewer* m_guiConstViewer; // Implementation class of SoXxConstrainedViewer 00158 }; 00159 00160 #include <Inventor/Win/SoWinEndStrict.h> 00161 00162 #endif /* _SO_WIN_CONSTRAINED_VIEWER_ */ 00163 00164