ViewManager Class Reference
[Nodes]

VSG extension [PREVIEW] [Medical] View manager for use with viewer components. More...

#include <Medical/nodes/ViewManager.h>

Inheritance diagram for ViewManager:
SoGroup SoNode SoFieldContainer SoBase SoRefCounter SoTypedObject

List of all members.

Public Member Functions

virtual SoType getTypeId () const
 ViewManager ()
void addView (const SceneView *newView)
int getNumViews () const
SceneViewgetView (int index) const
SceneViewgetView (const SbVec2f &position) const
int getViewIndex (const SceneView *view) const
int getViewIndex (const SbVec2f &position) const
int getLastEventViewIndex () const
SbVec2f getLastEventPosition () const
void setViewport (int index, SbVec4f &vport)
void setViewport (int index, float xorig, float yorig, float xsize, float ysize)
void setEventCaptureView (int viewIndex)

Static Public Member Functions

static SoType getClassTypeId ()
static void initClass ()
static void exitClass ()

Detailed Description

VSG extension [PREVIEW] [Medical] View manager for use with viewer components.

This is a group node that manages a list of SceneView nodes to allow rendering multiple views inside a render area.

Each SceneView node defines a viewport (sub-region of the render area), a scene to render (usually including a camera node) and optionally a border. SceneView nodes may be used without a ViewManager node, but they rely on a ViewManager node to route user events like mouse button and keyboard presses to the appropriate SceneView scene graph for handling.

Primary distribution of events is based on the event position, the viewport and the order the SceneView nodes are traversed. If no mouse buttons are pressed, then all events are sent to the first SceneView whose viewport contains the event position. When a mouse button is pressed, the view that handles that event "captures" the event stream until all mouse buttons are released. This is convenient because it allows the user to drag the cursor anywhere while, for example, moving the camera. While at least one mouse button is pressed, all events are sent to the SceneView that owns the event stream. This is similar to the way the classic Open Inventor viewers capture events while a mouse button is pressed. It is also similar to the SoHandleEventAction setGrabber() feature that is used by Open Inventor draggers (see SoDragger). The ViewManager event capture and setGrabber() are independent and complementary.

The application can also choose to do "global" event handing by adding an SoEventCallback node above the ViewManager node. If the application needs to know which view the event should affect, for example a key press that means to reset the camera, use the getViewIndex(SbVec2f position) method to know which view contains the event position. Finally, on some devices it is not possible to know the position of some events, for example key press events. So ViewManager also tracks the last known event position, based on mouse move events. The application can query this using getLastEventViewIndex() and getLastEventPosition().

ViewManager also provides convenience methods for setting and getting the viewports of the child views. This is convenient for managing the layout of the viewports. For example to change from four equal size viewports to one large viewport plus three small viewports.

Note: Only SceneView nodes are allowed as children of a ViewManager node. Attempts to add any other kind of node are ignored.

Example 1:

   // Create 2 x 2 view layout
   ViewManager* m_viewManager = new ViewManager();
   for (int i = 0; i < 4; ++i)
     m_viewManager->addView( new SceneView() );
   m_viewManager->getView(0)->setViewport( 0, 0.5f, 0.5f, 0.5f );    // Upper left
   m_viewManager->getView(1)->setViewport( 0.5f, 0.5f, 0.5f, 0.5f ); // Upper right
   m_viewManager->getView(2)->setViewport( 0, 0, 0.5f, 0.5f );       // Lower left
   m_viewManager->getView(3)->setViewport( 0.5f, 0, 0.5f, 0.5f );    // Lower right

SEE ALSO

SceneView

What is a Preview Feature ?:

Constructor & Destructor Documentation

ViewManager::ViewManager (  ) 

Constructor.


Member Function Documentation

void ViewManager::addView ( const SceneView newView  ) 

Add a view.

Adds the specified view to the end of the list.

static void ViewManager::exitClass (  )  [static]

Finish using the class.

Reimplemented from SoGroup.

static SoType ViewManager::getClassTypeId (  )  [static]

Returns the type identifier for this class.

Reimplemented from SoGroup.

SbVec2f ViewManager::getLastEventPosition (  )  const

Returns the position of the last event handled (in pixels).

Generally Open Inventor sets the cursor position for all mouse and keyboard events. But this query could be useful if it is necessary to handle an event that does not have an associated position on screen. Returns (0,0) if no other info.

int ViewManager::getLastEventViewIndex (  )  const

Returns the index of the view that handled the last event.

If event capture is active (a mouse button was pressed), then the index returned is the event capture view, not necessarily the same as the view currently containing the cursor. Returns -1 if not possible to answer the query.

int ViewManager::getNumViews (  )  const

Returns the current number of views being managed.

virtual SoType ViewManager::getTypeId (  )  const [virtual]

Returns the type identifier for this specific instance.

Reimplemented from SoGroup.

SceneView* ViewManager::getView ( const SbVec2f position  )  const

Returns the first view containing the specified pixel coordinate.

This is the view that would handle an event at this location. This is convenient, for example, to implement global hot keys that should only affect the view that contains the event. Then it is not necessary to duplicate an SoEventCallback in each view for this purpose. Returns null if the location is not valid.

SceneView* ViewManager::getView ( int  index  )  const

Returns the view with the specified index.

Same as getChild() but avoids the need to cast the result. Returns null if index is not valid.

int ViewManager::getViewIndex ( const SbVec2f position  )  const

Returns a view index for the specified pixel coordinate.

This is the index of the view that would handle an event at this location. This is convenient, for example, to implement global hot keys that should only affect the view that contains the event. Then it is not necessary to duplicate an SoEventCallback in each view for this purpose. Returns -1 if the location is not valid.

int ViewManager::getViewIndex ( const SceneView view  )  const

Returns the index of the specified view.

Returns -1 if the specified view does not exist.

static void ViewManager::initClass (  )  [static]

Initialize the class.

Reimplemented from SoGroup.

void ViewManager::setEventCaptureView ( int  viewIndex  ) 

Set event capture view.

If viewIndex >= 0, calls enableEventHandling with true for that view and false for every other view. If viewIndex < 0, sets true for all views. Invalid indices are ignored. Used internally to manage event capture.

Generally the application should not call this method.

void ViewManager::setViewport ( int  index,
float  xorig,
float  yorig,
float  xsize,
float  ysize 
)

Convenience method to set the viewport of a view.

Ignored if the index is out of range.

void ViewManager::setViewport ( int  index,
SbVec4f vport 
)

Convenience method to set the viewport of a view.

Ignored if the index is out of range.


The documentation for this class was generated from the following file:

Open Inventor Toolkit reference manual, generated on 12 Feb 2024
Copyright © Thermo Fisher Scientific All rights reserved.
http://www.openinventor.com/