Open Inventor Release 2023.2.3
 
Loading...
Searching...
No Matches
SoXtRenderArea.h
Go to the documentation of this file.
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-2023 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
53#elif defined _WIN32
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>
67
68#include <Inventor/nodes/SoCamera.h> // stereo settings
71
73
75class SoXtDevice;
76class SoNode;
77class SoXtMouse;
78class SoXtKeyboard;
79class SoSelection;
80class SbConfig;
81class SoXtRenderArea;
82class ScTracking;
85
86// callback function prototypes
87typedef SbBool SoXtRenderAreaEventCB( void* userData, XAnyEvent* anyevent );
88typedef SbBool SoXtRenderAreaRenderCB( void* userData, SoXtRenderArea* rendArea );
89
91//
92// Class: SoXtRenderArea
93//
94// Class to do Inventor rendering in a GLX Motif widget.
95//
97
138{
139 public:
140
145 SoXtRenderArea( SoWidget parent = NULL,
146 const char* name = NULL,
147 SbBool buildInsideParent = TRUE,
148 SbBool getMouseInput = TRUE,
149 SbBool getKeyboardInput = TRUE );
154
158 virtual void setSceneGraph( SoNode* newScene );
159
164
171
178
185 void setBackgroundColor( const SbColor& c );
186
190 SbColor getBackgroundColor() const { return m_guiRenderArea->getBackgroundColor(); }
191
196 void setBackgroundIndex( int index ) { m_guiRenderArea->setBackgroundIndex( index ); }
197
201 int getBackgroundIndex() const { return m_guiRenderArea->getBackgroundIndex(); }
202
207 void setColorMap( int startIndex, int num, const SbColor* colors );
208
212 void setViewportRegion( const SbViewportRegion& newRegion )
213 { m_guiRenderArea->setViewportRegion( newRegion ); }
214
219 { return m_guiRenderArea->getViewportRegion(); }
220
231
237 { return m_guiRenderArea->getTransparencyType(); }
238
248 SbBool fastEditDelayedObjects = FALSE);
249
254 { return m_guiRenderArea->getFastEditSavePolicy(); }
255
272
277
285 void setClearBeforeRender( SbBool trueOrFalse, SbBool zbTrueOrFalse = TRUE )
286 { m_guiRenderArea->setClearBeforeRender( trueOrFalse, zbTrueOrFalse ); }
287
291 SbBool isClearBeforeRender() const { return m_guiRenderArea->isClearBeforeRender(); }
292
297 SbBool isClearZBufferBeforeRender() const { return m_guiRenderArea->isClearZBufferBeforeRender(); }
298
303 void setAutoRedraw( SbBool trueOrFalse );
304
309 SbBool isAutoRedraw() const { return m_guiRenderArea->isAutoRedraw(); }
310
314 void setRedrawPriority( uint32_t priority ) { m_guiRenderArea->setRedrawPriority(priority); }
315
319 uint32_t getRedrawPriority() const { return m_guiRenderArea->getRedrawPriority(); }
320
325
330 void render() { redraw(); }
331
337
349
361 void setEventCallback( SoXtRenderAreaEventCB* fcn, void* userData = NULL );
362
370
377 SoSceneManager* getSceneManager() const { return m_guiRenderArea->getSceneManager(); }
378
389
393 SoGLRenderAction* getGLRenderAction() const { return m_guiRenderArea->getGLRenderAction(); }
394
400
416 void setPostRenderCallback( SoXtRenderAreaRenderCB* fcn, void* userData = NULL )
417 { appPostRenderCB = fcn; appPostRenderData = userData; }
418
423 SoXtRenderAreaRenderCB* getPostRenderCallback( const void* &userData ) const
424 { userData = appPostRenderData; return appPostRenderCB; }
425
441
447
451 void sendEvent( XAnyEvent* anEvent );
452
458 virtual void setMPEGRecorder( SoMPEGRenderer* recorder )
459 { m_guiRenderArea->setMPEGRecorder( recorder ); }
460
465 { return m_guiRenderArea->getMPEGRecorder(); }
466
467#if 1 SoDEPRECATED
485 void setAntialiasing( SbBool smoothing, int numPasses );
487SoDEPRECATED
492 void getAntialiasing( SbBool& smoothing, int& numPasses ) const;
493
494#endif
496private:
497
498 SoXtRenderArea( SoWidget parent,
499 const char* name,
500 SbBool buildInsideParent,
501 SbBool getMouseInput,
502 SbBool getKeyboardInput,
503 SoGuiAlgoViewers* guiAlgos );
504
505 SoXtRenderArea( SoWidget parent,
506 const char* name,
507 SbBool buildInsideParent,
508 SbBool getMouseInput,
509 SbBool getKeyboardInput,
510 SbBool buildNow,
511 SbBool sync,
512 SoGuiAlgoViewers* guiAlgos );
513
514 SoXtRenderArea( SoWidget parent,
515 const char* name,
516 SbBool buildInsideParent,
517 SbBool getMouseInput,
518 SbBool getKeyboardInput,
519 SbBool buildNow,
520 SoGuiAlgoViewers* guiAlgos );
524 SoGuiAlgoViewers* getGuiAlgoViewers() const { return (SoGuiAlgoViewers*)m_guiRenderArea; }
525
526 private:
527 void setStereoMode( SoCamera::StereoMode stMode );
528 void setStereoElement();
529
530 SoGuiRenderArea* getGuiRenderArea() const;
531
532 SbBool isFloatingColorBufferSupported();
533
534 virtual SbBool isInteractive() const;
535
537
538 SoXtRenderArea( SoWidget parent,
539 const char* name,
540 SbBool buildInsideParent,
541 SbBool getMouseInput,
542 SbBool getKeyboardInput,
543 SbBool buildNow,
544 SbBool sync );
545
546 // Retro compatibility only.
547 // These members shouldn't be used directly, instead call their accessors
548 float stereoBalance, stereoOffset;
549 SbBool stereoAbsoluteAdjustments;
550 SoCamera::StereoMode stereoMode;
551 SbBool stereoReversed;
552
553 private:
554
555 //
556 // This constructor takes a boolean whether to build the widget now.
557 // Subclasses can pass FALSE, then call SoXtRenderArea::buildWidget()
558 // when they are ready for it to be built.
559
560 SoXtRenderArea( SoWidget parent,
561 const char* name,
562 SbBool buildInsideParent,
563 SbBool getMouseInput,
564 SbBool getKeyboardInput,
565 SbBool buildNow );
566
567 //Constructors provided to avoid multiple instance of implementation objects
568 //Equivalent to the public constructor
569 SoXtRenderArea( SoWidget parent,
570 const char* name,
571 SbBool buildInsideParent,
572 SbBool getMouseInput,
573 SbBool getKeyboardInput,
574 SoGuiRenderArea* guiRenderArea );
575
576 SoXtRenderArea( SoWidget parent,
577 const char* name,
578 SbBool buildInsideParent,
579 SbBool getMouseInput,
580 SbBool getKeyboardInput,
581 SbBool buildNow,
582 SbBool sync,
583 SoGuiRenderArea* guiRenderArea );
584
585 SoXtRenderArea( SoWidget parent,
586 const char* name,
587 SbBool buildInsideParent,
588 SbBool getMouseInput,
589 SbBool getKeyboardInput,
590 SbBool buildNow,
591 SoGuiRenderArea* guiRenderArea );
592
593 //
594 // redraw() calls actualRedraw(), followed by swapbuffers if necessary.
595 // actualRedraw will have the scene manager render the scene. Rendering
596 // is broken up into two routines like this so that subclasses can
597 // redefine or simply add to rendering (in actualRedraw) without having
598 // to worry about being visible, seting up the window or
599 // single/double buffer swapping.
600 //
601 virtual void redraw();
602 virtual void actualRedraw();
603
604 //
605 // Redefine these to do Inventor-specific things
606 //
607 virtual void processEvent( XAnyEvent* anyevent );
608 virtual void initGraphic();
609 virtual void sizeChanged( const SbVec2s& );
610 virtual void posChanged( const SbVec2i32&, const SbVec2i32& );
611 virtual void widgetChanged( SoWidget w );
612
613 SoWidget buildWidget( SoWidget parent );
614
615 // redefine these
616 virtual SbString getDefaultWidgetName() const;
617 virtual SbString getDefaultTitle() const;
618 virtual SbString getDefaultIconTitle() const;
619
620 // subclasses have access to the device list for event processing
621 SbPList* m_deviceList; // list of devices
622
623 // application event callbacks variables
624 SoXtRenderAreaEventCB* defaultAppEventHandler;
625 void* defaultAppEventHandlerData;
626 SoXtRenderAreaEventCB* appEventHandler;
627 void* appEventHandlerData;
628
629 // invoke the application event callback - returns what the app cb returns
630 SbBool invokeAppCB( XAnyEvent* anyevent );
631 SbBool processInventorEvent( XAnyEvent* anyevent );
632 const SoEvent* translateAnyEvent( XAnyEvent* anyevent );
633
634 // application pre/post render callback variables
635 SoXtRenderAreaRenderCB* appPostRenderCB;
636 void* appPostRenderData;
637
638private:
639 // these make rendering/redrawing happen
640 XColor* m_mapColors; // saved colors
641 int m_mapColorNum; // number of saved colors
642
643 SoXtMouse* m_mouseDevice;
644 SoXtKeyboard* m_keybdDevice;
645 void reinstallDevices( SoWidget newWidget );
646
647 static void selectionChangeCB( void* p, SoSelection* s );
648 SoWidget m_deviceWidget;
649
650 // static callbacks
651 SbBool m_firstEvent; // used to init the action SoWindowElement
652 static void windowEventCB( SoWidget w, SoXtRenderArea* p, XAnyEvent* xe, Boolean* b );
653 static void renderCB( void* v, SoSceneManager* sm );
654
655 static void visibilityChangeCB( void* pt, SbBool visible );
656 void activate(); // connects the sensor
657 void deactivate(); // disconnects the sensor
658
659 // this is called by both constructors
660 void constructorCommon( SbBool getMouseInput, SbBool getKeyboardInput, SbBool buildNow );
661
662 // this is called by constructorCommon
663 void constructorCommon2( SbBool getMouseInput,
664 SbBool getKeyboardInput,
665 SbBool buildNow );
666
667 SbVec2i32 getWindowPosition() { return SbVec2i32( INT_MAX, INT_MAX ); }
668
669 SbConfig* m_vrConfig;
670 SbBool m_forceRedraw;
671 SbBool m_forceSyncRedraw;
672
673 ScTracking* m_tracking;
674
675 SoGuiRenderArea* m_guiRenderArea; // Implementation class for SoXxRendeArea
676
677 // this is the default implementation of the hasRenderAbortCallback passed to the scenemanager
678 // at construction. Implementation is common to all created renderArea.
679 // If an event is received to one renderArea, all renderArea of the process will consider it as
680 // a candidate for abortion (only implemented on Windows)
681 static SbBool s_abortRenderCallback(SoAction*,void*);
682
683 SoAntialiasingParameters* m_accumulationParameters;
684
685 bool m_firstStdRedraw;
686 bool m_firstConnectedRedraw;
687 SoTimerSensor* m_viewerUpdaterSensor;
688 static void viewerUpdaterCB( void*, SoSensor* );
689 void updateFirstFrame();
690};
691
692
693#endif /* _SO_XT_RENDER_AREA_H_ */
694
695#endif
696
#define TRUE
Possible value of SbBool.
Definition SbBase.h:77
#define FALSE
Possible value of SbBool.
Definition SbBase.h:75
SbBool isInteractive()
char Boolean
Definition SoQtDef.h:119
#define SoWidget
Definition SoQtDef.h:40
virtual void enable(QWidget *w, XtEventHandler f, XtPointer data, void *unused=NULL)
#define XColor
Definition SoWinDef.h:95
#define XAnyEvent
Definition SoWinDef.h:100
#define SoXtRenderAreaEventCB
Definition SoXt2SoQt.h:130
#define SoXtRenderArea
Definition SoXt2SoQt.h:129
SbBool SoXtRenderAreaRenderCB(void *userData, SoXtRenderArea *rendArea)
SbBool SoXtRenderAreaEventCB(void *userData, XAnyEvent *anyevent)
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:97
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.
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 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
size_t size() const