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 <Inventor/SbColor.h>
00036 #include <Inventor/SoSceneManager.h>
00037 #include <Inventor/sensors/SoNodeSensor.h>
00038 #include <Inventor/actions/SoGLRenderAction.h>
00039 #include <Inventor/nodes/SoCamera.h>
00040 #include <Inventor/SbElapsedTime.h>
00041
00042 #include <Inventor/Gui/SoGuiRenderArea.h>
00043
00044 class SoSelection;
00045 class SoWxDevice;
00046 class SoNode;
00047 class SoWxMouse;
00048 class SoWxKeyboard;
00049 class SoWxRenderArea;
00050 class SoGuiAlgoViewers;
00051 class SoAntialiasingParameters;
00052
00053
00054 typedef SbBool SoWxRenderAreaEventCB( void* userData, wxEvent& anyEvent );
00055 typedef SbBool SoWxRenderAreaRenderCB( void* userData, SoWxRenderArea* renderArea );
00056
00098 class SoWxRenderArea : public SoWxGLWidget
00099 {
00100 public:
00105 SoWxRenderArea( wxWindow* parent = NULL,
00106 const char *name = NULL,
00107 SbBool buildInsideParent = TRUE,
00108 SbBool getMouseInput = TRUE,
00109 SbBool getKeyboardInput = TRUE );
00113 ~SoWxRenderArea();
00114
00118 virtual void setSceneGraph( SoNode* newScene );
00119
00123 virtual SoNode* getSceneGraph();
00124
00130 void registerDevice( SoWxDevice* d );
00131
00137 void unregisterDevice( SoWxDevice* d );
00138
00146 void setBackgroundColor( const SbColor& c );
00147
00151 const SbColor& getBackgroundColor() const { return m_guiRenderArea->getBackgroundColor(); }
00152
00157 void setBackgroundIndex( int index ) { m_guiRenderArea->setBackgroundIndex( index ); }
00158
00162 int getBackgroundIndex() const { return m_guiRenderArea->getBackgroundIndex(); }
00163
00168 void setColorMap( int startIndex, int num, const SbColor* colors );
00169
00173 void setViewportRegion( const SbViewportRegion& newRegion )
00174 { m_guiRenderArea->setViewportRegion( newRegion ); }
00178 const SbViewportRegion &getViewportRegion() const { return m_guiRenderArea->getViewportRegion(); }
00179
00189 void setTransparencyType( SoGLRenderAction::TransparencyType type );
00190
00195 SoGLRenderAction::TransparencyType getTransparencyType() const
00196 { return m_guiRenderArea->getTransparencyType(); }
00197
00206 void setFastEditSavePolicy( SoGLRenderAction::FastEditSavePolicy policy,
00207 SbBool fastEditDelayedObjects = FALSE);
00208
00212 SoGLRenderAction::FastEditSavePolicy getFastEditSavePolicy() const
00213 { return m_guiRenderArea->getFastEditSavePolicy(); }
00214
00231 void setSortedTrianglesSortFrequency( int angle );
00232
00237 int getSortedTrianglesSortFrequency();
00238
00251 void setSortedTrianglesNumCaches( int numCaches );
00252
00256 int getSortedTrianglesNumCaches();
00257
00273 void setInvalidateCacheMode( SoGLRenderAction::InvalidateCacheMode icm );
00274
00278 SoGLRenderAction::InvalidateCacheMode getInvalidateCacheMode();
00279
00287 void setClearBeforeRender( SbBool trueOrFalse, SbBool zbTrueOrFalse = TRUE )
00288 { m_guiRenderArea->setClearBeforeRender( trueOrFalse, zbTrueOrFalse ); }
00292 SbBool isClearBeforeRender() const { return m_guiRenderArea->isClearBeforeRender(); }
00293
00298 SbBool isClearZBufferBeforeRender() const { return m_guiRenderArea->isClearZBufferBeforeRender(); }
00299
00304 void setAutoRedraw( SbBool trueOrFalse );
00305
00310 SbBool isAutoRedraw() const { return m_guiRenderArea->isAutoRedraw(); }
00311
00315 void setRedrawPriority( uint32_t priority ) { m_guiRenderArea->setRedrawPriority( priority ); }
00316
00320 uint32_t getRedrawPriority() const { return m_guiRenderArea->getRedrawPriority(); }
00321
00325 static uint32_t getDefaultRedrawPriority() { return SoSceneManager::getDefaultRedrawPriority(); }
00326
00327 void render() { redraw(); }
00328
00333 void scheduleRedraw();
00334
00345 void redrawOnSelectionChange( SoSelection* s );
00346
00358 void setEventCallback( SoWxRenderAreaEventCB* fcn, void* userData = NULL );
00365 void setSceneManager( SoSceneManager* sm );
00366
00373 SoSceneManager* getSceneManager() const { return m_guiRenderArea->getSceneManager(); }
00374
00375 #if 1 SoDEPRECATED
00381 void setOverlaySceneGraph( SoNode* newScene );
00382 SoDEPRECATED
00388 SoNode* getOverlaySceneGraph() { return m_guiRenderArea->getOverlaySceneGraph(); }
00389 SoDEPRECATED
00395 void scheduleOverlayRedraw();
00396 SoDEPRECATED
00408 void redrawOverlayOnSelectionChange( SoSelection* s );
00409 SoDEPRECATED
00417 SoSceneManager* getOverlaySceneManager() const { return m_guiRenderArea->getOverlaySceneManager(); }
00418 #endif
00425 void setGLRenderAction( SoGLRenderAction* ra );
00426
00432 SoGLRenderAction* getGLRenderAction() const { return m_guiRenderArea->getGLRenderAction(); }
00433
00441 const SbGLShareContext getShareContext();
00442
00458 void setPostRenderCallback( SoWxRenderAreaRenderCB* fcn, void* userData = NULL )
00459 { appPostRenderCB = fcn; appPostRenderData = userData; }
00460
00465 SoWxRenderAreaRenderCB* getPostRenderCallback( const void* &userData ) const
00466 { userData = appPostRenderData; return appPostRenderCB; }
00467
00482 void setFloatingColorBuffer( SbBool enable,
00483 FloatColorBufferSize size = FLOAT_16_COLOR_BUFFER );
00484
00489 void getFloatingColorBuffer( SbBool& enable, FloatColorBufferSize& size );
00490
00494 static SbBool isFloatingColorBufferSupported();
00495
00499 void sendEvent( wxEvent& anEvent );
00500
00506 virtual void setMPEGRecorder( SoMPEGRenderer* recorder )
00507 { m_guiRenderArea->setMPEGRecorder( recorder ); }
00508
00512 virtual SoMPEGRenderer* getMPEGRecorder() const
00513 { return m_guiRenderArea->getMPEGRecorder(); }
00514
00515 #if 1 SoDEPRECATED
00536 void setAntialiasing( SbBool smoothing, int numPasses );
00537 using SoWxGLWidget::setAntialiasing;
00538 SoDEPRECATED
00543 void getAntialiasing(SbBool &smoothing, int &numPasses) const;
00544
00545 #endif
00547 private:
00548 SoWxRenderArea( wxWindow* parent,
00549 const char* name,
00550 SbBool buildInsideParent,
00551 SbBool getMouseInput,
00552 SbBool getKeyboardInput,
00553 SoGuiAlgoViewers* guiAlgos );
00554
00555 SoWxRenderArea( wxWindow* parent,
00556 const char* name,
00557 SbBool buildInsideParent,
00558 SbBool getMouseInput,
00559 SbBool getKeyboardInput,
00560 SbBool buildNow,
00561 SbBool sync,
00562 SoGuiAlgoViewers* guiAlgos );
00563
00564 SoWxRenderArea( wxWindow* parent,
00565 const char* name,
00566 SbBool buildInsideParent,
00567 SbBool getMouseInput,
00568 SbBool getKeyboardInput,
00569 SbBool buildNow,
00570 SoGuiAlgoViewers* guiAlgos );
00574 SoGuiAlgoViewers* getGuiAlgoViewers() const { return (SoGuiAlgoViewers*)m_guiRenderArea; }
00575
00576 private:
00577
00578 void setDoubleBuffer( SbBool db );
00579
00580 SoGuiRenderArea* getGuiRenderArea() const;
00581
00582 void setStereoMode( SoCamera::StereoMode stMode );
00583 void setStereoElement();
00584 virtual SbBool isInteractive() const;
00585 void redrawCleanUp();
00586
00587 SoWxRenderArea( wxWindow* parent,
00588 const char* name,
00589 SbBool buildInsideParent,
00590 SbBool getMouseInput,
00591 SbBool getKeyboardInput,
00592 SbBool buildNow,
00593 SbBool sync );
00594
00595 void visibilityChangeCB( wxShowEvent& se );
00596 void onFocusEvent(SbBool hasFocus);
00597
00598
00599
00600 float stereoBalance, stereoOffset;
00601 SbBool stereoAbsoluteAdjustments;
00602 SoCamera::StereoMode stereoMode;
00603 SbBool stereoReversed;
00604
00605 private:
00606
00607
00608
00609
00610
00611
00612 SoWxRenderArea( wxWindow* parent,
00613 const char* name,
00614 SbBool buildInsideParent,
00615 SbBool getMouseInput,
00616 SbBool getKeyboardInput,
00617 SbBool buildNow );
00618
00619
00620
00621 SoWxRenderArea( wxWindow* parent,
00622 const char* name,
00623 SbBool buildInsideParent,
00624 SbBool getMouseInput,
00625 SbBool getKeyboardInput,
00626 SoGuiRenderArea* guiRenderArea );
00627
00628 SoWxRenderArea( wxWindow* parent,
00629 const char* name,
00630 SbBool buildInsideParent,
00631 SbBool getMouseInput,
00632 SbBool getKeyboardInput,
00633 SbBool buildNow,
00634 SbBool sync,
00635 SoGuiRenderArea* guiRenderArea );
00636
00637 SoWxRenderArea( wxWindow* parent,
00638 const char* name,
00639 SbBool buildInsideParent,
00640 SbBool getMouseInput,
00641 SbBool getKeyboardInput,
00642 SbBool buildNow,
00643 SoGuiRenderArea* guiRenderArea );
00644
00645
00646
00647
00648
00649
00650
00651
00652 virtual void redraw();
00653 virtual void actualRedraw();
00654 #if 1 SoDEPRECATED
00656 virtual void redrawOverlay();SoDEPRECATED
00658 virtual void actualOverlayRedraw();
00659 #endif
00661 //
00662
00663
00664 virtual void processEvent( wxEvent& anyEvent );
00665 virtual void initGraphic();
00666 virtual void sizeChanged( const SbVec2s& );
00667 virtual void posChanged( const SbVec2i32&, const SbVec2i32& );
00668 virtual void widgetChanged( wxWindow* w );
00669
00670 wxPanel* buildWidget( wxWindow* parent );
00671
00672
00673 virtual SbString getDefaultWidgetName() const;
00674 virtual SbString getDefaultTitle() const;
00675 virtual SbString getDefaultIconTitle() const;
00676
00677
00678 SbPList* m_deviceList;
00679
00680
00681 static void renderCB( void* data, SoSceneManager* sm );
00682 #if 1 SoDEPRECATED
00684 static void renderOverlayCB( void* v, SoSceneManager* sm );
00685 #endif
00687 // application event callbacks variables
00688 SoWxRenderAreaEventCB* defaultAppEventHandler;
00689 void* defaultAppEventHandlerData;
00690 SoWxRenderAreaEventCB* appEventHandler;
00691 void* appEventHandlerData;
00692
00693 SbBool invokeAppCB( wxEvent& anyEvent );
00694 SbBool processInventorEvent( wxEvent& anyEvent );
00695 const SoEvent* translateAnyEvent( wxEvent& anyevent );
00696
00697
00698 SoWxRenderAreaRenderCB* appPostRenderCB;
00699 void* appPostRenderData;
00700
00701 private:
00702
00703 SbBool m_isFloatingPointRendering;
00704 FloatColorBufferSize m_floatingPointRenderingPrecision;
00705
00706
00707 XColor* m_mapColors, *m_overlayMapColors;
00708 int m_mapColorNum, m_overlayMapColorNum;
00709
00710 SoWxMouse* m_mouseDevice;
00711 SoWxKeyboard* m_keybdDevice;
00712
00713 void reinstallDevices( wxWindow* newWidget );
00714
00715 static void selectionChangeCB( void* userData, SoSelection* s );
00716 static void overlaySelectionChangeCB( void* userData, SoSelection* s );
00717
00718 wxWindow* m_deviceWidget;
00719 SbBool m_firstEvent;
00720
00721 void activate();
00722 void deactivate();
00723
00724
00725 void constructorCommon( SbBool getMouseInput, SbBool getKeyboardInput, SbBool buildNow );
00726
00727
00728 void constructorCommon2( SbBool getMouseInput, SbBool getKeyboardInput, SbBool buildNow );
00729
00730 wxPoint m_oldPos;
00731 wxSize m_oldSize;
00732 wxSize m_minimumSize;
00733 wxSize m_maximumSize;
00734
00735 SoGuiRenderArea* m_guiRenderArea;
00736
00737
00738
00739
00740
00741 static SbBool s_abortRenderCallback(SoAction*,void*);
00742
00743 SbBool m_runOnce;
00744
00745 bool m_firstStdRedraw;
00746 bool m_firstConnectedRedraw;
00747 SoTimerSensor* m_viewerUpdaterSensor;
00748 static void viewerUpdaterCB( void*, SoSensor* );
00749 void updateFirstFrame();
00750
00751 SoAntialiasingParameters* m_accumulationParameters;
00752 };
00753
00754
00755 #endif // SO_WX_RENDERAREA
00756
00757
00758