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