00001 // View manager 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 _VIEW_MANAGER_H_ 00019 #define _VIEW_MANAGER_H_ 00020 00021 #include <Inventor/nodes/SoGroup.h> 00022 #include <Medical/InventorMedical.h> 00023 00024 // It's convenient for applications to get this automatically. 00025 #include "SceneView.h" 00026 00027 class SoNodeSensor; 00028 class SoHandleEventAction; 00029 class SoPickAction; 00030 00095 class INVENTORMEDICAL_API ViewManager : public SoGroup { 00096 00097 SO_NODE_HEADER(ViewManager); 00098 00099 public: 00100 00102 static void initClass(); 00103 00105 static void exitClass(); 00106 00108 ViewManager(); 00109 00112 void addView( const SceneView* newView ); 00113 00115 int getNumViews() const; 00116 00120 SceneView* getView( int index ) const; 00121 00128 SceneView* getView( const SbVec2f& position ) const; 00129 00132 int getViewIndex( const SceneView* view ) const; 00133 00140 int getViewIndex( const SbVec2f& position ) const; 00141 00148 int getLastEventViewIndex() const; 00149 00155 SbVec2f getLastEventPosition() const; 00156 00159 void setViewport( int index, SbVec4f& vport ); 00160 00163 void setViewport( int index, float xorig, float yorig, float xsize, float ysize ); 00164 00172 void setEventCaptureView( int viewIndex ); 00173 00174 private: 00175 00177 virtual void addChild( SoNode* child ); 00178 virtual void insertChild( SoNode *child, int newChildIndex ); 00179 virtual void replaceChild( SoNode* oldChild, SoNode* newChild ); 00180 virtual void replaceChild( int index, SoNode* newChild ); 00181 00182 private: 00184 virtual ~ViewManager(); 00185 00186 // Actions we handle directly 00187 virtual void handleEvent( SoHandleEventAction* action ); 00188 00189 // Internal state 00190 int m_numViews; // Remember this to check for changes 00191 unsigned int m_buttonsPressed; // Which buttons are currently pressed? 00192 00193 SbVec2f m_eventPos; // Position of last event handled 00194 int m_eventViewIndex; // View that handled the last event 00195 int m_captureViewIndex; // View that "owns" the event stream 00196 00197 SoNodeSensor* m_sensor; 00198 static void sensorCB( void* data, SoSensor* sensor ); 00199 }; 00200 00201 #endif