00001 // Define a view (within a render area) 00002 // 00003 // Mike Heck, FEI/VSG, November 2016 00004 00006 // 00007 // This class is part of the Open Inventor Medical utility library. 00008 // 00009 // The medical utility classes are provided as a prebuilt library named 00010 // "fei_inventor_medical", that can be used directly in an Open Inventor 00011 // application. The classes in the prebuilt library are documented and 00012 // supported by FEI. These classes are also provided as source code. 00013 // 00014 // Please see $OIVHOME/include/Medical/InventorMedical.h for the full text. 00015 // 00017 00018 #ifndef _SCENE_VIEW_H_ 00019 #define _SCENE_VIEW_H_ 00020 00021 // Note: Full header files are required to use SoRef on member variables. 00022 #include <Inventor/nodes/SoLineSet.h> 00023 #include <Inventor/nodes/SoSeparator.h> 00024 #include <Inventor/nodes/SoSwitch.h> 00025 #include <Inventor/nodes/SoViewport.h> 00026 00027 #include <Inventor/fields/SoSFBool.h> 00028 #include <Inventor/fields/SoSFNode.h> 00029 #include <Inventor/fields/SoSFVec2f.h> 00030 #include <Inventor/SbViewportRegion.h> 00031 00032 #include <Medical/InventorMedical.h> 00033 00034 class SoAction; 00035 class SoNodeSensor; 00036 00134 class INVENTORMEDICAL_API SceneView : public SoSeparator { 00135 00136 SO_NODE_HEADER(SceneView); 00137 00138 public: 00139 00144 SoSFVec2f viewportOrigin; 00145 00150 SoSFVec2f viewportSize; 00151 00153 SoSFBool active; 00154 00164 SoSFBool drawBorder; 00165 00166 00169 void setViewport( float origX, float origY, float sizeX, float sizeY ); 00170 00173 void setViewport( const SbVec4f& viewport ); 00174 00176 const SbVec4f& getViewport() const; 00177 00180 const SbViewportRegion& getViewportRegion() const; 00181 00183 const SbVec4f& getViewportPixels() const; 00184 00189 void enableEventHandling( SbBool onoff ); 00190 00192 static void initClass(); 00193 00195 static void exitClass(); 00196 00198 SceneView(); 00199 00200 private: 00201 00203 virtual void addChild( SoNode* child ); 00204 virtual int findChild( const SoNode* child ) const; 00205 virtual SoNode* getChild( int index ) const; 00206 virtual void insertChild( SoNode* child, int newChildIndex ); 00207 virtual void removeChild( SoNode* child ); 00208 virtual void removeChild( int index ); 00209 virtual void removeAllChildren(); 00210 virtual void replaceChild( SoNode* oldChild, SoNode* newChild ); 00211 virtual void replaceChild( int index, SoNode* newChild ); 00212 virtual int getNumChildren() const; 00213 00214 private: 00216 virtual ~SceneView(); 00217 00218 // Internal helpers 00219 void viewportFieldChanged(); 00220 void viewportParentChanged( const SbViewportRegion& vpregion ); 00221 void updateOurViewport(); 00222 static void callback(void* userData, SoAction* action); 00223 00224 // Internal state 00225 SbVec4f m_curViewport; // Current viewport in normalized coords 00226 SbViewportRegion m_vportRegion; // Used to answer queries 00227 00228 SbVec4f m_viewport; // What we actually set (pixels) as float 00229 SbVec4i32 m_viewportPixels; // What we actually set (pixels) as int 00230 SbVec2i32 m_viewportOrig; // What we actually set (pixels) 00231 SbVec2i32 m_viewportSize; // What we actually set (pixels) 00232 00233 SbVec2i32 m_parentOrig; // What we inherited (pixels) 00234 SbVec2i32 m_parentSize; // What we inherited (pixels) 00235 00236 SoRef<SoSwitch> m_masterSwitch; // Internal scene graph 00237 SoRef<SoViewport> m_vportNode; 00238 SoRef<SoSeparator> m_sceneNode; 00239 SoRef<SoSwitch> m_borderSwitch; 00240 SoRef<SoLineSet> m_borderLine; 00241 00242 bool m_handleEvents; // See enableEventHandling() method. 00243 00244 SoNodeSensor* m_sensor; 00245 bool m_ignoreSensor; // Used to temporarily disable sensor 00246 static void sensorCB( void* data, SoSensor* sensor ); 00247 }; 00248 00249 #endif