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 Edition 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 00125 class INVENTORMEDICAL_API SceneView : public SoSeparator { 00126 00127 SO_NODE_HEADER(SceneView); 00128 00129 public: 00130 00135 SoSFVec2f viewportOrigin; 00136 00141 SoSFVec2f viewportSize; 00142 00144 SoSFBool active; 00145 00155 SoSFBool drawBorder; 00156 00157 00160 void setViewport( float origX, float origY, float sizeX, float sizeY ); 00161 00164 void setViewport( const SbVec4f& viewport ); 00165 00167 const SbVec4f& getViewport() const; 00168 00171 const SbViewportRegion& getViewportRegion() const; 00172 00174 const SbVec4f& getViewportPixels() const; 00175 00180 void enableEventHandling( SbBool onoff ); 00181 00183 static void initClass(); 00184 00186 static void exitClass(); 00187 00189 SceneView(); 00190 00191 private: 00192 00194 virtual void addChild( SoNode* child ); 00195 virtual int findChild( const SoNode* child ) const; 00196 virtual SoNode* getChild( int index ) const; 00197 virtual void insertChild( SoNode* child, int newChildIndex ); 00198 virtual void removeChild( SoNode* child ); 00199 virtual void removeChild( int index ); 00200 virtual void removeAllChildren(); 00201 virtual void replaceChild( SoNode* oldChild, SoNode* newChild ); 00202 virtual void replaceChild( int index, SoNode* newChild ); 00203 00204 private: 00206 virtual ~SceneView(); 00207 00208 // Internal helpers 00209 void viewportFieldChanged(); 00210 void viewportParentChanged( const SbViewportRegion& vpregion ); 00211 void updateOurViewport(); 00212 static void callback(void* userData, SoAction* action); 00213 00214 // Internal state 00215 SbVec4f m_curViewport; // Current viewport in normalized coords 00216 SbViewportRegion m_vportRegion; // Used to answer queries 00217 00218 SbVec4f m_viewport; // What we actually set (pixels) as float 00219 SbVec4i32 m_viewportPixels; // What we actually set (pixels) as int 00220 SbVec2i32 m_viewportOrig; // What we actually set (pixels) 00221 SbVec2i32 m_viewportSize; // What we actually set (pixels) 00222 00223 SbVec2i32 m_parentOrig; // What we inherited (pixels) 00224 SbVec2i32 m_parentSize; // What we inherited (pixels) 00225 00226 SoRef<SoSwitch> m_masterSwitch; // Internal scene graph 00227 SoRef<SoViewport> m_vportNode; 00228 SoRef<SoSeparator> m_sceneNode; 00229 SoRef<SoSwitch> m_borderSwitch; 00230 SoRef<SoLineSet> m_borderLine; 00231 00232 bool m_handleEvents; // See enableEventHandling() method. 00233 00234 SoNodeSensor* m_sensor; 00235 bool m_ignoreSensor; // Used to temporarily disable sensor 00236 static void sensorCB( void* data, SoSensor* sensor ); 00237 }; 00238 00239 #endif