Open Inventor Release 2024.2.0
 
Loading...
Searching...
No Matches
SoWinRenderArea.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 : VSG (MMM YYYY)
22**=======================================================================*/
23
24#ifndef _SO_WIN_RENDER_AREA_H_
25#define _SO_WIN_RENDER_AREA_H_
26
27#include <Inventor/Win/SoWinBeginStrict.h>
28#include <windows.h>
29#include <Inventor/Win/SoWinDef.h>
30
31#include <climits>
32
33#include <Inventor/SbColor.h>
34#include <Inventor/sensors/SoNodeSensor.h>
35#include <Inventor/SoSceneManager.h>
36#include <Inventor/Win/SoWinGLWidget.h>
37#include <Inventor/actions/SoGLRenderAction.h>
38
39#include <Inventor/nodes/SoCamera.h> // stereo settings
40#include <Inventor/elements/SoStereoElement.h>
41#include <Inventor/nodes/SoFullSceneAntialiasing.h>
42#include <Inventor/SbElapsedTime.h>
43
44
45#include <Inventor/Gui/SoGuiRenderArea.h>
46
48class SoWinDevice;
49class SoNode;
50class SoWinMouse;
51class SoWinKeyboard;
52class SoSelection;
53class SoWinRenderArea;
56
62typedef SbBool SoWinRenderAreaEventCB( void* userData, XAnyEvent* anyevent );
63
69typedef SbBool SoWinRenderAreaRenderCB( void* userData, SoWinRenderArea* rendArea );
70
72//
73// Class: SoWinRenderArea
74//
75// Class to do Inventor rendering in a GLX Motif widget.
76//
78
114{
115 public:
116
125 SoWinRenderArea( SoWidget parent = NULL,
126 const char* name = NULL,
127 SbBool buildInsideParent = TRUE,
128 SbBool getMouseInput = TRUE,
129 SbBool getKeyboardInput = TRUE );
134
140 virtual void setSceneGraph( SoNode *newScene );
141
146
161
168 void setBackgroundColor( const SbColor& c );
169
173 SbColor getBackgroundColor() const { return m_guiRenderArea->getBackgroundColor(); }
174
179 void setBackgroundIndex( int index ) { m_guiRenderArea->setBackgroundIndex( index ); }
180
184 int getBackgroundIndex() const { return m_guiRenderArea->getBackgroundIndex(); }
185
191 void setColorMap( int startIndex, int num, const SbColor* colors );
192
196 void setViewportRegion( const SbViewportRegion& newRegion )
197 { m_guiRenderArea->setViewportRegion( newRegion ); }
198
203 { return m_guiRenderArea->getViewportRegion(); }
204
215
221 { return m_guiRenderArea->getTransparencyType(); }
222
232 SbBool fastEditDelayedObjects = FALSE);
233
238 { return m_guiRenderArea->getFastEditSavePolicy(); }
239
256
261
269 void setClearBeforeRender( SbBool trueOrFalse, SbBool zbTrueOrFalse = TRUE )
270 { m_guiRenderArea->setClearBeforeRender( trueOrFalse, zbTrueOrFalse ); }
271
275 SbBool isClearBeforeRender() const { return m_guiRenderArea->isClearBeforeRender(); }
276
281 SbBool isClearZBufferBeforeRender() const { return m_guiRenderArea->isClearZBufferBeforeRender(); }
282
290 void setAutoRedraw( SbBool trueOrFalse );
291
296 SbBool isAutoRedraw() const { return m_guiRenderArea->isAutoRedraw(); }
297
301 void setRedrawPriority( unsigned long priority ) { m_guiRenderArea->setRedrawPriority(priority); }
302
306 unsigned long getRedrawPriority() const { return m_guiRenderArea->getRedrawPriority(); }
307
312
317 void render() { redraw(); }
318
324
336
374 void setEventCallback( SoWinRenderAreaEventCB* fcn, void* userData = NULL );
375
383
390 SoSceneManager* getSceneManager() const { return m_guiRenderArea->getSceneManager(); }
391
402
406 SoGLRenderAction* getGLRenderAction() const { return m_guiRenderArea->getGLRenderAction(); }
407
413
429 void setPostRenderCallback( SoWinRenderAreaRenderCB* fcn, void* userData = NULL )
430 { appPostRenderCB = fcn; appPostRenderData = userData; }
431
437 SoWinRenderAreaRenderCB* getPostRenderCallback( const void* &userData ) const
438 { userData = appPostRenderData; return appPostRenderCB; }
439
443
446
451
455 void sendEvent( XAnyEvent* anEvent );
456
462 virtual void setMPEGRecorder( SoMPEGRenderer* recorder )
463 { m_guiRenderArea->setMPEGRecorder( recorder ); }
464
469 { return m_guiRenderArea->getMPEGRecorder(); }
470
471private:
472 SoWinRenderArea( SoWidget parent,
473 const char* name,
474 SbBool buildInsideParent,
475 SbBool getMouseInput,
476 SbBool getKeyboardInput,
477 SoGuiAlgoViewers* guiAlgos );
478
479 //Equivalent to the SoExtender constructor
480 SoWinRenderArea( SoWidget parent,
481 const char* name,
482 SbBool buildInsideParent,
483 SbBool getMouseInput,
484 SbBool getKeyboardInput,
485 SbBool buildNow,
486 SbBool sync,
487 SoGuiAlgoViewers* guiAlgos );
488
489 //Equivalent to the protected constructor
490 SoWinRenderArea( SoWidget parent,
491 const char* name,
492 SbBool buildInsideParent,
493 SbBool getMouseInput,
494 SbBool getKeyboardInput,
495 SbBool buildNow,
496 SoGuiAlgoViewers* guiAlgos );
497
501 SoGuiAlgoViewers* getGuiAlgoViewers() const { return (SoGuiAlgoViewers*)m_guiRenderArea; }
502
503private:
504
505 SoGuiRenderArea* getGuiRenderArea() const;
506
507 void setStereoMode( SoCamera::StereoMode stMode );
508 void setStereoElement();
509
510 virtual void setDoubleBuffer( SbBool db );
511
512 virtual SbBool isInteractive() const;
513
514 SoWinRenderArea( SoWidget parent,
515 const char* name,
516 SbBool buildInsideParent,
517 SbBool getMouseInput,
518 SbBool getKeyboardInput,
519 SbBool buildNow,
520 SbBool sync );
521
522 // Retro compatibility only.
523 // These members shouldn't be used directly, instead call their accessors
524 float stereoBalance, stereoOffset;
525 SbBool stereoAbsoluteAdjustments;
526 SoCamera::StereoMode stereoMode;
527 SbBool stereoReversed;
528
529private:
530
531 //
532 // This constructor takes a boolean whether to build the widget now.
533 // Subclasses can pass FALSE, then call SoWinRenderArea::buildWidget()
534 // when they are ready for it to be built.
535
536 SoWinRenderArea( SoWidget parent,
537 const char* name,
538 SbBool buildInsideParent,
539 SbBool getMouseInput,
540 SbBool getKeyboardInput,
541 SbBool buildNow );
542
543 //Constructors provided to avoid multiple instance of implementation objects
544 //Equivalent to the public constructor
545 SoWinRenderArea( SoWidget parent,
546 const char* name,
547 SbBool buildInsideParent,
548 SbBool getMouseInput,
549 SbBool getKeyboardInput,
550 SoGuiRenderArea* guiRenderArea );
551
552 //Equivalent to the SoExtender constructor
553 SoWinRenderArea( SoWidget parent,
554 const char* name,
555 SbBool buildInsideParent,
556 SbBool getMouseInput,
557 SbBool getKeyboardInput,
558 SbBool buildNow,
559 SbBool sync,
560 SoGuiRenderArea* guiRenderArea );
561
562 //Equivalent to the protected constructor
563 SoWinRenderArea( SoWidget parent,
564 const char* name,
565 SbBool buildInsideParent,
566 SbBool getMouseInput,
567 SbBool getKeyboardInput,
568 SbBool buildNow,
569 SoGuiRenderArea* guiRenderArea );
570
571 // redraw() calls actualRedraw(), followed by swapbuffers if necessary.
572 // actualRedraw will have the scene manager render the scene. Rendering
573 // is broken up into two routines like this so that subclasses can
574 // redefine or simply add to rendering (in actualRedraw) without having
575 // to worry about being visible, seting up the window or
576 // single/double buffer swapping.
577 //
578 virtual void redraw();
579 virtual void actualRedraw();
580
581 //
582 // Redefine these to do Inventor-specific things
583 //
584 virtual void processEvent( XAnyEvent* anyevent );
585 virtual void initGraphic();
586 virtual void sizeChanged( const SbVec2s& );
587 virtual void posChanged( const SbVec2i32&, const SbVec2i32& );
588 virtual void widgetChanged( SoWidget );
589
590 SoWidget buildWidget( SoWidget parent );
591
592 // redefine these
593 virtual SbString getDefaultWidgetName() const;
594 virtual SbString getDefaultTitle() const;
595 virtual SbString getDefaultIconTitle() const;
596
597 // subclasses have access to the device list for event processing
598 SbPList* m_deviceList; // list of devices
599
600 // application event callbacks variables
601 SoWinRenderAreaEventCB *defaultAppEventHandler;
602 void *defaultAppEventHandlerData;
603 SoWinRenderAreaEventCB *appEventHandler;
604 void *appEventHandlerData;
605 // invoke the application event callback - returns what the app cb returns
606 SbBool invokeAppCB( XAnyEvent* anyevent );
607 SbBool processInventorEvent( XAnyEvent* anyevent );
608 const SoEvent* translateAnyEvent( XAnyEvent* anyevent );
609
610 // application pre/post render callback variables
611 SoWinRenderAreaRenderCB *appPostRenderCB;
612 void *appPostRenderData;
613
614private:
615 // Floating point rendering
616 SbBool m_isFloatingPointRendering;
617 FloatColorBufferSize m_floatingPointRenderingPrecision;
618
619#if defined(__linux__)
620 XColor* m_mapColors; // saved colors
621 int m_mapColorNum; // number of saved colors
622#endif
623
624 SoWinMouse* m_mouseDevice;
625 SoWinKeyboard* m_keybdDevice;
626 void reinstallDevices( SoWidget newWidget );
627
628 static void selectionChangeCB( void* userData, SoSelection* s );
629 SoWidget m_deviceWidget;
630
631 // static callbacks
632 SbBool m_firstEvent;
633
634private:
635 static void windowEventCB( SoWidget w, SoWinRenderArea* wra, XAnyEvent* e, Boolean* b );
636private:
637 static void renderCB( void* v, SoSceneManager* sm );
638
639 static void visibilityChangeCB( void* pt, SbBool visible );
640
641 // this is called by constructors
642 void constructorCommon( SbBool getMouseInput,
643 SbBool getKeyboardInput,
644 SbBool buildNow );
645
646 // this is called by constructorCommon
647 void constructorCommon2( SbBool getMouseInput,
648 SbBool getKeyboardInput,
649 SbBool buildNow );
650
651 void activate();
652 void deactivate();
653
654 SbVec2i32 getWindowPosition() { return SbVec2i32( INT_MAX, INT_MAX ); }
655
656 int inRedraw;
657
658 SoGuiRenderArea* m_guiRenderArea; // Implementation class for SoXxRendeArea
659
660 // this is the default implementation of the hasRenderAbortCallback passed to the scenemanager
661 // at construction. Implementation is common to all created renderArea.
662 // If an event is received to one renderArea, all renderArea of the process will consider it as
663 // a candidate for abortion (only implemented on Windows)
664 static SbBool s_abortRenderCallback(SoAction*,void*);
665
666 SoAntialiasingParameters* m_accumulationParameters;
667
668 bool m_firstStdRedraw;
669 bool m_firstConnectedRedraw;
670 SoTimerSensor* m_viewerUpdaterSensor;
671 static void viewerUpdaterCB( void*, SoSensor* );
672 void updateFirstFrame();
673
674};
675
676#include <Inventor/Win/SoWinEndStrict.h>
677
678#endif /* _SO_WIN_RENDER_AREA_H_ */
679
680
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...
Allows nodes in a graph to receive input events.
<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
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.
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Abstract base cl...
Definition SoWinDevice.h:58
<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 SoWinMouse.h:56
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Component for re...
void setSceneManager(SoSceneManager *sm)
Sets the normal scene manager.
int getBackgroundIndex() const
Gets the window background color when in color index mode.
virtual void setMPEGRecorder(SoMPEGRenderer *recorder)
Sets the recorder used for MPEG encoding.
void redrawOnSelectionChange(SoSelection *s)
Call this convenience method to have this render area redraw whenever the selection list changes in t...
const SbGLShareContext getShareContext()
Returns the information needed to make OpenGL render contexts share OpenGL objects,...
const SbViewportRegion & getViewportRegion() const
Gets current viewport region to use for rendering.
void setColorMap(int startIndex, int num, const SbColor *colors)
Sets the colors to use when displaying in color index mode.
static SbBool isFloatingColorBufferSupported()
Returns TRUE if floating point rendering is available.
unsigned long getRedrawPriority() const
Gets the priority of the redraw sensor.
SoSceneManager * getSceneManager() const
Gets the normal scene manager.
void getFloatingColorBuffer(SbBool &enable, FloatColorBufferSize &size)
Returns TRUE if floating point rendering is used and its precision.
SoWinRenderArea(SoWidget 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 setPostRenderCallback(SoWinRenderAreaRenderCB *fcn, void *userData=NULL)
Specifies a function to be called after the Open Inventor render traversal and immediately before the...
virtual void setSceneGraph(SoNode *newScene)
Sets the scene graph to be rendered in this component's window.
void setRedrawPriority(unsigned long priority)
Sets the priority of the redraw sensor.
void render()
Calling this forces the render area to be redrawn now.
void setTransparencyType(SoGLRenderAction::TransparencyType type)
Sets the algorithm for rendering transparent objects.
SoGLRenderAction::InvalidateCacheMode getInvalidateCacheMode()
Returns the current cache invalidation mode.
void setBackgroundIndex(int index)
Sets the window background color when in color index mode.
SoWinRenderAreaRenderCB * getPostRenderCallback(const void *&userData) const
Gets the post-render callback function and data.
~SoWinRenderArea()
Destructor.
SbColor getBackgroundColor() const
Gets the background color for this window.
void setClearBeforeRender(SbBool trueOrFalse, SbBool zbTrueOrFalse=TRUE)
Enables/prevents window clearing from happening before a rendering starts (default is clear TRUE).
void setFloatingColorBuffer(SbBool enable, FloatColorBufferSize size=FLOAT_16_COLOR_BUFFER)
Enables/disables floating point rendering using 16- or 32-bit components.
void setAutoRedraw(SbBool trueOrFalse)
The render area will automatically redraw whenever something in the scene graph changes.
void sendEvent(XAnyEvent *anEvent)
Sends the event to be processed by the renderArea.
SbBool isClearZBufferBeforeRender() const
Queries whether the depth buffer (sometimes called the Z buffer) will be cleared before rendering sta...
SbBool isClearBeforeRender() const
Queries whether the window will be cleared before rendering starts.
void registerDevice(SoWinDevice *d)
Registers interest in devices.
void scheduleRedraw()
Schedules a redraw to happen sometime soon (as opposed to immediately).
void unregisterDevice(SoWinDevice *d)
Unregisters interest in devices.
SoGLRenderAction::TransparencyType getTransparencyType() const
Gets the algorithm for rendering transparent objects.
static unsigned long getDefaultRedrawPriority()
Gets the default priority number of the redraw sensor.
SbBool isAutoRedraw() const
Queries whether the render area will automatically redraw whenever something in the scene graph chang...
void setFastEditSavePolicy(SoGLRenderAction::FastEditSavePolicy policy, SbBool fastEditDelayedObjects=FALSE)
Sets fast editing save policy to use when rendering.
virtual SoNode * getSceneGraph()
Gets the scene graph to be rendered in this component's window.
virtual SoMPEGRenderer * getMPEGRecorder() const
Returns the recorder used for MPEG encoding.
void setViewportRegion(const SbViewportRegion &newRegion)
Sets viewport region to use for rendering.
SbBool SoWinRenderAreaRenderCB(void *userData, SoWinRenderArea *rendArea)
SoGLRenderAction::FastEditSavePolicy getFastEditSavePolicy() const
Returns fast editing save policy used when rendering.
void setGLRenderAction(SoGLRenderAction *ra)
Sets the GL render action to use.
void setBackgroundColor(const SbColor &c)
Sets the background color for this window.
SbBool SoWinRenderAreaEventCB(void *userData, XAnyEvent *anyevent)
void setEventCallback(SoWinRenderAreaEventCB *fcn, void *userData=NULL)
Windows messages which occur in the render area window are either directly handled by the viewer (whe...
SoGLRenderAction * getGLRenderAction() const
Gets the current GL render action.
void setInvalidateCacheMode(SoGLRenderAction::InvalidateCacheMode icm)
Enables or disables the invalidation of render caches.
int SbBool
Boolean type.
Definition SbBase.h:87
char Boolean
Definition SoQtDef.h:124