00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051 #ifdef SOQT
00052 # include <Inventor/Qt/SoQtRenderArea.h>
00053 #elif defined(SOWX)
00054 # include <Inventor/Wx/SoWxRenderArea.h>
00055 #elif defined _WIN32
00056 # include <Inventor/Win/SoWinRenderArea.h>
00057 #else
00058
00059 #ifndef _SO_XT_RENDER_AREA_H_
00060 #define _SO_XT_RENDER_AREA_H_
00061
00062 #include <Inventor/SbColor.h>
00063 #include <Inventor/sensors/SoNodeSensor.h>
00064 #include <Inventor/SoSceneManager.h>
00065 #include <Inventor/Xt/SoXtGLWidget.h>
00066 #include <Inventor/actions/SoGLRenderAction.h>
00067
00068 #include <Inventor/nodes/SoCamera.h>
00069 #include <Inventor/nodes/SoFullSceneAntialiasing.h>
00070 #include <Inventor/SbElapsedTime.h>
00071
00072 #include <Inventor/Gui/SoGuiRenderArea.h>
00073
00074 class SoHandleEventAction;
00075 class SoXtDevice;
00076 class SoNode;
00077 class SoXtMouse;
00078 class SoXtKeyboard;
00079 class SoSelection;
00080 class SbConfig;
00081 class SoXtRenderArea;
00082 class ScTracking;
00083 class SoGuiAlgoViewers;
00084 class SoAntialiasingParameters;
00085
00086
00087 typedef SbBool SoXtRenderAreaEventCB( void* userData, XAnyEvent* anyevent );
00088 typedef SbBool SoXtRenderAreaRenderCB( void* userData, SoXtRenderArea* rendArea );
00089
00091
00092
00093
00094
00095
00097
00136 class SoXtRenderArea : public SoXtGLWidget
00137 {
00138 public:
00139
00144 SoXtRenderArea( SoWidget parent = NULL,
00145 const char* name = NULL,
00146 SbBool buildInsideParent = TRUE,
00147 SbBool getMouseInput = TRUE,
00148 SbBool getKeyboardInput = TRUE );
00152 ~SoXtRenderArea();
00153
00157 virtual void setSceneGraph( SoNode* newScene );
00158
00162 virtual SoNode* getSceneGraph();
00163
00169 void registerDevice( SoXtDevice* d );
00170
00176 void unregisterDevice( SoXtDevice* d );
00177
00184 void setBackgroundColor( const SbColor& c );
00185
00189 SbColor getBackgroundColor() const { return m_guiRenderArea->getBackgroundColor(); }
00190
00195 void setBackgroundIndex( int index ) { m_guiRenderArea->setBackgroundIndex( index ); }
00196
00200 int getBackgroundIndex() const { return m_guiRenderArea->getBackgroundIndex(); }
00201
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
00270 void setInvalidateCacheMode( SoGLRenderAction::InvalidateCacheMode icm );
00271
00275 SoGLRenderAction::InvalidateCacheMode getInvalidateCacheMode();
00276
00284 void setClearBeforeRender( SbBool trueOrFalse, SbBool zbTrueOrFalse = TRUE )
00285 { m_guiRenderArea->setClearBeforeRender( trueOrFalse, zbTrueOrFalse ); }
00286
00290 SbBool isClearBeforeRender() const { return m_guiRenderArea->isClearBeforeRender(); }
00291
00296 SbBool isClearZBufferBeforeRender() const { return m_guiRenderArea->isClearZBufferBeforeRender(); }
00297
00302 void setAutoRedraw( SbBool trueOrFalse );
00303
00308 SbBool isAutoRedraw() const { return m_guiRenderArea->isAutoRedraw(); }
00309
00313 void setRedrawPriority( uint32_t priority ) { m_guiRenderArea->setRedrawPriority(priority); }
00314
00318 uint32_t getRedrawPriority() const { return m_guiRenderArea->getRedrawPriority(); }
00319
00323 static uint32_t getDefaultRedrawPriority() { return SoSceneManager::getDefaultRedrawPriority(); }
00324
00329 void render() { redraw(); }
00330
00335 void scheduleRedraw();
00336
00347 void redrawOnSelectionChange( SoSelection* s );
00348
00360 void setEventCallback( SoXtRenderAreaEventCB* fcn, void* userData = NULL );
00361
00368 void setSceneManager( SoSceneManager* sm );
00369
00376 SoSceneManager* getSceneManager() const { return m_guiRenderArea->getSceneManager(); }
00377
00383 void setGLRenderAction( SoGLRenderAction* ra );
00384
00390 SoGLRenderAction* getGLRenderAction() const { return m_guiRenderArea->getGLRenderAction(); }
00391
00396 const SbGLShareContext getShareContext();
00397
00413 void setPostRenderCallback( SoXtRenderAreaRenderCB* fcn, void* userData = NULL )
00414 { appPostRenderCB = fcn; appPostRenderData = userData; }
00415
00420 SoXtRenderAreaRenderCB* getPostRenderCallback( const void* &userData ) const
00421 { userData = appPostRenderData; return appPostRenderCB; }
00422
00437 void setFloatingColorBuffer( SbBool enable, FloatColorBufferSize size = FLOAT_16_COLOR_BUFFER );
00438
00443 void getFloatingColorBuffer( SbBool& enable, FloatColorBufferSize& size );
00444
00448 void sendEvent( XAnyEvent* anEvent );
00449
00455 virtual void setMPEGRecorder( SoMPEGRenderer* recorder )
00456 { m_guiRenderArea->setMPEGRecorder( recorder ); }
00457
00461 virtual SoMPEGRenderer* getMPEGRecorder() const
00462 { return m_guiRenderArea->getMPEGRecorder(); }
00463
00464 #if 1 SoDEPRECATED
00482 void setAntialiasing( SbBool smoothing, int numPasses );
00483 using SoXtGLWidget::setAntialiasing;
00484 SoDEPRECATED
00489 void getAntialiasing( SbBool& smoothing, int& numPasses ) const;
00490
00491 #endif
00493 private:
00494
00495 SoXtRenderArea( SoWidget parent,
00496 const char* name,
00497 SbBool buildInsideParent,
00498 SbBool getMouseInput,
00499 SbBool getKeyboardInput,
00500 SoGuiAlgoViewers* guiAlgos );
00501
00502 SoXtRenderArea( SoWidget parent,
00503 const char* name,
00504 SbBool buildInsideParent,
00505 SbBool getMouseInput,
00506 SbBool getKeyboardInput,
00507 SbBool buildNow,
00508 SbBool sync,
00509 SoGuiAlgoViewers* guiAlgos );
00510
00511 SoXtRenderArea( SoWidget parent,
00512 const char* name,
00513 SbBool buildInsideParent,
00514 SbBool getMouseInput,
00515 SbBool getKeyboardInput,
00516 SbBool buildNow,
00517 SoGuiAlgoViewers* guiAlgos );
00521 SoGuiAlgoViewers* getGuiAlgoViewers() const { return (SoGuiAlgoViewers*)m_guiRenderArea; }
00522
00523 private:
00524 void setStereoMode( SoCamera::StereoMode stMode );
00525 void setStereoElement();
00526
00527 SoGuiRenderArea* getGuiRenderArea() const;
00528
00529 SbBool isFloatingColorBufferSupported();
00530
00531 virtual SbBool isInteractive() const;
00532
00533 SoXtRenderArea();
00534
00535 SoXtRenderArea( SoWidget parent,
00536 const char* name,
00537 SbBool buildInsideParent,
00538 SbBool getMouseInput,
00539 SbBool getKeyboardInput,
00540 SbBool buildNow,
00541 SbBool sync );
00542
00543
00544
00545 float stereoBalance, stereoOffset;
00546 SbBool stereoAbsoluteAdjustments;
00547 SoCamera::StereoMode stereoMode;
00548 SbBool stereoReversed;
00549
00550 private:
00551
00552
00553
00554
00555
00556
00557 SoXtRenderArea( SoWidget parent,
00558 const char* name,
00559 SbBool buildInsideParent,
00560 SbBool getMouseInput,
00561 SbBool getKeyboardInput,
00562 SbBool buildNow );
00563
00564
00565
00566 SoXtRenderArea( SoWidget parent,
00567 const char* name,
00568 SbBool buildInsideParent,
00569 SbBool getMouseInput,
00570 SbBool getKeyboardInput,
00571 SoGuiRenderArea* guiRenderArea );
00572
00573 SoXtRenderArea( SoWidget parent,
00574 const char* name,
00575 SbBool buildInsideParent,
00576 SbBool getMouseInput,
00577 SbBool getKeyboardInput,
00578 SbBool buildNow,
00579 SbBool sync,
00580 SoGuiRenderArea* guiRenderArea );
00581
00582 SoXtRenderArea( SoWidget parent,
00583 const char* name,
00584 SbBool buildInsideParent,
00585 SbBool getMouseInput,
00586 SbBool getKeyboardInput,
00587 SbBool buildNow,
00588 SoGuiRenderArea* guiRenderArea );
00589
00590
00591
00592
00593
00594
00595
00596
00597
00598 virtual void redraw();
00599 virtual void actualRedraw();
00600
00601
00602
00603
00604 virtual void processEvent( XAnyEvent* anyevent );
00605 virtual void initGraphic();
00606 virtual void sizeChanged( const SbVec2s& );
00607 virtual void posChanged( const SbVec2i32&, const SbVec2i32& );
00608 virtual void widgetChanged( SoWidget w );
00609
00610 SoWidget buildWidget( SoWidget parent );
00611
00612
00613 virtual SbString getDefaultWidgetName() const;
00614 virtual SbString getDefaultTitle() const;
00615 virtual SbString getDefaultIconTitle() const;
00616
00617
00618 SbPList* m_deviceList;
00619
00620
00621 SoXtRenderAreaEventCB* defaultAppEventHandler;
00622 void* defaultAppEventHandlerData;
00623 SoXtRenderAreaEventCB* appEventHandler;
00624 void* appEventHandlerData;
00625
00626
00627 SbBool invokeAppCB( XAnyEvent* anyevent );
00628 SbBool processInventorEvent( XAnyEvent* anyevent );
00629 const SoEvent* translateAnyEvent( XAnyEvent* anyevent );
00630
00631
00632 SoXtRenderAreaRenderCB* appPostRenderCB;
00633 void* appPostRenderData;
00634
00635 private:
00636
00637 XColor* m_mapColors;
00638 int m_mapColorNum;
00639
00640 SoXtMouse* m_mouseDevice;
00641 SoXtKeyboard* m_keybdDevice;
00642 void reinstallDevices( SoWidget newWidget );
00643
00644 static void selectionChangeCB( void* p, SoSelection* s );
00645 SoWidget m_deviceWidget;
00646
00647
00648 SbBool m_firstEvent;
00649 static void windowEventCB( SoWidget w, SoXtRenderArea* p, XAnyEvent* xe, Boolean* b );
00650 static void renderCB( void* v, SoSceneManager* sm );
00651
00652 static void visibilityChangeCB( void* pt, SbBool visible );
00653 void activate();
00654 void deactivate();
00655
00656
00657 void constructorCommon( SbBool getMouseInput, SbBool getKeyboardInput, SbBool buildNow );
00658
00659
00660 void constructorCommon2( SbBool getMouseInput,
00661 SbBool getKeyboardInput,
00662 SbBool buildNow );
00663
00664 SbConfig* m_vrConfig;
00665 SbBool m_forceRedraw;
00666 SbBool m_forceSyncRedraw;
00667
00668 ScTracking* m_tracking;
00669
00670 SoGuiRenderArea* m_guiRenderArea;
00671
00672
00673
00674
00675
00676 static SbBool s_abortRenderCallback(SoAction*,void*);
00677
00678 SoAntialiasingParameters* m_accumulationParameters;
00679
00680 bool m_firstStdRedraw;
00681 bool m_firstConnectedRedraw;
00682 SoTimerSensor* m_viewerUpdaterSensor;
00683 static void viewerUpdaterCB( void*, SoSensor* );
00684 void updateFirstFrame();
00685 };
00686
00687
00688 #endif
00689
00690 #endif
00691
00692