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 #if defined(_WIN32) 00026 # include <Inventor/Win/viewers/SoWinConstrainedViewer.h> 00027 #else // _WIN32 00028 00029 #ifndef _SO_XT_MP_CONSTRAINED_VIEWER_ 00030 #define _SO_XT_MP_CONSTRAINED_VIEWER_ 00031 00032 #include <Inventor/MP/Xt/viewers/SoXtMPFullViewer.h> 00033 #include <Inventor/SbBox.h> 00034 00035 00037 // 00038 // Class: SoXtConstrainedViewer 00039 // 00041 00066 class SoXtMPConstrainedViewer : public SoXtMPFullViewer { 00067 public: 00068 00074 void setUpDirection(const SbVec3f &newUpDirection); 00078 SbVec3f getUpDirection() { return upDirection; } 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 SoXtMPConstrainedViewer( 00090 SoWidget parent, 00091 const char *name, 00092 SbBool buildInsideParent, 00093 SoXtMPFullViewer::BuildFlag flag, 00094 SoXtMPViewer::Type type, 00095 SbBool buildNow); 00096 ~SoXtMPConstrainedViewer(); 00097 00098 SbVec3f upDirection; 00099 float sceneHeight; 00100 00101 // Tilts the camera, restraining it to 180 degree rotation from the 00102 // up direction. A positive angle tilts the camera up. 00103 virtual void tiltCamera(float deltaAngle); 00104 00105 // Redefine these to do constrained viewing tasks. 00106 // The bottom wheel rotates the camera around the up direction, the 00107 // left wheel tilts the camera up/down constraning to 180 degree from 00108 // the up direction. 00109 virtual void bottomWheelMotion(float newVal); 00110 virtual void leftWheelMotion(float newVal); 00111 00112 // This is called during a paste. 00113 // We redefine this to keep the right vector of the camera 00114 // in a parallel plane. 00115 virtual void changeCameraValues(SoCamera *newCamera); 00116 00117 // this routine is called by subclasses to find and set the new 00118 // up direction given the current mouse position. If something is 00119 // picked, the normal to the object picked will be used to specify 00120 // the new up direction. 00121 void findUpDirection(const SbVec2s &mouseLocation); 00122 00123 // this routine checks the camera orientation and makes sure that the 00124 // current right vector and the ideal right vector (cross between the 00125 // view vector and world up direction) are the same (i.e. no unwanted 00126 // roll), else it fixes it. This keeps the up direction valid. 00127 void checkForCameraUpConstrain(); 00128 00129 // Redefine this to keep the up vector when seeking 00130 virtual void computeSeekFinalOrientation(); 00131 00132 private: 00133 SbVec3f origUpDirection; // used to save/reset 00134 00135 }; 00136 00137 #endif /* _SO_XT_CONSTRAINED_VIEWER_ */ 00138 00139 #endif // _WIN32 00140 00141 00142