Open Inventor Release 2024.1.0
 
Loading...
Searching...
No Matches
SoQtRenderArea.h
Go to the documentation of this file.
1/*=======================================================================
2 *** THE CONTENT OF THIS WORK IS PROPRIETARY TO FEI S.A.S, (FEI S.A.S.), ***
3 *** AND IS DISTRIBUTED UNDER A LICENSE AGREEMENT. ***
4 *** ***
5 *** REPRODUCTION, DISCLOSURE, OR USE, IN WHOLE OR IN PART, OTHER THAN AS ***
6 *** SPECIFIED IN THE LICENSE ARE NOT TO BE UNDERTAKEN EXCEPT WITH PRIOR ***
7 *** WRITTEN AUTHORIZATION OF FEI S.A.S. ***
8 *** ***
9 *** RESTRICTED RIGHTS LEGEND ***
10 *** USE, DUPLICATION, OR DISCLOSURE BY THE GOVERNMENT OF THE CONTENT OF THIS ***
11 *** WORK OR RELATED DOCUMENTATION IS SUBJECT TO RESTRICTIONS AS SET FORTH IN ***
12 *** SUBPARAGRAPH (C)(1) OF THE COMMERCIAL COMPUTER SOFTWARE RESTRICTED RIGHT ***
13 *** CLAUSE AT FAR 52.227-19 OR SUBPARAGRAPH (C)(1)(II) OF THE RIGHTS IN ***
14 *** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 52.227-7013. ***
15 *** ***
16 *** COPYRIGHT (C) 1996-2020 BY FEI S.A.S, ***
17 *** BORDEAUX, FRANCE ***
18 *** ALL RIGHTS RESERVED ***
19**=======================================================================*/
20/*=======================================================================
21** Author : Author(s) (MMM yyyy)
22** Modified by : David Mott (MMM yyyy)
23** Modified by : Alain Dumesny (MMM yyyy)
24**=======================================================================*/
25
26
27#ifndef _SO_QT_RENDERAREA_
28#define _SO_QT_RENDERAREA_
29
30#include <QtOpenGL/QGLColormap>
31
34
35#include <Inventor/SbColor.h>
38#include <Inventor/nodes/SoCamera.h> // stereo settings
40
42
43class SoSelection;
44class SoQtDevice;
45class SoNode;
46class SoQtMouse;
47class SoQtKeyboard;
48class SoQtRenderArea;
50class SoTimerSensor;
52
56typedef SbBool SoQtRenderAreaEventCB( void* userData, QEvent* anyevent );
57
61typedef SbBool SoQtRenderAreaRenderCB( void* userData, SoQtRenderArea* rendArea );
62
102{
103 Q_OBJECT
104
105public:
110 SoQtRenderArea( QWidget* parent = NULL,
111 const char* name = NULL,
112 SbBool buildInsideParent = TRUE,
113 SbBool getMouseInput = TRUE,
114 SbBool getKeyboardInput = TRUE );
119
123 virtual void setSceneGraph( SoNode* newScene );
124
129
136
143
151 void setBackgroundColor( const SbColor& c );
152
156 SbColor getBackgroundColor() const { return m_guiRenderArea->getBackgroundColor(); }
157
162 void setBackgroundIndex( int index ) { m_guiRenderArea->setBackgroundIndex( index ); }
163
167 int getBackgroundIndex() const { return m_guiRenderArea->getBackgroundIndex(); }
168
173 void setColorMap( QGLColormap* cmap );
174
178 void setViewportRegion( const SbViewportRegion& newRegion )
179 { m_guiRenderArea->setViewportRegion( newRegion ); }
180
185 { return m_guiRenderArea->getViewportRegion(); }
186
197
203 { return m_guiRenderArea->getTransparencyType(); }
204
214 SbBool fastEditDelayedObjects = FALSE);
215
220 { return m_guiRenderArea->getFastEditSavePolicy(); }
221
238
243
251 void setClearBeforeRender( SbBool trueOrFalse, SbBool zbTrueOrFalse = TRUE )
252 { m_guiRenderArea->setClearBeforeRender( trueOrFalse, zbTrueOrFalse ); }
253
257 SbBool isClearBeforeRender() const { return m_guiRenderArea->isClearBeforeRender(); }
258
263 SbBool isClearZBufferBeforeRender() const { return m_guiRenderArea->isClearZBufferBeforeRender(); }
264
272 void setAutoRedraw( SbBool trueOrFalse );
273
278 SbBool isAutoRedraw() const { return m_guiRenderArea->isAutoRedraw(); }
279
283 void setRedrawPriority( uint32_t priority ) { m_guiRenderArea->setRedrawPriority( priority ); }
284
288 uint32_t getRedrawPriority() const { return m_guiRenderArea->getRedrawPriority(); }
289
294
299 void render() { redraw(); }
300
306
318
330 void setEventCallback( SoQtRenderAreaEventCB *fcn, void* userData = NULL );
331
339
346 SoSceneManager* getSceneManager() const { return m_guiRenderArea->getSceneManager(); }
347
358
362 SoGLRenderAction* getGLRenderAction() const { return m_guiRenderArea->getGLRenderAction(); }
363
369
385 void setPostRenderCallback( SoQtRenderAreaRenderCB *fcn, void* userData = NULL )
386 { appPostRenderCB = fcn; appPostRenderData = userData; }
387
392 SoQtRenderAreaRenderCB *getPostRenderCallback( const void* &userData ) const
393 { userData = appPostRenderData; return appPostRenderCB; }
394
410
415
420
424 void sendEvent( QEvent* anEvent );
425
431 virtual void setMPEGRecorder( SoMPEGRenderer* recorder )
432 { m_guiRenderArea->setMPEGRecorder( recorder ); }
433
438 { return m_guiRenderArea->getMPEGRecorder(); }
439
440private:
441 SoQtRenderArea( QWidget* parent,
442 const char* name,
443 SbBool buildInsideParent,
444 SbBool getMouseInput,
445 SbBool getKeyboardInput,
446 SoGuiAlgoViewers* guiAlgos );
447
448 SoQtRenderArea( QWidget* parent,
449 const char* name,
450 SbBool buildInsideParent,
451 SbBool getMouseInput,
452 SbBool getKeyboardInput,
453 SbBool buildNow,
454 SbBool sync,
455 SoGuiAlgoViewers* guiAlgos );
456
457 SoQtRenderArea( QWidget* parent,
458 const char* name,
459 SbBool buildInsideParent,
460 SbBool getMouseInput,
461 SbBool getKeyboardInput,
462 SbBool buildNow,
463 SoGuiAlgoViewers* guiAlgos );
464
468 SoGuiAlgoViewers* getGuiAlgoViewers() const { return (SoGuiAlgoViewers*)m_guiRenderArea; }
469
470private:
471 SoGuiRenderArea* getGuiRenderArea() const;
472
473 void setStereoMode( SoCamera::StereoMode stMode );
474 void setStereoElement();
475 virtual SbBool isInteractive() const;
476 void redrawCleanUp(); //replace some goto in the previous function
477
478 SoQtRenderArea( QWidget* parent,
479 const char* name,
480 SbBool buildInsideParent,
481 SbBool getMouseInput,
482 SbBool getKeyboardInput,
483 SbBool buildNow,
484 SbBool sync );
485
486 //These members shouldn't be used directly, instead call their accessors
487 float stereoBalance, stereoOffset;
488 SbBool stereoAbsoluteAdjustments;
489 SoCamera::StereoMode stereoMode;
490 SbBool stereoReversed;
491
492 private:
493
494 //
495 // This constructor takes a boolean whether to build the widget now.
496 // Subclasses can pass FALSE, then call SoQtRenderArea::buildWidget()
497 // when they are ready for it to be built.
498
499 SoQtRenderArea( QWidget* parent,
500 const char* name,
501 SbBool buildInsideParent,
502 SbBool getMouseInput,
503 SbBool getKeyboardInput,
504 SbBool buildNow );
505
506 //Constructors provided to avoid multiple instance of implementation objects
507 //Equivalent to the public constructor
508 SoQtRenderArea( QWidget* parent,
509 const char* name,
510 SbBool buildInsideParent,
511 SbBool getMouseInput,
512 SbBool getKeyboardInput,
513 SoGuiRenderArea* guiRenderArea );
514
515 SoQtRenderArea( QWidget* parent,
516 const char* name,
517 SbBool buildInsideParent,
518 SbBool getMouseInput,
519 SbBool getKeyboardInput,
520 SbBool buildNow,
521 SbBool sync,
522 SoGuiRenderArea* guiRenderArea );
523
524 SoQtRenderArea( QWidget* parent,
525 const char* name,
526 SbBool buildInsideParent,
527 SbBool getMouseInput,
528 SbBool getKeyboardInput,
529 SbBool buildNow,
530 SoGuiRenderArea* guiRenderArea );
531
532 // redraw() calls actualRedraw(), followed by swapbuffers if necessary.
533 // actualRedraw will have the scene manager render the scene. Rendering
534 // is broken up into two routines like this so that subclasses can
535 // redefine or simply add to rendering (in actualRedraw) without having
536 // to worry about being visible, seting up the window or
537 // single/double buffer swapping.
538 //
539 virtual void redraw();
540 virtual void actualRedraw();
541
542 //
543 // Redefine these to do Inventor-specific things
544 //
545 virtual void processEvent( QEvent* anyevent );
546 virtual void initGraphic();
547 virtual void sizeChanged( const SbVec2s& );
548 virtual void posChanged( const SbVec2i32&, const SbVec2i32& );
549 virtual void widgetChanged( QWidget* w );
550
551 QWidget* buildWidget(QWidget* parent);
552
553 // redefine these
554 virtual SbString getDefaultWidgetName() const;
555 virtual SbString getDefaultTitle() const;
556 virtual SbString getDefaultIconTitle() const;
557
558 // subclasses have access to the device list for event processing
559 SbPList* m_deviceList; // list of devices
560
561 // static callbacks
562 static void renderCB( void* v, SoSceneManager* sm );
563
564 // application event callbacks variables
565 SoQtRenderAreaEventCB *defaultAppEventHandler;
566 void *defaultAppEventHandlerData;
567 SoQtRenderAreaEventCB *appEventHandler;
568 void *appEventHandlerData;
569
570 // invoke the application event callback - returns what the app cb returns
571 SbBool invokeAppCB( QEvent* anyevent );
572 SbBool processInventorEvent( QEvent* anyevent );
573 const SoEvent* translateAnyEvent( QEvent* anyevent );
574
575 // application pre/post render callback variables
576 SoQtRenderAreaRenderCB *appPostRenderCB;
577 void *appPostRenderData;
578
579 // Floating point rendering
580 SbBool m_isFloatingPointRendering;
581 FloatColorBufferSize m_floatingPointRenderingPrecision;
582
583 // This function is overloaded to set the window element
584 void onFocusEvent(SbBool hasFocus);
585
586private:
587
588 // these make rendering/redrawing happen
589#if defined(__linux__)
590 XColorPointer m_mapColors; // saved colors
591 int m_mapColorNum; // number of saved colors
592#endif
593
594 SoQtMouse* m_mouseDevice;
595 SoQtKeyboard* m_keybdDevice;
596 void reinstallDevices( QWidget* newWidget );
597
598 static void selectionChangeCB( void* userData, SoSelection* s );
599 QWidget* m_deviceWidget;
600
601 SbBool m_firstEvent;
602
603 void activate(); // connects the sensor
604 void deactivate(); // disconnects the sensor
605
606 // this is called by constructors
607 void constructorCommon( SbBool getMouseInput,
608 SbBool getKeyboardInput,
609 SbBool buildNow );
610 // this is called by constructorCommon
611 void constructorCommon2( SbBool getMouseInput,
612 SbBool getKeyboardInput,
613 SbBool buildNow );
614
615 SbVec2i32 getWindowPosition();
616
617 QPoint m_oldPos;
618 QSize m_oldSize;
619 QSize m_minimumSize;
620 QSize m_maximumSize;
621
622 SoGuiRenderArea* m_guiRenderArea; // Implementation class for SoXxRendeArea
623
624 // this is the default implementation of the hasRenderAbortCallback passed to the scenemanager
625 // at construction. Implementation is common to all created renderArea.
626 // If an event is received to one renderArea, all renderArea of the process will consider it as
627 // a candidate for abortion (only implemented on Windows)
628 static SbBool s_abortRenderCallback(SoAction*,void*);
629
630 bool m_firstStdRedraw;
631 bool m_firstConnectedRedraw;
632 SoTimerSensor* m_viewerUpdaterSensor;
633 static void viewerUpdaterCB( void*, SoSensor* );
634 void updateFirstFrame();
635
636 SoAntialiasingParameters* m_accumulationParameters;
637
638 private Q_SLOTS:
639 void visibilityChangeCB( SbBool visible );
640
641};
642
643
644#endif // _SO_QT_RENDERAREA_
645
646
#define TRUE
Possible value of SbBool.
Definition SbBase.h:77
#define FALSE
Possible value of SbBool.
Definition SbBase.h:75
void * XColorPointer
Definition SoQtDef.h:126
virtual void enable(QWidget *w, XtEventHandler f, XtPointer data, void *unused=NULL)
SbBool SoQtRenderAreaEventCB(void *userData, QEvent *anyevent)
se External event callback functions registered with the render area should be of this type.
SbBool SoQtRenderAreaRenderCB(void *userData, SoQtRenderArea *rendArea)
External post rendering callback functions registered with the render area should be of this type.
Color vector class.
Definition SbColor.h:82
Class encapsulating information about an OpenGL context: a handle on an OpenGL context and its id.
List of generic (void *) pointers.
Definition SbPList.h:77
Class for smart character strings.
Definition SbString.h:202
2D vector class.
Definition SbVec.h:517
2D vector class.
Definition SbVec.h:700
Class for representing a viewport.
Abstract base class for all actions.
Definition SoAction.h:132
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Antialiasing par...
StereoMode
Stereo mode.
Definition SoCamera.h:518
Base class for all events.
Definition SoEvent.h:116
Renders a scene graph using Open Inventor's Render Engine.
FastEditSavePolicy
Fast edit traversal types.
InvalidateCacheMode
Invalidate cache mode.
TransparencyType
Transparency rendering algorithm.
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Common algorithm...
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Base class for g...
Abstract base class for all database nodes.
Definition SoNode.h:145
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Abstract base cl...
Definition SoQtDevice.h:102
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Component for Op...
FloatColorBufferSize
FloatColorBufferSize.
@ FLOAT_16_COLOR_BUFFER
16-bit rendering per component.
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Translates and r...
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Translates and r...
Definition SoQtMouse.h:58
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Component for re...
SbBool isClearZBufferBeforeRender() const
Queries whether the depth buffer (sometimes called the Z buffer) will be cleared before rendering sta...
void setClearBeforeRender(SbBool trueOrFalse, SbBool zbTrueOrFalse=TRUE)
Enables/prevents window clearing from happening before a rendering starts (default is clear TRUE).
void setRedrawPriority(uint32_t priority)
Sets the priority of the redraw sensor.
void setColorMap(QGLColormap *cmap)
Sets the colors to use when displaying in color index mode.
void setGLRenderAction(SoGLRenderAction *ra)
Sets the GL render action to use.
void scheduleRedraw()
Schedules a redraw to happen sometime soon (as opposed to immediately).
void setBackgroundColor(const SbColor &c)
Sets the background color for this window.
void setViewportRegion(const SbViewportRegion &newRegion)
Sets viewport region to use for rendering.
SoGLRenderAction::FastEditSavePolicy getFastEditSavePolicy() const
Returns fast editing save policy used when rendering.
void setPostRenderCallback(SoQtRenderAreaRenderCB *fcn, void *userData=NULL)
Specifies a function to be called after the Open Inventor render traversal and immediately before the...
void sendEvent(QEvent *anEvent)
Sends the event to be processed by the renderArea.
SoSceneManager * getSceneManager() const
Gets the normal scene manager.
virtual SoMPEGRenderer * getMPEGRecorder() const
Returns the recorder used for MPEG encoding.
void setTransparencyType(SoGLRenderAction::TransparencyType type)
Sets the algorithm for rendering transparent objects.
void setBackgroundIndex(int index)
Sets the window background color when in color index mode.
int getBackgroundIndex() const
Gets the window background color when in color index mode.
SoQtRenderArea(QWidget *parent=NULL, const char *name=NULL, SbBool buildInsideParent=TRUE, SbBool getMouseInput=TRUE, SbBool getKeyboardInput=TRUE)
Constructor which is passed arguments which tell it whether to register the mouse and keyboard device...
void setSceneManager(SoSceneManager *sm)
Sets the normal scene manager.
SbBool isAutoRedraw() const
Queries whether the render area will automatically redraw whenever something in the scene graph chang...
void registerDevice(SoQtDevice *d)
Registers interest in devices.
virtual void setMPEGRecorder(SoMPEGRenderer *recorder)
Sets the recorder used for MPEG encoding.
SoGLRenderAction::TransparencyType getTransparencyType() const
Gets the algorithm for rendering transparent objects.
void redrawOnSelectionChange(SoSelection *s)
Call this convenience method to have this render area redraw whenever the selection list changes in t...
virtual SoNode * getSceneGraph()
Gets the scene graph to be rendered in this component's window.
const SbViewportRegion & getViewportRegion() const
Gets current viewport region to use for rendering.
void unregisterDevice(SoQtDevice *d)
Unregisters interest in devices.
void setFloatingColorBuffer(SbBool enable, FloatColorBufferSize size=FLOAT_16_COLOR_BUFFER)
Enables/disables floating point rendering using 16- or 32-bit components.
void setFastEditSavePolicy(SoGLRenderAction::FastEditSavePolicy policy, SbBool fastEditDelayedObjects=FALSE)
Sets fast editing save policy to use when rendering.
void setInvalidateCacheMode(SoGLRenderAction::InvalidateCacheMode icm)
Enables or disables the invalidation of render caches.
SoGLRenderAction * getGLRenderAction() const
Gets the current GL render action.
SoGLRenderAction::InvalidateCacheMode getInvalidateCacheMode()
Returns the current cache invalidation mode.
static SbBool isFloatingColorBufferSupported()
Returns TRUE if floating point rendering is available.
~SoQtRenderArea()
Destructor.
void getFloatingColorBuffer(SbBool &enable, FloatColorBufferSize &size)
Returns TRUE if floating point rendering is used and its precision.
SoQtRenderAreaRenderCB * getPostRenderCallback(const void *&userData) const
Gets the post-render callback function and data.
const SbGLShareContext getShareContext()
Returns the information needed to make OpenGL render contexts share OpenGL objects,...
void render()
Calling this forces the render area to be redrawn now.
SbBool isClearBeforeRender() const
Queries whether the window will be cleared before rendering starts.
virtual void setSceneGraph(SoNode *newScene)
Sets the scene graph to be rendered in this component's window.
static uint32_t getDefaultRedrawPriority()
Gets the default priority number of the redraw sensor.
void setAutoRedraw(SbBool trueOrFalse)
The render area will automatically redraw whenever something in the scene graph changes.
uint32_t getRedrawPriority() const
Gets the priority of the redraw sensor.
SbColor getBackgroundColor() const
Gets the background color for this window.
void setEventCallback(SoQtRenderAreaEventCB *fcn, void *userData=NULL)
Windows messages which occur in the render area window are either directly handled by the viewer (whe...
Manages scene graph rendering and event handling.
static uint32_t getDefaultRedrawPriority()
Gets the default priority of the redraw sensor.
Manages a list of selected objects.
Abstract base class for Open Inventor sensors.
Definition SoSensor.h:97
Sensor that triggers repeatedly at regular intervals.
int SbBool
Boolean type.
Definition SbBase.h:87