Open Inventor Release 2024.2.0
 
Loading...
Searching...
No Matches
SoXtRenderArea.h
1/*=======================================================================
2 * Copyright 1991-1996, Silicon Graphics, Inc.
3 * ALL RIGHTS RESERVED
4 *
5 * UNPUBLISHED -- Rights reserved under the copyright laws of the United
6 * States. Use of a copyright notice is precautionary only and does not
7 * imply publication or disclosure.
8 *
9 * U.S. GOVERNMENT RESTRICTED RIGHTS LEGEND:
10 * Use, duplication or disclosure by the Government is subject to restrictions
11 * as set forth in FAR 52.227.19(c)(2) or subparagraph (c)(1)(ii) of the Rights
12 * in Technical Data and Computer Software clause at DFARS 252.227-7013 and/or
13 * in similar or successor clauses in the FAR, or the DOD or NASA FAR
14 * Supplement. Contractor/manufacturer is Silicon Graphics, Inc.,
15 * 2011 N. Shoreline Blvd. Mountain View, CA 94039-7311.
16 *
17 * THE CONTENT OF THIS WORK CONTAINS CONFIDENTIAL AND PROPRIETARY
18 * INFORMATION OF SILICON GRAPHICS, INC. ANY DUPLICATION, MODIFICATION,
19 * DISTRIBUTION, OR DISCLOSURE IN ANY FORM, IN WHOLE, OR IN PART, IS STRICTLY
20 * PROHIBITED WITHOUT THE PRIOR EXPRESS WRITTEN PERMISSION OF SILICON
21 * GRAPHICS, INC.
22**=======================================================================*/
23/*=======================================================================
24** Author : Author(s) (MMM yyyy)
25** Modified by : David Mott (MMM yyyy)
26** Modified by : Alain Dumesny (MMM yyyy)
27**=======================================================================*/
28/*=======================================================================
29 *** THE CONTENT OF THIS WORK IS PROPRIETARY TO FEI S.A.S, (FEI S.A.S.), ***
30 *** AND IS DISTRIBUTED UNDER A LICENSE AGREEMENT. ***
31 *** ***
32 *** REPRODUCTION, DISCLOSURE, OR USE, IN WHOLE OR IN PART, OTHER THAN AS ***
33 *** SPECIFIED IN THE LICENSE ARE NOT TO BE UNDERTAKEN EXCEPT WITH PRIOR ***
34 *** WRITTEN AUTHORIZATION OF FEI S.A.S. ***
35 *** ***
36 *** RESTRICTED RIGHTS LEGEND ***
37 *** USE, DUPLICATION, OR DISCLOSURE BY THE GOVERNMENT OF THE CONTENT OF THIS ***
38 *** WORK OR RELATED DOCUMENTATION IS SUBJECT TO RESTRICTIONS AS SET FORTH IN ***
39 *** SUBPARAGRAPH (C)(1) OF THE COMMERCIAL COMPUTER SOFTWARE RESTRICTED RIGHT ***
40 *** CLAUSE AT FAR 52.227-19 OR SUBPARAGRAPH (C)(1)(II) OF THE RIGHTS IN ***
41 *** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 52.227-7013. ***
42 *** ***
43 *** COPYRIGHT (C) 1996-2024 BY FEI S.A.S, ***
44 *** BORDEAUX, FRANCE ***
45 *** ALL RIGHTS RESERVED ***
46**=======================================================================*/
47/*=======================================================================
48** Modified by : VSG (MMM YYYY)
49**=======================================================================*/
50
51#ifdef SOQT
52# include <Inventor/Qt/SoQtRenderArea.h>
53#elif defined _WIN32
54# include <Inventor/Win/SoWinRenderArea.h>
55#else
56
57#ifndef _SO_XT_RENDER_AREA_H_
58#define _SO_XT_RENDER_AREA_H_
59
60#include <climits>
61
62#include <Inventor/SbColor.h>
63#include <Inventor/sensors/SoNodeSensor.h>
64#include <Inventor/SoSceneManager.h>
65#include <Inventor/Xt/SoXtGLWidget.h>
66#include <Inventor/actions/SoGLRenderAction.h>
67
68#include <Inventor/nodes/SoCamera.h> // stereo settings
69#include <Inventor/nodes/SoFullSceneAntialiasing.h>
70#include <Inventor/SbElapsedTime.h>
71
72#include <Inventor/Gui/SoGuiRenderArea.h>
73
75class SoXtDevice;
76class SoNode;
77class SoXtMouse;
78class SoXtKeyboard;
79class SoSelection;
80class SbConfig;
81class SoXtRenderArea;
82class ScTracking;
85
86// callback function prototypes
88typedef SbBool SoXtRenderAreaEventCB( void* userData, XAnyEvent* anyevent );
90typedef SbBool SoXtRenderAreaRenderCB( void* userData, SoXtRenderArea* rendArea );
91
93//
94// Class: SoXtRenderArea
95//
96// Class to do Inventor rendering in a GLX Motif widget.
97//
99
140{
141 public:
142
147 SoXtRenderArea( SoWidget parent = NULL,
148 const char* name = NULL,
149 SbBool buildInsideParent = TRUE,
150 SbBool getMouseInput = TRUE,
151 SbBool getKeyboardInput = TRUE );
156
160 virtual void setSceneGraph( SoNode* newScene );
161
166
173
180
187 void setBackgroundColor( const SbColor& c );
188
192 SbColor getBackgroundColor() const { return m_guiRenderArea->getBackgroundColor(); }
193
198 void setBackgroundIndex( int index ) { m_guiRenderArea->setBackgroundIndex( index ); }
199
203 int getBackgroundIndex() const { return m_guiRenderArea->getBackgroundIndex(); }
204
209 void setColorMap( int startIndex, int num, const SbColor* colors );
210
214 void setViewportRegion( const SbViewportRegion& newRegion )
215 { m_guiRenderArea->setViewportRegion( newRegion ); }
216
221 { return m_guiRenderArea->getViewportRegion(); }
222
233
239 { return m_guiRenderArea->getTransparencyType(); }
240
250 SbBool fastEditDelayedObjects = FALSE);
251
256 { return m_guiRenderArea->getFastEditSavePolicy(); }
257
274
279
287 void setClearBeforeRender( SbBool trueOrFalse, SbBool zbTrueOrFalse = TRUE )
288 { m_guiRenderArea->setClearBeforeRender( trueOrFalse, zbTrueOrFalse ); }
289
293 SbBool isClearBeforeRender() const { return m_guiRenderArea->isClearBeforeRender(); }
294
299 SbBool isClearZBufferBeforeRender() const { return m_guiRenderArea->isClearZBufferBeforeRender(); }
300
305 void setAutoRedraw( SbBool trueOrFalse );
306
311 SbBool isAutoRedraw() const { return m_guiRenderArea->isAutoRedraw(); }
312
316 void setRedrawPriority( uint32_t priority ) { m_guiRenderArea->setRedrawPriority(priority); }
317
321 uint32_t getRedrawPriority() const { return m_guiRenderArea->getRedrawPriority(); }
322
327
332 void render() { redraw(); }
333
339
351
363 void setEventCallback( SoXtRenderAreaEventCB* fcn, void* userData = NULL );
364
372
379 SoSceneManager* getSceneManager() const { return m_guiRenderArea->getSceneManager(); }
380
391
395 SoGLRenderAction* getGLRenderAction() const { return m_guiRenderArea->getGLRenderAction(); }
396
402
418 void setPostRenderCallback( SoXtRenderAreaRenderCB* fcn, void* userData = NULL )
419 { appPostRenderCB = fcn; appPostRenderData = userData; }
420
425 SoXtRenderAreaRenderCB* getPostRenderCallback( const void* &userData ) const
426 { userData = appPostRenderData; return appPostRenderCB; }
427
442 void setFloatingColorBuffer( SbBool enable, FloatColorBufferSize size = FLOAT_16_COLOR_BUFFER );
443
449
453 void sendEvent( XAnyEvent* anEvent );
454
460 virtual void setMPEGRecorder( SoMPEGRenderer* recorder )
461 { m_guiRenderArea->setMPEGRecorder( recorder ); }
462
467 { return m_guiRenderArea->getMPEGRecorder(); }
468
469#if 1 SoDEPRECATED
487 void setAntialiasing( SbBool smoothing, int numPasses );
489SoDEPRECATED
494 void getAntialiasing( SbBool& smoothing, int& numPasses ) const;
495
496#endif
498private:
499
500 SoXtRenderArea( SoWidget parent,
501 const char* name,
502 SbBool buildInsideParent,
503 SbBool getMouseInput,
504 SbBool getKeyboardInput,
505 SoGuiAlgoViewers* guiAlgos );
506
507 SoXtRenderArea( SoWidget parent,
508 const char* name,
509 SbBool buildInsideParent,
510 SbBool getMouseInput,
511 SbBool getKeyboardInput,
512 SbBool buildNow,
513 SbBool sync,
514 SoGuiAlgoViewers* guiAlgos );
515
516 SoXtRenderArea( SoWidget parent,
517 const char* name,
518 SbBool buildInsideParent,
519 SbBool getMouseInput,
520 SbBool getKeyboardInput,
521 SbBool buildNow,
522 SoGuiAlgoViewers* guiAlgos );
526 SoGuiAlgoViewers* getGuiAlgoViewers() const { return (SoGuiAlgoViewers*)m_guiRenderArea; }
527
528 private:
529 void setStereoMode( SoCamera::StereoMode stMode );
530 void setStereoElement();
531
532 SoGuiRenderArea* getGuiRenderArea() const;
533
534 SbBool isFloatingColorBufferSupported();
535
536 virtual SbBool isInteractive() const;
537
539
540 SoXtRenderArea( SoWidget parent,
541 const char* name,
542 SbBool buildInsideParent,
543 SbBool getMouseInput,
544 SbBool getKeyboardInput,
545 SbBool buildNow,
546 SbBool sync );
547
548 // Retro compatibility only.
549 // These members shouldn't be used directly, instead call their accessors
550 float stereoBalance, stereoOffset;
551 SbBool stereoAbsoluteAdjustments;
552 SoCamera::StereoMode stereoMode;
553 SbBool stereoReversed;
554
555 private:
556
557 //
558 // This constructor takes a boolean whether to build the widget now.
559 // Subclasses can pass FALSE, then call SoXtRenderArea::buildWidget()
560 // when they are ready for it to be built.
561
562 SoXtRenderArea( SoWidget parent,
563 const char* name,
564 SbBool buildInsideParent,
565 SbBool getMouseInput,
566 SbBool getKeyboardInput,
567 SbBool buildNow );
568
569 //Constructors provided to avoid multiple instance of implementation objects
570 //Equivalent to the public constructor
571 SoXtRenderArea( SoWidget parent,
572 const char* name,
573 SbBool buildInsideParent,
574 SbBool getMouseInput,
575 SbBool getKeyboardInput,
576 SoGuiRenderArea* guiRenderArea );
577
578 SoXtRenderArea( SoWidget parent,
579 const char* name,
580 SbBool buildInsideParent,
581 SbBool getMouseInput,
582 SbBool getKeyboardInput,
583 SbBool buildNow,
584 SbBool sync,
585 SoGuiRenderArea* guiRenderArea );
586
587 SoXtRenderArea( SoWidget parent,
588 const char* name,
589 SbBool buildInsideParent,
590 SbBool getMouseInput,
591 SbBool getKeyboardInput,
592 SbBool buildNow,
593 SoGuiRenderArea* guiRenderArea );
594
595 //
596 // redraw() calls actualRedraw(), followed by swapbuffers if necessary.
597 // actualRedraw will have the scene manager render the scene. Rendering
598 // is broken up into two routines like this so that subclasses can
599 // redefine or simply add to rendering (in actualRedraw) without having
600 // to worry about being visible, seting up the window or
601 // single/double buffer swapping.
602 //
603 virtual void redraw();
604 virtual void actualRedraw();
605
606 //
607 // Redefine these to do Inventor-specific things
608 //
609 virtual void processEvent( XAnyEvent* anyevent );
610 virtual void initGraphic();
611 virtual void sizeChanged( const SbVec2s& );
612 virtual void posChanged( const SbVec2i32&, const SbVec2i32& );
613 virtual void widgetChanged( SoWidget w );
614
615 SoWidget buildWidget( SoWidget parent );
616
617 // redefine these
618 virtual SbString getDefaultWidgetName() const;
619 virtual SbString getDefaultTitle() const;
620 virtual SbString getDefaultIconTitle() const;
621
622 // subclasses have access to the device list for event processing
623 SbPList* m_deviceList; // list of devices
624
625 // application event callbacks variables
626 SoXtRenderAreaEventCB* defaultAppEventHandler;
627 void* defaultAppEventHandlerData;
628 SoXtRenderAreaEventCB* appEventHandler;
629 void* appEventHandlerData;
630
631 // invoke the application event callback - returns what the app cb returns
632 SbBool invokeAppCB( XAnyEvent* anyevent );
633 SbBool processInventorEvent( XAnyEvent* anyevent );
634 const SoEvent* translateAnyEvent( XAnyEvent* anyevent );
635
636 // application pre/post render callback variables
637 SoXtRenderAreaRenderCB* appPostRenderCB;
638 void* appPostRenderData;
639
640private:
641 // these make rendering/redrawing happen
642 XColor* m_mapColors; // saved colors
643 int m_mapColorNum; // number of saved colors
644
645 SoXtMouse* m_mouseDevice;
646 SoXtKeyboard* m_keybdDevice;
647 void reinstallDevices( SoWidget newWidget );
648
649 static void selectionChangeCB( void* p, SoSelection* s );
650 SoWidget m_deviceWidget;
651
652 // static callbacks
653 SbBool m_firstEvent; // used to init the action SoWindowElement
654 static void windowEventCB( SoWidget w, SoXtRenderArea* p, XAnyEvent* xe, Boolean* b );
655 static void renderCB( void* v, SoSceneManager* sm );
656
657 static void visibilityChangeCB( void* pt, SbBool visible );
658 void activate(); // connects the sensor
659 void deactivate(); // disconnects the sensor
660
661 // this is called by both constructors
662 void constructorCommon( SbBool getMouseInput, SbBool getKeyboardInput, SbBool buildNow );
663
664 // this is called by constructorCommon
665 void constructorCommon2( SbBool getMouseInput,
666 SbBool getKeyboardInput,
667 SbBool buildNow );
668
669 SbVec2i32 getWindowPosition() { return SbVec2i32( INT_MAX, INT_MAX ); }
670
671 SbConfig* m_vrConfig;
672 SbBool m_forceRedraw;
673 SbBool m_forceSyncRedraw;
674
675 ScTracking* m_tracking;
676
677 SoGuiRenderArea* m_guiRenderArea; // Implementation class for SoXxRendeArea
678
679 // this is the default implementation of the hasRenderAbortCallback passed to the scenemanager
680 // at construction. Implementation is common to all created renderArea.
681 // If an event is received to one renderArea, all renderArea of the process will consider it as
682 // a candidate for abortion (only implemented on Windows)
683 static SbBool s_abortRenderCallback(SoAction*,void*);
684
685 SoAntialiasingParameters* m_accumulationParameters;
686
687 bool m_firstStdRedraw;
688 bool m_firstConnectedRedraw;
689 SoTimerSensor* m_viewerUpdaterSensor;
690 static void viewerUpdaterCB( void*, SoSensor* );
691 void updateFirstFrame();
692};
693
694
695#endif /* _SO_XT_RENDER_AREA_H_ */
696
697#endif
698
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.
Abstract base class for input devices.
Definition SoXtDevice.h:85
Component for OpenGL rendering.
void setAntialiasing(const float quality, const SoSceneManager::AntialiasingMode mode=SoSceneManager::AUTO)
Enable (or disable) antialiasing with specified quality and mode.
FloatColorBufferSize
FloatColorBufferSize.
Translates and reports events for the keyboard device.
Translates and reports events for the mouse device.
Definition SoXtMouse.h:87
Component for rendering Open Inventor scene graphs.
SbColor getBackgroundColor() const
Gets the background color for this window.
SoDEPRECATED void getAntialiasing(SbBool &smoothing, int &numPasses) const
Gets the antialiasing used for rendering.
virtual void setSceneGraph(SoNode *newScene)
Sets the scene graph to be rendered in this component's window.
SoGLRenderAction::InvalidateCacheMode getInvalidateCacheMode()
Returns the current cache invalidation mode.
SbBool isClearBeforeRender() const
Queries whether the window will be cleared before rendering starts.
void setClearBeforeRender(SbBool trueOrFalse, SbBool zbTrueOrFalse=TRUE)
Enables/prevents window clearing from happening before a rendering starts (default is clear TRUE).
virtual void setMPEGRecorder(SoMPEGRenderer *recorder)
Sets the recorder used for MPEG encoding.
void render()
Calling this forces the render area to be redrawn now.
uint32_t getRedrawPriority() const
Gets the priority of the redraw sensor.
void sendEvent(XAnyEvent *anEvent)
Sends the event to be processed by the renderArea.
SoSceneManager * getSceneManager() const
Gets the normal scene manager.
void registerDevice(SoXtDevice *d)
Registers interest in devices.
const SbGLShareContext getShareContext()
Returns the information needed to make OpenGL render contexts share OpenGL objects,...
SbBool isClearZBufferBeforeRender() const
Queries whether the depth buffer (sometimes called the Z buffer) will be cleared before rendering sta...
SoGLRenderAction::TransparencyType getTransparencyType() const
Gets the algorithm for rendering transparent objects.
void setFastEditSavePolicy(SoGLRenderAction::FastEditSavePolicy policy, SbBool fastEditDelayedObjects=FALSE)
Sets fast editing save policy to use when rendering.
~SoXtRenderArea()
Destructor.
void setInvalidateCacheMode(SoGLRenderAction::InvalidateCacheMode icm)
Enables or disables the invalidation of render caches.
const SbViewportRegion & getViewportRegion() const
Gets current viewport region to use for rendering.
void setBackgroundIndex(int index)
Sets the window background color when in color index mode.
virtual SoNode * getSceneGraph()
Gets the scene graph to be rendered in this component's window.
SoDEPRECATED void setAntialiasing(SbBool smoothing, int numPasses)
Enables smoothing and/or multi-pass antialiasing for rendering.
virtual SoMPEGRenderer * getMPEGRecorder() const
Returns the recorder used for the MPEG encoding.
void setAutoRedraw(SbBool trueOrFalse)
The render area will automatically redraw whenever something in the scene graph changes.
void setRedrawPriority(uint32_t priority)
Sets the priority of the redraw sensor.
void unregisterDevice(SoXtDevice *d)
Unregisters interest in devices.
SoXtRenderArea(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 getFloatingColorBuffer(SbBool &enable, FloatColorBufferSize &size)
Returns TRUE if floating point rendering is used and its precision.
void setBackgroundColor(const SbColor &c)
Sets the background color for this window.
SoXtRenderAreaRenderCB * getPostRenderCallback(const void *&userData) const
Gets the post-render callback function and data.
SoGLRenderAction::FastEditSavePolicy getFastEditSavePolicy() const
Returns fast editing save policy used when rendering.
SoGLRenderAction * getGLRenderAction() const
Gets the current GL render action.
void setSceneManager(SoSceneManager *sm)
Sets the normal scene manager.
void setTransparencyType(SoGLRenderAction::TransparencyType type)
Sets the algorithm for rendering transparent objects.
static uint32_t getDefaultRedrawPriority()
Gets the default priority number of the redraw sensor.
void setPostRenderCallback(SoXtRenderAreaRenderCB *fcn, void *userData=NULL)
Specifies a function to be called after the Open Inventor render traversal and immediately before the...
void setColorMap(int startIndex, int num, const SbColor *colors)
Sets the colors to use when displaying in color index mode.
void setGLRenderAction(SoGLRenderAction *ra)
Sets the GL render action to use.
SbBool SoXtRenderAreaRenderCB(void *userData, SoXtRenderArea *rendArea)
void setEventCallback(SoXtRenderAreaEventCB *fcn, void *userData=NULL)
X events which occur in the render area window are either directly handled by the viewer (when this i...
int getBackgroundIndex() const
Gets the window background color when in color index mode.
SbBool SoXtRenderAreaEventCB(void *userData, XAnyEvent *anyevent)
SbBool isAutoRedraw() const
Queries whether the render area will automatically redraw whenever something in the scene graph chang...
void setViewportRegion(const SbViewportRegion &newRegion)
Sets viewport region to use for rendering.
void setFloatingColorBuffer(SbBool enable, FloatColorBufferSize size=FLOAT_16_COLOR_BUFFER)
Enables/disables floating point rendering using 16- or 32-bit components.
void redrawOnSelectionChange(SoSelection *s)
Call this convenience method to have this render area redraw whenever the selection list changes in t...
void scheduleRedraw()
Schedules a redraw to happen sometime soon (as opposed to immediately).
int SbBool
Boolean type.
Definition SbBase.h:87
char Boolean
Definition SoQtDef.h:124