Open Inventor Release 2024.2.2
 
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
173#if 1 SoDEPRECATED
179 void setColorMap( QGLColormap* cmap );
180#endif
185 void setViewportRegion( const SbViewportRegion& newRegion )
186 { m_guiRenderArea->setViewportRegion( newRegion ); }
187
192 { return m_guiRenderArea->getViewportRegion(); }
193
204
210 { return m_guiRenderArea->getTransparencyType(); }
211
221 SbBool fastEditDelayedObjects = FALSE);
222
227 { return m_guiRenderArea->getFastEditSavePolicy(); }
228
245
250
258 void setClearBeforeRender( SbBool trueOrFalse, SbBool zbTrueOrFalse = TRUE )
259 { m_guiRenderArea->setClearBeforeRender( trueOrFalse, zbTrueOrFalse ); }
260
264 SbBool isClearBeforeRender() const { return m_guiRenderArea->isClearBeforeRender(); }
265
270 SbBool isClearZBufferBeforeRender() const { return m_guiRenderArea->isClearZBufferBeforeRender(); }
271
279 void setAutoRedraw( SbBool trueOrFalse );
280
285 SbBool isAutoRedraw() const { return m_guiRenderArea->isAutoRedraw(); }
286
290 void setRedrawPriority( uint32_t priority ) { m_guiRenderArea->setRedrawPriority( priority ); }
291
295 uint32_t getRedrawPriority() const { return m_guiRenderArea->getRedrawPriority(); }
296
301
306 void render() { redraw(); }
307
313
325
337 void setEventCallback( SoQtRenderAreaEventCB *fcn, void* userData = NULL );
338
346
353 SoSceneManager* getSceneManager() const { return m_guiRenderArea->getSceneManager(); }
354
365
369 SoGLRenderAction* getGLRenderAction() const { return m_guiRenderArea->getGLRenderAction(); }
370
376
392 void setPostRenderCallback( SoQtRenderAreaRenderCB *fcn, void* userData = NULL )
393 { appPostRenderCB = fcn; appPostRenderData = userData; }
394
399 SoQtRenderAreaRenderCB *getPostRenderCallback( const void* &userData ) const
400 { userData = appPostRenderData; return appPostRenderCB; }
401
417
422
427
431 void sendEvent( QEvent* anEvent );
432
438 virtual void setMPEGRecorder( SoMPEGRenderer* recorder )
439 { m_guiRenderArea->setMPEGRecorder( recorder ); }
440
445 { return m_guiRenderArea->getMPEGRecorder(); }
446
447private:
448 SoQtRenderArea( QWidget* parent,
449 const char* name,
450 SbBool buildInsideParent,
451 SbBool getMouseInput,
452 SbBool getKeyboardInput,
453 SoGuiAlgoViewers* guiAlgos );
454
455 SoQtRenderArea( QWidget* parent,
456 const char* name,
457 SbBool buildInsideParent,
458 SbBool getMouseInput,
459 SbBool getKeyboardInput,
460 SbBool buildNow,
461 SbBool sync,
462 SoGuiAlgoViewers* guiAlgos );
463
464 SoQtRenderArea( QWidget* parent,
465 const char* name,
466 SbBool buildInsideParent,
467 SbBool getMouseInput,
468 SbBool getKeyboardInput,
469 SbBool buildNow,
470 SoGuiAlgoViewers* guiAlgos );
471
475 SoGuiAlgoViewers* getGuiAlgoViewers() const { return (SoGuiAlgoViewers*)m_guiRenderArea; }
476
477private:
478 SoGuiRenderArea* getGuiRenderArea() const;
479
480 void setStereoMode( SoCamera::StereoMode stMode );
481 void setStereoElement();
482 virtual SbBool isInteractive() const;
483 void redrawCleanUp(); //replace some goto in the previous function
484
485 SoQtRenderArea( QWidget* parent,
486 const char* name,
487 SbBool buildInsideParent,
488 SbBool getMouseInput,
489 SbBool getKeyboardInput,
490 SbBool buildNow,
491 SbBool sync );
492
493 //These members shouldn't be used directly, instead call their accessors
494 float stereoBalance, stereoOffset;
495 SbBool stereoAbsoluteAdjustments;
496 SoCamera::StereoMode stereoMode;
497 SbBool stereoReversed;
498
499 private:
500
501 //
502 // This constructor takes a boolean whether to build the widget now.
503 // Subclasses can pass FALSE, then call SoQtRenderArea::buildWidget()
504 // when they are ready for it to be built.
505
506 SoQtRenderArea( QWidget* parent,
507 const char* name,
508 SbBool buildInsideParent,
509 SbBool getMouseInput,
510 SbBool getKeyboardInput,
511 SbBool buildNow );
512
513 //Constructors provided to avoid multiple instance of implementation objects
514 //Equivalent to the public constructor
515 SoQtRenderArea( QWidget* parent,
516 const char* name,
517 SbBool buildInsideParent,
518 SbBool getMouseInput,
519 SbBool getKeyboardInput,
520 SoGuiRenderArea* guiRenderArea );
521
522 SoQtRenderArea( QWidget* parent,
523 const char* name,
524 SbBool buildInsideParent,
525 SbBool getMouseInput,
526 SbBool getKeyboardInput,
527 SbBool buildNow,
528 SbBool sync,
529 SoGuiRenderArea* guiRenderArea );
530
531 SoQtRenderArea( QWidget* parent,
532 const char* name,
533 SbBool buildInsideParent,
534 SbBool getMouseInput,
535 SbBool getKeyboardInput,
536 SbBool buildNow,
537 SoGuiRenderArea* guiRenderArea );
538
539 // redraw() calls actualRedraw(), followed by swapbuffers if necessary.
540 // actualRedraw will have the scene manager render the scene. Rendering
541 // is broken up into two routines like this so that subclasses can
542 // redefine or simply add to rendering (in actualRedraw) without having
543 // to worry about being visible, seting up the window or
544 // single/double buffer swapping.
545 //
546 virtual void redraw();
547 virtual void actualRedraw();
548
549 //
550 // Redefine these to do Inventor-specific things
551 //
552 virtual void processEvent( QEvent* anyevent );
553 virtual void initGraphic();
554 virtual void sizeChanged( const SbVec2s& );
555 virtual void posChanged( const SbVec2i32&, const SbVec2i32& );
556 virtual void widgetChanged( QWidget* w );
557
558 QWidget* buildWidget(QWidget* parent);
559
560 // redefine these
561 virtual SbString getDefaultWidgetName() const;
562 virtual SbString getDefaultTitle() const;
563 virtual SbString getDefaultIconTitle() const;
564
565 // subclasses have access to the device list for event processing
566 SbPList* m_deviceList; // list of devices
567
568 // static callbacks
569 static void renderCB( void* v, SoSceneManager* sm );
570
571 // application event callbacks variables
572 SoQtRenderAreaEventCB *defaultAppEventHandler;
573 void *defaultAppEventHandlerData;
574 SoQtRenderAreaEventCB *appEventHandler;
575 void *appEventHandlerData;
576
577 // invoke the application event callback - returns what the app cb returns
578 SbBool invokeAppCB( QEvent* anyevent );
579 SbBool processInventorEvent( QEvent* anyevent );
580 const SoEvent* translateAnyEvent( QEvent* anyevent );
581
582 // application pre/post render callback variables
583 SoQtRenderAreaRenderCB *appPostRenderCB;
584 void *appPostRenderData;
585
586 // Floating point rendering
587 SbBool m_isFloatingPointRendering;
588 FloatColorBufferSize m_floatingPointRenderingPrecision;
589
590 // This function is overloaded to set the window element
591 void onFocusEvent(SbBool hasFocus);
592
593private:
594
595 // these make rendering/redrawing happen
596#if defined(__linux__)
597 XColorPointer m_mapColors; // saved colors
598 int m_mapColorNum; // number of saved colors
599#endif
600
601 SoQtMouse* m_mouseDevice;
602 SoQtKeyboard* m_keybdDevice;
603 void reinstallDevices( QWidget* newWidget );
604
605 static void selectionChangeCB( void* userData, SoSelection* s );
606 QWidget* m_deviceWidget;
607
608 SbBool m_firstEvent;
609
610 void activate(); // connects the sensor
611 void deactivate(); // disconnects the sensor
612
613 // this is called by constructors
614 void constructorCommon( SbBool getMouseInput,
615 SbBool getKeyboardInput,
616 SbBool buildNow );
617 // this is called by constructorCommon
618 void constructorCommon2( SbBool getMouseInput,
619 SbBool getKeyboardInput,
620 SbBool buildNow );
621
622 SbVec2i32 getWindowPosition();
623
624 QPoint m_oldPos;
625 QSize m_oldSize;
626 QSize m_minimumSize;
627 QSize m_maximumSize;
628
629 SoGuiRenderArea* m_guiRenderArea; // Implementation class for SoXxRendeArea
630
631 // this is the default implementation of the hasRenderAbortCallback passed to the scenemanager
632 // at construction. Implementation is common to all created renderArea.
633 // If an event is received to one renderArea, all renderArea of the process will consider it as
634 // a candidate for abortion (only implemented on Windows)
635 static SbBool s_abortRenderCallback(SoAction*,void*);
636
637 bool m_firstStdRedraw;
638 bool m_firstConnectedRedraw;
639 SoTimerSensor* m_viewerUpdaterSensor;
640 static void viewerUpdaterCB( void*, SoSensor* );
641 void updateFirstFrame();
642
643 SoAntialiasingParameters* m_accumulationParameters;
644
645 private Q_SLOTS:
646 void visibilityChangeCB( SbBool visible );
647
648};
649
650
651#endif // _SO_QT_RENDERAREA_
652
653
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 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.
SoDEPRECATED void setColorMap(QGLColormap *cmap)
Sets the colors to use when displaying in color index mode.
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