SoWx
0.1.0
Coin3D GUI toolkit binding
|
The SoWxViewer class is the top level base viewer class. More...
#include <Inventor/Wx/viewers/SoWxViewer.h>
Public Types | |
enum | AutoClippingStrategy { VARIABLE_NEAR_PLANE , CONSTANT_NEAR_PLANE } |
enum | BufferType { BUFFER_SINGLE , BUFFER_DOUBLE , BUFFER_INTERACTIVE } |
enum | DrawStyle { VIEW_AS_IS , VIEW_HIDDEN_LINE , VIEW_NO_TEXTURE , VIEW_LOW_COMPLEXITY , VIEW_LINE , VIEW_POINT , VIEW_BBOX , VIEW_LOW_RES_LINE , VIEW_LOW_RES_POINT , VIEW_SAME_AS_STILL , VIEW_WIREFRAME_OVERLAY } |
enum | DrawType { STILL = 0 , INTERACTIVE } |
enum | StereoType { STEREO_NONE , STEREO_ANAGLYPH , STEREO_QUADBUFFER , STEREO_INTERLEAVED_ROWS , STEREO_INTERLEAVED_COLUMNS } |
enum | Type { BROWSER , EDITOR } |
Public Member Functions | |
void | addFinishCallback (SoWxViewerCB *func, void *data=NULL) |
void | addStartCallback (SoWxViewerCB *func, void *data=NULL) |
void | getAnaglyphStereoColorMasks (SbBool left[3], SbBool right[3]) |
SoWxViewer::BufferType | getBufferingType (void) const |
SoCamera * | getCamera (void) const |
SoType | getCameraType (void) const |
SoWxViewer::DrawStyle | getDrawStyle (const SoWxViewer::DrawType type) const |
SoDirectionalLight * | getHeadlight (void) const |
virtual SoNode * | getSceneGraph (void) |
float | getSeekTime (void) const |
float | getStereoOffset (void) const |
SoWxViewer::StereoType | getStereoType (void) const |
const SbColor & | getWireframeOverlayColor (void) const |
SbBool | isAutoClipping (void) const |
SbBool | isCursorEnabled (void) const |
SbBool | isDetailSeek (void) const |
SbBool | isHeadlight (void) const |
SbBool | isStereoViewing (void) const |
SbBool | isViewing (void) const |
void | removeFinishCallback (SoWxViewerCB *func, void *data=NULL) |
void | removeStartCallback (SoWxViewerCB *func, void *data=NULL) |
virtual void | resetToHomePosition (void) |
virtual void | saveHomePosition (void) |
void | setAnaglyphStereoColorMasks (const SbBool left[3], const SbBool right[3]) |
void | setAutoClipping (SbBool enable) |
void | setAutoClippingStrategy (const AutoClippingStrategy strategy, const float value=0.6f, SoWxAutoClippingCB *cb=NULL, void *cbuserdata=NULL) |
virtual void | setBufferingType (SoWxViewer::BufferType type) |
virtual void | setCamera (SoCamera *camera) |
virtual void | setCameraType (SoType type) |
virtual void | setCursorEnabled (SbBool enable) |
void | setDetailSeek (const SbBool enable) |
virtual void | setDoubleBuffer (const SbBool enable) |
virtual void | setDrawStyle (SoWxViewer::DrawType type, SoWxViewer::DrawStyle style) |
virtual void | setHeadlight (SbBool enable) |
virtual void | setSceneGraph (SoNode *root) |
void | setSeekTime (const float seconds) |
virtual void | setStereoOffset (const float dist) |
SbBool | setStereoType (SoWxViewer::StereoType s) |
virtual void | setStereoViewing (SbBool enable) |
virtual void | setViewing (SbBool enable) |
void | setWireframeOverlayColor (const SbColor &color) |
virtual void | toggleCameraType (void) |
virtual void | viewAll (void) |
Public Member Functions inherited from SoWxRenderArea | |
SoWxRenderArea (wxWindow *parent=NULL, const char *name=NULL, SbBool embed=TRUE, SbBool mouseInput=TRUE, SbBool keyboardInput=TRUE) | |
~SoWxRenderArea () | |
void | getAntialiasing (SbBool &smoothing, int &numPasses) const |
const SbColor & | getBackgroundColor (void) const |
int | getBackgroundIndex (void) const |
SoGLRenderAction * | getGLRenderAction (void) const |
int | getOverlayBackgroundIndex (void) const |
SoGLRenderAction * | getOverlayGLRenderAction (void) const |
SoNode * | getOverlaySceneGraph (void) |
SoSceneManager * | getOverlaySceneManager (void) const |
uint32_t | getRedrawPriority (void) const |
SoSceneManager * | getSceneManager (void) const |
SoGLRenderAction::TransparencyType | getTransparencyType (void) const |
const SbViewportRegion & | getViewportRegion (void) const |
SbBool | isAutoRedraw (void) const |
SbBool | isClearBeforeOverlayRender (void) const |
SbBool | isClearBeforeRender (void) const |
SbBool | isClearZBufferBeforeRender (void) const |
void | redrawOnSelectionChange (SoSelection *selection) |
void | redrawOverlayOnSelectionChange (SoSelection *selection) |
void | registerDevice (SoWxDevice *device) |
void | render (void) |
void | renderOverlay (void) |
void | scheduleOverlayRedraw (void) |
void | scheduleRedraw (void) |
SbBool | sendSoEvent (const SoEvent *event) |
void | setAntialiasing (SbBool smoothing, int numPasses) |
void | setAutoRedraw (SbBool enable) |
void | setBackgroundColor (const SbColor &color) |
void | setBackgroundIndex (int idx) |
void | setClearBeforeOverlayRender (SbBool enable) |
void | setClearBeforeRender (SbBool enable, SbBool zbEnable=TRUE) |
void | setColorMap (int start, int num, const SbColor *colors) |
void | setEventCallback (SoWxRenderAreaEventCB *func, void *user=NULL) |
void | setGLRenderAction (SoGLRenderAction *action) |
void | setOverlayBackgroundIndex (int idx) |
void | setOverlayColorMap (int start, int num, const SbColor *colors) |
void | setOverlayGLRenderAction (SoGLRenderAction *action) |
void | setOverlaySceneGraph (SoNode *scene) |
void | setOverlaySceneManager (SoSceneManager *manager) |
void | setRedrawPriority (uint32_t priority) |
void | setSceneManager (SoSceneManager *manager) |
void | setTransparencyType (SoGLRenderAction::TransparencyType type) |
void | setViewportRegion (const SbViewportRegion &newRegion) |
void | unregisterDevice (SoWxDevice *device) |
Public Member Functions inherited from SoWxGLWidget | |
SbBool | getAccumulationBuffer (void) const |
SbBool | getAlphaChannel (void) const |
wxWindow * | getGLWidget (void) const |
void | getLineWidthLimits (SbVec2f &range, float &granularity) |
wxWindow * | getNormalWidget (void) const |
unsigned long | getOverlayTransparentPixel (void) |
wxWindow * | getOverlayWidget (void) const |
void | getPointSizeLimits (SbVec2f &range, float &granularity) |
int | getSampleBuffers (void) const |
SbBool | getStencilBuffer (void) const |
SbBool | hasNormalGLArea (void) const |
SbBool | hasOverlayGLArea (void) const |
SbBool | isBorder (void) const |
SbBool | isDoubleBuffer (void) const |
SbBool | isDrawToFrontBufferEnable (void) const |
SbBool | isOverlayRender (void) const |
SbBool | isQuadBufferStereo (void) const |
SbBool | isStealFocus (void) const |
void | setAccumulationBuffer (const SbBool enable) |
void | setAlphaChannel (const SbBool enable) |
void | setBorder (const SbBool enable) |
void | setDrawToFrontBufferEnable (const SbBool enable) |
void | setOverlayRender (const SbBool onoff) |
void | setQuadBufferStereo (const SbBool enable) |
void | setSampleBuffers (const int numsamples) |
void | setStealFocus (SbBool enable) |
void | setStencilBuffer (const SbBool enable) |
Public Member Functions inherited from SoWxComponent | |
virtual | ~SoWxComponent () |
wxWindow * | getBaseWidget (void) const |
const char * | getClassName (void) const |
const char * | getIconTitle (void) const |
wxWindow * | getParentWidget (void) const |
wxWindow * | getShellWidget (void) const |
SbVec2s | getSize (void) const |
const char * | getTitle (void) const |
wxWindow * | getWidget (void) const |
const char * | getWidgetName (void) const |
virtual void | hide (void) |
SbBool | isFullScreen (void) const |
SbBool | isTopLevelShell (void) const |
SbBool | isVisible (void) |
virtual void | setComponentCursor (const SoWxCursor &cursor) |
SbBool | setFullScreen (const SbBool onoff) |
void | setIconTitle (const char *const title) |
void | setSize (const SbVec2s size) |
void | setTitle (const char *const title) |
void | setWindowCloseCallback (SoWxComponentCB *const func, void *const user=NULL) |
virtual void | show (void) |
Public Member Functions inherited from SoWxObject | |
virtual SoType | getTypeId (void) const =0 |
SbBool | isOfType (SoType type) const |
Protected Member Functions | |
SoWxViewer (wxWindow *parent, const char *name, SbBool embed, Type type, SbBool build) | |
~SoWxViewer () | |
virtual void | actualRedraw (void) |
void | addSuperimposition (SoNode *scene) |
virtual void | changeCameraValues (SoCamera *camera) |
virtual void | computeSeekFinalOrientation (void) |
int | getInteractiveCount (void) const |
float | getSeekDistance (void) const |
SbBool | getSuperimpositionEnabled (SoNode *scene) const |
void | interactiveCountDec (void) |
void | interactiveCountInc (void) |
SbBool | isSeekMode (void) const |
SbBool | isSeekValuePercentage (void) const |
virtual SbBool | processSoEvent (const SoEvent *const event) |
void | removeSuperimposition (SoNode *scene) |
SbBool | seekToPoint (const SbVec2s screenpos) |
void | seekToPoint (const SbVec3f &scenepos) |
void | setSeekDistance (const float distance) |
virtual void | setSeekMode (SbBool enable) |
void | setSeekValueAsPercentage (const SbBool on) |
void | setSuperimpositionEnabled (SoNode *scene, const SbBool enable) |
virtual void | sizeChanged (const SbVec2s &size) |
Protected Member Functions inherited from SoWxRenderArea | |
SoWxRenderArea (wxWindow *parent, const char *name, SbBool embed, SbBool mouseInput, SbBool keyboardInput, SbBool build) | |
virtual void | actualOverlayRedraw (void) |
virtual void | afterRealizeHook (void) |
wxWindow * | buildWidget (wxWindow *parent) |
virtual const char * | getDefaultIconTitle (void) const |
virtual const char * | getDefaultTitle (void) const |
virtual const char * | getDefaultWidgetName (void) const |
virtual SbBool | glScheduleRedraw (void) |
virtual void | initGraphic (void) |
virtual void | initOverlayGraphic (void) |
virtual void | processEvent (wxEvent &event) |
virtual void | redraw (void) |
virtual void | redrawOverlay (void) |
virtual void | widgetChanged (wxWindow *widget) |
Protected Member Functions inherited from SoWxGLWidget | |
SoWxGLWidget (wxWindow *const parent=NULL, const char *const name=NULL, const SbBool embed=TRUE, const int glmodes=SO_GL_RGB, const SbBool build=TRUE) | |
~SoWxGLWidget () | |
wxWindow * | buildWidget (wxWindow *parent) |
float | getGLAspectRatio (void) const |
SbVec2s | getGLSize (void) const |
float | getGlxAspectRatio (void) const |
SbVec2s | getGlxSize (void) const |
void | glFlushBuffer (void) |
void | glLockNormal (void) |
void | glLockOverlay (void) |
void | glSwapBuffers (void) |
void | glUnlockNormal (void) |
void | glUnlockOverlay (void) |
SbBool | isRGBMode (void) |
SbBool | isStereoBuffer (void) const |
void | setGLSize (const SbVec2s size) |
void | setGlxSize (const SbVec2s size) |
void | setStereoBuffer (SbBool flag) |
Protected Member Functions inherited from SoWxComponent | |
SoWxComponent (wxWindow *const parent=NULL, const char *const name=NULL, const SbBool embed=TRUE) | |
void | addVisibilityChangeCallback (SoWxComponentVisibilityCB *const func, void *const user=NULL) |
void | registerWidget (wxWindow *widget) |
void | removeVisibilityChangeCallback (SoWxComponentVisibilityCB *const func, void *const user=NULL) |
void | setBaseWidget (wxWindow *widget) |
void | setClassName (const char *const name) |
void | unregisterWidget (wxWindow *widget) |
Additional Inherited Members | |
Static Public Member Functions inherited from SoWxRenderArea | |
static uint32_t | getDefaultRedrawPriority (void) |
Static Public Member Functions inherited from SoWxComponent | |
static SoWxComponent * | getComponent (wxWindow *widget) |
static void | initClasses (void) |
static void | setWidgetCursor (wxWindow *w, const SoWxCursor &cursor) |
Static Public Member Functions inherited from SoWxObject | |
static SoType | getClassTypeId (void) |
static void | init (void) |
static void | initClass (void) |
Protected Attributes inherited from SoWxGLWidget | |
SbBool | drawToFrontBuffer |
SbBool | waitForExpose |
Protected Attributes inherited from SoWxComponent | |
SbBool | firstRealize |
The SoWxViewer class is the top level base viewer class.
This is an abstract class, which adds the following features to its SoWxRenderArea superclass: convenient methods for camera handling, an automatic headlight configuration.
As for the camera handling: when setting a new scene graph for the viewer, the scene graph will automatically be scanned for a node derived from SoCamera. If not found, the viewer will itself set up a camera for the scene. The camera can then be conveniently controlled by the application programmers in many aspects:
camera type: toggle between using an orthographic camera and a perspective camera with SoWxViewer::toggleCameraType()
zoom out to exactly encompass all scene geometry within the view by using SoWxViewer::viewAll()
tag a specific position and orientation for the camera as the "home" position with SoWxViewer::saveHomePosition(), which one can then return to by using SoWxViewer::resetToHomePosition()
automatically fit the near and far clipping planes of the camera around the scene's geometry by using SoWxViewer::setAutoClipping()
control stereo viewing parameters
Note that there is no dragger or manipulator attached to the scene camera. The camera transform manipulation is calculated in a more direct manner in the non-abstract viewer classes inheriting SoWxViewer by reading mouse and keyboard events and interpreting how these should influence the camera. The calculations results in new values for SoCamera::position, SoCamera::orientation, and the other SoCamera field values for the camera designated to be the viewer viewpoint camera. These values are then inserted directly into the viewer's SoCamera node.
See e.g. the source code for SoWxExaminerViewer::processSoEvent() for the details.
The SoWxViewer class automatically adds a headlight to the scene, which will always point in the approximate same direction as the current viewer camera, thereby securing that the scene geometry is always lighted and visible. (If you don't want the constant headlight, but rather want to light the scene on your own, this behavior can be turned off with SoWxViewer::setHeadlight()).
SoWxViewer-derived viewers all inherit the following keyboard controls from this class (but only when the viewer is in "examine
mode", i.e. SoWxViewer::isViewing() returns TRUE
):
"s": put the viewer in "seek mode", where the end user may click anywhere on scene geometry to trigger an animation which moves the camera towards the point clicked
"Home": hit this key to move camera back to last saved "home position"
arrow keys: moves camera slightly left, right, up or down
"q": exit application
Enum for auto clipping strategy.
Enumerator | |
---|---|
VARIABLE_NEAR_PLANE | Variable near plane auto clipping strategy. Explained in detail in the documentation for the SoWxViewer::setAutoClippingStrategy() method. |
CONSTANT_NEAR_PLANE | Constant near plane auto clipping strategy. Explained in detail in the documentation for the SoWxViewer::setAutoClippingStrategy() method. |
Set of valid values for SoWxViewer::setBufferingType().
Enumerator | |
---|---|
BUFFER_SINGLE | Change underlying OpenGL canvas to be single buffered. |
BUFFER_DOUBLE | Change underlying OpenGL canvas to be double buffered. |
BUFFER_INTERACTIVE | Set up so animation rendering is done in a double buffered OpenGL canvas, but ordinary rendering happens directly in the front buffer. This mode can be useful with absurdly large scenes, as the rendering will visibly progress, and one will avoid having the end user wonder why nothing is happening while the scene is rendered to the back buffer in the default SoWxViewer::BUFFER_DOUBLE mode. |
Decides draw style for a scene with either a still camera or an animating camera.
Enumerator | |
---|---|
VIEW_AS_IS | Normal rendering, draws all scene geometry in its original style. |
VIEW_HIDDEN_LINE | Draw scene in "hidden line" mode: that is, as wireframe with no "see-through". Note that this is actually an expensive way to render, as the scene must be rendered twice to achieve the effect of hiding lines behind the invisible geometry. |
VIEW_NO_TEXTURE | Render scene without textures. |
VIEW_LOW_COMPLEXITY | Render all "complex" shape types with low complexity to improve rendering performance. "Complex shapes" in this context includes spheres, cones, cylinder, NURBS surfaces, and others which are tessellated to polygons before being rendered. |
VIEW_LINE | View all polygon geometry in wireframe mode. |
VIEW_POINT | Render only the vertex positions of the geometry. |
VIEW_BBOX | View the scene's bounding boxes, instead of rendering the full geometry. A very efficient way of optimizing rendering performance for scenes with high primitive counts while moving the camera about is to set this mode for the SoWxViewer::INTERACTIVE DrawType. |
VIEW_LOW_RES_LINE | Render as wireframe and don't bother with getting them rendered correctly in depth. |
VIEW_LOW_RES_POINT | Render as vertex points and don't bother with getting them rendered correctly in depth. |
VIEW_SAME_AS_STILL | Always render a scene with an animating camera (i.e. SoWxViewer::INTERACTIVE DrawType) in the same manner as scene with a still camera. |
VIEW_WIREFRAME_OVERLAY | Render the scene as normal, but overlay a set of lines showing the contours of all polygons. |
enum SoWxViewer::DrawType |
Contains valid values for the first argument to the SoWxViewer::setDrawStyle() call. Decides the effect of the second argument.
Enumerator | |
---|---|
STILL | If this value is passed as the first argument of SoWxViewer::setDrawStyle(), the second argument decides which draw style to use when the viewer camera is standing still in the same position with the same orientation – i.e. when the end user is not interacting with the scene camera. |
INTERACTIVE | If this value is passed as the first argument of SoWxViewer::setDrawStyle(), the second argument decides which draw style to use when the end user is interacting with the scene camera, causing continuous animation redraws. |
Contains list of supported stereo rendering techniques.
Enumerator | |
---|---|
STEREO_NONE | Use monoscopic rendering. |
STEREO_ANAGLYPH | Render stereo by superimposing two images of the same scene, but with different color filters over the left and right view (or "eye"). This is a way of rendering stereo which works on any display, using color-filter glasses. Such glasses are usually cheap and easy to come by.
|
STEREO_QUADBUFFER | Render stereo by using OpenGL quad-buffers. This is the most common interface for stereo rendering for more expensive hardware devices, such as shutter glasses and polarized glasses. The well known Crystal Eyes glasses are commonly used with this type of stereo display. |
STEREO_INTERLEAVED_ROWS | Interleaving / interlacing rows from the left and right eye is another stereo rendering method requiring special hardware. One example of a provider of shutter glasses working with interleaved glasses is VRex: |
STEREO_INTERLEAVED_COLUMNS | Basically the same technique as SoWxViewer::STEREO_INTERLEAVED_ROWS, but vertical lines are interleaved / interlaced, instead of horizontal lines. |
enum SoWxViewer::Type |
Hints about what context the viewer will be used in. Usually not very interesting for the application programmer, it doesn't matter much which value is used for the viewer type. This "feature" of the viewer is included just to be compatible with the old SGI Inventor API.
Enumerator | |
---|---|
BROWSER | If a user-supplied scene graph passed into the setSceneGraph() function does not contain a camera, setting the viewer type to BROWSER will make the viewer in that case automatically set up a camera outside the scene, as part of the viewer's private and hidden "supergraph". |
EDITOR | If a user-supplied scene graph passed into the setSceneGraph() function does not contain a camera, setting the viewer type to EDITOR will make the viewer in that case automatically set up a camera in the user-supplied scene. So if you want to avoid having the SoWxViewer class muck about with your supplied scene graph, set the type-flag to SoWxViewer::BROWSER instead, which makes an inserted camera node go into the viewer's own "wrapper" scene graph instead. |
|
protected |
Constructor. parent, name and embed are passed on to SoWxRenderArea, so see the documentation for our parent constructor for for more information on those.
The t type setting hints about what context the viewer will be used in. Usually not very interesting for the application programmer, but if you want to make sure the SoWxViewer class doesn't muck about with your supplied scene graph, set the type-flag to SoWxViewer::BROWSER. (This "feature" of the viewer is included just to be compatible with the old SGI Inventor API.)
The build flag decides whether or not to delay building the widgets / window which is going to make up the components of the viewer.
|
protected |
Destructor.
|
protectedvirtual |
This method instantly redraws the normal (non-overlay) scene graph by calling SoSceneManager::render().
Subclasses may override this method to add their own rendering before or after Coin renders its scene graph.
The following is a complete example that demonstrates one way of adding both a background image and foreground (overlay) geometry to the "normal" rendering:
Reimplemented from SoWxRenderArea.
Reimplemented in SoWxExaminerViewer, SoWxFlyViewer, and SoWxPlaneViewer.
void SoWxViewer::addFinishCallback | ( | SoWxViewerCB * | func, |
void * | data = NULL ) |
Add a function to call when user interaction with the scene ends.
void SoWxViewer::addStartCallback | ( | SoWxViewerCB * | func, |
void * | data = NULL ) |
Add a function to call when user interaction with the scene starts.
|
protected |
This method is for setting up a superimposed scene graph on top of the viewer scene graph. It will be used for adding spin-rotation coordinate systems, fly-viewer speed indicators and similar things.
This method is not part of the original InventorXt API.
|
protectedvirtual |
Copies the settings of camera into our current camera. Cameras must be of the same class type.
Reimplemented in SoWxConstrainedViewer.
|
protectedvirtual |
This method can be overridden in subclasses if the final orientation of the camera after a seek should be something other than what is computed in SoWxViewer::seekToPoint(const SbVec3f & scenepos)
Reimplemented in SoWxPlaneViewer.
void SoWxViewer::getAnaglyphStereoColorMasks | ( | SbBool | left[3], |
SbBool | right[3] ) |
Returns color masks for left and right eye filters in anaglyph stereo.
SoWxViewer::BufferType SoWxViewer::getBufferingType | ( | void | ) | const |
Return the viewer's buffer type.
SoCamera * SoWxViewer::getCamera | ( | void | ) | const |
Returns the camera currently used by the viewer for the user's main viewpoint.
It is possible that this function returns NULL
, for instance if there's no scene graph present in the viewer. (This is mostly meant as a note for developers extending the SoWx library, as application programmers usually controls if and when a viewer contains a scene graph, and therefore know in advance if this method will return a valid camera pointer.)
SoType SoWxViewer::getCameraType | ( | void | ) | const |
Returns camera type which will be used when the viewer has to make its own camera.
Note that this call does not return the current camera type, as one might expect. Use getCamera() and SoType::getTypeId() for that inquiry.
SoWxViewer::DrawStyle SoWxViewer::getDrawStyle | ( | const SoWxViewer::DrawType | type | ) | const |
Return current draw styles for the given type (STILL or INTERACTIVE).
SoDirectionalLight * SoWxViewer::getHeadlight | ( | void | ) | const |
Returns the a pointer to the directional light node which is the viewer headlight.
The fields of the node is available for user editing.
|
protected |
Return current interaction count nesting. If equal to zero, the viewer is in animation mode, otherwise the camera is still.
|
virtual |
This method returns a reference to the scene graph root node as set by the user.
Reimplemented from SoWxRenderArea.
|
protected |
Returns the current seek distance. Value given as an absolute scalar length or as a percentage value of the original distance between the hit point and the camera starting position.
float SoWxViewer::getSeekTime | ( | void | ) | const |
Returns the camera repositioning duration following a seek action.
float SoWxViewer::getStereoOffset | ( | void | ) | const |
Return the offset distance between the two viewpoints when in stereo mode.
SoWxViewer::StereoType SoWxViewer::getStereoType | ( | void | ) | const |
Returns the current type of stereo rendering used (or SoWxViewer::STEREO_NONE if monoscopic).
|
protected |
This method returns whether the superimposed scene is rendered or not.
This method is not part of the original InventorXt API.
const SbColor & SoWxViewer::getWireframeOverlayColor | ( | void | ) | const |
Returns the current color of the overlay wireframe. The default color is [1,0,0], i.e. pure red.
|
protected |
To be able to trigger callback functions when user interaction starts and/or stops, we need to keep track of the viewer state (i.e. are we in still mode or in animation mode?).
SoWxViewer automatically adds callbacks to switch between still and moving draw style, and to switch between single/double buffer when the buffer type is INTERACTIVE.
|
protected |
To be able to trigger callback functions when user interaction starts and/or stops, we need to keep track of the viewer state (i.e. are we in still mode or in animation mode?).
SoWxViewer automatically adds callbacks to switch between still and moving draw style, and to switch between single/double buffer when the buffer type is INTERACTIVE.
SbBool SoWxViewer::isAutoClipping | ( | void | ) | const |
Return value of the automatic near/far clip plane adjustment indicator.
SbBool SoWxViewer::isCursorEnabled | ( | void | ) | const |
Returns visibility status of mouse cursor.
SbBool SoWxViewer::isDetailSeek | ( | void | ) | const |
Returns a value indicating whether or not seeks will be performed to the exact point of picking or just towards the picked object.
SbBool SoWxViewer::isHeadlight | ( | void | ) | const |
Returns status of the viewer headlight, whether it is on or off.
|
protected |
Return a flag which indicates whether or not the viewer is in "waiting-to-seek" mode.
(The actual animated translation will not occur until the end user really starts the seek operation, typically by clicking with the left mouse button.)
|
protected |
Returns an boolean which indicates if the seek distance value from getSeekDistance() should be interpreted as a percentage value or as an absolute value.
SbBool SoWxViewer::isStereoViewing | ( | void | ) | const |
Returns a boolean indicating whether or not we're in stereo viewing mode.
NOTE: in the original InventorXt API, this method was virtual. It is not virtual here.
SbBool SoWxViewer::isViewing | ( | void | ) | const |
Return state of view mode.
TRUE
means that the mode of the viewer is set such that user interaction with the mouse is used to modify the position and orientation of the camera.
|
protectedvirtual |
Toolkit-native events are tried to convert to Coin-generic events in the SoWxRenderArea::processEvent() method. If this succeeds, they are forwarded to this method.
This is a virtual method, and is overridden in its subclasses to catch events of particular interest to the viewer classes, for instance.
Return TRUE
if the event was processed. If not it should be passed on further up in the inheritance hierarchy by the caller. This last point is extremely important to take note of if you are expanding the toolkit with your own viewer class.
This method is not part of the original SGI InventorXt API. Note that you can still override the toolkit-native processEvent() method instead of this "generic" method.
Reimplemented from SoWxRenderArea.
Reimplemented in SoWxExaminerViewer, SoWxFlyViewer, SoWxFullViewer, and SoWxPlaneViewer.
void SoWxViewer::removeFinishCallback | ( | SoWxViewerCB * | func, |
void * | data = NULL ) |
Remove one of the functions which has been set up to be called when user interaction with the scene ends.
void SoWxViewer::removeStartCallback | ( | SoWxViewerCB * | func, |
void * | data = NULL ) |
Remove one of the functions which has been set up to be called when user interaction with the scene starts.
|
protected |
This method is not part of the original InventorXt API.
|
virtual |
Restore the saved camera settings.
Reimplemented in SoWxConstrainedViewer, and SoWxFlyViewer.
|
virtual |
Store the current camera settings for later retrieval with resetToHomePosition().
Reimplemented in SoWxConstrainedViewer.
|
protected |
Call this method to initiate a seek action towards the 3D intersection of the scene and the ray from the screen coordinate's point and in the same direction as the camera is pointing.
Returns TRUE
if the ray from the screenpos position intersect with any parts of the onscreen geometry, otherwise FALSE
.
|
protected |
Call this method to initiate a seek action towards the given 3D world coordinate point in the scene, scenepos.
void SoWxViewer::setAnaglyphStereoColorMasks | ( | const SbBool | left[3], |
const SbBool | right[3] ) |
If display is configured to render in anaglyph stereo, this function can be used to control which filter is used for each eye.
The default filters are red (i.e. color vector [TRUE,FALSE,FALSE]) for the left eye, and cyan (color vector [FALSE,TRUE,TRUE]) for the right eye.
void SoWxViewer::setAutoClipping | ( | SbBool | enable | ) |
Turn on or off continuous automatic adjustments of the near and far clipping planes.
If on, the distance from the camera position to the near and far planes will be calculated to be a "best fit" around the geometry in the scene, to maximize the "stretch" of values for the visible geometry in the z-buffer. This is important, as z-buffer resolution is usually limited enough that one will quickly see flickering in the rasterization of close polygons upon lousy utilization of the z-buffer.
Automatic calculations of near and far clip planes are on as default.
For better control over what happens in boundary conditions (for instance when the distance between near and far planes get very far, or if geometry gets very close to the camera position), it is possible to use the SoWxViewer::setAutoClippingStrategy() method to fine-tune the near/far clipping plane settings.
On a major note, be aware that turning auto-updating of near and far clip planes off have a potentially serious detrimental effect on performance, due to an important side effect: updating the near and far clip planes triggers an SoGetBoundingBoxAction to traverse the scene graph, which causes bounding boxes to be calculated and stored in caches. The bounding box caches are then used by the SoGLRenderAction traversal for view frustum culling operations. With no bounding box caches, the rendering will not do culling, which can cause much worse performance. Kongsberg Oil & Gas Technologies are working on correcting this problem properly from within the Coin library.
On a minor note, be aware that notifications will be temporarily turned off for the scene's SoCamera when changing the near and far clipping planes (which is done right before each redraw). This is done to avoid notifications being sent through the scene graph right before rendering, as that causes some latency. It is mentioned here in case you have any client code which for some reason needs to sense all changes to the scene camera. This is however unlikely, so you can very probably ignore this.
void SoWxViewer::setAutoClippingStrategy | ( | const AutoClippingStrategy | strategy, |
const float | value = 0.6f, | ||
SoWxAutoClippingCB * | cb = NULL, | ||
void * | cbuserdata = NULL ) |
Set the strategy used for automatic updates of the distances to the near and far clipping planes.
When auto clipping is enabled, the near plane distance is calculated so that it is just in front of the scene bounding box. If this near plane is behind or very close to the projection point, one of the following strategies will be used to calculate the new clipping plane.
The VARIABLE_NEAR_PLANE strategy considers the number of z buffer bits available for the current OpenGL context, and uses value to calculate the number of bits that is lost because of the far/near ratio. value should be in the range [0.0, 1.0]. A higher value will increase the z-buffer precision, but also push the near plane further away from the projection point.
The CONSTANT_NEAR_PLANE strategy simply sets the near plane to value. If value at some point approaches the far clipping plane distance, the near plane distance will be set to far plane distance divided by 5000.0.
The default strategy is VARIABLE_NEAR_PLANE.
It is also possible to register a callback method cb, which will then be invoked after the near and far clipping planes have been calculated by the SoWxViewer code. The callback can then adjust the values for the distance to the near and far planes to exactly match the needs of the application (for instance at specific parts in the scene), to limit the distance to either plane, or whatever else needs to be controlled.
The signature of the SoWxAutoClippingCB callback must match:
The first argument is the cbuserdata passed in along with the callback function pointer itself (i.e. the callback function's closure). The second argument are the near and far clipping plane distances from the camera position, as calculated internally by the viewer, including "slack".
The function callback can then modify the near and far clipping plane distances to what will actually be used by the viewer. These values will then be used unmodified for the viewer's camera.
This is a good way of dynamically modifying the near and far distances such that they at all times exactly matches the specific layout of the application scene, for instance with regard to the trade-off between z-buffer resolution and how early geometry is clipped at the near plane (or at the far plane).
Note that the internal near/far calculations should be good enough for the vast majority of scenes. Application programmers should only need to set up their own adjustments upon "unusual" scenes, like for instance scenes with a large world space, but where one would still like to be able to get up extremely close on details in some parts of the scene.
|
virtual |
Set the viewer's buffer type. Available types are SoWxViewer::BUFFER_SINGLE
, SoWxViewer::BUFFER_DOUBLE
and SoWxViewer::BUFFER_INTERACTIVE
.
(With a buffer type of SoWxViewer::BUFFER_INTERACTIVE
, the viewer will render with double buffering during user interaction and with single buffering otherwise.)
Default is SoWxViewer::BUFFER_DOUBLE
.
|
virtual |
Set the camera we want the viewer to manipulate when interacting with the viewer controls.
The camera passed in as an argument to this method must already be part of the viewer's scene graph. You do not inject viewpoint cameras to the viewer with this method.
You should rather insert a camera into the scene graph first (if necessary, often one will be present already), then register it as the camera used by the viewer controls with this method.
If the application code doesn't explicitly set up a camera through this method, the viewer will automatically scan through the scene graph to find a camera to use. If no camera is available in the scene graph at all, it will set up its own camera.
Reimplemented in SoWxExaminerViewer, SoWxFlyViewer, SoWxPlaneViewer, and SoWxConstrainedViewer.
|
virtual |
When the viewer has to make its own camera as a result of the graph passed to setSceneGraph() not containing any camera nodes, this call can be made in advance to decide which type the camera will be of.
Default is to use an SoPerspectiveCamera.
If this method is called when there is a scene graph and a camera already set up, it will delete the old camera and set up a camera with the new type if the t type is different from that of the current camera.
Reimplemented in SoWxFlyViewer.
|
virtual |
Set whether or not the mouse cursor representation should be visible in the viewer canvas.
Default value is on.
Reimplemented in SoWxExaminerViewer, SoWxFlyViewer, and SoWxPlaneViewer.
void SoWxViewer::setDetailSeek | ( | const SbBool | on | ) |
Toggle between seeking to a point or seeking to an object.
Default is to seek to a point.
|
virtual |
Overloaded to update the local bufferingtype variable.
Reimplemented from SoWxGLWidget.
|
virtual |
Set up a drawing style. The type argument specifies if the given style should be interpreted as the draw style during animation or when the camera is static.
Default values for the drawing style is to render the scene "as is" in both still mode and while the camera is moving.
See the documentation for the DrawType and DrawStyle for more information.
|
virtual |
Turn the camera headlight on or off.
Default is to have a headlight turned on.
|
virtual |
Give the viewer a scene graph to render and interact with. Overridden from parent class so the viewer can add its own nodes to control rendering in different styles, rendering with a headlight, etc.
The root node will be inserted under the viewer's root node, which also covers the nodes necessary to implement the different preferences drawing style settings.
If no camera is part of the scene graph under root, one will automatically be instantiated and added. You can get a reference to this camera by using the SoWxViewer::getCamera() method.
Reimplemented from SoWxRenderArea.
|
protected |
Set the value used for calculating how close the camera and intersection hit point should be made at the end of a seek operation.
The value can be interpreted as an absolute value in the given world unit (which typically is meters) or as a percentage value of the distance between the camera starting position and the intersection hit point. This can be controlled through the setSeekValueAsPercentage() method. It is as default used as an absolute value.
Default value is 50 (absolute distance or percent).
|
protectedvirtual |
Put the viewer in or out of "waiting-to-seek" mode.
If the user performs a mouse button click when the viewer is in "waiting-to-seek" mode, the camera will be repositioned so the camera focal point lies on the point of the geometry under the mouse cursor.
Reimplemented in SoWxExaminerViewer, SoWxFlyViewer, and SoWxPlaneViewer.
void SoWxViewer::setSeekTime | ( | const float | seconds | ) |
Set the duration of animating the camera repositioning after a successful seek. Call with seconds equal to 0.0 to make the camera jump immediately to the correct spot.
Default value is 2 seconds.
|
protected |
Control whether or not the seek distance value should be interpreted as a percentage value or as an absolute distance. See documentation on setSeekDistance() for more information.
|
virtual |
Set the offset between the two viewpoints when in stereo mode. Default value is 0.1.
NOTE: In the original InventorXt API, this method was not virtual.
SbBool SoWxViewer::setStereoType | ( | SoWxViewer::StereoType | s | ) |
Set up stereo rendering.
Coin does "correct" stereo rendering, using the method known as "parallel axis asymmetric frustum perspective projection". For more information, see this link:
http://astronomy.swin.edu.au/~pbourke/opengl/stereogl/
Note: it is preferred that one uses this function for control of which type of stereo rendering to use, instead of the older SoWxViewer::setStereoViewing() and SoWxGLWidget::setQuadBufferStereo() functions.
The default is to do monoscopic rendering, i.e. the default SoWxViewer::StereoType value is SoWxViewer::STEREO_NONE.
|
virtual |
Turn stereo viewing on or off.
Note: this function is being obsoleted, you should use the setStereoType() function instead.
Coin does "correct" stereo rendering, using the method known as "parallel axis asymmetric frustum perspective projection". For more information, see this link:
http://astronomy.swin.edu.au/~pbourke/opengl/stereogl/
|
protected |
This method sets whether the superimposed scene graph should be traversed or not.
This method is not part of the original InventorXt API.
|
virtual |
Set view mode.
If the view mode is on, user events will be caught and used to influence the camera position / orientation. If view mode is off, all events in the viewer canvas (like for instance keypresses or mouse clicks and -movements) will be passed along to the scene graph.
Default is to have the view mode active.
Reimplemented in SoWxExaminerViewer, SoWxFlyViewer, SoWxPlaneViewer, and SoWxFullViewer.
void SoWxViewer::setWireframeOverlayColor | ( | const SbColor & | color | ) |
Set the color of the overlay wireframe to color.
|
protectedvirtual |
Called internally from within the SoWx library when the widget embedded in a component changes its size, which is usually triggered by end-user interaction.
This method is then invoked to notify the component that the size has changed. It is called from the top and all the way down to the bottom, the size being adjusted to take into account extra decorations having been added at each level in the component class hierarchy.
Reimplemented from SoWxRenderArea.
Reimplemented in SoWxFullViewer.
|
virtual |
If the current camera is of perspective type, switch to orthographic, and vice versa.
Automatically calls SoWxViewer::setCameraType() so the change will immediately take place.
|
virtual |
Reposition the current camera so we can see the complete scene.
Reimplemented in SoWxFlyViewer.