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 class SoDEPRECATED SoWxRenderArea : public SoWxGLWidget
00096 {
00097 public:
00102 SoWxRenderArea( wxWindow* parent = NULL,
00103 const char *name = NULL,
00104 SbBool buildInsideParent = TRUE,
00105 SbBool getMouseInput = TRUE,
00106 SbBool getKeyboardInput = TRUE );
00110 ~SoWxRenderArea();
00111
00115 virtual void setSceneGraph( SoNode* newScene );
00116
00120 virtual SoNode* getSceneGraph();
00121
00127 void registerDevice( SoWxDevice* d );
00128
00134 void unregisterDevice( SoWxDevice* d );
00135
00143 void setBackgroundColor( const SbColor& c );
00144
00148 SbColor getBackgroundColor() const { return m_guiRenderArea->getBackgroundColor(); }
00149
00154 void setBackgroundIndex( int index ) { m_guiRenderArea->setBackgroundIndex( index ); }
00155
00159 int getBackgroundIndex() const { return m_guiRenderArea->getBackgroundIndex(); }
00160
00165 void setColorMap( int startIndex, int num, const SbColor* colors );
00166
00170 void setViewportRegion( const SbViewportRegion& newRegion )
00171 { m_guiRenderArea->setViewportRegion( newRegion ); }
00175 const SbViewportRegion &getViewportRegion() const { return m_guiRenderArea->getViewportRegion(); }
00176
00186 void setTransparencyType( SoGLRenderAction::TransparencyType type );
00187
00192 SoGLRenderAction::TransparencyType getTransparencyType() const
00193 { return m_guiRenderArea->getTransparencyType(); }
00194
00203 void setFastEditSavePolicy( SoGLRenderAction::FastEditSavePolicy policy,
00204 SbBool fastEditDelayedObjects = FALSE);
00205
00209 SoGLRenderAction::FastEditSavePolicy getFastEditSavePolicy() const
00210 { return m_guiRenderArea->getFastEditSavePolicy(); }
00211
00227 void setInvalidateCacheMode( SoGLRenderAction::InvalidateCacheMode icm );
00228
00232 SoGLRenderAction::InvalidateCacheMode getInvalidateCacheMode();
00233
00241 void setClearBeforeRender( SbBool trueOrFalse, SbBool zbTrueOrFalse = TRUE )
00242 { m_guiRenderArea->setClearBeforeRender( trueOrFalse, zbTrueOrFalse ); }
00246 SbBool isClearBeforeRender() const { return m_guiRenderArea->isClearBeforeRender(); }
00247
00252 SbBool isClearZBufferBeforeRender() const { return m_guiRenderArea->isClearZBufferBeforeRender(); }
00253
00258 void setAutoRedraw( SbBool trueOrFalse );
00259
00264 SbBool isAutoRedraw() const { return m_guiRenderArea->isAutoRedraw(); }
00265
00269 void setRedrawPriority( uint32_t priority ) { m_guiRenderArea->setRedrawPriority( priority ); }
00270
00274 uint32_t getRedrawPriority() const { return m_guiRenderArea->getRedrawPriority(); }
00275
00279 static uint32_t getDefaultRedrawPriority() { return SoSceneManager::getDefaultRedrawPriority(); }
00280
00281 void render() { redraw(); }
00282
00287 void scheduleRedraw();
00288
00299 void redrawOnSelectionChange( SoSelection* s );
00300
00312 void setEventCallback( SoWxRenderAreaEventCB* fcn, void* userData = NULL );
00319 void setSceneManager( SoSceneManager* sm );
00320
00327 SoSceneManager* getSceneManager() const { return m_guiRenderArea->getSceneManager(); }
00328
00334 void setGLRenderAction( SoGLRenderAction* ra );
00335
00341 SoGLRenderAction* getGLRenderAction() const { return m_guiRenderArea->getGLRenderAction(); }
00342
00347 const SbGLShareContext getShareContext();
00348
00364 void setPostRenderCallback( SoWxRenderAreaRenderCB* fcn, void* userData = NULL )
00365 { appPostRenderCB = fcn; appPostRenderData = userData; }
00366
00371 SoWxRenderAreaRenderCB* getPostRenderCallback( const void* &userData ) const
00372 { userData = appPostRenderData; return appPostRenderCB; }
00373
00388 void setFloatingColorBuffer( SbBool enable,
00389 FloatColorBufferSize size = FLOAT_16_COLOR_BUFFER );
00390
00395 void getFloatingColorBuffer( SbBool& enable, FloatColorBufferSize& size );
00396
00400 static SbBool isFloatingColorBufferSupported();
00401
00405 void sendEvent( wxEvent& anEvent );
00406
00412 virtual void setMPEGRecorder( SoMPEGRenderer* recorder )
00413 { m_guiRenderArea->setMPEGRecorder( recorder ); }
00414
00418 virtual SoMPEGRenderer* getMPEGRecorder() const
00419 { return m_guiRenderArea->getMPEGRecorder(); }
00420
00421 #if 1 SoDEPRECATED
00442 void setAntialiasing( SbBool smoothing, int numPasses );
00443 using SoWxGLWidget::setAntialiasing;
00444 SoDEPRECATED
00449 void getAntialiasing(SbBool &smoothing, int &numPasses) const;
00450
00451 #endif
00453 private:
00454 SoWxRenderArea( wxWindow* parent,
00455 const char* name,
00456 SbBool buildInsideParent,
00457 SbBool getMouseInput,
00458 SbBool getKeyboardInput,
00459 SoGuiAlgoViewers* guiAlgos );
00460
00461 SoWxRenderArea( wxWindow* parent,
00462 const char* name,
00463 SbBool buildInsideParent,
00464 SbBool getMouseInput,
00465 SbBool getKeyboardInput,
00466 SbBool buildNow,
00467 SbBool sync,
00468 SoGuiAlgoViewers* guiAlgos );
00469
00470 SoWxRenderArea( wxWindow* parent,
00471 const char* name,
00472 SbBool buildInsideParent,
00473 SbBool getMouseInput,
00474 SbBool getKeyboardInput,
00475 SbBool buildNow,
00476 SoGuiAlgoViewers* guiAlgos );
00480 SoGuiAlgoViewers* getGuiAlgoViewers() const { return (SoGuiAlgoViewers*)m_guiRenderArea; }
00481
00482 private:
00483
00484 void setDoubleBuffer( SbBool db );
00485
00486 SoGuiRenderArea* getGuiRenderArea() const;
00487
00488 void setStereoMode( SoCamera::StereoMode stMode );
00489 void setStereoElement();
00490 virtual SbBool isInteractive() const;
00491 void redrawCleanUp();
00492
00493 SoWxRenderArea( wxWindow* parent,
00494 const char* name,
00495 SbBool buildInsideParent,
00496 SbBool getMouseInput,
00497 SbBool getKeyboardInput,
00498 SbBool buildNow,
00499 SbBool sync );
00500
00501 void visibilityChangeCB( wxShowEvent& se );
00502 void onFocusEvent(SbBool hasFocus);
00503
00504
00505
00506 float stereoBalance, stereoOffset;
00507 SbBool stereoAbsoluteAdjustments;
00508 SoCamera::StereoMode stereoMode;
00509 SbBool stereoReversed;
00510
00511 private:
00512
00513
00514
00515
00516
00517
00518 SoWxRenderArea( wxWindow* parent,
00519 const char* name,
00520 SbBool buildInsideParent,
00521 SbBool getMouseInput,
00522 SbBool getKeyboardInput,
00523 SbBool buildNow );
00524
00525
00526
00527 SoWxRenderArea( wxWindow* parent,
00528 const char* name,
00529 SbBool buildInsideParent,
00530 SbBool getMouseInput,
00531 SbBool getKeyboardInput,
00532 SoGuiRenderArea* guiRenderArea );
00533
00534 SoWxRenderArea( wxWindow* parent,
00535 const char* name,
00536 SbBool buildInsideParent,
00537 SbBool getMouseInput,
00538 SbBool getKeyboardInput,
00539 SbBool buildNow,
00540 SbBool sync,
00541 SoGuiRenderArea* guiRenderArea );
00542
00543 SoWxRenderArea( wxWindow* parent,
00544 const char* name,
00545 SbBool buildInsideParent,
00546 SbBool getMouseInput,
00547 SbBool getKeyboardInput,
00548 SbBool buildNow,
00549 SoGuiRenderArea* guiRenderArea );
00550
00551
00552
00553
00554
00555
00556
00557
00558 virtual void redraw();
00559 virtual void actualRedraw();
00560
00561
00562
00563
00564 virtual void processEvent( wxEvent& anyEvent );
00565 virtual void initGraphic();
00566 virtual void sizeChanged( const SbVec2s& );
00567 virtual void posChanged( const SbVec2i32&, const SbVec2i32& );
00568 virtual void widgetChanged( wxWindow* w );
00569
00570 wxPanel* buildWidget( wxWindow* parent );
00571
00572
00573 virtual SbString getDefaultWidgetName() const;
00574 virtual SbString getDefaultTitle() const;
00575 virtual SbString getDefaultIconTitle() const;
00576
00577
00578 SbPList* m_deviceList;
00579
00580
00581 static void renderCB( void* data, SoSceneManager* sm );
00582
00583
00584 SoWxRenderAreaEventCB* defaultAppEventHandler;
00585 void* defaultAppEventHandlerData;
00586 SoWxRenderAreaEventCB* appEventHandler;
00587 void* appEventHandlerData;
00588
00589 SbBool invokeAppCB( wxEvent& anyEvent );
00590 SbBool processInventorEvent( wxEvent& anyEvent );
00591 const SoEvent* translateAnyEvent( wxEvent& anyevent );
00592
00593
00594 SoWxRenderAreaRenderCB* appPostRenderCB;
00595 void* appPostRenderData;
00596
00597 private:
00598
00599 SbBool m_isFloatingPointRendering;
00600 FloatColorBufferSize m_floatingPointRenderingPrecision;
00601
00602
00603 XColor* m_mapColors;
00604 int m_mapColorNum;
00605
00606 SoWxMouse* m_mouseDevice;
00607 SoWxKeyboard* m_keybdDevice;
00608
00609 void reinstallDevices( wxWindow* newWidget );
00610
00611 static void selectionChangeCB( void* userData, SoSelection* s );
00612
00613 wxWindow* m_deviceWidget;
00614 SbBool m_firstEvent;
00615
00616 void activate();
00617 void deactivate();
00618
00619
00620 void constructorCommon( SbBool getMouseInput, SbBool getKeyboardInput, SbBool buildNow );
00621
00622
00623 void constructorCommon2( SbBool getMouseInput, SbBool getKeyboardInput, SbBool buildNow );
00624
00625 wxPoint m_oldPos;
00626 wxSize m_oldSize;
00627 wxSize m_minimumSize;
00628 wxSize m_maximumSize;
00629
00630 SoGuiRenderArea* m_guiRenderArea;
00631
00632
00633
00634
00635
00636 static SbBool s_abortRenderCallback(SoAction*,void*);
00637
00638 bool m_firstStdRedraw;
00639 bool m_firstConnectedRedraw;
00640 SoTimerSensor* m_viewerUpdaterSensor;
00641 static void viewerUpdaterCB( void*, SoSensor* );
00642 void updateFirstFrame();
00643
00644 SoAntialiasingParameters* m_accumulationParameters;
00645 };
00646
00647
00648 #endif // SO_WX_RENDERAREA
00649