.TH "SoQtRenderArea" 3 "Sun Dec 11 2011" "Version 1.5.0" "SoQt" \" -*- nroff -*- .ad l .nh .SH NAME SoQtRenderArea \- .PP The \fBSoQtRenderArea\fP class adds scenegraph handling and event management\&. .PP The \fBSoQtRenderArea\fP class is a component that adds scenegraph management and input device event handling to the \fBSoQtGLWidget\fP component\&. .SH SYNOPSIS .br .PP .PP \fC#include \fP .PP Inherits \fBSoQtGLWidget\fP\&. .PP Inherited by \fBSoQtViewer\fP\&. .SS "Public Member Functions" .in +1c .ti -1c .RI "\fBSoQtRenderArea\fP (QWidget *parent=NULL, const char *name=NULL, SbBool embed=TRUE, SbBool mouseInput=TRUE, SbBool keyboardInput=TRUE)" .br .ti -1c .RI "\fB~SoQtRenderArea\fP ()" .br .ti -1c .RI "virtual void \fBsetSceneGraph\fP (SoNode *scene)" .br .ti -1c .RI "virtual SoNode * \fBgetSceneGraph\fP (void)" .br .ti -1c .RI "void \fBsetOverlaySceneGraph\fP (SoNode *scene)" .br .ti -1c .RI "SoNode * \fBgetOverlaySceneGraph\fP (void)" .br .ti -1c .RI "void \fBsetBackgroundColor\fP (const SbColor &color)" .br .ti -1c .RI "const SbColor & \fBgetBackgroundColor\fP (void) const " .br .ti -1c .RI "void \fBsetBackgroundIndex\fP (int idx)" .br .ti -1c .RI "int \fBgetBackgroundIndex\fP (void) const " .br .ti -1c .RI "void \fBsetOverlayBackgroundIndex\fP (int idx)" .br .ti -1c .RI "int \fBgetOverlayBackgroundIndex\fP (void) const " .br .ti -1c .RI "void \fBsetColorMap\fP (int start, int num, const SbColor *colors)" .br .ti -1c .RI "void \fBsetOverlayColorMap\fP (int start, int num, const SbColor *colors)" .br .ti -1c .RI "void \fBsetViewportRegion\fP (const SbViewportRegion &newRegion)" .br .ti -1c .RI "const SbViewportRegion & \fBgetViewportRegion\fP (void) const " .br .ti -1c .RI "void \fBsetTransparencyType\fP (SoGLRenderAction::TransparencyType type)" .br .ti -1c .RI "SoGLRenderAction::TransparencyType \fBgetTransparencyType\fP (void) const " .br .ti -1c .RI "void \fBsetAntialiasing\fP (SbBool smoothing, int numPasses)" .br .ti -1c .RI "void \fBgetAntialiasing\fP (SbBool &smoothing, int &numPasses) const " .br .ti -1c .RI "void \fBsetClearBeforeRender\fP (SbBool enable, SbBool zbEnable=TRUE)" .br .ti -1c .RI "SbBool \fBisClearBeforeRender\fP (void) const " .br .ti -1c .RI "SbBool \fBisClearZBufferBeforeRender\fP (void) const " .br .ti -1c .RI "void \fBsetClearBeforeOverlayRender\fP (SbBool enable)" .br .ti -1c .RI "SbBool \fBisClearBeforeOverlayRender\fP (void) const " .br .ti -1c .RI "void \fBsetAutoRedraw\fP (SbBool enable)" .br .ti -1c .RI "SbBool \fBisAutoRedraw\fP (void) const " .br .ti -1c .RI "void \fBsetRedrawPriority\fP (uint32_t priority)" .br .ti -1c .RI "uint32_t \fBgetRedrawPriority\fP (void) const " .br .ti -1c .RI "void \fBrender\fP (void)" .br .ti -1c .RI "void \fBrenderOverlay\fP (void)" .br .ti -1c .RI "void \fBscheduleRedraw\fP (void)" .br .ti -1c .RI "void \fBscheduleOverlayRedraw\fP (void)" .br .ti -1c .RI "void \fBredrawOnSelectionChange\fP (SoSelection *selection)" .br .ti -1c .RI "void \fBredrawOverlayOnSelectionChange\fP (SoSelection *selection)" .br .ti -1c .RI "void \fBsetEventCallback\fP (SoQtRenderAreaEventCB *func, void *user=NULL)" .br .ti -1c .RI "void \fBsetSceneManager\fP (SoSceneManager *manager)" .br .ti -1c .RI "SoSceneManager * \fBgetSceneManager\fP (void) const " .br .ti -1c .RI "void \fBsetOverlaySceneManager\fP (SoSceneManager *manager)" .br .ti -1c .RI "SoSceneManager * \fBgetOverlaySceneManager\fP (void) const " .br .ti -1c .RI "void \fBsetGLRenderAction\fP (SoGLRenderAction *action)" .br .ti -1c .RI "SoGLRenderAction * \fBgetGLRenderAction\fP (void) const " .br .ti -1c .RI "void \fBsetOverlayGLRenderAction\fP (SoGLRenderAction *action)" .br .ti -1c .RI "SoGLRenderAction * \fBgetOverlayGLRenderAction\fP (void) const " .br .ti -1c .RI "SbBool \fBsendSoEvent\fP (const SoEvent *event)" .br .ti -1c .RI "void \fBregisterDevice\fP (\fBSoQtDevice\fP *device)" .br .ti -1c .RI "void \fBunregisterDevice\fP (\fBSoQtDevice\fP *device)" .br .in -1c .SS "Static Public Member Functions" .in +1c .ti -1c .RI "static uint32_t \fBgetDefaultRedrawPriority\fP (void)" .br .in -1c .SS "Protected Member Functions" .in +1c .ti -1c .RI "\fBSoQtRenderArea\fP (QWidget *parent, const char *name, SbBool embed, SbBool mouseInput, SbBool keyboardInput, SbBool build)" .br .ti -1c .RI "virtual void \fBredraw\fP (void)" .br .ti -1c .RI "virtual void \fBactualRedraw\fP (void)" .br .ti -1c .RI "virtual void \fBredrawOverlay\fP (void)" .br .ti -1c .RI "virtual void \fBactualOverlayRedraw\fP (void)" .br .ti -1c .RI "virtual SbBool \fBprocessSoEvent\fP (const SoEvent *const event)" .br .ti -1c .RI "virtual void \fBprocessEvent\fP (QEvent *event)" .br .ti -1c .RI "virtual void \fBinitGraphic\fP (void)" .br .ti -1c .RI "virtual void \fBinitOverlayGraphic\fP (void)" .br .ti -1c .RI "virtual void \fBsizeChanged\fP (const SbVec2s &size)" .br .ti -1c .RI "virtual void \fBwidgetChanged\fP (QWidget *widget)" .br .ti -1c .RI "virtual void \fBafterRealizeHook\fP (void)" .br .ti -1c .RI "QWidget * \fBbuildWidget\fP (QWidget *parent)" .br .ti -1c .RI "virtual const char * \fBgetDefaultWidgetName\fP (void) const " .br .ti -1c .RI "virtual const char * \fBgetDefaultTitle\fP (void) const " .br .ti -1c .RI "virtual const char * \fBgetDefaultIconTitle\fP (void) const " .br .ti -1c .RI "virtual SbBool \fBglScheduleRedraw\fP (void)" .br .in -1c .SS "Friends" .in +1c .ti -1c .RI "class \fBSoQtRenderAreaP\fP" .br .in -1c .SH "Detailed Description" .PP The \fBSoQtRenderArea\fP class adds scenegraph handling and event management\&. .PP The \fBSoQtRenderArea\fP class is a component that adds scenegraph management and input device event handling to the \fBSoQtGLWidget\fP component\&. The class has many convenient methods for controlling aspects of the rendering, like for instance transparency, aliasing and for scheduling of redraws\&. .PP Native toolkit events are caught by \fBSoQtRenderArea\fP components, translated to Coin SoEvent instances and passed on to the scenegraph, in case the user is doing interactive operations on for instance Coin geometry draggers\&. .PP \fBSoQtRenderArea\fP is the first non-abstract component in it's inheritance hierarchy that you can use directly from client application code to set up a scenegraph viewer canvas\&. .PP For an \fBSoQtRenderArea\fP component to properly display your scenegraph, it must contain an SoCamera-derived node and at least one SoLight-derived lightsource node\&. .PP Here's a complete, stand-alone example on how to set up an \fBSoQtRenderArea\fP with a scenegraph: .PP .PP .nf #include #include #include #include #include #include #include #include // Set up a simple scenegraph, just for demonstration purposes\&. static SoSeparator * get_scene_graph(void) { SoSeparator * root = new SoSeparator; SoGroup * group = new SoGroup; SoRotor * rotor = new SoRotor; rotor->rotation = SbRotation(SbVec3f(0\&.2, 0\&.5, 0\&.9), M_PI/4\&.0); group->addChild(rotor); SoCube * cube = new SoCube; group->addChild(cube); SoArray * array = new SoArray; array->origin = SoArray::CENTER; array->addChild(group); array->numElements1 = 2; array->numElements2 = 2; array->separation1 = SbVec3f(4, 0, 0); array->separation2 = SbVec3f(0, 4, 0); root->addChild(array); return root; } int main(int argc, char ** argv) { QWidget * window = SoQt::init(argv[0]); SoSeparator * root = new SoSeparator; root->ref(); SoPerspectiveCamera * camera; root->addChild(camera = new SoPerspectiveCamera); root->addChild(new SoDirectionalLight); SoSeparator * userroot = get_scene_graph(); root->addChild(userroot); SoQtRenderArea * renderarea = new SoQtRenderArea(window); camera->viewAll(userroot, renderarea->getViewportRegion()); renderarea->setSceneGraph(root); renderarea->setBackgroundColor(SbColor(0\&.0f, 0\&.2f, 0\&.3f)); if (argc > 1) { renderarea->setTitle(argv[1]); renderarea->setIconTitle(argv[1]); } renderarea->show(); SoQt::show(window); SoQt::mainLoop(); delete renderarea; root->unref(); return 0; } .fi .PP .SH "Constructor & Destructor Documentation" .PP .SS "\fBSoQtRenderArea::SoQtRenderArea\fP (QWidget *parent = \fCNULL\fP, const char *name = \fCNULL\fP, SbBoolembed = \fCTRUE\fP, SbBoolmouseInput = \fCTRUE\fP, SbBoolkeyboardInput = \fCTRUE\fP)"Public constructor\&. .SS "\fBSoQtRenderArea::~SoQtRenderArea\fP ()"Destructor\&. .PP References redrawOnSelectionChange(), redrawOverlayOnSelectionChange(), and unregisterDevice()\&. .SS "\fBSoQtRenderArea::SoQtRenderArea\fP (QWidget *parent, const char *name, SbBoolembed, SbBoolmouseInput, SbBoolkeyboardInput, SbBoolbuild)\fC [protected]\fP"Protected constructor used by derived classes\&. .SH "Member Function Documentation" .PP .SS "void \fBSoQtRenderArea::setSceneGraph\fP (SoNode *scene)\fC [virtual]\fP"This method sets the scene graph to be rendered in the normal bitmap planes\&. .PP \fBSee also:\fP .RS 4 \fBgetSceneGraph()\fP, \fBsetOverlaySceneGraph()\fP .RE .PP .PP Reimplemented in \fBSoQtViewer\fP\&. .SS "SoNode * \fBSoQtRenderArea::getSceneGraph\fP (void)\fC [virtual]\fP"This method returns a reference to the scene graph root node as set by the user\&. .PP \fBSee also:\fP .RS 4 \fBSoQtRenderArea::getSceneManager()\fP .RE .PP .PP Reimplemented in \fBSoQtViewer\fP\&. .SS "void \fBSoQtRenderArea::setOverlaySceneGraph\fP (SoNode *scene)"This method sets the scene graph to render for the overlay bitmap planes\&. .PP It will automatically take care of setting up overplay planes in the OpenGL canvas if the OpenGL hardware and driver supports it\&. .PP 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\&. .PP \fBSee also:\fP .RS 4 \fBsetSceneGraph()\fP, \fBgetOverlaySceneGraph()\fP .RE .PP .PP References getOverlaySceneGraph(), and SoQtGLWidget::setOverlayRender()\&. .SS "SoNode * \fBSoQtRenderArea::getOverlaySceneGraph\fP (void)"This method returns the scene graph for the overlay scene\&. .PP Referenced by glScheduleRedraw(), and setOverlaySceneGraph()\&. .SS "void \fBSoQtRenderArea::setBackgroundColor\fP (const SbColor &color)"This method sets the background color of the scene\&. .PP References scheduleRedraw()\&. .SS "const SbColor & \fBSoQtRenderArea::getBackgroundColor\fP (void) const"This method returns the background color for the scene\&. .PP Referenced by SoQtViewer::actualRedraw()\&. .SS "void \fBSoQtRenderArea::setBackgroundIndex\fP (intidx)"This method sets the index of the background color for the scene\&. .PP References scheduleRedraw()\&. .SS "int \fBSoQtRenderArea::getBackgroundIndex\fP (void) const"This method returns the index of the background color for the scene\&. .SS "void \fBSoQtRenderArea::setOverlayBackgroundIndex\fP (intidx)"This method sets the index of the background for the overlay scene\&. .PP References scheduleOverlayRedraw()\&. .SS "int \fBSoQtRenderArea::getOverlayBackgroundIndex\fP (void) const"This method returns the index of the background for the overlay scene\&. .SS "void \fBSoQtRenderArea::setColorMap\fP (intstart, intnum, const SbColor *colors)"This method sets the colormap for the scene\&. .PP References scheduleRedraw()\&. .SS "void \fBSoQtRenderArea::setOverlayColorMap\fP (intstart, intnum, const SbColor *colors)"This method sets the colormap for the overlay scene\&. .PP References scheduleOverlayRedraw()\&. .SS "void \fBSoQtRenderArea::setViewportRegion\fP (const SbViewportRegion ®ion)"This method sets the viewport region\&. .PP References scheduleRedraw()\&. .PP Referenced by sizeChanged()\&. .SS "const SbViewportRegion & \fBSoQtRenderArea::getViewportRegion\fP (void) const"This method returns the viewport region\&. .PP Referenced by SoQtConstrainedViewer::findUpDirection(), SoQtViewer::seekToPoint(), SoQtViewer::setSceneGraph(), and SoQtViewer::viewAll()\&. .SS "void \fBSoQtRenderArea::setTransparencyType\fP (SoGLRenderAction::TransparencyTypetype)"This method sets the transparency type to be used for the scene\&. .PP References scheduleRedraw()\&. .SS "SoGLRenderAction::TransparencyType \fBSoQtRenderArea::getTransparencyType\fP (void) const"This method returns the transparency type used for the scene\&. .SS "void \fBSoQtRenderArea::setAntialiasing\fP (SbBoolsmoothing, intnumPasses)"This method sets the antialiasing used for the scene\&. .PP The \fIsmoothing\fP 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\&. .PP \fInumPasses\fP 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 \fBSoQtGLWidget::setAccumulationBuffer()\fP\&. .PP References scheduleRedraw()\&. .SS "void \fBSoQtRenderArea::getAntialiasing\fP (SbBool &smoothing, int &numPasses) const"This method returns the antialiasing used for the scene\&. .SS "void \fBSoQtRenderArea::setClearBeforeRender\fP (SbBoolenable, SbBoolzbEnable = \fCTRUE\fP)"This method sets whether the render buffer should be cleared before rendering\&. .PP 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\&. .PP Setting the first argument to \fCFALSE\fP 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\&. .PP References scheduleRedraw()\&. .SS "SbBool \fBSoQtRenderArea::isClearBeforeRender\fP (void) const"This method returns whether the render buffer is cleared before each render\&. .PP Referenced by SoQtViewer::actualRedraw()\&. .SS "SbBool \fBSoQtRenderArea::isClearZBufferBeforeRender\fP (void) const"This method returns whether the render buffer's Z buffer is cleared before each render\&. .PP Referenced by SoQtViewer::actualRedraw()\&. .SS "void \fBSoQtRenderArea::setClearBeforeOverlayRender\fP (SbBoolenable)"This method sets whether the overlay render buffer should be cleared before each render or not\&. .PP References scheduleOverlayRedraw()\&. .SS "SbBool \fBSoQtRenderArea::isClearBeforeOverlayRender\fP (void) const"This method returns whether the overlay render buffer is cleared before each redraw or not\&. .SS "void \fBSoQtRenderArea::setAutoRedraw\fP (SbBoolenable)"This method sets whether redrawing should be handled automatically or not when data in the scenegraph changes\&. .PP The default setting causes the renderarea to automatically trigger a redraw of the scenegraph contents\&. .SS "SbBool \fBSoQtRenderArea::isAutoRedraw\fP (void) const"This method returns whether redrawing is handled automatically not\&. .SS "void \fBSoQtRenderArea::setRedrawPriority\fP (uint32_tpriority)"This method sets the redraw priority\&. .SS "uint32_t \fBSoQtRenderArea::getRedrawPriority\fP (void) const"This method returns the redraw priority\&. .SS "uint32_t \fBSoQtRenderArea::getDefaultRedrawPriority\fP (void)\fC [static]\fP"This function returns the default redraw priority\&. .SS "void \fBSoQtRenderArea::render\fP (void)"This method causes the immediate rendering of the scene, by calling \fBSoQtRenderArea::redraw()\fP\&. .PP References redraw()\&. .SS "void \fBSoQtRenderArea::renderOverlay\fP (void)"This method renders the overlay scene\&. .PP References redrawOverlay()\&. .SS "void \fBSoQtRenderArea::scheduleRedraw\fP (void)"This method schedules a redraw to happen at a later time (when the application has processed it's other events first)\&. .PP 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()\&. .SS "void \fBSoQtRenderArea::scheduleOverlayRedraw\fP (void)"This method schedules a redraw of the overlay scene\&. .PP Referenced by glScheduleRedraw(), setClearBeforeOverlayRender(), setOverlayBackgroundIndex(), and setOverlayColorMap()\&. .SS "void \fBSoQtRenderArea::redrawOnSelectionChange\fP (SoSelection *selection)"Do automatic redraw of the scenegraph when a selection under the SoSelection node is changed\&. .PP Pass \fCNULL\fP to deactivate\&. .PP (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\&.) .PP Referenced by ~SoQtRenderArea()\&. .SS "void \fBSoQtRenderArea::redrawOverlayOnSelectionChange\fP (SoSelection *selection)"Do automatic redraw of the scenegraph in the overlay planes when a selection under the SoSelection node is changed\&. .PP Pass \fCNULL\fP to deactivate\&. .PP \fBSee also:\fP .RS 4 \fBSoQtRenderArea::redrawOnSelectionChange()\fP .RE .PP .PP Referenced by ~SoQtRenderArea()\&. .SS "void \fBSoQtRenderArea::setEventCallback\fP (SoQtRenderAreaEventCB *func, void *user = \fCNULL\fP)"This method sets the render area event callback\&. .SS "void \fBSoQtRenderArea::setSceneManager\fP (SoSceneManager *manager)"This method sets the normal scene SoSceneManager object\&. .PP The previous set scene manager is deleted, and there is no way to currently avoid that\&. This might change in the future\&. .PP References SoQtGLWidget::getGLSize()\&. .SS "SoSceneManager * \fBSoQtRenderArea::getSceneManager\fP (void) const"This method returns the normal scene SoSceneManager object\&. .PP Having a reference to the SoSceneManager instance is useful for getting at the \fIreal\fP root node of the rendering scenegraph, including camera, headlight and miscellaneous drawstyle nodes\&. The \fBgetSceneGraph()\fP method will only return the \fIuser\fP scenegrah for \fBSoQtRenderArea\fP subclass \fBSoQtViewer\fP 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\&. .PP If you need to get a pointer to the \fIreal\fP root node use this method to get the SoSceneManager instance reference used by the \fBSoQtRenderArea\fP, then use SoSceneManager::getSceneGraph() to get the root node Coin uses for rendering\&. .PP Referenced by SoQtViewer::actualRedraw(), SoQtConstrainedViewer::findUpDirection(), and initGraphic()\&. .SS "void \fBSoQtRenderArea::setOverlaySceneManager\fP (SoSceneManager *manager)"This method sets the overlay scene SoSceneManager object\&. .PP The previous set scene manager is not freed and will leak unless the user frees it\&. .PP References SoQtGLWidget::getGLSize()\&. .SS "SoSceneManager * \fBSoQtRenderArea::getOverlaySceneManager\fP (void) const"This method returns the overlay scene SoSceneManager object\&. .PP Referenced by initOverlayGraphic()\&. .SS "void \fBSoQtRenderArea::setGLRenderAction\fP (SoGLRenderAction *action)"This method sets the SoGLRenderAction object for the normal scene\&. .PP References SoQtComponent::getSize(), and sizeChanged()\&. .SS "SoGLRenderAction * \fBSoQtRenderArea::getGLRenderAction\fP (void) const"This method returns the SoGLRenderAction object for the normal scene\&. .PP Referenced by SoQtViewer::setViewing()\&. .SS "void \fBSoQtRenderArea::setOverlayGLRenderAction\fP (SoGLRenderAction *action)"This method sets the SoGLRenderAction object for rendering the overlay scenegraph\&. .SS "SoGLRenderAction * \fBSoQtRenderArea::getOverlayGLRenderAction\fP (void) const"This method returns the SoGLRenderAction object for the overlay scene graph\&. .SS "SbBool \fBSoQtRenderArea::sendSoEvent\fP (const SoEvent *event)"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\&. .PP References processSoEvent()\&. .SS "void \fBSoQtRenderArea::registerDevice\fP (\fBSoQtDevice\fP *device)"This method adds \fIdevice\fP to the list of devices handling events for this component\&. .PP References SoQtDevice::enable(), SoQtGLWidget::getGLSize(), SoQtGLWidget::getGLWidget(), and SoQtDevice::setWindowSize()\&. .PP Referenced by afterRealizeHook()\&. .SS "void \fBSoQtRenderArea::unregisterDevice\fP (\fBSoQtDevice\fP *device)"This method removes \fIdevice\fP from the list of devices handling events for this component\&. .PP References SoQtDevice::disable(), and SoQtGLWidget::getGLWidget()\&. .PP Referenced by ~SoQtRenderArea()\&. .SS "void \fBSoQtRenderArea::redraw\fP (void)\fC [protected, virtual]\fP"This method is called from the \fBrender()\fP 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)\&. .PP After setting up the OpenGL context, it calls \fBactualRedraw()\fP for the actual scenegraph rendering to take place\&. .PP Finally, the OpenGL buffers are either swapped back-to-front (for doublebuffering) or flushed (for singlebuffering), and our OpenGL context is unlocked\&. .PP 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 \fBactualRedraw()\fP for special cases, though\&. .PP Implements \fBSoQtGLWidget\fP\&. .PP References actualRedraw(), SoQtGLWidget::glFlushBuffer(), SoQtGLWidget::glLockNormal(), SoQtGLWidget::glSwapBuffers(), SoQtGLWidget::glUnlockNormal(), SoQtGLWidget::hasNormalGLArea(), SoQtGLWidget::isDoubleBuffer(), SoQtGLWidget::isDrawToFrontBufferEnable(), SoQtComponent::isVisible(), and SoQtGLWidget::waitForExpose\&. .PP Referenced by render()\&. .SS "void \fBSoQtRenderArea::actualRedraw\fP (void)\fC [protected, virtual]\fP"This method instantly redraws the normal (non-overlay) scenegraph by calling SoSceneManager::render()\&. .PP Subclasses may override this method to add their own rendering before or after Coin renders it's scenegraph\&. .PP The following is a complete example that demonstrates one way of adding both a background image and foreground (overlay) geometry to the 'normal' rendering: .PP .PP .nf // 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 #include #include #include #include #include #include #include #include #include #include #include // ************************************************************************* 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, '\n\n\tUsage: %s \n\n', 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; } // ************************************************************************* .fi .PP .PP Reimplemented in \fBSoQtViewer\fP, \fBSoQtExaminerViewer\fP, \fBSoQtFlyViewer\fP, and \fBSoQtPlaneViewer\fP\&. .PP References SoQtComponent::isVisible()\&. .PP Referenced by redraw()\&. .SS "void \fBSoQtRenderArea::redrawOverlay\fP (void)\fC [protected, virtual]\fP"This method redraws the overlay scene\&. .PP Reimplemented from \fBSoQtGLWidget\fP\&. .PP References actualOverlayRedraw(), SoQtGLWidget::glFlushBuffer(), SoQtGLWidget::glLockOverlay(), SoQtGLWidget::glUnlockOverlay(), SoQtGLWidget::hasOverlayGLArea(), SoQtComponent::isVisible(), and SoQtGLWidget::waitForExpose\&. .PP Referenced by renderOverlay()\&. .SS "void \fBSoQtRenderArea::actualOverlayRedraw\fP (void)\fC [protected, virtual]\fP"This method renders the overlay scene\&. .PP References SoQtComponent::isVisible()\&. .PP Referenced by redrawOverlay()\&. .SS "SbBool \fBSoQtRenderArea::processSoEvent\fP (const SoEvent *constevent)\fC [protected, virtual]\fP"Toolkit-native events are attempted converted to Coin-generic events in the \fBSoQtRenderArea::processEvent()\fP method\&. If this succeeds, they are forwarded to this method\&. .PP This is a virtual method, and is overridden in it's subclasses to catch events of particular interest to the viewer classes, for instance\&. .PP Return \fCTRUE\fP 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\&. .PP This method is not part of the original SGI InventorXt API\&. Note that you can still override the toolkit-native \fBprocessEvent()\fP method instead of this 'generic' method\&. .PP Reimplemented in \fBSoQtViewer\fP, \fBSoQtFullViewer\fP, \fBSoQtExaminerViewer\fP, \fBSoQtFlyViewer\fP, and \fBSoQtPlaneViewer\fP\&. .PP Referenced by processEvent(), and sendSoEvent()\&. .SS "void \fBSoQtRenderArea::processEvent\fP (QEvent *event)\fC [protected, virtual]\fP"Overrides \fBSoQtGLWidget::processEvent()\fP to attempt to convert toolkit-native events to Coin-generic events\&. If this succeeds, the generic SoEvent is forwarded to \fBSoQtRenderArea::processSoEvent()\fP\&. .PP Reimplemented from \fBSoQtGLWidget\fP\&. .PP References SoQtGLWidget::glLockNormal(), SoQtGLWidget::glUnlockNormal(), and processSoEvent()\&. .SS "void \fBSoQtRenderArea::initGraphic\fP (void)\fC [protected, virtual]\fP"This method is invoked to initialize the normal graphics\&. .PP Reimplemented from \fBSoQtGLWidget\fP\&. .PP References getSceneManager(), and SoQtGLWidget::isRGBMode()\&. .SS "void \fBSoQtRenderArea::initOverlayGraphic\fP (void)\fC [protected, virtual]\fP"This method is invoked to initialize the overlay graphics\&. .PP Reimplemented from \fBSoQtGLWidget\fP\&. .PP References getOverlaySceneManager()\&. .SS "void \fBSoQtRenderArea::sizeChanged\fP (const SbVec2s &size)\fC [protected, virtual]\fP"Called internally from within the \fBSoQt\fP library when the widget embedded in a component changes it size, which is usually triggered by end-user interaction\&. .PP 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\&. .PP Reimplemented from \fBSoQtGLWidget\fP\&. .PP Reimplemented in \fBSoQtViewer\fP, and \fBSoQtFullViewer\fP\&. .PP References SoQtObject::getClassTypeId(), SoQtGLWidget::getGLSize(), SoQtObject::getTypeId(), SoQtGLWidget::setGLSize(), and setViewportRegion()\&. .PP Referenced by setGLRenderAction()\&. .SS "void \fBSoQtRenderArea::widgetChanged\fP (QWidget *w)\fC [protected, virtual]\fP"This is the method which gets called whenever we change which OpenGL widget is used\&. .PP Should be overridden in subclasses which directly or indirectly store the return value from the \fBSoQtGLWidget::getGLWidget()\fP method\&. .PP \fBSee also:\fP .RS 4 \fBsizeChanged()\fP .RE .PP .PP Reimplemented from \fBSoQtGLWidget\fP\&. .PP References SoQtGLWidget::isRGBMode()\&. .SS "void \fBSoQtRenderArea::afterRealizeHook\fP (void)\fC [protected, virtual]\fP"A function 'hook' / callback invoked just after the window for the component has been realized\&. .PP 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: .PP .PP .nf void MyLittleViewer::afterRealizeHook(void) { ::afterRealizeHook(); // [own initialization here] } .fi .PP .PP Reimplemented from \fBSoQtComponent\fP\&. .PP Reimplemented in \fBSoQtExaminerViewer\fP, \fBSoQtPlaneViewer\fP, and \fBSoQtFlyViewer\fP\&. .PP References registerDevice()\&. .SS "QWidget * \fBSoQtRenderArea::buildWidget\fP (QWidget *parent)\fC [protected]\fP"This method builds the component contents in the given \fIparent\fP widget\&. For subclasses adding new user interface items, this method is typically overridden in the following manner: .PP .PP .nf QWidget * MyOwnViewer::buildWidget(QWidget * parent) { QWidget * superw = ::buildWidget(parent); // [then move superw within MyOwnViewer framework and add own // user interface components] } .fi .PP .PP Reimplemented from \fBSoQtGLWidget\fP\&. .PP Reimplemented in \fBSoQtFullViewer\fP, and \fBSoQtPlaneViewer\fP\&. .PP References SoQtDevice::enable(), and SoQtGLWidget::getGLWidget()\&. .PP Referenced by SoQtViewer::SoQtViewer()\&. .SS "const char * \fBSoQtRenderArea::getDefaultWidgetName\fP (void) const\fC [protected, virtual]\fP"This method returns the default name of a component widget class\&. .PP It should be overridden by derived non-abstract classes for the topmost widget in the component to have a proper name\&. .PP Reimplemented from \fBSoQtComponent\fP\&. .PP Reimplemented in \fBSoQtExaminerViewer\fP, \fBSoQtFlyViewer\fP, and \fBSoQtPlaneViewer\fP\&. .SS "const char * \fBSoQtRenderArea::getDefaultTitle\fP (void) const\fC [protected, virtual]\fP"This method returns the default window caption string of the component\&. .PP It should be overridden by derived non-abstract classes so the window and popup menu will get a proper title\&. .PP Reimplemented from \fBSoQtComponent\fP\&. .PP Reimplemented in \fBSoQtExaminerViewer\fP, \fBSoQtFlyViewer\fP, and \fBSoQtPlaneViewer\fP\&. .SS "const char * \fBSoQtRenderArea::getDefaultIconTitle\fP (void) const\fC [protected, virtual]\fP"This method returns the default icon title of the component\&. .PP It should be overridden by derived non-abstract classes so icons will get proper titles\&. .PP Reimplemented from \fBSoQtComponent\fP\&. .PP Reimplemented in \fBSoQtExaminerViewer\fP, \fBSoQtFlyViewer\fP, and \fBSoQtPlaneViewer\fP\&. .SS "SbBool \fBSoQtRenderArea::glScheduleRedraw\fP (void)\fC [protected, virtual]\fP"Will be called whenever scene graph needs to be redrawn\&. If this method return \fCFALSE\fP, \fBredraw()\fP will be called immediately\&. .PP Default method simply returns \fCFALSE\fP\&. Override this method to schedule a redraw and return \fCTRUE\fP if you're trying to do The Right Thing\&. .PP Reimplemented from \fBSoQtGLWidget\fP\&. .PP References getOverlaySceneGraph(), SoQtGLWidget::hasOverlayGLArea(), scheduleOverlayRedraw(), and scheduleRedraw()\&. .SH "Author" .PP Generated automatically by Doxygen for SoQt from the source code\&.