00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051 #ifdef SOQT
00052 # include <Inventor/Qt/SoQtRenderArea.h>
00053 #elif defined(SOWX)
00054 # include <Inventor/Wx/SoWxRenderArea.h>
00055 #elif defined _WIN32
00056 # include <Inventor/Win/SoWinRenderArea.h>
00057 #else
00058
00059 #ifndef _SO_XT_RENDER_AREA_H_
00060 #define _SO_XT_RENDER_AREA_H_
00061
00062 #include <climits>
00063
00064 #include <Inventor/SbColor.h>
00065 #include <Inventor/sensors/SoNodeSensor.h>
00066 #include <Inventor/SoSceneManager.h>
00067 #include <Inventor/Xt/SoXtGLWidget.h>
00068 #include <Inventor/actions/SoGLRenderAction.h>
00069
00070 #include <Inventor/nodes/SoCamera.h>
00071 #include <Inventor/nodes/SoFullSceneAntialiasing.h>
00072 #include <Inventor/SbElapsedTime.h>
00073
00074 #include <Inventor/Gui/SoGuiRenderArea.h>
00075
00076 class SoHandleEventAction;
00077 class SoXtDevice;
00078 class SoNode;
00079 class SoXtMouse;
00080 class SoXtKeyboard;
00081 class SoSelection;
00082 class SbConfig;
00083 class SoXtRenderArea;
00084 class ScTracking;
00085 class SoGuiAlgoViewers;
00086 class SoAntialiasingParameters;
00087
00088
00089 typedef SbBool SoXtRenderAreaEventCB( void* userData, XAnyEvent* anyevent );
00090 typedef SbBool SoXtRenderAreaRenderCB( void* userData, SoXtRenderArea* rendArea );
00091
00093
00094
00095
00096
00097
00099
00161 class SoXtRenderArea : public SoXtGLWidget
00162 {
00163 public:
00164
00169 SoXtRenderArea( SoWidget parent = NULL,
00170 const char* name = NULL,
00171 SbBool buildInsideParent = TRUE,
00172 SbBool getMouseInput = TRUE,
00173 SbBool getKeyboardInput = TRUE );
00177 ~SoXtRenderArea();
00178
00182 virtual void setSceneGraph( SoNode* newScene );
00183
00187 virtual SoNode* getSceneGraph();
00188
00194 void registerDevice( SoXtDevice* d );
00195
00201 void unregisterDevice( SoXtDevice* d );
00202
00209 void setBackgroundColor( const SbColor& c );
00210
00214 const SbColor& getBackgroundColor() const { return m_guiRenderArea->getBackgroundColor(); }
00215
00220 void setBackgroundIndex( int index ) { m_guiRenderArea->setBackgroundIndex( index ); }
00221
00225 int getBackgroundIndex() const { return m_guiRenderArea->getBackgroundIndex(); }
00226
00231 void setColorMap( int startIndex, int num, const SbColor* colors );
00232
00236 void setViewportRegion( const SbViewportRegion& newRegion )
00237 { m_guiRenderArea->setViewportRegion( newRegion ); }
00238
00242 const SbViewportRegion& getViewportRegion() const
00243 { return m_guiRenderArea->getViewportRegion(); }
00244
00254 void setTransparencyType( SoGLRenderAction::TransparencyType type );
00255
00260 SoGLRenderAction::TransparencyType getTransparencyType() const
00261 { return m_guiRenderArea->getTransparencyType(); }
00262
00271 void setFastEditSavePolicy( SoGLRenderAction::FastEditSavePolicy policy,
00272 SbBool fastEditDelayedObjects = FALSE);
00273
00277 SoGLRenderAction::FastEditSavePolicy getFastEditSavePolicy() const
00278 { return m_guiRenderArea->getFastEditSavePolicy(); }
00279
00296 void setSortedTrianglesSortFrequency( int angle );
00297
00302 int getSortedTrianglesSortFrequency();
00303
00316 void setSortedTrianglesNumCaches( int numCaches );
00317
00321 int getSortedTrianglesNumCaches();
00322
00338 void setInvalidateCacheMode( SoGLRenderAction::InvalidateCacheMode icm );
00339
00343 SoGLRenderAction::InvalidateCacheMode getInvalidateCacheMode();
00344
00352 void setClearBeforeRender( SbBool trueOrFalse, SbBool zbTrueOrFalse = TRUE )
00353 { m_guiRenderArea->setClearBeforeRender( trueOrFalse, zbTrueOrFalse ); }
00354
00358 SbBool isClearBeforeRender() const { return m_guiRenderArea->isClearBeforeRender(); }
00359
00364 SbBool isClearZBufferBeforeRender() const { return m_guiRenderArea->isClearZBufferBeforeRender(); }
00365
00370 void setAutoRedraw( SbBool trueOrFalse );
00371
00376 SbBool isAutoRedraw() const { return m_guiRenderArea->isAutoRedraw(); }
00377
00381 void setRedrawPriority( uint32_t priority ) { m_guiRenderArea->setRedrawPriority(priority); }
00382
00386 uint32_t getRedrawPriority() const { return m_guiRenderArea->getRedrawPriority(); }
00387
00391 static uint32_t getDefaultRedrawPriority() { return SoSceneManager::getDefaultRedrawPriority(); }
00392
00397 void render() { redraw(); }
00398
00403 void scheduleRedraw();
00404
00415 void redrawOnSelectionChange( SoSelection* s );
00416
00428 void setEventCallback( SoXtRenderAreaEventCB* fcn, void* userData = NULL );
00429
00436 void setSceneManager( SoSceneManager* sm );
00437
00444 SoSceneManager* getSceneManager() const { return m_guiRenderArea->getSceneManager(); }
00445
00451 void setGLRenderAction( SoGLRenderAction* ra );
00452
00458 SoGLRenderAction* getGLRenderAction() const { return m_guiRenderArea->getGLRenderAction(); }
00459
00460 #if 1
00461 #if defined(sun) || defined(__linux__)
00462 SoDEPRECATED
00463 virtual void setSunOverlayBackgroundIndex();
00464 #endif
00465 SoDEPRECATED
00471 void setOverlaySceneGraph( SoNode* newScene );
00472 SoDEPRECATED
00478 SoNode* getOverlaySceneGraph() { return m_guiRenderArea->getOverlaySceneGraph(); }
00479 SoDEPRECATED
00485 void setOverlayBackgroundIndex( int index ) { m_guiRenderArea->setOverlayBackgroundIndex( index ); }
00486 SoDEPRECATED
00491 int getOverlayBackgroundIndex() const { return m_guiRenderArea->getOverlayBackgroundIndex(); }
00492 SoDEPRECATED
00498 void setOverlayColorMap( int startIndex, int num, const SbColor* colors );
00499 SoDEPRECATED
00505 void setClearBeforeOverlayRender( SbBool trueOrFalse )
00506 { m_guiRenderArea->setClearBeforeOverlayRender( trueOrFalse ); }
00507 SoDEPRECATED
00512 SbBool isClearBeforeOverlayRender() const { return m_guiRenderArea->isClearBeforeOverlayRender(); }
00513 SoDEPRECATED
00519 void renderOverlay() { redrawOverlay(); }
00520 SoDEPRECATED
00526 void scheduleOverlayRedraw();
00527 SoDEPRECATED
00539 void redrawOverlayOnSelectionChange( SoSelection* s );
00540 SoDEPRECATED
00548 void setOverlaySceneManager( SoSceneManager* sm ) { m_guiRenderArea->setOverlaySceneManager( sm ); }
00549 SoDEPRECATED
00557 SoSceneManager* getOverlaySceneManager() const { return m_guiRenderArea->getOverlaySceneManager(); }
00558 SoDEPRECATED
00563 void setOverlayGLRenderAction( SoGLRenderAction* ra ) { m_guiRenderArea->setOverlayGLRenderAction( ra ); }
00564 SoDEPRECATED
00569 SoGLRenderAction* getOverlayGLRenderAction() const { return m_guiRenderArea->getOverlayGLRenderAction(); }
00570 #endif
00579 const SbGLShareContext getShareContext();
00580
00596 void setPostRenderCallback( SoXtRenderAreaRenderCB* fcn, void* userData = NULL )
00597 { appPostRenderCB = fcn; appPostRenderData = userData; }
00598
00603 SoXtRenderAreaRenderCB* getPostRenderCallback( const void* &userData ) const
00604 { userData = appPostRenderData; return appPostRenderCB; }
00605
00620 void setFloatingColorBuffer( SbBool enable, FloatColorBufferSize size = FLOAT_16_COLOR_BUFFER );
00621
00626 void getFloatingColorBuffer( SbBool& enable, FloatColorBufferSize& size );
00627
00631 void sendEvent( XAnyEvent* anEvent );
00632
00638 virtual void setMPEGRecorder( SoMPEGRenderer* recorder )
00639 { m_guiRenderArea->setMPEGRecorder( recorder ); }
00640
00644 virtual SoMPEGRenderer* getMPEGRecorder() const
00645 { return m_guiRenderArea->getMPEGRecorder(); }
00646
00647 #if 1 SoDEPRECATED
00665 void setAntialiasing( SbBool smoothing, int numPasses );
00666 using SoXtGLWidget::setAntialiasing;
00667 SoDEPRECATED
00672 void getAntialiasing( SbBool& smoothing, int& numPasses ) const;
00673
00674 #endif
00676 private:
00677
00678 SoXtRenderArea( SoWidget parent,
00679 const char* name,
00680 SbBool buildInsideParent,
00681 SbBool getMouseInput,
00682 SbBool getKeyboardInput,
00683 SoGuiAlgoViewers* guiAlgos );
00684
00685 SoXtRenderArea( SoWidget parent,
00686 const char* name,
00687 SbBool buildInsideParent,
00688 SbBool getMouseInput,
00689 SbBool getKeyboardInput,
00690 SbBool buildNow,
00691 SbBool sync,
00692 SoGuiAlgoViewers* guiAlgos );
00693
00694 SoXtRenderArea( SoWidget parent,
00695 const char* name,
00696 SbBool buildInsideParent,
00697 SbBool getMouseInput,
00698 SbBool getKeyboardInput,
00699 SbBool buildNow,
00700 SoGuiAlgoViewers* guiAlgos );
00704 SoGuiAlgoViewers* getGuiAlgoViewers() const { return (SoGuiAlgoViewers*)m_guiRenderArea; }
00705
00706 private:
00707 void setStereoMode( SoCamera::StereoMode stMode );
00708 void setStereoElement();
00709
00710 SoGuiRenderArea* getGuiRenderArea() const;
00711
00712 SbBool isFloatingColorBufferSupported();
00713
00714 virtual SbBool isInteractive() const;
00715
00716 SoXtRenderArea();
00717
00718 SoXtRenderArea( SoWidget parent,
00719 const char* name,
00720 SbBool buildInsideParent,
00721 SbBool getMouseInput,
00722 SbBool getKeyboardInput,
00723 SbBool buildNow,
00724 SbBool sync );
00725
00726
00727
00728 float stereoBalance, stereoOffset;
00729 SbBool stereoAbsoluteAdjustments;
00730 SoCamera::StereoMode stereoMode;
00731 SbBool stereoReversed;
00732
00733 private:
00734
00735
00736
00737
00738
00739
00740 SoXtRenderArea( SoWidget parent,
00741 const char* name,
00742 SbBool buildInsideParent,
00743 SbBool getMouseInput,
00744 SbBool getKeyboardInput,
00745 SbBool buildNow );
00746
00747
00748
00749 SoXtRenderArea( SoWidget parent,
00750 const char* name,
00751 SbBool buildInsideParent,
00752 SbBool getMouseInput,
00753 SbBool getKeyboardInput,
00754 SoGuiRenderArea* guiRenderArea );
00755
00756 SoXtRenderArea( SoWidget parent,
00757 const char* name,
00758 SbBool buildInsideParent,
00759 SbBool getMouseInput,
00760 SbBool getKeyboardInput,
00761 SbBool buildNow,
00762 SbBool sync,
00763 SoGuiRenderArea* guiRenderArea );
00764
00765 SoXtRenderArea( SoWidget parent,
00766 const char* name,
00767 SbBool buildInsideParent,
00768 SbBool getMouseInput,
00769 SbBool getKeyboardInput,
00770 SbBool buildNow,
00771 SoGuiRenderArea* guiRenderArea );
00772
00773
00774
00775
00776
00777
00778
00779
00780
00781 virtual void redraw();
00782 virtual void actualRedraw();
00783 #if 1 SoDEPRECATED
00785 virtual void redrawOverlay();SoDEPRECATED
00787 virtual void actualOverlayRedraw();
00788 #endif
00790 //
00791
00792
00793 virtual void processEvent( XAnyEvent* anyevent );
00794 virtual void initGraphic();
00795 #if 1 SoDEPRECATED
00797 virtual void initOverlayGraphic();
00798 #endif
00799 virtual void sizeChanged( const SbVec2s& );
00800 virtual void posChanged( const SbVec2i32&, const SbVec2i32& );
00801 virtual void widgetChanged( SoWidget w );
00802
00803 SoWidget buildWidget( SoWidget parent );
00804
00805
00806 virtual SbString getDefaultWidgetName() const;
00807 virtual SbString getDefaultTitle() const;
00808 virtual SbString getDefaultIconTitle() const;
00809
00810
00811 SbPList* m_deviceList;
00812
00813
00814 SoXtRenderAreaEventCB* defaultAppEventHandler;
00815 void* defaultAppEventHandlerData;
00816 SoXtRenderAreaEventCB* appEventHandler;
00817 void* appEventHandlerData;
00818
00819
00820 SbBool invokeAppCB( XAnyEvent* anyevent );
00821 SbBool processInventorEvent( XAnyEvent* anyevent );
00822 const SoEvent* translateAnyEvent( XAnyEvent* anyevent );
00823
00824
00825 SoXtRenderAreaRenderCB* appPostRenderCB;
00826 void* appPostRenderData;
00827
00828 SbBool m_runOnce;
00829
00830 private:
00831
00832 XColor* m_mapColors, *m_overlayMapColors;
00833 int m_mapColorNum, m_overlayMapColorNum;
00834
00835 SoXtMouse* m_mouseDevice;
00836 SoXtKeyboard* m_keybdDevice;
00837 void reinstallDevices( SoWidget newWidget );
00838
00839 static void selectionChangeCB( void* p, SoSelection* s );
00840 static void overlaySelectionChangeCB( void* p, SoSelection* s );
00841 SoWidget m_deviceWidget;
00842
00843
00844 SbBool m_firstEvent;
00845 static void windowEventCB( SoWidget w, SoXtRenderArea* p, XAnyEvent* xe, Boolean* b );
00846 static void renderCB( void* v, SoSceneManager* sm );
00847 static void renderOverlayCB( void* v, SoSceneManager* sm );
00848
00849 static void visibilityChangeCB( void* pt, SbBool visible );
00850 void activate();
00851 void deactivate();
00852
00853
00854 void constructorCommon( SbBool getMouseInput, SbBool getKeyboardInput, SbBool buildNow );
00855
00856
00857 void constructorCommon2( SbBool getMouseInput,
00858 SbBool getKeyboardInput,
00859 SbBool buildNow );
00860
00861 SbVec2i32 getWindowPosition() { return SbVec2i32( INT_MAX, INT_MAX ); }
00862
00863 SbConfig* m_vrConfig;
00864 SbBool m_forceRedraw;
00865 SbBool m_forceSyncRedraw;
00866
00867 ScTracking* m_tracking;
00868
00869 SoGuiRenderArea* m_guiRenderArea;
00870
00871
00872
00873
00874
00875 static SbBool s_abortRenderCallback(SoAction*,void*);
00876
00877 SoAntialiasingParameters* m_accumulationParameters;
00878
00879 bool m_firstStdRedraw;
00880 bool m_firstConnectedRedraw;
00881 SoTimerSensor* m_viewerUpdaterSensor;
00882 static void viewerUpdaterCB( void*, SoSensor* );
00883 void updateFirstFrame();
00884 };
00885
00886
00887 #endif
00888
00889 #endif
00890
00891