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 <Inventor/SbColor.h>
00063 #include <Inventor/sensors/SoNodeSensor.h>
00064 #include <Inventor/SoSceneManager.h>
00065 #include <Inventor/Xt/SoXtGLWidget.h>
00066 #include <Inventor/actions/SoGLRenderAction.h>
00067
00068 #include <Inventor/nodes/SoCamera.h>
00069 #include <Inventor/nodes/SoFullSceneAntialiasing.h>
00070 #include <Inventor/SbElapsedTime.h>
00071
00072 #include <Inventor/Gui/SoGuiRenderArea.h>
00073
00074 class SoHandleEventAction;
00075 class SoXtDevice;
00076 class SoNode;
00077 class SoXtMouse;
00078 class SoXtKeyboard;
00079 class SoSelection;
00080 class SbConfig;
00081 class SoXtRenderArea;
00082 class ScTracking;
00083 class SoGuiAlgoViewers;
00084 class SoAntialiasingParameters;
00085
00086
00087 typedef SbBool SoXtRenderAreaEventCB( void* userData, XAnyEvent* anyevent );
00088 typedef SbBool SoXtRenderAreaRenderCB( void* userData, SoXtRenderArea* rendArea );
00089
00091
00092
00093
00094
00095
00097
00159 class SoXtRenderArea : public SoXtGLWidget
00160 {
00161 public:
00162
00167 SoXtRenderArea( SoWidget parent = NULL,
00168 const char* name = NULL,
00169 SbBool buildInsideParent = TRUE,
00170 SbBool getMouseInput = TRUE,
00171 SbBool getKeyboardInput = TRUE );
00175 ~SoXtRenderArea();
00176
00180 virtual void setSceneGraph( SoNode* newScene );
00181
00185 virtual SoNode* getSceneGraph();
00186
00192 void registerDevice( SoXtDevice* d );
00193
00199 void unregisterDevice( SoXtDevice* d );
00200
00207 void setBackgroundColor( const SbColor& c );
00208
00212 const SbColor& getBackgroundColor() const { return m_guiRenderArea->getBackgroundColor(); }
00213
00218 void setBackgroundIndex( int index ) { m_guiRenderArea->setBackgroundIndex( index ); }
00219
00223 int getBackgroundIndex() const { return m_guiRenderArea->getBackgroundIndex(); }
00224
00229 void setColorMap( int startIndex, int num, const SbColor* colors );
00230
00234 void setViewportRegion( const SbViewportRegion& newRegion )
00235 { m_guiRenderArea->setViewportRegion( newRegion ); }
00236
00240 const SbViewportRegion& getViewportRegion() const
00241 { return m_guiRenderArea->getViewportRegion(); }
00242
00252 void setTransparencyType( SoGLRenderAction::TransparencyType type );
00253
00258 SoGLRenderAction::TransparencyType getTransparencyType() const
00259 { return m_guiRenderArea->getTransparencyType(); }
00260
00269 void setFastEditSavePolicy( SoGLRenderAction::FastEditSavePolicy policy,
00270 SbBool fastEditDelayedObjects = FALSE);
00271
00275 SoGLRenderAction::FastEditSavePolicy getFastEditSavePolicy() const
00276 { return m_guiRenderArea->getFastEditSavePolicy(); }
00277
00294 void setSortedTrianglesSortFrequency( int angle );
00295
00300 int getSortedTrianglesSortFrequency();
00301
00314 void setSortedTrianglesNumCaches( int numCaches );
00315
00319 int getSortedTrianglesNumCaches();
00320
00336 void setInvalidateCacheMode( SoGLRenderAction::InvalidateCacheMode icm );
00337
00341 SoGLRenderAction::InvalidateCacheMode getInvalidateCacheMode();
00342
00350 void setClearBeforeRender( SbBool trueOrFalse, SbBool zbTrueOrFalse = TRUE )
00351 { m_guiRenderArea->setClearBeforeRender( trueOrFalse, zbTrueOrFalse ); }
00352
00356 SbBool isClearBeforeRender() const { return m_guiRenderArea->isClearBeforeRender(); }
00357
00362 SbBool isClearZBufferBeforeRender() const { return m_guiRenderArea->isClearZBufferBeforeRender(); }
00363
00368 void setAutoRedraw( SbBool trueOrFalse );
00369
00374 SbBool isAutoRedraw() const { return m_guiRenderArea->isAutoRedraw(); }
00375
00379 void setRedrawPriority( uint32_t priority ) { m_guiRenderArea->setRedrawPriority(priority); }
00380
00384 uint32_t getRedrawPriority() const { return m_guiRenderArea->getRedrawPriority(); }
00385
00389 static uint32_t getDefaultRedrawPriority() { return SoSceneManager::getDefaultRedrawPriority(); }
00390
00395 void render() { redraw(); }
00396
00401 void scheduleRedraw();
00402
00413 void redrawOnSelectionChange( SoSelection* s );
00414
00426 void setEventCallback( SoXtRenderAreaEventCB* fcn, void* userData = NULL );
00427
00434 void setSceneManager( SoSceneManager* sm );
00435
00442 SoSceneManager* getSceneManager() const { return m_guiRenderArea->getSceneManager(); }
00443
00449 void setGLRenderAction( SoGLRenderAction* ra );
00450
00456 SoGLRenderAction* getGLRenderAction() const { return m_guiRenderArea->getGLRenderAction(); }
00457
00458 #if 1
00459 #if defined(sun) || defined(__linux__)
00460 SoDEPRECATED
00461 virtual void setSunOverlayBackgroundIndex();
00462 #endif
00463 SoDEPRECATED
00469 void setOverlaySceneGraph( SoNode* newScene );
00470 SoDEPRECATED
00476 SoNode* getOverlaySceneGraph() { return m_guiRenderArea->getOverlaySceneGraph(); }
00477 SoDEPRECATED
00483 void setOverlayBackgroundIndex( int index ) { m_guiRenderArea->setOverlayBackgroundIndex( index ); }
00484 SoDEPRECATED
00489 int getOverlayBackgroundIndex() const { return m_guiRenderArea->getOverlayBackgroundIndex(); }
00490 SoDEPRECATED
00496 void setOverlayColorMap( int startIndex, int num, const SbColor* colors );
00497 SoDEPRECATED
00503 void setClearBeforeOverlayRender( SbBool trueOrFalse )
00504 { m_guiRenderArea->setClearBeforeOverlayRender( trueOrFalse ); }
00505 SoDEPRECATED
00510 SbBool isClearBeforeOverlayRender() const { return m_guiRenderArea->isClearBeforeOverlayRender(); }
00511 SoDEPRECATED
00517 void renderOverlay() { redrawOverlay(); }
00518 SoDEPRECATED
00524 void scheduleOverlayRedraw();
00525 SoDEPRECATED
00537 void redrawOverlayOnSelectionChange( SoSelection* s );
00538 SoDEPRECATED
00546 void setOverlaySceneManager( SoSceneManager* sm ) { m_guiRenderArea->setOverlaySceneManager( sm ); }
00547 SoDEPRECATED
00555 SoSceneManager* getOverlaySceneManager() const { return m_guiRenderArea->getOverlaySceneManager(); }
00556 SoDEPRECATED
00561 void setOverlayGLRenderAction( SoGLRenderAction* ra ) { m_guiRenderArea->setOverlayGLRenderAction( ra ); }
00562 SoDEPRECATED
00567 SoGLRenderAction* getOverlayGLRenderAction() const { return m_guiRenderArea->getOverlayGLRenderAction(); }
00568 #endif
00577 const SbGLShareContext getShareContext();
00578
00594 void setPostRenderCallback( SoXtRenderAreaRenderCB* fcn, void* userData = NULL )
00595 { appPostRenderCB = fcn; appPostRenderData = userData; }
00596
00601 SoXtRenderAreaRenderCB* getPostRenderCallback( const void* &userData ) const
00602 { userData = appPostRenderData; return appPostRenderCB; }
00603
00618 void setFloatingColorBuffer( SbBool enable, FloatColorBufferSize size = FLOAT_16_COLOR_BUFFER );
00619
00624 void getFloatingColorBuffer( SbBool& enable, FloatColorBufferSize& size );
00625
00629 void sendEvent( XAnyEvent* anEvent );
00630
00636 virtual void setMPEGRecorder( SoMPEGRenderer* recorder )
00637 { m_guiRenderArea->setMPEGRecorder( recorder ); }
00638
00642 virtual SoMPEGRenderer* getMPEGRecorder() const
00643 { return m_guiRenderArea->getMPEGRecorder(); }
00644
00645 #if 1 SoDEPRECATED
00663 void setAntialiasing( SbBool smoothing, int numPasses );
00664 using SoXtGLWidget::setAntialiasing;
00665 SoDEPRECATED
00670 void getAntialiasing( SbBool& smoothing, int& numPasses ) const;
00671
00672 #endif
00674 private:
00675
00676 SoXtRenderArea( SoWidget parent,
00677 const char* name,
00678 SbBool buildInsideParent,
00679 SbBool getMouseInput,
00680 SbBool getKeyboardInput,
00681 SoGuiAlgoViewers* guiAlgos );
00682
00683 SoXtRenderArea( SoWidget parent,
00684 const char* name,
00685 SbBool buildInsideParent,
00686 SbBool getMouseInput,
00687 SbBool getKeyboardInput,
00688 SbBool buildNow,
00689 SbBool sync,
00690 SoGuiAlgoViewers* guiAlgos );
00691
00692 SoXtRenderArea( SoWidget parent,
00693 const char* name,
00694 SbBool buildInsideParent,
00695 SbBool getMouseInput,
00696 SbBool getKeyboardInput,
00697 SbBool buildNow,
00698 SoGuiAlgoViewers* guiAlgos );
00702 SoGuiAlgoViewers* getGuiAlgoViewers() const { return (SoGuiAlgoViewers*)m_guiRenderArea; }
00703
00704 private:
00705 void setStereoMode( SoCamera::StereoMode stMode );
00706 void setStereoElement();
00707
00708 SoGuiRenderArea* getGuiRenderArea() const;
00709
00710 SbBool isFloatingColorBufferSupported();
00711
00712 virtual SbBool isInteractive() const;
00713
00714 SoXtRenderArea();
00715
00716 SoXtRenderArea( SoWidget parent,
00717 const char* name,
00718 SbBool buildInsideParent,
00719 SbBool getMouseInput,
00720 SbBool getKeyboardInput,
00721 SbBool buildNow,
00722 SbBool sync );
00723
00724
00725
00726 float stereoBalance, stereoOffset;
00727 SbBool stereoAbsoluteAdjustments;
00728 SoCamera::StereoMode stereoMode;
00729 SbBool stereoReversed;
00730
00731 private:
00732
00733
00734
00735
00736
00737
00738 SoXtRenderArea( SoWidget parent,
00739 const char* name,
00740 SbBool buildInsideParent,
00741 SbBool getMouseInput,
00742 SbBool getKeyboardInput,
00743 SbBool buildNow );
00744
00745
00746
00747 SoXtRenderArea( SoWidget parent,
00748 const char* name,
00749 SbBool buildInsideParent,
00750 SbBool getMouseInput,
00751 SbBool getKeyboardInput,
00752 SoGuiRenderArea* guiRenderArea );
00753
00754 SoXtRenderArea( SoWidget parent,
00755 const char* name,
00756 SbBool buildInsideParent,
00757 SbBool getMouseInput,
00758 SbBool getKeyboardInput,
00759 SbBool buildNow,
00760 SbBool sync,
00761 SoGuiRenderArea* guiRenderArea );
00762
00763 SoXtRenderArea( SoWidget parent,
00764 const char* name,
00765 SbBool buildInsideParent,
00766 SbBool getMouseInput,
00767 SbBool getKeyboardInput,
00768 SbBool buildNow,
00769 SoGuiRenderArea* guiRenderArea );
00770
00771
00772
00773
00774
00775
00776
00777
00778
00779 virtual void redraw();
00780 virtual void actualRedraw();
00781 #if 1 SoDEPRECATED
00783 virtual void redrawOverlay();SoDEPRECATED
00785 virtual void actualOverlayRedraw();
00786 #endif
00788 //
00789
00790
00791 virtual void processEvent( XAnyEvent* anyevent );
00792 virtual void initGraphic();
00793 #if 1 SoDEPRECATED
00795 virtual void initOverlayGraphic();
00796 #endif
00797 virtual void sizeChanged( const SbVec2s& );
00798 virtual void posChanged( const SbVec2i32&, const SbVec2i32& );
00799 virtual void widgetChanged( SoWidget w );
00800
00801 SoWidget buildWidget( SoWidget parent );
00802
00803
00804 virtual SbString getDefaultWidgetName() const;
00805 virtual SbString getDefaultTitle() const;
00806 virtual SbString getDefaultIconTitle() const;
00807
00808
00809 SbPList* m_deviceList;
00810
00811
00812 SoXtRenderAreaEventCB* defaultAppEventHandler;
00813 void* defaultAppEventHandlerData;
00814 SoXtRenderAreaEventCB* appEventHandler;
00815 void* appEventHandlerData;
00816
00817
00818 SbBool invokeAppCB( XAnyEvent* anyevent );
00819 SbBool processInventorEvent( XAnyEvent* anyevent );
00820 const SoEvent* translateAnyEvent( XAnyEvent* anyevent );
00821
00822
00823 SoXtRenderAreaRenderCB* appPostRenderCB;
00824 void* appPostRenderData;
00825
00826 SbBool m_runOnce;
00827
00828 private:
00829
00830 XColor* m_mapColors, *m_overlayMapColors;
00831 int m_mapColorNum, m_overlayMapColorNum;
00832
00833 SoXtMouse* m_mouseDevice;
00834 SoXtKeyboard* m_keybdDevice;
00835 void reinstallDevices( SoWidget newWidget );
00836
00837 static void selectionChangeCB( void* p, SoSelection* s );
00838 static void overlaySelectionChangeCB( void* p, SoSelection* s );
00839 SoWidget m_deviceWidget;
00840
00841
00842 SbBool m_firstEvent;
00843 static void windowEventCB( SoWidget w, SoXtRenderArea* p, XAnyEvent* xe, Boolean* b );
00844 static void renderCB( void* v, SoSceneManager* sm );
00845 static void renderOverlayCB( void* v, SoSceneManager* sm );
00846
00847 static void visibilityChangeCB( void* pt, SbBool visible );
00848 void activate();
00849 void deactivate();
00850
00851
00852 void constructorCommon( SbBool getMouseInput, SbBool getKeyboardInput, SbBool buildNow );
00853
00854
00855 void constructorCommon2( SbBool getMouseInput,
00856 SbBool getKeyboardInput,
00857 SbBool buildNow );
00858
00859 SbConfig* m_vrConfig;
00860 SbBool m_forceRedraw;
00861 SbBool m_forceSyncRedraw;
00862
00863 ScTracking* m_tracking;
00864
00865 SoGuiRenderArea* m_guiRenderArea;
00866
00867
00868
00869
00870
00871 static SbBool s_abortRenderCallback(SoAction*,void*);
00872
00873 SoAntialiasingParameters* m_accumulationParameters;
00874
00875 bool m_firstStdRedraw;
00876 bool m_firstConnectedRedraw;
00877 SoTimerSensor* m_viewerUpdaterSensor;
00878 static void viewerUpdaterCB( void*, SoSensor* );
00879 void updateFirstFrame();
00880 };
00881
00882
00883 #endif
00884
00885 #endif
00886
00887