00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef _SO_WIN_RENDER_AREA_H_
00025 #define _SO_WIN_RENDER_AREA_H_
00026
00027 #include <Inventor/Win/SoWinBeginStrict.h>
00028 #include <windows.h>
00029 #include <Inventor/Win/SoWinDef.h>
00030
00031 #include <climits>
00032
00033 #include <Inventor/SbColor.h>
00034 #include <Inventor/sensors/SoNodeSensor.h>
00035 #include <Inventor/SoSceneManager.h>
00036 #include <Inventor/Win/SoWinGLWidget.h>
00037 #include <Inventor/actions/SoGLRenderAction.h>
00038
00039 #include <Inventor/nodes/SoCamera.h>
00040 #include <Inventor/elements/SoStereoElement.h>
00041 #include <Inventor/nodes/SoFullSceneAntialiasing.h>
00042 #include <Inventor/SbElapsedTime.h>
00043
00044
00045 #include <Inventor/Gui/SoGuiRenderArea.h>
00046
00047 class SoHandleEventAction;
00048 class SoWinDevice;
00049 class SoNode;
00050 class SoWinMouse;
00051 class SoWinKeyboard;
00052 class SoSelection;
00053 class SoWinRenderArea;
00054 class SoGuiAlgoViewers;
00055 class SoAntialiasingParameters;
00056
00060 typedef SbBool SoWinRenderAreaEventCB( void* userData, XAnyEvent* anyevent );
00061
00065 typedef SbBool SoWinRenderAreaRenderCB( void* userData, SoWinRenderArea* rendArea );
00066
00068
00069
00070
00071
00072
00074
00130 class SoWinRenderArea : public SoWinGLWidget
00131 {
00132 public:
00133
00142 SoWinRenderArea( SoWidget parent = NULL,
00143 const char* name = NULL,
00144 SbBool buildInsideParent = TRUE,
00145 SbBool getMouseInput = TRUE,
00146 SbBool getKeyboardInput = TRUE );
00150 ~SoWinRenderArea();
00151
00157 virtual void setSceneGraph( SoNode *newScene );
00158
00162 virtual SoNode* getSceneGraph();
00163
00170 void registerDevice( SoWinDevice* d );
00177 void unregisterDevice( SoWinDevice* d );
00178
00185 void setBackgroundColor( const SbColor& c );
00186
00190 const SbColor& getBackgroundColor() const { return m_guiRenderArea->getBackgroundColor(); }
00191
00196 void setBackgroundIndex( int index ) { m_guiRenderArea->setBackgroundIndex( index ); }
00197
00201 int getBackgroundIndex() const { return m_guiRenderArea->getBackgroundIndex(); }
00202
00208 void setColorMap( int startIndex, int num, const SbColor* colors );
00209
00213 void setViewportRegion( const SbViewportRegion& newRegion )
00214 { m_guiRenderArea->setViewportRegion( newRegion ); }
00215
00219 const SbViewportRegion &getViewportRegion() const
00220 { return m_guiRenderArea->getViewportRegion(); }
00221
00231 void setTransparencyType( SoGLRenderAction::TransparencyType type );
00232
00237 SoGLRenderAction::TransparencyType getTransparencyType() const
00238 { return m_guiRenderArea->getTransparencyType(); }
00239
00248 void setFastEditSavePolicy( SoGLRenderAction::FastEditSavePolicy policy,
00249 SbBool fastEditDelayedObjects = FALSE);
00250
00254 SoGLRenderAction::FastEditSavePolicy getFastEditSavePolicy() const
00255 { return m_guiRenderArea->getFastEditSavePolicy(); }
00256
00273 void setSortedTrianglesSortFrequency( int angle );
00274
00279 int getSortedTrianglesSortFrequency();
00280
00293 void setSortedTrianglesNumCaches( int numCaches );
00294
00298 int getSortedTrianglesNumCaches();
00299
00315 void setInvalidateCacheMode( SoGLRenderAction::InvalidateCacheMode icm );
00316
00320 SoGLRenderAction::InvalidateCacheMode getInvalidateCacheMode();
00321
00329 void setClearBeforeRender( SbBool trueOrFalse, SbBool zbTrueOrFalse = TRUE )
00330 { m_guiRenderArea->setClearBeforeRender( trueOrFalse, zbTrueOrFalse ); }
00331
00335 SbBool isClearBeforeRender() const { return m_guiRenderArea->isClearBeforeRender(); }
00336
00341 SbBool isClearZBufferBeforeRender() const { return m_guiRenderArea->isClearZBufferBeforeRender(); }
00342
00350 void setAutoRedraw( SbBool trueOrFalse );
00351
00356 SbBool isAutoRedraw() const { return m_guiRenderArea->isAutoRedraw(); }
00357
00361 void setRedrawPriority( unsigned long priority ) { m_guiRenderArea->setRedrawPriority(priority); }
00362
00366 unsigned long getRedrawPriority() const { return m_guiRenderArea->getRedrawPriority(); }
00367
00371 static unsigned long getDefaultRedrawPriority() { return SoSceneManager::getDefaultRedrawPriority(); }
00372
00377 void render() { redraw(); }
00378
00383 void scheduleRedraw();
00384
00395 void redrawOnSelectionChange( SoSelection* s );
00396
00431 void setEventCallback( SoWinRenderAreaEventCB* fcn, void* userData = NULL );
00432
00439 void setSceneManager( SoSceneManager* sm );
00440
00447 SoSceneManager* getSceneManager() const { return m_guiRenderArea->getSceneManager(); }
00448
00457 void setGLRenderAction( SoGLRenderAction* ra );
00458
00464 SoGLRenderAction* getGLRenderAction() const { return m_guiRenderArea->getGLRenderAction(); }
00465
00466 #if 1 SoDEPRECATED
00472 void setOverlaySceneGraph( SoNode* newScene );
00473 SoDEPRECATED
00479 SoNode* getOverlaySceneGraph() { return m_guiRenderArea->getOverlaySceneGraph(); }
00480 SoDEPRECATED
00486 void setOverlayBackgroundIndex( int index ) { m_guiRenderArea->setOverlayBackgroundIndex( index ); }
00487 SoDEPRECATED
00492 int getOverlayBackgroundIndex() const { return m_guiRenderArea->getOverlayBackgroundIndex(); }
00493 SoDEPRECATED
00500 void setOverlayColorMap( int startIndex, int num, const SbColor* colors );
00501 SoDEPRECATED
00507 void setClearBeforeOverlayRender( SbBool trueOrFalse )
00508 {
00509 m_guiRenderArea->setClearBeforeOverlayRender( trueOrFalse );
00510 }
00511 SoDEPRECATED
00516 SbBool isClearBeforeOverlayRender() const { return m_guiRenderArea->isClearBeforeOverlayRender(); }
00517 SoDEPRECATED
00523 void renderOverlay();
00524 SoDEPRECATED
00530 void scheduleOverlayRedraw();
00531 SoDEPRECATED
00543 void redrawOverlayOnSelectionChange( SoSelection* s );
00544 SoDEPRECATED
00552 void setOverlaySceneManager( SoSceneManager* sm ) { m_guiRenderArea->setOverlaySceneManager( sm ); }
00553 SoDEPRECATED
00561 SoSceneManager* getOverlaySceneManager() const { return m_guiRenderArea->getOverlaySceneManager(); }
00562 SoDEPRECATED
00567 void setOverlayGLRenderAction( SoGLRenderAction* ra )
00568 { m_guiRenderArea->setOverlayGLRenderAction( ra ); }
00569 SoDEPRECATED
00574 SoGLRenderAction* getOverlayGLRenderAction() const
00575 { return m_guiRenderArea->getOverlayGLRenderAction(); }
00576 #endif
00585 const SbGLShareContext getShareContext();
00586
00602 void setPostRenderCallback( SoWinRenderAreaRenderCB* fcn, void* userData = NULL )
00603 { appPostRenderCB = fcn; appPostRenderData = userData; }
00604
00610 SoWinRenderAreaRenderCB* getPostRenderCallback( const void* &userData ) const
00611 { userData = appPostRenderData; return appPostRenderCB; }
00612
00626 void setFloatingColorBuffer( SbBool enable,
00627 FloatColorBufferSize size = FLOAT_16_COLOR_BUFFER );
00628
00632 void getFloatingColorBuffer( SbBool& enable, FloatColorBufferSize& size );
00633
00637 static SbBool isFloatingColorBufferSupported();
00638
00642 void sendEvent( XAnyEvent* anEvent );
00643
00649 virtual void setMPEGRecorder( SoMPEGRenderer* recorder )
00650 { m_guiRenderArea->setMPEGRecorder( recorder ); }
00651
00655 virtual SoMPEGRenderer* getMPEGRecorder() const
00656 { return m_guiRenderArea->getMPEGRecorder(); }
00657
00658 #if 1 SoDEPRECATED
00679 void setAntialiasing( SbBool smoothing, int numPasses );
00680 using SoWinGLWidget::setAntialiasing;
00681 SoDEPRECATED
00686 void getAntialiasing( SbBool& smoothing, int& numPasses) const;
00687
00688 #endif
00690 private:
00691 SoWinRenderArea( SoWidget parent,
00692 const char* name,
00693 SbBool buildInsideParent,
00694 SbBool getMouseInput,
00695 SbBool getKeyboardInput,
00696 SoGuiAlgoViewers* guiAlgos );
00697
00698
00699 SoWinRenderArea( SoWidget parent,
00700 const char* name,
00701 SbBool buildInsideParent,
00702 SbBool getMouseInput,
00703 SbBool getKeyboardInput,
00704 SbBool buildNow,
00705 SbBool sync,
00706 SoGuiAlgoViewers* guiAlgos );
00707
00708
00709 SoWinRenderArea( SoWidget parent,
00710 const char* name,
00711 SbBool buildInsideParent,
00712 SbBool getMouseInput,
00713 SbBool getKeyboardInput,
00714 SbBool buildNow,
00715 SoGuiAlgoViewers* guiAlgos );
00716
00720 SoGuiAlgoViewers* getGuiAlgoViewers() const { return (SoGuiAlgoViewers*)m_guiRenderArea; }
00721
00722 private:
00723
00724 SoGuiRenderArea* getGuiRenderArea() const;
00725
00726 void setStereoMode( SoCamera::StereoMode stMode );
00727 void setStereoElement();
00728
00729 virtual void setDoubleBuffer( SbBool db );
00730
00731 virtual SbBool isInteractive() const;
00732
00733 SoWinRenderArea( SoWidget parent,
00734 const char* name,
00735 SbBool buildInsideParent,
00736 SbBool getMouseInput,
00737 SbBool getKeyboardInput,
00738 SbBool buildNow,
00739 SbBool sync );
00740
00741
00742
00743 float stereoBalance, stereoOffset;
00744 SbBool stereoAbsoluteAdjustments;
00745 SoCamera::StereoMode stereoMode;
00746 SbBool stereoReversed;
00747
00748 private:
00749
00750
00751
00752
00753
00754
00755 SoWinRenderArea( SoWidget parent,
00756 const char* name,
00757 SbBool buildInsideParent,
00758 SbBool getMouseInput,
00759 SbBool getKeyboardInput,
00760 SbBool buildNow );
00761
00762
00763
00764 SoWinRenderArea( SoWidget parent,
00765 const char* name,
00766 SbBool buildInsideParent,
00767 SbBool getMouseInput,
00768 SbBool getKeyboardInput,
00769 SoGuiRenderArea* guiRenderArea );
00770
00771
00772 SoWinRenderArea( SoWidget parent,
00773 const char* name,
00774 SbBool buildInsideParent,
00775 SbBool getMouseInput,
00776 SbBool getKeyboardInput,
00777 SbBool buildNow,
00778 SbBool sync,
00779 SoGuiRenderArea* guiRenderArea );
00780
00781
00782 SoWinRenderArea( SoWidget parent,
00783 const char* name,
00784 SbBool buildInsideParent,
00785 SbBool getMouseInput,
00786 SbBool getKeyboardInput,
00787 SbBool buildNow,
00788 SoGuiRenderArea* guiRenderArea );
00789
00790
00791
00792
00793
00794
00795
00796
00797 virtual void redraw();
00798 virtual void actualRedraw();
00799 #if 1 SoDEPRECATED
00801 virtual void redrawOverlay();SoDEPRECATED
00803 virtual void actualOverlayRedraw();
00804 #endif
00806 //
00807
00808
00809 virtual void processEvent( XAnyEvent* anyevent );
00810 virtual void initGraphic();
00811 #if 1 SoDEPRECATED
00813 virtual void initOverlayGraphic();
00814 #endif
00815 virtual void sizeChanged( const SbVec2s& );
00816 virtual void posChanged( const SbVec2i32&, const SbVec2i32& );
00817 virtual void widgetChanged( SoWidget );
00818
00819 SoWidget buildWidget( SoWidget parent );
00820
00821
00822 virtual SbString getDefaultWidgetName() const;
00823 virtual SbString getDefaultTitle() const;
00824 virtual SbString getDefaultIconTitle() const;
00825
00826
00827 SbPList* m_deviceList;
00828
00829
00830 SoWinRenderAreaEventCB *defaultAppEventHandler;
00831 void *defaultAppEventHandlerData;
00832 SoWinRenderAreaEventCB *appEventHandler;
00833 void *appEventHandlerData;
00834
00835 SbBool invokeAppCB( XAnyEvent* anyevent );
00836 SbBool processInventorEvent( XAnyEvent* anyevent );
00837 const SoEvent* translateAnyEvent( XAnyEvent* anyevent );
00838
00839
00840 SoWinRenderAreaRenderCB *appPostRenderCB;
00841 void *appPostRenderData;
00842
00843 private:
00844
00845 SbBool m_isFloatingPointRendering;
00846 FloatColorBufferSize m_floatingPointRenderingPrecision;
00847
00848 #if defined(sun) || defined(__linux__)
00849 XColor* m_mapColors, *m_overlayMapColors;
00850 int m_mapColorNum, m_overlayMapColorNum;
00851 #endif
00852
00853 SoWinMouse* m_mouseDevice;
00854 SoWinKeyboard* m_keybdDevice;
00855 void reinstallDevices( SoWidget newWidget );
00856
00857 static void selectionChangeCB( void* userData, SoSelection* s );
00858 static void overlaySelectionChangeCB( void* userData, SoSelection* s );
00859 SoWidget m_deviceWidget;
00860
00861
00862 SbBool m_firstEvent;
00863
00864 private:
00865 SbBool m_runOnce;
00866 static void windowEventCB( SoWidget w, SoWinRenderArea* wra, XAnyEvent* e, Boolean* b );
00867 private:
00868 static void renderCB( void* v, SoSceneManager* sm );
00869 static void renderOverlayCB( void* v, SoSceneManager* sm );
00870
00871 static void visibilityChangeCB( void* pt, SbBool visible );
00872
00873
00874 void constructorCommon( SbBool getMouseInput,
00875 SbBool getKeyboardInput,
00876 SbBool buildNow );
00877
00878
00879 void constructorCommon2( SbBool getMouseInput,
00880 SbBool getKeyboardInput,
00881 SbBool buildNow );
00882
00883 void activate();
00884 void deactivate();
00885
00886 SbVec2i32 getWindowPosition() { return SbVec2i32( INT_MAX, INT_MAX ); }
00887
00888 int inRedraw;
00889 int inOverlayRedraw;
00890
00891 SoGuiRenderArea* m_guiRenderArea;
00892
00893
00894
00895
00896
00897 static SbBool s_abortRenderCallback(SoAction*,void*);
00898
00899 SoAntialiasingParameters* m_accumulationParameters;
00900
00901 bool m_firstStdRedraw;
00902 bool m_firstConnectedRedraw;
00903 SoTimerSensor* m_viewerUpdaterSensor;
00904 static void viewerUpdaterCB( void*, SoSensor* );
00905 void updateFirstFrame();
00906
00907 };
00908
00909 #include <Inventor/Win/SoWinEndStrict.h>
00910
00911 #endif
00912
00913
00914