Viewer component lowest base class. More...
#include <Inventor/MP/Xt/viewers/SoXtMPViewer.h>
Viewer component lowest base class.
This is the lowest base class for viewer components. This class adds the notion of a camera to the SoXtMPRenderArea class. Whenever a new scene is specified with setSceneGraph(), the first camera encountered will be by default used as the edited camera. If no camera is found in the scene, the viewer will automatically create one. The viewer will use the first SoVRMLViewpoint encountered (if any) to define the parameters of the created camera. If the viewer type is SoXtMPViewer::BROWSER then the camera is told to view the supplied scene graph but is not added beneath that scene graph root. If the viewer type is SoXtMPViewer::EDITOR then the camera is added beneath the supplied scene graph root.
NOTE: This class does not exist in Open Inventor 10.0 and later.In addition to automatically creating a camera if needed, this base class also creates a headlight (directional light which is made to follow the camera), enables the user to change drawing styles (like wireframe or move wireframe), and buffering types. This base class also provides a convenient way to have the camera near and far clipping planes be automatically adjusted to minimize the clipping of objects in the scene.
Viewers allow the application to shadow event processing. When the application registers an event processing callback by calling setEventCallback() the viewer will invoke this callback for every X event it receives. However, unlike the render area, the viewer ignores the return value of this callback, and processes the event as usual. This allows the application to expand viewing capabilities without breaking the viewing paradigm. It is an easy way to hook up other devices, like the spaceball, to an existing viewer.
Depending on the DecimationStrategy, a viewer can control the complexity of a scene by adjusting the Decimation elements to reach certain goals. The viewer can attempt to keep a constant frame rate or a constant number of triangles rendered. The viewer can be set to switch to full detail when the scene is not moving.
In order to set the frame rate, the viewer times each render action traversal, and then adjusts the Decimation percentage to keep the time within a range depending on the goal frames per second. To fix the number of triangles, the viewer applies a GetPrimitiveCountAction before each traversal and sets the DecimationPercentage to the desired percentage of the resulting count.
If the DecimationStrategy is NORMAL (the default) then nothing special is done. If the strategy is FIXED_PERCENTAGE, then the same percentage is used for every render. Also note that FIXED_PERCENTAGE sets the DecimationType to be PERCENTAGE (all others use AUTOMATIC), which means that instances of SoLOD will not use the camera position in their calculations, and can therefore be cached.
The application can add callbacks from the viewer to get the current decimation level, the current primitive count and the current frames per second. The decimation level and primitive count callbacks are called every frame. The frames per second callback is called after a certain number of samples have been averaged together.
SoXtComponent, SoXtMPRenderArea, SoXtMPExaminerViewer, SoXtMPWalkViewer, SoXtMPFlyViewer, SoXtMPPlaneViewer
list of possible drawing styles
Note: Refer to the SoXtMPViewer man pages for a complete description of those draw styles.
enum SoXtMPViewer::Type |
An EDITOR viewer will create a camera under the user supplied scene graph (specified in setSceneGraph()) if it cannot find one in the scene and will leave the camera behind when supplied with a new scene.
A BROWSER viewer will also create a camera if it cannot find one in the scene, but will place it above the scene graph node (camera will not appear in the user supplied scene graph), and will automatically remove it when another scene is supplied to the viewer.
void SoXtMPViewer::addFinishCallback | ( | SoXtMPViewerCB * | f, | |
void * | userData = NULL | |||
) | [inline] |
Adds finish callback routines on the viewer.
Start callbacks are called whenever the user starts doing interactive viewing (for example, mouse down), and finish callbacks are called when user is done doing interactive work (for example, mouse up).
Note: The viewer "this" pointer is passed as callback data.
void SoXtMPViewer::addStartCallback | ( | SoXtMPViewerCB * | f, | |
void * | userData = NULL | |||
) | [inline] |
Adds start callback routine on the viewer.
Start callbacks are called whenever the user starts doing interactive viewing (for example, mouse down), and finish callbacks are called when user is done doing interactive work (for example, mouse up).
Note: The viewer "this" pointer is passed as callback data.
void SoXtMPViewer::copyView | ( | Time | eventTime | ) |
Copies the view.
eventTime should be the time of the X event which initiated the copy (e.g. if copy is initiated from a keystroke, eventTime should be the time in the key down message.)
void SoXtMPViewer::enableFullRenderingWhenStill | ( | SbBool | onOff | ) |
If this flag is set, the viewer will render at full resolution when it sits still for a certain period of time.
virtual void SoXtMPViewer::enableSeekWithOrtho | ( | SbBool | flag | ) | [inline, virtual] |
If FALSE, the seek functionality is disabled for an SoOrthographicCamera.
Default is TRUE.
float SoXtMPViewer::getAutoClipTolerance | ( | ) | const [inline] |
Gets the auto clipping tolerance value.
SoXtMPViewer::BufferType SoXtMPViewer::getBufferingType | ( | ) | [inline] |
Gets the current buffering type in the main view.
SoCamera* SoXtMPViewer::getCamera | ( | ) | [inline] |
Gets the edited camera.
SoType SoXtMPViewer::getCameraType | ( | ) | [inline] |
Gets the camera type that will be created by the viewer if no cameras are found in the scene graph (see SoPerspectiveCamera and SoOrthographicCamera).
float SoXtMPViewer::getCurrentDecimationPercentage | ( | ) |
Returns the Decimation Percentage the viewer used in its last render.
DecimationStrategy SoXtMPViewer::getDecimationStrategy | ( | ) | [inline] |
Gets strategy to use to decide on decimation value.
SoXtMPViewer::DrawStyle SoXtMPViewer::getDrawStyle | ( | SoXtMPViewer::DrawType | type | ) |
Queries the current drawing style in the main view.
float SoXtMPViewer::getFixedPercentage | ( | ) | [inline] |
Gets fixed percentage for the viewer to render (0.0 to 1.0).
float SoXtMPViewer::getGoalFramesPerSecond | ( | ) | [inline] |
Gets goal frames per second for the viewer to try to render.
int32_t SoXtMPViewer::getGoalNumberOfTriangles | ( | ) | [inline] |
Gets goal number of triangles for the viewer to try to render.
SoDirectionalLight* SoXtMPViewer::getHeadlight | ( | ) | [inline] |
Returns the headlight node.
int SoXtMPViewer::getNumSamples | ( | ) | [inline] |
Gets how many frames should be timed before frames per second callback is called.
virtual SoNode* SoXtMPViewer::getSceneGraph | ( | ) | [virtual] |
Gets the scene graph to render.
Reimplemented from SoXtMPRenderArea.
SoTransform* SoXtMPViewer::getSceneTransform | ( | void | ) |
returns the SoTransform node
float SoXtMPViewer::getSeekTime | ( | ) | [inline] |
Queries the seek time.
SoNode* SoXtMPViewer::getViewAllScene | ( | ) | [inline] |
SoTransform* SoXtMPViewer::getWandTransform | ( | void | ) |
returns the SoTransform that modifies the wand
void SoXtMPViewer::insertSceneTransform | ( | void | ) |
Always returns NULL on UNIX systems.
add an SoTransform node just after the viewer's camera
SbBool SoXtMPViewer::isAutoClipping | ( | ) | const [inline] |
Queries if auto clipping is ON.
virtual SbBool SoXtMPViewer::isCameraHeightAnglePreserved | ( | ) | const [inline, virtual] |
Query whether the SoPerspectiveCamera's heightAngle is preserved if the camera is changed to an SoOrthographicCamera and then toggled back to an SoPerspectiveCamera.
SbBool SoXtMPViewer::isCursorEnabled | ( | ) | const [inline] |
Queries whether the viewer is allowed to change the cursor over the renderArea window.
SbBool SoXtMPViewer::isDetailSeek | ( | ) | [inline] |
Queries whether the viewer is in seek mode.
SbBool SoXtMPViewer::isFullRenderingWhenStill | ( | ) | [inline] |
Queries if the viewer will render at full resolution when it sits still for a certain period of time.
SbBool SoXtMPViewer::isHeadlight | ( | ) | [inline] |
Queries if the headlight is on.
virtual SbBool SoXtMPViewer::isSeekWithOrthoEnabled | ( | ) | const [inline, virtual] |
Query whether the seek functionality is enabled for an SoOrthographicCamera.
SbBool SoXtMPViewer::isStillNow | ( | ) | [inline] |
Returns whether the viewer is currently still.
SbBool SoXtMPViewer::isViewing | ( | ) | const [inline] |
Queries whether the viewer is turned on or off.
See setViewing() for details.
virtual void SoXtMPViewer::navigate | ( | void | ) | [virtual] |
void SoXtMPViewer::pasteView | ( | Time | eventTime | ) |
Pastes the view.
eventTime should be the time of the X event which initiated the paste (e.g. if paste is initiated from a keystroke, eventTime should be the time in the key down message.)
virtual void SoXtMPViewer::recomputeSceneSize | ( | ) | [virtual] |
This can be used to let the viewer know that the scene graph has changed so that the viewer can recompute things like speed which depend on the scene graph size.
Note: This routine is automatically called whenever setSceneGraph() is called.
Reimplemented in SoXtMPConstrainedViewer.
void SoXtMPViewer::removeFinishCallback | ( | SoXtMPViewerCB * | f, | |
void * | userData = NULL | |||
) | [inline] |
Removes finish callback routine from the viewer.
Note: The viewer "this" pointer is passed as callback data.
void SoXtMPViewer::removeStartCallback | ( | SoXtMPViewerCB * | f, | |
void * | userData = NULL | |||
) | [inline] |
Removes start callback routine from the viewer.
Note: The viewer "this" pointer is passed as callback data.
virtual void SoXtMPViewer::resetToHomePosition | ( | ) | [virtual] |
Restores the camera values.
Reimplemented in SoXtMPConstrainedViewer, SoXtMPExaminerViewer, and SoXtMPFlyViewer.
virtual void SoXtMPViewer::saveHomePosition | ( | ) | [virtual] |
Saves the camera values.
Reimplemented in SoXtMPConstrainedViewer.
void SoXtMPViewer::setAutoClipping | ( | SbBool | onOrOff | ) |
Sets the auto clipping plane.
When auto clipping is ON, the camera near and far planes are dynamically adjusted to be as tight as possible around the objects being viewed. When OFF, the user is expected to manually set those planes within the preference sheet (default is on).
void SoXtMPViewer::setAutoClipTolerance | ( | float | tolerance | ) | [inline] |
Sets the auto clipping tolerance value.
Auto clipping normally sets the near and far clip planes based on the scene's bounding box. If the camera is inside the scene bounding box, the near plane is moved in front of the camera using tolerance *bbox size. The default is 0.001.
virtual void SoXtMPViewer::setBufferingType | ( | SoXtMPViewer::BufferType | type | ) | [virtual] |
Sets the current buffering type in the main view (default SoXtMPViewer::BUFFER_DOUBLE).
Reimplemented in SoXtMPFullViewer.
virtual void SoXtMPViewer::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 in SoXtMPConstrainedViewer, SoXtMPExaminerViewer, SoXtMPFlyViewer, SoXtMPFullViewer, SoXtMPPlaneViewer, and SoXtMPWalkViewer.
virtual void SoXtMPViewer::setCameraType | ( | SoType | type | ) | [virtual] |
Sets the camera type that will be created by the viewer if no cameras are found in the scene graph (see SoPerspectiveCamera and SoOrthographicCamera).
By default an SoPerspectiveCamera will be created if no cameras are found.
Note: The set method will only take effect the next time a scene graph is specified (and if no cameras are found).
Reimplemented in SoXtMPFlyViewer, and SoXtMPWalkViewer.
void SoXtMPViewer::setCameraTypeChangeCallback | ( | SoXtMPViewerCameraTypeChangeCB * | callback, | |
void * | userdata | |||
) |
Defines a callback which is called each time the camera type has changed (change from SoPerspectiveCamera to SoOrthographicCamera or vice versa).
virtual void SoXtMPViewer::setCursorEnabled | ( | SbBool | onOrOff | ) | [virtual] |
Sets whether the viewer is allowed to change the cursor over the renderArea window.
When disabled, the cursor is undefined 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 in SoXtMPExaminerViewer, SoXtMPFlyViewer, SoXtMPPlaneViewer, and SoXtMPWalkViewer.
void SoXtMPViewer::setDecimationPercentageCallback | ( | SoXtMPViewerDecimationPercentageCB * | callback, | |
void * | userData = NULL | |||
) |
Registers decimation percentage callback.
void SoXtMPViewer::setDecimationStrategy | ( | DecimationStrategy | strategy | ) |
Sets strategy to use to decide on decimation value.
void SoXtMPViewer::setDetailSeek | ( | SbBool | onOrOff | ) | [inline] |
Turns stereo viewing on/off on the viewer (default off).
When in stereo mode, which may not work on all machines, the scene is rendered twice (in the left and right buffers) with an offset between the two views to simulate stereo viewing. Stereo glasses have to be used to see the effect. Stereo viewing is only possible with a graphics board that has support for stereo. Queries if stereo viewing is on or off on the viewer. See setStereoViewing() for additional info. When the viewer is in seek mode, left mouse clicks initiate a pick, and the viewer changes its orientation and position to look at the picked object. This routine tells the seeking viewer whether to orient the camera towards the picked point (detail on), or the center of the object's bounding box (detail off). Default is detail on.
virtual void SoXtMPViewer::setDrawStyle | ( | SoXtMPViewer::DrawType | type, | |
SoXtMPViewer::DrawStyle | style | |||
) | [virtual] |
Sets the current drawing style in the main view.
The user can specify the INTERACTIVE draw style (draw style used when the scene changes) independently from the STILL style. Default is VIEW_AS_IS draw style for STILL and VIEW_SAME_AS_STILL for INTERACTIVE. Possible draw styles are:
VIEW_AS_IS - Leaves the objects unchanged.
VIEW_HIDDEN_LINE - Renders the object as wireframe, but only shows the object front faces. This is accomplished using a two-pass rendering. In the first pass, the objects are rendered as FILLED using the background BASE_COLOR (this sets up the wanted z-buffer values). The second pass then renders the objects as LINES, while adjusting the z-buffer range to limit overlapping polygons problems.
VIEW_NO_TEXTURE - Renders the objects without any textures. This is done by setting the override flag on an empty SoTexture2 node.
VIEW_LOW_COMPLEXITY - Renders the objects without any textures and with a low complexity. This is done by setting the override flag on an empty SoTexture2 node, and by setting a low complexity value on an SoComplexity node with override set to TRUE.
VIEW_LINE - Renders the objects as LINES (no texture) with lighting model set to BASE_COLOR.
VIEW_LOW_RES_LINE - Renders the objects as LINES (no texture) using a low complexity, with lighting model set to BASE_COLOR and no depth comparison.
VIEW_POINT - Renders the objects as POINTS (no texture) with lighting model set to BASE_COLOR.
VIEW_LOW_RES_POINT - Renders the objects as POINTS (no texture) using a low complexity, with lighting model set to BASE_COLOR and no depth comparison.
VIEW_BBOX - Renders the objects with complexity BOUNDING_BOX, lighting model set to BASE_COLOR and drawing style LINES (no texture) with no depth comparison.
VIEW_SAME_AS_STILL - This only applies to INTERACTIVE draw type. It enables the interactive draw style mode to match the regular draw style mode without having to set it explicitly.
Reimplemented in SoXtMPFullViewer.
void SoXtMPViewer::setFixedPercentage | ( | float | percent | ) |
Sets fixed percentage for the viewer to render (0.0 to 1.0).
void SoXtMPViewer::setFramesPerSecondCallback | ( | SoXtMPViewerFPSCB * | callback, | |
void * | userData = NULL | |||
) |
Registers frames per second callback.
void SoXtMPViewer::setGoalFramesPerSecond | ( | float | goal | ) |
Sets goal frames per second for the viewer to try to render.
void SoXtMPViewer::setGoalNumberOfTriangles | ( | int32_t | goal | ) |
Sets goal number of triangles for the viewer to try to render.
virtual void SoXtMPViewer::setHeadlight | ( | SbBool | onOrOff | ) | [virtual] |
Turns the headlight on/off (default on).
Reimplemented in SoXtMPFullViewer.
void SoXtMPViewer::setHeadTracking | ( | int | value | ) |
sets the sensor id that tracks the head.
If set with value of -1, headtracking is disabled.
void SoXtMPViewer::setNumSamples | ( | int | numFrames | ) |
Sets how many frames should be timed before frames per second callback is called, default is 10.
virtual void SoXtMPViewer::setPreserveCameraHeightAngle | ( | SbBool | flag | ) | [inline, virtual] |
If TRUE, an SoPerspectiveCamera's heightAngle is preserved if the camera is changed to an SoOrthographicCamera and then toggled back to an SoPerspectiveCamera.
Default is FALSE.
virtual void SoXtMPViewer::setSceneGraph | ( | SoNode * | newScene | ) | [virtual] |
Sets the scene graph to render.
Whenever a new scene is supplied the first camera encountered will be by default used as the edited camera, else a new camera will be created.
Reimplemented from SoXtMPRenderArea.
void SoXtMPViewer::setSeekTime | ( | float | seconds | ) | [inline] |
Sets the time a seek takes to change to the new camera location.
A value of zero seeks directly to the point without any animation. Default value is 2 seconds.
void SoXtMPViewer::setViewAllScene | ( | SoNode * | node | ) | [inline] |
virtual void SoXtMPViewer::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 in SoXtMPExaminerViewer, SoXtMPFlyViewer, SoXtMPFullViewer, SoXtMPPlaneViewer, and SoXtMPWalkViewer.
void SoXtMPViewer::setWandGeometryFile | ( | SbString | wandFile | ) |
set the file containing the wand geometry
virtual void SoXtMPViewer::toggleCameraType | ( | ) | [virtual] |
This routine will toggle the current camera from perspective to orthographic, and from orthographic back to perspective.
Note: It is not actually possible to "toggle" the type of a camera. In fact the current camera will be replaced by a new camera of the appropriate type. Of course the current camera node will be destroyed in the process unless it has been ref'd elsewhere.
virtual void SoXtMPViewer::viewAll | ( | ) | [virtual] |
Changes the camera position to view the entire scene (the camera zoom or orientation isn't changed).
Reimplemented in SoXtMPExaminerViewer.