Open Inventor Release 2024.1.3
 
Loading...
Searching...
No Matches
SoQtRenderArea.h
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-2024 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
32#include <Inventor/Qt/OivQtCompat.h>
33#include <Inventor/Qt/SoQtGLWidget.h>
34
35#include <Inventor/SbColor.h>
36#include <Inventor/SoSceneManager.h>
37#include <Inventor/actions/SoGLRenderAction.h>
38#include <Inventor/nodes/SoCamera.h> // stereo settings
39#include <Inventor/SbElapsedTime.h>
40
41#include <Inventor/Gui/SoGuiRenderArea.h>
42
43class SoSelection;
44class SoQtDevice;
45class SoNode;
46class SoQtMouse;
47class SoQtKeyboard;
48class SoQtRenderArea;
50class SoTimerSensor;
52
58typedef SbBool SoQtRenderAreaEventCB( void* userData, QEvent* anyevent );
59
65typedef SbBool SoQtRenderAreaRenderCB( void* userData, SoQtRenderArea* rendArea );
66
106{
107 Q_OBJECT
108
109public:
114 SoQtRenderArea( QWidget* parent = NULL,
115 const char* name = NULL,
116 SbBool buildInsideParent = TRUE,
117 SbBool getMouseInput = TRUE,
118 SbBool getKeyboardInput = TRUE );
123
127 virtual void setSceneGraph( SoNode* newScene );
128
133
140
147
155 void setBackgroundColor( const SbColor& c );
156
160 SbColor getBackgroundColor() const { return m_guiRenderArea->getBackgroundColor(); }
161
166 void setBackgroundIndex( int index ) { m_guiRenderArea->setBackgroundIndex( index ); }
167
171 int getBackgroundIndex() const { return m_guiRenderArea->getBackgroundIndex(); }
172
177 void setColorMap( QGLColormap* cmap );
178
182 void setViewportRegion( const SbViewportRegion& newRegion )
183 { m_guiRenderArea->setViewportRegion( newRegion ); }
184
189 { return m_guiRenderArea->getViewportRegion(); }
190
201
207 { return m_guiRenderArea->getTransparencyType(); }
208
218 SbBool fastEditDelayedObjects = FALSE);
219
224 { return m_guiRenderArea->getFastEditSavePolicy(); }
225
242
247
255 void setClearBeforeRender( SbBool trueOrFalse, SbBool zbTrueOrFalse = TRUE )
256 { m_guiRenderArea->setClearBeforeRender( trueOrFalse, zbTrueOrFalse ); }
257
261 SbBool isClearBeforeRender() const { return m_guiRenderArea->isClearBeforeRender(); }
262
267 SbBool isClearZBufferBeforeRender() const { return m_guiRenderArea->isClearZBufferBeforeRender(); }
268
276 void setAutoRedraw( SbBool trueOrFalse );
277
282 SbBool isAutoRedraw() const { return m_guiRenderArea->isAutoRedraw(); }
283
287 void setRedrawPriority( uint32_t priority ) { m_guiRenderArea->setRedrawPriority( priority ); }
288
292 uint32_t getRedrawPriority() const { return m_guiRenderArea->getRedrawPriority(); }
293
298
303 void render() { redraw(); }
304
310
322
334 void setEventCallback( SoQtRenderAreaEventCB *fcn, void* userData = NULL );
335
343
350 SoSceneManager* getSceneManager() const { return m_guiRenderArea->getSceneManager(); }
351
362
366 SoGLRenderAction* getGLRenderAction() const { return m_guiRenderArea->getGLRenderAction(); }
367
373
389 void setPostRenderCallback( SoQtRenderAreaRenderCB *fcn, void* userData = NULL )
390 { appPostRenderCB = fcn; appPostRenderData = userData; }
391
396 SoQtRenderAreaRenderCB *getPostRenderCallback( const void* &userData ) const
397 { userData = appPostRenderData; return appPostRenderCB; }
398
414
419
424
428 void sendEvent( QEvent* anEvent );
429
435 virtual void setMPEGRecorder( SoMPEGRenderer* recorder )
436 { m_guiRenderArea->setMPEGRecorder( recorder ); }
437
442 { return m_guiRenderArea->getMPEGRecorder(); }
443
444private:
445 SoQtRenderArea( QWidget* parent,
446 const char* name,
447 SbBool buildInsideParent,
448 SbBool getMouseInput,
449 SbBool getKeyboardInput,
450 SoGuiAlgoViewers* guiAlgos );
451
452 SoQtRenderArea( QWidget* parent,
453 const char* name,
454 SbBool buildInsideParent,
455 SbBool getMouseInput,
456 SbBool getKeyboardInput,
457 SbBool buildNow,
458 SbBool sync,
459 SoGuiAlgoViewers* guiAlgos );
460
461 SoQtRenderArea( QWidget* parent,
462 const char* name,
463 SbBool buildInsideParent,
464 SbBool getMouseInput,
465 SbBool getKeyboardInput,
466 SbBool buildNow,
467 SoGuiAlgoViewers* guiAlgos );
468
472 SoGuiAlgoViewers* getGuiAlgoViewers() const { return (SoGuiAlgoViewers*)m_guiRenderArea; }
473
474private:
475 SoGuiRenderArea* getGuiRenderArea() const;
476
477 void setStereoMode( SoCamera::StereoMode stMode );
478 void setStereoElement();
479 virtual SbBool isInteractive() const;
480 void redrawCleanUp(); //replace some goto in the previous function
481
482 SoQtRenderArea( QWidget* parent,
483 const char* name,
484 SbBool buildInsideParent,
485 SbBool getMouseInput,
486 SbBool getKeyboardInput,
487 SbBool buildNow,
488 SbBool sync );
489
490 //These members shouldn't be used directly, instead call their accessors
491 float stereoBalance, stereoOffset;
492 SbBool stereoAbsoluteAdjustments;
493 SoCamera::StereoMode stereoMode;
494 SbBool stereoReversed;
495
496 private:
497
498 //
499 // This constructor takes a boolean whether to build the widget now.
500 // Subclasses can pass FALSE, then call SoQtRenderArea::buildWidget()
501 // when they are ready for it to be built.
502
503 SoQtRenderArea( QWidget* parent,
504 const char* name,
505 SbBool buildInsideParent,
506 SbBool getMouseInput,
507 SbBool getKeyboardInput,
508 SbBool buildNow );
509
510 //Constructors provided to avoid multiple instance of implementation objects
511 //Equivalent to the public constructor
512 SoQtRenderArea( QWidget* parent,
513 const char* name,
514 SbBool buildInsideParent,
515 SbBool getMouseInput,
516 SbBool getKeyboardInput,
517 SoGuiRenderArea* guiRenderArea );
518
519 SoQtRenderArea( QWidget* parent,
520 const char* name,
521 SbBool buildInsideParent,
522 SbBool getMouseInput,
523 SbBool getKeyboardInput,
524 SbBool buildNow,
525 SbBool sync,
526 SoGuiRenderArea* guiRenderArea );
527
528 SoQtRenderArea( QWidget* parent,
529 const char* name,
530 SbBool buildInsideParent,
531 SbBool getMouseInput,
532 SbBool getKeyboardInput,
533 SbBool buildNow,
534 SoGuiRenderArea* guiRenderArea );
535
536 // redraw() calls actualRedraw(), followed by swapbuffers if necessary.
537 // actualRedraw will have the scene manager render the scene. Rendering
538 // is broken up into two routines like this so that subclasses can
539 // redefine or simply add to rendering (in actualRedraw) without having
540 // to worry about being visible, seting up the window or
541 // single/double buffer swapping.
542 //
543 virtual void redraw();
544 virtual void actualRedraw();
545
546 //
547 // Redefine these to do Inventor-specific things
548 //
549 virtual void processEvent( QEvent* anyevent );
550 virtual void initGraphic();
551 virtual void sizeChanged( const SbVec2s& );
552 virtual void posChanged( const SbVec2i32&, const SbVec2i32& );
553 virtual void widgetChanged( QWidget* w );
554
555 QWidget* buildWidget(QWidget* parent);
556
557 // redefine these
558 virtual SbString getDefaultWidgetName() const;
559 virtual SbString getDefaultTitle() const;
560 virtual SbString getDefaultIconTitle() const;
561
562 // subclasses have access to the device list for event processing
563 SbPList* m_deviceList; // list of devices
564
565 // static callbacks
566 static void renderCB( void* v, SoSceneManager* sm );
567
568 // application event callbacks variables
569 SoQtRenderAreaEventCB *defaultAppEventHandler;
570 void *defaultAppEventHandlerData;
571 SoQtRenderAreaEventCB *appEventHandler;
572 void *appEventHandlerData;
573
574 // invoke the application event callback - returns what the app cb returns
575 SbBool invokeAppCB( QEvent* anyevent );
576 SbBool processInventorEvent( QEvent* anyevent );
577 const SoEvent* translateAnyEvent( QEvent* anyevent );
578
579 // application pre/post render callback variables
580 SoQtRenderAreaRenderCB *appPostRenderCB;
581 void *appPostRenderData;
582
583 // Floating point rendering
584 SbBool m_isFloatingPointRendering;
585 FloatColorBufferSize m_floatingPointRenderingPrecision;
586
587 // This function is overloaded to set the window element
588 void onFocusEvent(SbBool hasFocus);
589
590private:
591
592 // these make rendering/redrawing happen
593#if defined(__linux__)
594 XColorPointer m_mapColors; // saved colors
595 int m_mapColorNum; // number of saved colors
596#endif
597
598 SoQtMouse* m_mouseDevice;
599 SoQtKeyboard* m_keybdDevice;
600 void reinstallDevices( QWidget* newWidget );
601
602 static void selectionChangeCB( void* userData, SoSelection* s );
603 QWidget* m_deviceWidget;
604
605 SbBool m_firstEvent;
606
607 void activate(); // connects the sensor
608 void deactivate(); // disconnects the sensor
609
610 // this is called by constructors
611 void constructorCommon( SbBool getMouseInput,
612 SbBool getKeyboardInput,
613 SbBool buildNow );
614 // this is called by constructorCommon
615 void constructorCommon2( SbBool getMouseInput,
616 SbBool getKeyboardInput,
617 SbBool buildNow );
618
619 SbVec2i32 getWindowPosition();
620
621 QPoint m_oldPos;
622 QSize m_oldSize;
623 QSize m_minimumSize;
624 QSize m_maximumSize;
625
626 SoGuiRenderArea* m_guiRenderArea; // Implementation class for SoXxRendeArea
627
628 // this is the default implementation of the hasRenderAbortCallback passed to the scenemanager
629 // at construction. Implementation is common to all created renderArea.
630 // If an event is received to one renderArea, all renderArea of the process will consider it as
631 // a candidate for abortion (only implemented on Windows)
632 static SbBool s_abortRenderCallback(SoAction*,void*);
633
634 bool m_firstStdRedraw;
635 bool m_firstConnectedRedraw;
636 SoTimerSensor* m_viewerUpdaterSensor;
637 static void viewerUpdaterCB( void*, SoSensor* );
638 void updateFirstFrame();
639
640 SoAntialiasingParameters* m_accumulationParameters;
641
642 private Q_SLOTS:
643 void visibilityChangeCB( SbBool visible );
644
645};
646
647
648#endif // _SO_QT_RENDERAREA_
649
650
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,...
SbBool SoQtRenderAreaEventCB(void *userData, QEvent *anyevent)
External event callback functions registered with the render area should be of this type.
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.
SbBool SoQtRenderAreaRenderCB(void *userData, SoQtRenderArea *rendArea)
External post rendering callback functions registered with the render area should be of this type.
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:100
Sensor that triggers repeatedly at regular intervals.
int SbBool
Boolean type.
Definition SbBase.h:87
void * XColorPointer
Definition SoQtDef.h:135