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_WX_RENDERAREA
00025 #define SO_WX_RENDERAREA
00026
00028
00029
00030
00032
00033 #include <Inventor/Wx/SoWxGLWidget.h>
00034
00035 #include <climits>
00036
00037 #include <Inventor/SbColor.h>
00038 #include <Inventor/SoSceneManager.h>
00039 #include <Inventor/sensors/SoNodeSensor.h>
00040 #include <Inventor/actions/SoGLRenderAction.h>
00041 #include <Inventor/nodes/SoCamera.h>
00042 #include <Inventor/SbElapsedTime.h>
00043
00044 #include <Inventor/Gui/SoGuiRenderArea.h>
00045
00046 class SoSelection;
00047 class SoWxDevice;
00048 class SoNode;
00049 class SoWxMouse;
00050 class SoWxKeyboard;
00051 class SoWxRenderArea;
00052 class SoGuiAlgoViewers;
00053 class SoAntialiasingParameters;
00054
00055
00056 typedef SbBool SoWxRenderAreaEventCB( void* userData, wxEvent& anyEvent );
00057 typedef SbBool SoWxRenderAreaRenderCB( void* userData, SoWxRenderArea* renderArea );
00058
00100 class SoWxRenderArea : public SoWxGLWidget
00101 {
00102 public:
00107 SoWxRenderArea( wxWindow* parent = NULL,
00108 const char *name = NULL,
00109 SbBool buildInsideParent = TRUE,
00110 SbBool getMouseInput = TRUE,
00111 SbBool getKeyboardInput = TRUE );
00115 ~SoWxRenderArea();
00116
00120 virtual void setSceneGraph( SoNode* newScene );
00121
00125 virtual SoNode* getSceneGraph();
00126
00132 void registerDevice( SoWxDevice* d );
00133
00139 void unregisterDevice( SoWxDevice* d );
00140
00148 void setBackgroundColor( const SbColor& c );
00149
00153 const SbColor& getBackgroundColor() const { return m_guiRenderArea->getBackgroundColor(); }
00154
00159 void setBackgroundIndex( int index ) { m_guiRenderArea->setBackgroundIndex( index ); }
00160
00164 int getBackgroundIndex() const { return m_guiRenderArea->getBackgroundIndex(); }
00165
00170 void setColorMap( int startIndex, int num, const SbColor* colors );
00171
00175 void setViewportRegion( const SbViewportRegion& newRegion )
00176 { m_guiRenderArea->setViewportRegion( newRegion ); }
00180 const SbViewportRegion &getViewportRegion() const { return m_guiRenderArea->getViewportRegion(); }
00181
00191 void setTransparencyType( SoGLRenderAction::TransparencyType type );
00192
00197 SoGLRenderAction::TransparencyType getTransparencyType() const
00198 { return m_guiRenderArea->getTransparencyType(); }
00199
00208 void setFastEditSavePolicy( SoGLRenderAction::FastEditSavePolicy policy,
00209 SbBool fastEditDelayedObjects = FALSE);
00210
00214 SoGLRenderAction::FastEditSavePolicy getFastEditSavePolicy() const
00215 { return m_guiRenderArea->getFastEditSavePolicy(); }
00216
00233 void setSortedTrianglesSortFrequency( int angle );
00234
00239 int getSortedTrianglesSortFrequency();
00240
00253 void setSortedTrianglesNumCaches( int numCaches );
00254
00258 int getSortedTrianglesNumCaches();
00259
00275 void setInvalidateCacheMode( SoGLRenderAction::InvalidateCacheMode icm );
00276
00280 SoGLRenderAction::InvalidateCacheMode getInvalidateCacheMode();
00281
00289 void setClearBeforeRender( SbBool trueOrFalse, SbBool zbTrueOrFalse = TRUE )
00290 { m_guiRenderArea->setClearBeforeRender( trueOrFalse, zbTrueOrFalse ); }
00294 SbBool isClearBeforeRender() const { return m_guiRenderArea->isClearBeforeRender(); }
00295
00300 SbBool isClearZBufferBeforeRender() const { return m_guiRenderArea->isClearZBufferBeforeRender(); }
00301
00306 void setAutoRedraw( SbBool trueOrFalse );
00307
00312 SbBool isAutoRedraw() const { return m_guiRenderArea->isAutoRedraw(); }
00313
00317 void setRedrawPriority( uint32_t priority ) { m_guiRenderArea->setRedrawPriority( priority ); }
00318
00322 uint32_t getRedrawPriority() const { return m_guiRenderArea->getRedrawPriority(); }
00323
00327 static uint32_t getDefaultRedrawPriority() { return SoSceneManager::getDefaultRedrawPriority(); }
00328
00329 void render() { redraw(); }
00330
00335 void scheduleRedraw();
00336
00347 void redrawOnSelectionChange( SoSelection* s );
00348
00360 void setEventCallback( SoWxRenderAreaEventCB* fcn, void* userData = NULL );
00367 void setSceneManager( SoSceneManager* sm );
00368
00375 SoSceneManager* getSceneManager() const { return m_guiRenderArea->getSceneManager(); }
00376
00377 #if 1 SoDEPRECATED
00383 void setOverlaySceneGraph( SoNode* newScene );
00384 SoDEPRECATED
00390 SoNode* getOverlaySceneGraph() { return m_guiRenderArea->getOverlaySceneGraph(); }
00391 SoDEPRECATED
00397 void scheduleOverlayRedraw();
00398 SoDEPRECATED
00410 void redrawOverlayOnSelectionChange( SoSelection* s );
00411 SoDEPRECATED
00419 SoSceneManager* getOverlaySceneManager() const { return m_guiRenderArea->getOverlaySceneManager(); }
00420 #endif
00427 void setGLRenderAction( SoGLRenderAction* ra );
00428
00434 SoGLRenderAction* getGLRenderAction() const { return m_guiRenderArea->getGLRenderAction(); }
00435
00443 const SbGLShareContext getShareContext();
00444
00460 void setPostRenderCallback( SoWxRenderAreaRenderCB* fcn, void* userData = NULL )
00461 { appPostRenderCB = fcn; appPostRenderData = userData; }
00462
00467 SoWxRenderAreaRenderCB* getPostRenderCallback( const void* &userData ) const
00468 { userData = appPostRenderData; return appPostRenderCB; }
00469
00484 void setFloatingColorBuffer( SbBool enable,
00485 FloatColorBufferSize size = FLOAT_16_COLOR_BUFFER );
00486
00491 void getFloatingColorBuffer( SbBool& enable, FloatColorBufferSize& size );
00492
00496 static SbBool isFloatingColorBufferSupported();
00497
00501 void sendEvent( wxEvent& anEvent );
00502
00508 virtual void setMPEGRecorder( SoMPEGRenderer* recorder )
00509 { m_guiRenderArea->setMPEGRecorder( recorder ); }
00510
00514 virtual SoMPEGRenderer* getMPEGRecorder() const
00515 { return m_guiRenderArea->getMPEGRecorder(); }
00516
00517 #if 1 SoDEPRECATED
00538 void setAntialiasing( SbBool smoothing, int numPasses );
00539 using SoWxGLWidget::setAntialiasing;
00540 SoDEPRECATED
00545 void getAntialiasing(SbBool &smoothing, int &numPasses) const;
00546
00547 #endif
00549 private:
00550 SoWxRenderArea( wxWindow* parent,
00551 const char* name,
00552 SbBool buildInsideParent,
00553 SbBool getMouseInput,
00554 SbBool getKeyboardInput,
00555 SoGuiAlgoViewers* guiAlgos );
00556
00557 SoWxRenderArea( wxWindow* parent,
00558 const char* name,
00559 SbBool buildInsideParent,
00560 SbBool getMouseInput,
00561 SbBool getKeyboardInput,
00562 SbBool buildNow,
00563 SbBool sync,
00564 SoGuiAlgoViewers* guiAlgos );
00565
00566 SoWxRenderArea( wxWindow* parent,
00567 const char* name,
00568 SbBool buildInsideParent,
00569 SbBool getMouseInput,
00570 SbBool getKeyboardInput,
00571 SbBool buildNow,
00572 SoGuiAlgoViewers* guiAlgos );
00576 SoGuiAlgoViewers* getGuiAlgoViewers() const { return (SoGuiAlgoViewers*)m_guiRenderArea; }
00577
00578 private:
00579
00580 void setDoubleBuffer( SbBool db );
00581
00582 SoGuiRenderArea* getGuiRenderArea() const;
00583
00584 void setStereoMode( SoCamera::StereoMode stMode );
00585 void setStereoElement();
00586 virtual SbBool isInteractive() const;
00587 void redrawCleanUp();
00588
00589 SoWxRenderArea( wxWindow* parent,
00590 const char* name,
00591 SbBool buildInsideParent,
00592 SbBool getMouseInput,
00593 SbBool getKeyboardInput,
00594 SbBool buildNow,
00595 SbBool sync );
00596
00597 void visibilityChangeCB( wxShowEvent& se );
00598 void onFocusEvent(SbBool hasFocus);
00599
00600
00601
00602 float stereoBalance, stereoOffset;
00603 SbBool stereoAbsoluteAdjustments;
00604 SoCamera::StereoMode stereoMode;
00605 SbBool stereoReversed;
00606
00607 private:
00608
00609
00610
00611
00612
00613
00614 SoWxRenderArea( wxWindow* parent,
00615 const char* name,
00616 SbBool buildInsideParent,
00617 SbBool getMouseInput,
00618 SbBool getKeyboardInput,
00619 SbBool buildNow );
00620
00621
00622
00623 SoWxRenderArea( wxWindow* parent,
00624 const char* name,
00625 SbBool buildInsideParent,
00626 SbBool getMouseInput,
00627 SbBool getKeyboardInput,
00628 SoGuiRenderArea* guiRenderArea );
00629
00630 SoWxRenderArea( wxWindow* parent,
00631 const char* name,
00632 SbBool buildInsideParent,
00633 SbBool getMouseInput,
00634 SbBool getKeyboardInput,
00635 SbBool buildNow,
00636 SbBool sync,
00637 SoGuiRenderArea* guiRenderArea );
00638
00639 SoWxRenderArea( wxWindow* parent,
00640 const char* name,
00641 SbBool buildInsideParent,
00642 SbBool getMouseInput,
00643 SbBool getKeyboardInput,
00644 SbBool buildNow,
00645 SoGuiRenderArea* guiRenderArea );
00646
00647
00648
00649
00650
00651
00652
00653
00654 virtual void redraw();
00655 virtual void actualRedraw();
00656 #if 1 SoDEPRECATED
00658 virtual void redrawOverlay();SoDEPRECATED
00660 virtual void actualOverlayRedraw();
00661 #endif
00663 //
00664
00665
00666 virtual void processEvent( wxEvent& anyEvent );
00667 virtual void initGraphic();
00668 virtual void sizeChanged( const SbVec2s& );
00669 virtual void posChanged( const SbVec2i32&, const SbVec2i32& );
00670 virtual void widgetChanged( wxWindow* w );
00671
00672 wxPanel* buildWidget( wxWindow* parent );
00673
00674
00675 virtual SbString getDefaultWidgetName() const;
00676 virtual SbString getDefaultTitle() const;
00677 virtual SbString getDefaultIconTitle() const;
00678
00679
00680 SbPList* m_deviceList;
00681
00682
00683 static void renderCB( void* data, SoSceneManager* sm );
00684 #if 1 SoDEPRECATED
00686 static void renderOverlayCB( void* v, SoSceneManager* sm );
00687 #endif
00689 // application event callbacks variables
00690 SoWxRenderAreaEventCB* defaultAppEventHandler;
00691 void* defaultAppEventHandlerData;
00692 SoWxRenderAreaEventCB* appEventHandler;
00693 void* appEventHandlerData;
00694
00695 SbBool invokeAppCB( wxEvent& anyEvent );
00696 SbBool processInventorEvent( wxEvent& anyEvent );
00697 const SoEvent* translateAnyEvent( wxEvent& anyevent );
00698
00699
00700 SoWxRenderAreaRenderCB* appPostRenderCB;
00701 void* appPostRenderData;
00702
00703 private:
00704
00705 SbBool m_isFloatingPointRendering;
00706 FloatColorBufferSize m_floatingPointRenderingPrecision;
00707
00708
00709 XColor* m_mapColors, *m_overlayMapColors;
00710 int m_mapColorNum, m_overlayMapColorNum;
00711
00712 SoWxMouse* m_mouseDevice;
00713 SoWxKeyboard* m_keybdDevice;
00714
00715 void reinstallDevices( wxWindow* newWidget );
00716
00717 static void selectionChangeCB( void* userData, SoSelection* s );
00718 static void overlaySelectionChangeCB( void* userData, SoSelection* s );
00719
00720 wxWindow* m_deviceWidget;
00721 SbBool m_firstEvent;
00722
00723 void activate();
00724 void deactivate();
00725
00726
00727 void constructorCommon( SbBool getMouseInput, SbBool getKeyboardInput, SbBool buildNow );
00728
00729
00730 void constructorCommon2( SbBool getMouseInput, SbBool getKeyboardInput, SbBool buildNow );
00731
00732 SbVec2i32 getWindowPosition() { return SbVec2i32( INT_MAX, INT_MAX ); }
00733
00734 wxPoint m_oldPos;
00735 wxSize m_oldSize;
00736 wxSize m_minimumSize;
00737 wxSize m_maximumSize;
00738
00739 SoGuiRenderArea* m_guiRenderArea;
00740
00741
00742
00743
00744
00745 static SbBool s_abortRenderCallback(SoAction*,void*);
00746
00747 SbBool m_runOnce;
00748
00749 bool m_firstStdRedraw;
00750 bool m_firstConnectedRedraw;
00751 SoTimerSensor* m_viewerUpdaterSensor;
00752 static void viewerUpdaterCB( void*, SoSensor* );
00753 void updateFirstFrame();
00754
00755 SoAntialiasingParameters* m_accumulationParameters;
00756 };
00757
00758
00759 #endif // SO_WX_RENDERAREA
00760
00761
00762