SoWx
0.1.0
Coin3D GUI toolkit binding
|
The SoWxRenderArea class adds scene graph handling and event management. More...
#include <Inventor/Wx/SoWxRenderArea.h>
Public Member Functions | |
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 |
virtual SoNode * | getSceneGraph (void) |
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) |
virtual void | setSceneGraph (SoNode *scene) |
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) |
virtual void | setDoubleBuffer (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 |
Static Public Member Functions | |
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 Member Functions | |
SoWxRenderArea (wxWindow *parent, const char *name, SbBool embed, SbBool mouseInput, SbBool keyboardInput, SbBool build) | |
virtual void | actualOverlayRedraw (void) |
virtual void | actualRedraw (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 SbBool | processSoEvent (const SoEvent *const event) |
virtual void | redraw (void) |
virtual void | redrawOverlay (void) |
virtual void | sizeChanged (const SbVec2s &size) |
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 | |
Protected Attributes inherited from SoWxGLWidget | |
SbBool | drawToFrontBuffer |
SbBool | waitForExpose |
Protected Attributes inherited from SoWxComponent | |
SbBool | firstRealize |
The SoWxRenderArea class adds scene graph handling and event management.
The SoWxRenderArea class is a component that adds scene graph management and input device event handling to the SoWxGLWidget component.
The class has many convenient methods for controlling aspects of the rendering, like for instance transparency, aliasing and for scheduling of redraws.
Native toolkit events are caught by SoWxRenderArea components, translated to Coin SoEvent instances and passed on to the scene graph, in case the user is doing interactive operations on for instance Coin geometry draggers.
SoWxRenderArea is the first non-abstract component in its inheritance hierarchy that you can use directly from client application code to set up a scene graph viewer canvas.
For an SoWxRenderArea component to properly display your scene graph, it must contain an SoCamera-derived node and at least one SoLight-derived light source node.
Here's a complete, stand-alone example on how to set up an SoWxRenderArea with a scene graph:
SoWxRenderArea::SoWxRenderArea | ( | wxWindow * | parent = NULL, |
const char * | name = NULL, | ||
SbBool | embed = TRUE, | ||
SbBool | mouseInput = TRUE, | ||
SbBool | keyboardInput = TRUE ) |
Public constructor.
SoWxRenderArea::~SoWxRenderArea | ( | ) |
Destructor.
|
protected |
Protected constructor used by derived classes.
|
protectedvirtual |
This method renders the overlay scene.
|
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 in SoWxExaminerViewer, SoWxFlyViewer, SoWxPlaneViewer, and SoWxViewer.
|
protectedvirtual |
A function "hook" / callback invoked just after the window for the component has been realized.
Override this if you need specific initialization for your own component or viewer class to happen right after it has been made visible, but remember to call upwards in the inheritance hierarchy:
Reimplemented from SoWxComponent.
Reimplemented in SoWxExaminerViewer, SoWxFlyViewer, and SoWxPlaneViewer.
void SoWxRenderArea::getAntialiasing | ( | SbBool & | smoothing, |
int & | numPasses ) const |
This method returns the antialiasing used for the scene.
const SbColor & SoWxRenderArea::getBackgroundColor | ( | void | ) | const |
This method returns the background color for the scene.
int SoWxRenderArea::getBackgroundIndex | ( | void | ) | const |
This method returns the index of the background color for the scene.
|
protectedvirtual |
This method returns the default icon title of the component.
It should be overridden by derived non-abstract classes so icons will get proper titles.
Reimplemented from SoWxComponent.
Reimplemented in SoWxExaminerViewer, SoWxFlyViewer, and SoWxPlaneViewer.
|
static |
This function returns the default redraw priority.
|
protectedvirtual |
This method returns the default window caption string of the component.
It should be overridden by derived non-abstract classes so the window and pop-up menu will get a proper title.
Reimplemented from SoWxComponent.
Reimplemented in SoWxExaminerViewer, SoWxFlyViewer, and SoWxPlaneViewer.
|
protectedvirtual |
This method returns the default name of a component widget class.
It should be overridden by derived non-abstract classes for the topmost widget in the component to have a proper name.
Reimplemented from SoWxComponent.
Reimplemented in SoWxExaminerViewer, SoWxFlyViewer, and SoWxPlaneViewer.
SoGLRenderAction * SoWxRenderArea::getGLRenderAction | ( | void | ) | const |
This method returns the SoGLRenderAction object for the normal scene.
int SoWxRenderArea::getOverlayBackgroundIndex | ( | void | ) | const |
This method returns the index of the background for the overlay scene.
SoGLRenderAction * SoWxRenderArea::getOverlayGLRenderAction | ( | void | ) | const |
This method returns the SoGLRenderAction object for the overlay scene graph.
SoNode * SoWxRenderArea::getOverlaySceneGraph | ( | void | ) |
This method returns the scene graph for the overlay scene.
SoSceneManager * SoWxRenderArea::getOverlaySceneManager | ( | void | ) | const |
This method returns the overlay scene SoSceneManager object.
uint32_t SoWxRenderArea::getRedrawPriority | ( | void | ) | const |
This method returns the redraw priority.
|
virtual |
This method returns a reference to the scene graph root node as set by the user.
Reimplemented in SoWxViewer.
SoSceneManager * SoWxRenderArea::getSceneManager | ( | void | ) | const |
This method returns the normal scene SoSceneManager object.
Having a reference to the SoSceneManager instance is useful for getting at the real root node of the rendering scene graph, including camera, headlight and miscellaneous draw style nodes. The getSceneGraph() method will only return the user scene graph for SoWxRenderArea subclass SoWxViewer and further subclasses. The reason this is not always what you want is because certain actions (like the SoRayPickAction) needs to traverse a valid camera if it should work as expected.
If you need to get a pointer to the real root node use this method to get the SoSceneManager instance reference used by the SoWxRenderArea, then use SoSceneManager::getSceneGraph() to get the root node Coin uses for rendering.
SoGLRenderAction::TransparencyType SoWxRenderArea::getTransparencyType | ( | void | ) | const |
This method returns the transparency type used for the scene.
const SbViewportRegion & SoWxRenderArea::getViewportRegion | ( | void | ) | const |
This method returns the viewport region.
|
protectedvirtual |
Will be called whenever scene graph needs to be redrawn. If this method return FALSE
, redraw() will be called immediately.
Default method simply returns FALSE
. Override this method to schedule a redraw and return TRUE
if you're trying to do The Right Thing.
Reimplemented from SoWxGLWidget.
|
protectedvirtual |
This method is invoked to initialize the normal graphics.
Reimplemented from SoWxGLWidget.
|
protectedvirtual |
This method is invoked to initialize the overlay graphics.
Reimplemented from SoWxGLWidget.
SbBool SoWxRenderArea::isAutoRedraw | ( | void | ) | const |
This method returns whether redrawing is handled automatically not.
SbBool SoWxRenderArea::isClearBeforeOverlayRender | ( | void | ) | const |
This method returns whether the overlay render buffer is cleared before each redraw or not.
SbBool SoWxRenderArea::isClearBeforeRender | ( | void | ) | const |
This method returns whether the render buffer is cleared before each render.
SbBool SoWxRenderArea::isClearZBufferBeforeRender | ( | void | ) | const |
This method returns whether the render buffer's z-buffer is cleared before each render.
|
protectedvirtual |
Overrides SoWxGLWidget::processEvent() to try to convert toolkit-native events to Coin-generic events. If this succeeds, the generic SoEvent is forwarded to SoWxRenderArea::processSoEvent().
Reimplemented from SoWxGLWidget.
|
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 in SoWxExaminerViewer, SoWxFlyViewer, SoWxFullViewer, SoWxPlaneViewer, and SoWxViewer.
|
protectedvirtual |
This method is called from the render() method and takes care of setting up the context for OpenGL rendering (by making the OpenGL canvas the current context and specifying either the front or back buffer for rendering, depending on whether we're in single buffer or double buffer mode).
After setting up the OpenGL context, it calls actualRedraw() for the actual scene graph rendering to take place.
Finally, the OpenGL buffers are either swapped back-to-front (for double buffering) or flushed (for single buffering), and our OpenGL context is unlocked.
The application programmer may override this method if extreme low-level control of the rendering process is necessary. Usually, you should be able to get away with overriding actualRedraw() for special cases, though.
Implements SoWxGLWidget.
void SoWxRenderArea::redrawOnSelectionChange | ( | SoSelection * | selection | ) |
Do automatic redraw of the scene graph when a selection under the SoSelection node is changed.
Pass NULL
to deactivate.
(Only one SoSelection node can be monitored at any given time. This is obviously a rather silly design flaw. We choose to match the original Inventor API here, but this will probably change in the next major revision of the library.)
|
protectedvirtual |
This method redraws the overlay scene.
Reimplemented from SoWxGLWidget.
void SoWxRenderArea::redrawOverlayOnSelectionChange | ( | SoSelection * | selection | ) |
Do automatic redraw of the scene graph in the overlay planes when a selection under the SoSelection node is changed.
Pass NULL
to deactivate.
void SoWxRenderArea::registerDevice | ( | SoWxDevice * | device | ) |
This method adds device to the list of devices handling events for this component.
void SoWxRenderArea::render | ( | void | ) |
This method causes the immediate rendering of the scene, by calling SoWxRenderArea::redraw().
void SoWxRenderArea::renderOverlay | ( | void | ) |
This method renders the overlay scene.
void SoWxRenderArea::scheduleOverlayRedraw | ( | void | ) |
This method schedules a redraw of the overlay scene.
void SoWxRenderArea::scheduleRedraw | ( | void | ) |
This method schedules a redraw to happen at a later time (when the application has processed its other events first).
SbBool SoWxRenderArea::sendSoEvent | ( | const SoEvent * | event | ) |
This method posts and processes an SoEvent object to the SoWxRenderArea-based component and returns the result value from the event handler. This is a synchronous operation.
void SoWxRenderArea::setAntialiasing | ( | SbBool | smoothing, |
int | numPasses ) |
This method sets the antialiasing used for the scene.
The smoothing flag signifies whether or not line and point aliasing should be turned on. See documentation of SoGLRenderAction::setSmoothing(), which will be called from this function.
numPasses gives the number of re-renderings to do of the scene, blending together the results from slight "jitters" of the camera view into the OpenGL accumulation buffer. For further information, see documentation of SoGLRenderAction::setNumPasses() and SoWxGLWidget::setAccumulationBuffer().
void SoWxRenderArea::setAutoRedraw | ( | SbBool | enable | ) |
This method sets whether redrawing should be handled automatically or not when data in the scene graph changes.
The default setting causes the render area to automatically trigger a redraw of the scene graph contents.
void SoWxRenderArea::setBackgroundColor | ( | const SbColor & | color | ) |
This method sets the background color of the scene.
void SoWxRenderArea::setBackgroundIndex | ( | int | idx | ) |
This method sets the index of the background color for the scene.
void SoWxRenderArea::setClearBeforeOverlayRender | ( | SbBool | enable | ) |
This method sets whether the overlay render buffer should be cleared before each render or not.
void SoWxRenderArea::setClearBeforeRender | ( | SbBool | enable, |
SbBool | zbEnable = TRUE ) |
This method sets whether the render buffer should be cleared before rendering.
The first argument specifies whether or not to clear out the pixels in the buffer, the second argument specifies whether or not the z-buffer values should be cleared between renderings.
Setting the first argument to FALSE
can for instance be used when you want to clear out the buffer yourself, for instance by drawing a background image "under" the 3D scene rendered by Coin / Inventor.
void SoWxRenderArea::setColorMap | ( | int | start, |
int | num, | ||
const SbColor * | colors ) |
This method sets the colormap for the scene.
void SoWxRenderArea::setEventCallback | ( | SoWxRenderAreaEventCB * | func, |
void * | user = NULL ) |
This method sets the render area event callback.
void SoWxRenderArea::setGLRenderAction | ( | SoGLRenderAction * | action | ) |
This method sets the SoGLRenderAction object for the normal scene.
void SoWxRenderArea::setOverlayBackgroundIndex | ( | int | idx | ) |
This method sets the index of the background for the overlay scene.
void SoWxRenderArea::setOverlayColorMap | ( | int | start, |
int | num, | ||
const SbColor * | colors ) |
This method sets the colormap for the overlay scene.
void SoWxRenderArea::setOverlayGLRenderAction | ( | SoGLRenderAction * | action | ) |
This method sets the SoGLRenderAction object for rendering the overlay scene graph.
void SoWxRenderArea::setOverlaySceneGraph | ( | SoNode * | scene | ) |
This method sets the scene graph to render for the overlay bitmap planes.
It will automatically take care of setting up overplay planes in the OpenGL canvas if the OpenGL hardware and driver support it.
Important note: not all graphics hardware and / or drivers for graphics hardware support overlay planes, so application programmers are advised to find some other way of accomplishing what they want to do before resorting to using overlay planes. Using overlay planes will in practice severely limit the portability of applications which depend on them being available.
void SoWxRenderArea::setOverlaySceneManager | ( | SoSceneManager * | manager | ) |
This method sets the overlay scene SoSceneManager object.
The previously set scene manager is not freed and will leak unless the user frees it.
void SoWxRenderArea::setRedrawPriority | ( | uint32_t | priority | ) |
This method sets the redraw priority.
|
virtual |
This method sets the scene graph to be rendered in the normal bitmap planes.
Reimplemented in SoWxViewer.
void SoWxRenderArea::setSceneManager | ( | SoSceneManager * | manager | ) |
This method sets the normal scene SoSceneManager object.
The previously set scene manager is deleted, and there is no way to currently avoid that. This might change in the future.
void SoWxRenderArea::setTransparencyType | ( | SoGLRenderAction::TransparencyType | type | ) |
This method sets the transparency type to be used for the scene.
void SoWxRenderArea::setViewportRegion | ( | const SbViewportRegion & | region | ) |
This method sets the viewport region.
|
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 SoWxGLWidget.
Reimplemented in SoWxFullViewer, and SoWxViewer.
void SoWxRenderArea::unregisterDevice | ( | SoWxDevice * | device | ) |
This method removes device from the list of devices handling events for this component.
|
protectedvirtual |
This is the method which gets called whenever we change which OpenGL widget is used.
Should be overridden in subclasses which directly or indirectly store the return value from the SoWxGLWidget::getGLWidget() method.
Reimplemented from SoWxGLWidget.