Viewer component which uses a virtual trackball to view the data. More...
#include <Inventor/Wx/viewers/SoWxExaminerViewer.h>
The Examiner viewer component allows you to rotate the view around a point of interest using a virtual trackball. The viewer uses the camera focalDistance field to figure out the point of rotation, which is usually set to be at the center of the scene. In addition to allowing you to rotate the camera around the point of interest, this viewer also allows you to translate the camera in the viewer plane, as well as dolly (move forward and backward) to get closer to or further away from the point of interest. The viewer seek capability can be used to position the camera towards a selected object or point.
The center of rotation for the ExaminerViewer, called the focalPoint, is defined as a point that is focalDistance from the camera position, along the viewVector, where the viewVector is (indirectly) defined by the camera orientation. You can compute the focalPoint for the current camera settings like this:
SoCamera* camera = viewer->getCamera(); SbMatrix mx; // Note constructor does not accept SbRotation mx = camera->orientation.getValue(); // Assignment converts SbRotation to SbMatrix SbVec3f viewVec(-mx[2][0], -mx[2][1], -mx[2][2]); SbVec3f camPos = camera->position.getValue(); float focDist = camera->focalDistance.getValue(); SbVec3f focalPt = camPos + (focDist * viewVec);
To better understand the above code, remember that we can convert an SbRotation to an SbMatrix and, since orientation is a pure rotation matrix, we can consider the first three columns of this matrix to be the orthogonal X, Y and Z vectors defining the rotated coordinate system. Therefore the view vector is the inversion of the Z axis vector; and finally because this vector is already normalized, an offset of "dist" along this vector is simply "dist * vector". Of course if you have a focalPoint in mind, you can work backward to compute camera position or focalDistance depending on which parameters you want to keep constant.
Left Mouse: Rotate the virtual trackball.
Middle Mouse or
Ctrl + Left Mouse: Translate up, down, left, right.
Ctrl + Middle Mouse or
Left + Middle Mouse: Dolly in and out (gets closer to and further away from the object).
<s> + Left Mouse: Alternative to the Seek button. Press (but do not hold down) the <s> key, then click on a target object.
Right Mouse: Open the popup menu.
ALT: When the viewer is in selection (a.k.a. pick) mode, pressing and holding the ALT key temporarily switches the viewer to viewing mode. When the ALT key is released, the viewer returns to selection mode.
Note 1: If any of the mouse buttons are currently depressed, the ALT key has no effect.
Note 2: On UNIX, Open Inventor may lose track of the ALT key state (up or down) if you release the key outside of the Inventor window. Pressing and releasing the key inside the Inventor window will allow Open Inventor to once again know the key's correct state.
Note 3: If your WxExaminerViewer is encapsulated in a wx main frame, the wxMenuBar may receive the ALT key press event before the WxExaminerViewer. If this happens, the ALT key won't have any effect on the viewer's viewing mode.
Mouse Wheel: Dolly/zoom camera
Rotating the mouse wheel does a camera "dolly" operation on a perspective camera (moving the camera closer or farther away from the scene, which visually zoom) or a camera "zoom" operation on an orthographic camera (changing the view volume height).
Note that many users find the default dolly speed with the mouse wheel to be too slow. The user can hold down the Shift key to make the mouse wheel dolly go 2X faster. To increase the base speed set the environment variable OIV_WHEEL_DELTA. Mouse wheel events contain a "delta" that is a multiple of 120. The viewer divides this value by OIV_WHEEL_DELTA to compute the camera dolly increment. The default value for OIV_WHEEL_DELTA is 120. So, for example, setting OIV_WHEEL_DELTA to 12 makes the mouse wheel dolly go 10X faster.
SoWxFullViewer, SoWxViewer, SoWxComponent, SoWxRenderArea, SoWxPlaneViewer
Viewing mode.
SoWxExaminerViewer::SoWxExaminerViewer | ( | wxWindow * | parent = NULL , |
|
const char * | name = NULL , |
|||
SbBool | buildInsideParent = TRUE , |
|||
SoWxFullViewer::BuildFlag | flag = SoWxFullViewer::BUILD_ALL , |
|||
SoWxViewer::Type | type = SoWxViewer::BROWSER | |||
) |
Constructor which specifies the viewer type.
Please refer to SoWxViewer for a description of the viewer types.
SoWxExaminerViewer::~SoWxExaminerViewer | ( | ) |
Destructor.
virtual void SoWxExaminerViewer::activateDolly | ( | const SbVec2s & | newLocator | ) | [virtual] |
Sets the start locator for dolly camera animation.
This method should be called fisrt, before to start a dolly camera animation.
newLocator | The start mouse position in pixels. The coordinates must be defined with x in the range [0,window width] and y in the range [0,window height] with min y at the bottom and min x on the left. |
virtual void SoWxExaminerViewer::activatePanning | ( | const SbVec2s & | newLocator | ) | [virtual] |
Sets the start locator for pan camera animation.
This method should be called fisrt, before to start a pan camera animation.
newLocator | The start mouse position in pixels. The coordinates must be defined with x in the range [0,window width] and y in the range [0,window height] with min y at the bottom and min x on the left. |
virtual void SoWxExaminerViewer::activateRoll | ( | const SbVec2s & | newLocator | ) | [virtual] |
Sets the start locator for roll camera animation.
This method should be called fisrt, before to start a roll camera animation.
newLocator | The start mouse position in pixels. The coordinates must be defined with x in the range [0,window width] and y in the range [0,window height] with min y at the bottom and min x on the left. |
virtual void SoWxExaminerViewer::activateSpinning | ( | const SbVec2s & | newLocator | ) | [virtual] |
Sets the start locator for spin camera animation.
This method should be called fisrt, before to start a spin camera animation.
newLocator | The start mouse position in pixels. The coordinates must be defined with x in the range [0,window width] and y in the range [0,window height] with min y at the bottom and min x on the left. |
virtual void SoWxExaminerViewer::dollyCamera | ( | const SbVec2s & | newLocator | ) | [virtual] |
Move the camera on the z axis based on cursor motion.
This corresponds to pressing left and middle mouse buttons, pressing control + shift + left mouse button or using the mouse wheel.
newLocator | The new cursor position. The coordinates are in pixels with x in the range [0,window width-1] and y in the range [0,window height-1] with min y at the bottom and min x on the left. |
ConstrainedViewingMode SoWxExaminerViewer::getConstrainedViewingMode | ( | ) | const [inline] |
Returns the current constrained viewing mode.
int SoWxExaminerViewer::getFeedbackSize | ( | ) | const [inline] |
Returns the point of rotation feedback size in pixels.
ViewingMode SoWxExaminerViewer::getViewingMode | ( | ) | const [inline] |
Gets the current viewing mode.
SbBool SoWxExaminerViewer::isAnimating | ( | ) | [inline] |
Queries if the viewer is currently animating.
SbBool SoWxExaminerViewer::isAnimationEnabled | ( | ) | [inline] |
Returns whether spin animation is enabled.
SbBool SoWxExaminerViewer::isFeedbackVisible | ( | ) | const [inline] |
Returns the rotation feedback flag.
virtual void SoWxExaminerViewer::panCamera | ( | const SbVec2f & | newLocator | ) | [virtual] |
Pans the camera based on cursor motion.
newLocator | The new cursor position. The coordinates are in normalized device coordinates with x and y in the range [0,1] with min y at the bottom and min x on the left. |
virtual void SoWxExaminerViewer::resetToHomePosition | ( | ) | [virtual] |
Restores the camera values.
Reimplemented from SoWxViewer.
virtual void SoWxExaminerViewer::reverseDollyCamera | ( | const SbVec2s & | newLocator | ) | [virtual] |
Same as dollyCamera but reversed.
newLocator | The new cursor position. The coordinates are in pixels with x in the range [0,window width-1] and y in the range [0,window height-1] with min y at the bottom and min x on the left. |
virtual void SoWxExaminerViewer::rollCamera | ( | const SbVec2s & | newLocator | ) | [virtual] |
Roll the camera based on cursor motion.
newLocator | The new cursor position. The coordinates are in pixels with x in the range [0,window width-1] and y in the range [0,window height-1] with min y at the bottom and min x on the left. |
void SoWxExaminerViewer::setAnimationEnabled | ( | SbBool | onOrOff | ) |
Enables/disables the spin animation feature of the viewer (enabled by default).
The default value can be set using the environment variable OIV_VIEWER_ANIMATION (0 = OFF, 1 = ON).
virtual void SoWxExaminerViewer::setCamera | ( | SoCamera * | cam | ) | [virtual] |
Sets the edited camera.
Setting the camera is only needed if the first camera found in the scene when setting the scene graph isn't the one the user really wants to edit.
Reimplemented from SoWxFullViewer.
void SoWxExaminerViewer::setConstrainedViewingMode | ( | ConstrainedViewingMode | mode | ) |
Sets the constrained viewing mode.
This method is useful to associate a key combination with a constrained mode. Notes:
virtual void SoWxExaminerViewer::setCursorEnabled | ( | SbBool | onOrOff | ) | [virtual] |
Sets whether the viewer is allowed to change the cursor over the renderArea window.
When disabled, the cursor is not defined by the viewer and will not change as the mode of the viewer changes. When re-enabled, the viewer will reset it to the appropriate icon.
Disabling the cursor enables the application to set the cursor directly on the viewer window or on any parent widget of the viewer. This can be used when setting a busy cursor on the application shell.
Reimplemented from SoWxViewer.
void SoWxExaminerViewer::setFeedbackSize | ( | int | newSize | ) |
Sets the point of rotation feedback size in pixels (default 20 pix).
void SoWxExaminerViewer::setFeedbackVisibility | ( | SbBool | onOrOff | ) |
Shows/hides the point of rotation feedback, which only appears while in viewing mode (default is off).
virtual void SoWxExaminerViewer::setSeekMode | ( | SbBool | onOrOff | ) | [virtual] |
Set the viewer into/out of seek mode (default OFF).
Actual seeking will not happen until the viewer decides to, for example, on a mouse click.
Note: Setting the viewer out of seek mode while the camera is being animated will stop the animation at the current location.
Reimplemented from SoWxViewer.
virtual void SoWxExaminerViewer::setViewing | ( | SbBool | onOrOff | ) | [virtual] |
Sets whether the viewer is turned on or off.
When turned on, events are consumed by the viewer. When viewing is off, events are processed by the viewer's render area. This means events will be sent down to the scene graph for processing (i.e. picking can occur). Note that if the application has registered an event callback, it will be invoked on every message, whether viewing is turned on or not. However, the return value of this callback (which specifies whether the callback handled the event or not) is ignored when viewing is on. That is, the viewer will process the event even if the callback already did. This is to ensure that the viewing paradigm is not broken (default viewing is on).
Reimplemented from SoWxFullViewer.
void SoWxExaminerViewer::setViewingMode | ( | ViewingMode | viewingMode | ) |
Sets the viewing mode.
This method specifies what is the viewing behavior when the left mouse is pressed. The default value is SPIN_VIEWING_MODE.
virtual void SoWxExaminerViewer::spinCamera | ( | const SbVec2f & | newLocator | ) | [virtual] |
Spin the camera based on cursor motion.
newLocator | The new cursor position. The coordinates are in normalized device coordinates with x and y in the range [0,1] with min y at the bottom and min x on the left. |
virtual void SoWxExaminerViewer::spinConstrainedCamera | ( | const SbVec2f & | newLocator, | |
int | axisIndex | |||
) | [virtual] |
Spin the constrained camera based on cursor motion.
newLocator | The new cursor position. The coordinates are in normalized device coordinates with x and y in the range [0,1] with min y at the bottom and min x on the left. | |
axisIndex | the axis index:
|
void SoWxExaminerViewer::stopAnimating | ( | ) |
Stops animation, if it is occurring.
virtual void SoWxExaminerViewer::viewAll | ( | ) | [virtual] |
Changes the camera position to view the entire scene (the camera zoom or orientation isn't changed).
The viewer applies an SoGetBoundingBoxAction to the scene graph to get the bounding box of the entire scene. The bounding box will only include shapes that are actually traversed. For example the bounding box will not include shapes under an SoSwitch with whichChild set to SO_SWITCH_NONE. The action does not consider the visibility of shapes that are traversed. In other words the bounding box will include shapes that are invisible (SoDrawStyle), shapes that are clipped (SoClipPlane), etc. Use an SoBBox node to exclude shapes from the bounding box computation. Bounding boxes are automatically cached at SoSeparator nodes, so getting the bounding box is very fast when the scene graph has not been changed.
See all SoCamera::viewAll(). This method allows the application to adjust the camera based on a specific sub-graph or path in the scene graph.
Reimplemented from SoWxViewer.