This method sets the scene graph to be rendered in the normal
bitmap planes.
See also:
getSceneGraph(),
setOverlaySceneGraph()
Reimplemented in SoQtViewer.
This method returns a reference to the scene graph root node as
set by the user.
See also:
SoQtRenderArea::getSceneManager()
Reimplemented in SoQtViewer.
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 supports it.
Important note: not all graphics hardware and / or drivers for
graphics hardware support overlay planes, so application programmers are
adviced 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.
See also:
setSceneGraph(),
getOverlaySceneGraph()
References getOverlaySceneGraph(), and
SoQtGLWidget::setOverlayRender().
This method returns the scene graph for the overlay scene.
Referenced by glScheduleRedraw(), and setOverlaySceneGraph().
This method sets the background color of the scene.
References scheduleRedraw().
This method returns the background color for the scene.
Referenced by SoQtViewer::actualRedraw().
This method sets the index of the background color for the
scene.
References scheduleRedraw().
This method returns the index of the background color for the
scene.
This method sets the index of the background for the overlay
scene.
References scheduleOverlayRedraw().
This method returns the index of the background for the overlay
scene.
This method sets the colormap for the scene.
References scheduleRedraw().
This method sets the colormap for the overlay scene.
References scheduleOverlayRedraw().
This method sets the viewport region.
References scheduleRedraw().
Referenced by sizeChanged().
This method returns the viewport region.
Referenced by SoQtConstrainedViewer::findUpDirection(),
SoQtViewer::seekToPoint(), SoQtViewer::setSceneGraph(), and
SoQtViewer::viewAll().
This method sets the transparency type to be used for the
scene.
References scheduleRedraw().
This method returns the transparency type used for the scene.
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
SoQtGLWidget::setAccumulationBuffer().
References scheduleRedraw().
This method returns the antialiasing used for the scene.
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.
References scheduleRedraw().
This method returns whether the render buffer is cleared before
each render.
Referenced by SoQtViewer::actualRedraw().
This method returns whether the render buffer's Z buffer is
cleared before each render.
Referenced by SoQtViewer::actualRedraw().
This method sets whether the overlay render buffer should be
cleared before each render or not.
References scheduleOverlayRedraw().
This method returns whether the overlay render buffer is cleared
before each redraw or not.
This method sets whether redrawing should be handled automatically
or not when data in the scenegraph changes.
The default setting causes the renderarea to automatically trigger
a redraw of the scenegraph contents.
This method returns whether redrawing is handled automatically
not.
This method sets the redraw priority.
This method returns the redraw priority.
This function returns the default redraw priority.
This method causes the immediate rendering of the scene, by
calling SoQtRenderArea::redraw().
References redraw().
This method renders the overlay scene.
References redrawOverlay().
This method schedules a redraw to happen at a later time (when the
application has processed it's other events first).
Referenced by SoQtFlyViewer::actualRedraw(),
SoQtExaminerViewer::actualRedraw(), glScheduleRedraw(),
SoQtViewer::setAnaglyphStereoColorMasks(), setAntialiasing(),
SoQtViewer::setAutoClipping(), SoQtViewer::setAutoClippingStrategy(),
setBackgroundColor(), setBackgroundIndex(), setClearBeforeRender(),
setColorMap(), SoQtExaminerViewer::setFeedbackSize(),
SoQtExaminerViewer::setFeedbackVisibility(), SoQtViewer::setStereoOffset(),
SoQtViewer::setStereoViewing(), setTransparencyType(),
SoQtFlyViewer::setViewing(), setViewportRegion(), and
SoQtViewer::setWireframeOverlayColor().
This method schedules a redraw of the overlay scene.
Referenced by glScheduleRedraw(), setClearBeforeOverlayRender(),
setOverlayBackgroundIndex(), and setOverlayColorMap().
Do automatic redraw of the scenegraph 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.)
Referenced by ~SoQtRenderArea().
Do automatic redraw of the scenegraph in the overlay planes when a
selection under the SoSelection node is changed.
Pass NULL to deactivate.
See also:
SoQtRenderArea::redrawOnSelectionChange()
Referenced by ~SoQtRenderArea().
This method sets the render area event callback.
This method sets the normal scene SoSceneManager object.
The previous set scene manager is deleted, and there is no way to
currently avoid that. This might change in the future.
References SoQtGLWidget::getGLSize().
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 scenegraph, including
camera, headlight and miscellaneous drawstyle nodes. The
getSceneGraph() method will only return the user scenegrah for
SoQtRenderArea subclass SoQtViewer 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
SoQtRenderArea, then use SoSceneManager::getSceneGraph() to get the
root node Coin uses for rendering.
Referenced by SoQtViewer::actualRedraw(),
SoQtConstrainedViewer::findUpDirection(), and initGraphic().
This method sets the overlay scene SoSceneManager object.
The previous set scene manager is not freed and will leak unless
the user frees it.
References SoQtGLWidget::getGLSize().
This method returns the overlay scene SoSceneManager object.
Referenced by initOverlayGraphic().
This method sets the SoGLRenderAction object for the normal
scene.
References SoQtComponent::getSize(), and sizeChanged().
This method returns the SoGLRenderAction object for the normal
scene.
Referenced by SoQtViewer::setViewing().
This method sets the SoGLRenderAction object for rendering the
overlay scenegraph.
This method returns the SoGLRenderAction object for the overlay
scene graph.
This method posts and processes an SoEvent object to the
SoQtRenderArea-based component and returns the result value from the event
handler. This is a synchronous operation.
References processSoEvent().
This method adds device to the list of devices handling
events for this component.
References SoQtDevice::enable(), SoQtGLWidget::getGLSize(),
SoQtGLWidget::getGLWidget(), and SoQtDevice::setWindowSize().
Referenced by afterRealizeHook().
This method removes device from the list of devices
handling events for this component.
References SoQtDevice::disable(), and
SoQtGLWidget::getGLWidget().
Referenced by ~SoQtRenderArea().
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 singlebuffer or doublebuffer
mode).
After setting up the OpenGL context, it calls
actualRedraw() for the actual scenegraph rendering to take place.
Finally, the OpenGL buffers are either swapped back-to-front (for
doublebuffering) or flushed (for singlebuffering), 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 SoQtGLWidget.
References actualRedraw(), SoQtGLWidget::glFlushBuffer(),
SoQtGLWidget::glLockNormal(), SoQtGLWidget::glSwapBuffers(),
SoQtGLWidget::glUnlockNormal(), SoQtGLWidget::hasNormalGLArea(),
SoQtGLWidget::isDoubleBuffer(), SoQtGLWidget::isDrawToFrontBufferEnable(),
SoQtComponent::isVisible(), and SoQtGLWidget::waitForExpose.
Referenced by render().
This method instantly redraws the normal (non-overlay) scenegraph
by calling SoSceneManager::render().
Subclasses may override this method to add their own rendering
before or after Coin renders it's scenegraph.
The following is a complete example that demonstrates one way of
adding both a background image and foreground (overlay) geometry to the
'normal' rendering:
// This example shows how to put a permanent background image on
// your viewer canvas, below the 3D graphics, plus overlay
// foreground geometry. Written by mortene.
// Copyright Kongsberg Oil & Gas Technologies 2002.
// *************************************************************************
#include <Inventor/Qt/SoQt.h>
#include <Inventor/Qt/viewers/SoQtExaminerViewer.h>
#include <Inventor/nodes/SoBaseColor.h>
#include <Inventor/nodes/SoCone.h>
#include <Inventor/nodes/SoCube.h>
#include <Inventor/nodes/SoImage.h>
#include <Inventor/nodes/SoLightModel.h>
#include <Inventor/nodes/SoOrthographicCamera.h>
#include <Inventor/nodes/SoRotationXYZ.h>
#include <Inventor/nodes/SoSeparator.h>
#include <Inventor/nodes/SoTranslation.h>
#include <GL/gl.h>
// *************************************************************************
class MyExaminerViewer : public SoQtExaminerViewer {
public:
MyExaminerViewer(QWidget * parent, const char * filename);
~MyExaminerViewer();
protected:
virtual void actualRedraw(void);
private:
SoSeparator * bckgroundroot;
SoSeparator * foregroundroot;
SoRotationXYZ * arrowrotation;
};
MyExaminerViewer::MyExaminerViewer(QWidget * parent, const char * filename)
: SoQtExaminerViewer(parent)
{
// Coin should not clear the pixel-buffer, so the background image
// is not removed.
this->setClearBeforeRender(FALSE, TRUE);
// Set up background scenegraph with image in it.
this->bckgroundroot = new SoSeparator;
this->bckgroundroot->ref();
SoOrthographicCamera * cam = new SoOrthographicCamera;
cam->position = SbVec3f(0, 0, 1);
cam->height = 1;
// SoImage will be at z==0.0.
cam->nearDistance = 0.5;
cam->farDistance = 1.5;
SoImage * img = new SoImage;
img->vertAlignment = SoImage::HALF;
img->horAlignment = SoImage::CENTER;
img->filename = filename;
this->bckgroundroot->addChild(cam);
this->bckgroundroot->addChild(img);
// Set up foreground, overlayed scenegraph.
this->foregroundroot = new SoSeparator;
this->foregroundroot->ref();
SoLightModel * lm = new SoLightModel;
lm->model = SoLightModel::BASE_COLOR;
SoBaseColor * bc = new SoBaseColor;
bc->rgb = SbColor(1, 1, 0);
cam = new SoOrthographicCamera;
cam->position = SbVec3f(0, 0, 5);
cam->height = 10;
cam->nearDistance = 0;
cam->farDistance = 10;
const double ARROWSIZE = 2.0;
SoTranslation * posit = new SoTranslation;
posit->translation = SbVec3f(-2.5 * ARROWSIZE, 1.5 * ARROWSIZE, 0);
arrowrotation = new SoRotationXYZ;
arrowrotation->axis = SoRotationXYZ::Z;
SoTranslation * offset = new SoTranslation;
offset->translation = SbVec3f(ARROWSIZE/2.0, 0, 0);
SoCube * cube = new SoCube;
cube->width = ARROWSIZE;
cube->height = ARROWSIZE/15.0;
this->foregroundroot->addChild(cam);
this->foregroundroot->addChild(lm);
this->foregroundroot->addChild(bc);
this->foregroundroot->addChild(posit);
this->foregroundroot->addChild(arrowrotation);
this->foregroundroot->addChild(offset);
this->foregroundroot->addChild(cube);
}
MyExaminerViewer::~MyExaminerViewer()
{
this->bckgroundroot->unref();
this->foregroundroot->unref();
}
void
MyExaminerViewer::actualRedraw(void)
{
// Must set up the OpenGL viewport manually, as upon resize
// operations, Coin won't set it up until the SoGLRenderAction is
// applied again. And since we need to do glClear() before applying
// the action..
const SbViewportRegion vp = this->getViewportRegion();
SbVec2s origin = vp.getViewportOriginPixels();
SbVec2s size = vp.getViewportSizePixels();
glViewport(origin[0], origin[1], size[0], size[1]);
const SbColor col = this->getBackgroundColor();
glClearColor(col[0], col[1], col[2], 0.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// Render our scenegraph with the image.
SoGLRenderAction * glra = this->getGLRenderAction();
glra->apply(this->bckgroundroot);
// Render normal scenegraph.
SoQtExaminerViewer::actualRedraw();
// Increase arrow angle with 1/1000 ° every frame.
arrowrotation->angle = arrowrotation->angle.getValue() + (0.001 / M_PI * 180);
// Render overlay front scenegraph.
glClear(GL_DEPTH_BUFFER_BIT);
glra->apply(this->foregroundroot);
}
// *************************************************************************
int
main(int argc, char ** argv)
{
if (argc != 2) {
(void)fprintf(stderr, "0tUsage: %s <image-filename>0, argv[0]);
exit(1);
}
QWidget * window = SoQt::init(argv[0]);
MyExaminerViewer * viewer = new MyExaminerViewer(window, argv[1]);
viewer->setSceneGraph(new SoCone);
viewer->show();
SoQt::show(window);
SoQt::mainLoop();
delete viewer;
return 0;
}
// *************************************************************************
Reimplemented in SoQtViewer, SoQtExaminerViewer,
SoQtFlyViewer, and SoQtPlaneViewer.
References SoQtComponent::isVisible().
Referenced by redraw().
This method redraws the overlay scene.
Reimplemented from SoQtGLWidget.
References actualOverlayRedraw(), SoQtGLWidget::glFlushBuffer(),
SoQtGLWidget::glLockOverlay(), SoQtGLWidget::glUnlockOverlay(),
SoQtGLWidget::hasOverlayGLArea(), SoQtComponent::isVisible(), and
SoQtGLWidget::waitForExpose.
Referenced by renderOverlay().
This method renders the overlay scene.
References SoQtComponent::isVisible().
Referenced by redrawOverlay().
Toolkit-native events are attempted converted to Coin-generic
events in the SoQtRenderArea::processEvent() method. If this
succeeds, they are forwarded to this method.
This is a virtual method, and is overridden in it's subclasses to
catch events of particular interest to the viewer classes, for instance.
Return TRUE iff 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 SoQtViewer, SoQtFullViewer,
SoQtExaminerViewer, SoQtFlyViewer, and
SoQtPlaneViewer.
Referenced by processEvent(), and sendSoEvent().
Overrides SoQtGLWidget::processEvent() to attempt to
convert toolkit-native events to Coin-generic events. If this succeeds, the
generic SoEvent is forwarded to SoQtRenderArea::processSoEvent().
Reimplemented from SoQtGLWidget.
References SoQtGLWidget::glLockNormal(),
SoQtGLWidget::glUnlockNormal(), and processSoEvent().
This method is invoked to initialize the normal graphics.
Reimplemented from SoQtGLWidget.
References getSceneManager(), and SoQtGLWidget::isRGBMode().
This method is invoked to initialize the overlay graphics.
Reimplemented from SoQtGLWidget.
References getOverlaySceneManager().
Called internally from within the SoQt library when the
widget embedded in a component changes it 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 SoQtGLWidget.
Reimplemented in SoQtViewer, and SoQtFullViewer.
References SoQtObject::getClassTypeId(),
SoQtGLWidget::getGLSize(), SoQtObject::getTypeId(),
SoQtGLWidget::setGLSize(), and setViewportRegion().
Referenced by setGLRenderAction().
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 SoQtGLWidget::getGLWidget()
method.
See also:
sizeChanged()
Reimplemented from SoQtGLWidget.
References SoQtGLWidget::isRGBMode().
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:
void
MyLittleViewer::afterRealizeHook(void)
{
<superclass>::afterRealizeHook();
// [own initialization here]
}
Reimplemented from SoQtComponent.
Reimplemented in SoQtExaminerViewer,
SoQtPlaneViewer, and SoQtFlyViewer.
References registerDevice().
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 SoQtComponent.
Reimplemented in SoQtExaminerViewer, SoQtFlyViewer,
and SoQtPlaneViewer.
This method returns the default window caption string of the
component.
It should be overridden by derived non-abstract classes so the
window and popup menu will get a proper title.
Reimplemented from SoQtComponent.
Reimplemented in SoQtExaminerViewer, SoQtFlyViewer,
and SoQtPlaneViewer.
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 SoQtComponent.
Reimplemented in SoQtExaminerViewer, SoQtFlyViewer,
and SoQtPlaneViewer.
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 SoQtGLWidget.
References getOverlaySceneGraph(),
SoQtGLWidget::hasOverlayGLArea(), scheduleOverlayRedraw(), and
scheduleRedraw().