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 <Inventor/SbColor.h>
00032 #include <Inventor/sensors/SoNodeSensor.h>
00033 #include <Inventor/SoSceneManager.h>
00034 #include <Inventor/Win/SoWinGLWidget.h>
00035 #include <Inventor/actions/SoGLRenderAction.h>
00036
00037 #include <Inventor/nodes/SoCamera.h>
00038 #include <Inventor/elements/SoStereoElement.h>
00039 #include <Inventor/nodes/SoFullSceneAntialiasing.h>
00040 #include <Inventor/SbElapsedTime.h>
00041
00042
00043 #include <Inventor/Gui/SoGuiRenderArea.h>
00044
00045 class SoHandleEventAction;
00046 class SoWinDevice;
00047 class SoNode;
00048 class SoWinMouse;
00049 class SoWinKeyboard;
00050 class SoSelection;
00051 class SoWinRenderArea;
00052 class SoGuiAlgoViewers;
00053 class SoAntialiasingParameters;
00054
00058 typedef SbBool SoWinRenderAreaEventCB( void* userData, XAnyEvent* anyevent );
00059
00063 typedef SbBool SoWinRenderAreaRenderCB( void* userData, SoWinRenderArea* rendArea );
00064
00066
00067
00068
00069
00070
00072
00128 class SoWinRenderArea : public SoWinGLWidget
00129 {
00130 public:
00131
00140 SoWinRenderArea( SoWidget parent = NULL,
00141 const char* name = NULL,
00142 SbBool buildInsideParent = TRUE,
00143 SbBool getMouseInput = TRUE,
00144 SbBool getKeyboardInput = TRUE );
00148 ~SoWinRenderArea();
00149
00155 virtual void setSceneGraph( SoNode *newScene );
00156
00160 virtual SoNode* getSceneGraph();
00161
00168 void registerDevice( SoWinDevice* d );
00175 void unregisterDevice( SoWinDevice* d );
00176
00183 void setBackgroundColor( const SbColor& c );
00184
00188 const SbColor& getBackgroundColor() const { return m_guiRenderArea->getBackgroundColor(); }
00189
00194 void setBackgroundIndex( int index ) { m_guiRenderArea->setBackgroundIndex( index ); }
00195
00199 int getBackgroundIndex() const { return m_guiRenderArea->getBackgroundIndex(); }
00200
00206 void setColorMap( int startIndex, int num, const SbColor* colors );
00207
00211 void setViewportRegion( const SbViewportRegion& newRegion )
00212 { m_guiRenderArea->setViewportRegion( newRegion ); }
00213
00217 const SbViewportRegion &getViewportRegion() const
00218 { return m_guiRenderArea->getViewportRegion(); }
00219
00229 void setTransparencyType( SoGLRenderAction::TransparencyType type );
00230
00235 SoGLRenderAction::TransparencyType getTransparencyType() const
00236 { return m_guiRenderArea->getTransparencyType(); }
00237
00246 void setFastEditSavePolicy( SoGLRenderAction::FastEditSavePolicy policy,
00247 SbBool fastEditDelayedObjects = FALSE);
00248
00252 SoGLRenderAction::FastEditSavePolicy getFastEditSavePolicy() const
00253 { return m_guiRenderArea->getFastEditSavePolicy(); }
00254
00271 void setSortedTrianglesSortFrequency( int angle );
00272
00277 int getSortedTrianglesSortFrequency();
00278
00291 void setSortedTrianglesNumCaches( int numCaches );
00292
00296 int getSortedTrianglesNumCaches();
00297
00313 void setInvalidateCacheMode( SoGLRenderAction::InvalidateCacheMode icm );
00314
00318 SoGLRenderAction::InvalidateCacheMode getInvalidateCacheMode();
00319
00327 void setClearBeforeRender( SbBool trueOrFalse, SbBool zbTrueOrFalse = TRUE )
00328 { m_guiRenderArea->setClearBeforeRender( trueOrFalse, zbTrueOrFalse ); }
00329
00333 SbBool isClearBeforeRender() const { return m_guiRenderArea->isClearBeforeRender(); }
00334
00339 SbBool isClearZBufferBeforeRender() const { return m_guiRenderArea->isClearZBufferBeforeRender(); }
00340
00348 void setAutoRedraw( SbBool trueOrFalse );
00349
00354 SbBool isAutoRedraw() const { return m_guiRenderArea->isAutoRedraw(); }
00355
00359 void setRedrawPriority( unsigned long priority ) { m_guiRenderArea->setRedrawPriority(priority); }
00360
00364 unsigned long getRedrawPriority() const { return m_guiRenderArea->getRedrawPriority(); }
00365
00369 static unsigned long getDefaultRedrawPriority() { return SoSceneManager::getDefaultRedrawPriority(); }
00370
00375 void render() { redraw(); }
00376
00381 void scheduleRedraw();
00382
00393 void redrawOnSelectionChange( SoSelection* s );
00394
00429 void setEventCallback( SoWinRenderAreaEventCB* fcn, void* userData = NULL );
00430
00437 void setSceneManager( SoSceneManager* sm );
00438
00445 SoSceneManager* getSceneManager() const { return m_guiRenderArea->getSceneManager(); }
00446
00455 void setGLRenderAction( SoGLRenderAction* ra );
00456
00462 SoGLRenderAction* getGLRenderAction() const { return m_guiRenderArea->getGLRenderAction(); }
00463
00464 #if 1 SoDEPRECATED
00470 void setOverlaySceneGraph( SoNode* newScene );
00471 SoDEPRECATED
00477 SoNode* getOverlaySceneGraph() { return m_guiRenderArea->getOverlaySceneGraph(); }
00478 SoDEPRECATED
00484 void setOverlayBackgroundIndex( int index ) { m_guiRenderArea->setOverlayBackgroundIndex( index ); }
00485 SoDEPRECATED
00490 int getOverlayBackgroundIndex() const { return m_guiRenderArea->getOverlayBackgroundIndex(); }
00491 SoDEPRECATED
00498 void setOverlayColorMap( int startIndex, int num, const SbColor* colors );
00499 SoDEPRECATED
00505 void setClearBeforeOverlayRender( SbBool trueOrFalse )
00506 {
00507 m_guiRenderArea->setClearBeforeOverlayRender( trueOrFalse );
00508 }
00509 SoDEPRECATED
00514 SbBool isClearBeforeOverlayRender() const { return m_guiRenderArea->isClearBeforeOverlayRender(); }
00515 SoDEPRECATED
00521 void renderOverlay();
00522 SoDEPRECATED
00528 void scheduleOverlayRedraw();
00529 SoDEPRECATED
00541 void redrawOverlayOnSelectionChange( SoSelection* s );
00542 SoDEPRECATED
00550 void setOverlaySceneManager( SoSceneManager* sm ) { m_guiRenderArea->setOverlaySceneManager( sm ); }
00551 SoDEPRECATED
00559 SoSceneManager* getOverlaySceneManager() const { return m_guiRenderArea->getOverlaySceneManager(); }
00560 SoDEPRECATED
00565 void setOverlayGLRenderAction( SoGLRenderAction* ra )
00566 { m_guiRenderArea->setOverlayGLRenderAction( ra ); }
00567 SoDEPRECATED
00572 SoGLRenderAction* getOverlayGLRenderAction() const
00573 { return m_guiRenderArea->getOverlayGLRenderAction(); }
00574 #endif
00583 const SbGLShareContext getShareContext();
00584
00600 void setPostRenderCallback( SoWinRenderAreaRenderCB* fcn, void* userData = NULL )
00601 { appPostRenderCB = fcn; appPostRenderData = userData; }
00602
00608 SoWinRenderAreaRenderCB* getPostRenderCallback( const void* &userData ) const
00609 { userData = appPostRenderData; return appPostRenderCB; }
00610
00624 void setFloatingColorBuffer( SbBool enable,
00625 FloatColorBufferSize size = FLOAT_16_COLOR_BUFFER );
00626
00630 void getFloatingColorBuffer( SbBool& enable, FloatColorBufferSize& size );
00631
00635 static SbBool isFloatingColorBufferSupported();
00636
00640 void sendEvent( XAnyEvent* anEvent );
00641
00647 virtual void setMPEGRecorder( SoMPEGRenderer* recorder )
00648 { m_guiRenderArea->setMPEGRecorder( recorder ); }
00649
00653 virtual SoMPEGRenderer* getMPEGRecorder() const
00654 { return m_guiRenderArea->getMPEGRecorder(); }
00655
00656 #if 1 SoDEPRECATED
00677 void setAntialiasing( SbBool smoothing, int numPasses );
00678 using SoWinGLWidget::setAntialiasing;
00679 SoDEPRECATED
00684 void getAntialiasing( SbBool& smoothing, int& numPasses) const;
00685
00686 #endif
00688 private:
00689 SoWinRenderArea( SoWidget parent,
00690 const char* name,
00691 SbBool buildInsideParent,
00692 SbBool getMouseInput,
00693 SbBool getKeyboardInput,
00694 SoGuiAlgoViewers* guiAlgos );
00695
00696
00697 SoWinRenderArea( SoWidget parent,
00698 const char* name,
00699 SbBool buildInsideParent,
00700 SbBool getMouseInput,
00701 SbBool getKeyboardInput,
00702 SbBool buildNow,
00703 SbBool sync,
00704 SoGuiAlgoViewers* guiAlgos );
00705
00706
00707 SoWinRenderArea( SoWidget parent,
00708 const char* name,
00709 SbBool buildInsideParent,
00710 SbBool getMouseInput,
00711 SbBool getKeyboardInput,
00712 SbBool buildNow,
00713 SoGuiAlgoViewers* guiAlgos );
00714
00718 SoGuiAlgoViewers* getGuiAlgoViewers() const { return (SoGuiAlgoViewers*)m_guiRenderArea; }
00719
00720 private:
00721
00722 SoGuiRenderArea* getGuiRenderArea() const;
00723
00724 void setStereoMode( SoCamera::StereoMode stMode );
00725 void setStereoElement();
00726
00727 virtual void setDoubleBuffer( SbBool db );
00728
00729 virtual SbBool isInteractive() const;
00730
00731 SoWinRenderArea( SoWidget parent,
00732 const char* name,
00733 SbBool buildInsideParent,
00734 SbBool getMouseInput,
00735 SbBool getKeyboardInput,
00736 SbBool buildNow,
00737 SbBool sync );
00738
00739
00740
00741 float stereoBalance, stereoOffset;
00742 SbBool stereoAbsoluteAdjustments;
00743 SoCamera::StereoMode stereoMode;
00744 SbBool stereoReversed;
00745
00746 private:
00747
00748
00749
00750
00751
00752
00753 SoWinRenderArea( SoWidget parent,
00754 const char* name,
00755 SbBool buildInsideParent,
00756 SbBool getMouseInput,
00757 SbBool getKeyboardInput,
00758 SbBool buildNow );
00759
00760
00761
00762 SoWinRenderArea( SoWidget parent,
00763 const char* name,
00764 SbBool buildInsideParent,
00765 SbBool getMouseInput,
00766 SbBool getKeyboardInput,
00767 SoGuiRenderArea* guiRenderArea );
00768
00769
00770 SoWinRenderArea( SoWidget parent,
00771 const char* name,
00772 SbBool buildInsideParent,
00773 SbBool getMouseInput,
00774 SbBool getKeyboardInput,
00775 SbBool buildNow,
00776 SbBool sync,
00777 SoGuiRenderArea* guiRenderArea );
00778
00779
00780 SoWinRenderArea( SoWidget parent,
00781 const char* name,
00782 SbBool buildInsideParent,
00783 SbBool getMouseInput,
00784 SbBool getKeyboardInput,
00785 SbBool buildNow,
00786 SoGuiRenderArea* guiRenderArea );
00787
00788
00789
00790
00791
00792
00793
00794
00795 virtual void redraw();
00796 virtual void actualRedraw();
00797 #if 1 SoDEPRECATED
00799 virtual void redrawOverlay();SoDEPRECATED
00801 virtual void actualOverlayRedraw();
00802 #endif
00804 //
00805
00806
00807 virtual void processEvent( XAnyEvent* anyevent );
00808 virtual void initGraphic();
00809 #if 1 SoDEPRECATED
00811 virtual void initOverlayGraphic();
00812 #endif
00813 virtual void sizeChanged( const SbVec2s& );
00814 virtual void posChanged( const SbVec2i32&, const SbVec2i32& );
00815 virtual void widgetChanged( SoWidget );
00816
00817 SoWidget buildWidget( SoWidget parent );
00818
00819
00820 virtual SbString getDefaultWidgetName() const;
00821 virtual SbString getDefaultTitle() const;
00822 virtual SbString getDefaultIconTitle() const;
00823
00824
00825 SbPList* m_deviceList;
00826
00827
00828 SoWinRenderAreaEventCB *defaultAppEventHandler;
00829 void *defaultAppEventHandlerData;
00830 SoWinRenderAreaEventCB *appEventHandler;
00831 void *appEventHandlerData;
00832
00833 SbBool invokeAppCB( XAnyEvent* anyevent );
00834 SbBool processInventorEvent( XAnyEvent* anyevent );
00835 const SoEvent* translateAnyEvent( XAnyEvent* anyevent );
00836
00837
00838 SoWinRenderAreaRenderCB *appPostRenderCB;
00839 void *appPostRenderData;
00840
00841 private:
00842
00843 SbBool m_isFloatingPointRendering;
00844 FloatColorBufferSize m_floatingPointRenderingPrecision;
00845
00846 #if defined(sun) || defined(__linux__)
00847 XColor* m_mapColors, *m_overlayMapColors;
00848 int m_mapColorNum, m_overlayMapColorNum;
00849 #endif
00850
00851 SoWinMouse* m_mouseDevice;
00852 SoWinKeyboard* m_keybdDevice;
00853 void reinstallDevices( SoWidget newWidget );
00854
00855 static void selectionChangeCB( void* userData, SoSelection* s );
00856 static void overlaySelectionChangeCB( void* userData, SoSelection* s );
00857 SoWidget m_deviceWidget;
00858
00859
00860 SbBool m_firstEvent;
00861
00862 private:
00863 SbBool m_runOnce;
00864 static void windowEventCB( SoWidget w, SoWinRenderArea* wra, XAnyEvent* e, Boolean* b );
00865 private:
00866 static void renderCB( void* v, SoSceneManager* sm );
00867 static void renderOverlayCB( void* v, SoSceneManager* sm );
00868
00869 static void visibilityChangeCB( void* pt, SbBool visible );
00870
00871
00872 void constructorCommon( SbBool getMouseInput,
00873 SbBool getKeyboardInput,
00874 SbBool buildNow );
00875
00876
00877 void constructorCommon2( SbBool getMouseInput,
00878 SbBool getKeyboardInput,
00879 SbBool buildNow );
00880
00881 void activate();
00882 void deactivate();
00883
00884 int inRedraw;
00885 int inOverlayRedraw;
00886
00887 SoGuiRenderArea* m_guiRenderArea;
00888
00889
00890
00891
00892
00893 static SbBool s_abortRenderCallback(SoAction*,void*);
00894
00895 SoAntialiasingParameters* m_accumulationParameters;
00896
00897 bool m_firstStdRedraw;
00898 bool m_firstConnectedRedraw;
00899 SoTimerSensor* m_viewerUpdaterSensor;
00900 static void viewerUpdaterCB( void*, SoSensor* );
00901 void updateFirstFrame();
00902
00903 };
00904
00905 #include <Inventor/Win/SoWinEndStrict.h>
00906
00907 #endif
00908
00909
00910