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 : Alain Dumesny (MMM yyyy) 00022 **=======================================================================*/ 00023 00024 00025 #ifndef _SO_QT_CONSTRAINED_VIEWER_ 00026 #define _SO_QT_CONSTRAINED_VIEWER_ 00027 #include <Inventor/Qt/OivQtCompat.h> 00028 #include <Inventor/Qt/viewers/SoQtFullViewer.h> 00029 #include <Inventor/SbBox.h> 00030 00031 #include <Inventor/Gui/viewers/SoGuiConstrainedViewer.h> 00032 00034 // 00035 // Class: SoQtConstrainedViewer 00036 // 00038 00061 class SoQtConstrainedViewer : public SoQtFullViewer 00062 { 00063 00064 Q_OBJECT 00065 00066 public: 00067 00073 void setUpDirection( const SbVec3f& newUpDirection ); 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 SoGuiConstrainedViewer* getGuiConstrainedViewer() const; 00089 00090 // Retro compatibility only 00091 SbVec3f upDirection; 00092 float sceneHeight, sceneSize; 00093 00094 private: 00095 00096 SoQtConstrainedViewer( QWidget* parent, 00097 const char* name, 00098 SbBool buildInsideParent, 00099 SoQtFullViewer::BuildFlag flag, 00100 SoQtViewer::Type type, 00101 SbBool buildNow, 00102 SbBool sync = true ); 00103 00104 SoQtConstrainedViewer( QWidget* parent, 00105 const char* name, 00106 SbBool buildInsideParent, 00107 SoQtFullViewer::BuildFlag flag, 00108 SoQtViewer::Type type, 00109 SbBool buildNow, 00110 SbBool sync, 00111 SoGuiConstrainedViewer* guiConstViewer ); 00112 00113 private: 00114 ~SoQtConstrainedViewer(); 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 SoGuiConstrainedViewer* m_guiConstViewer; // Implementation class of SoXxConstrainedViewer 00157 }; 00158 00159 #endif /* _SO_QT_CONSTRAINED_VIEWER_ */ 00160 00161