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
00106 class SoWinRenderArea : public SoWinGLWidget
00107 {
00108 public:
00109
00118 SoWinRenderArea( SoWidget parent = NULL,
00119 const char* name = NULL,
00120 SbBool buildInsideParent = TRUE,
00121 SbBool getMouseInput = TRUE,
00122 SbBool getKeyboardInput = TRUE );
00126 ~SoWinRenderArea();
00127
00133 virtual void setSceneGraph( SoNode *newScene );
00134
00138 virtual SoNode* getSceneGraph();
00139
00146 void registerDevice( SoWinDevice* d );
00153 void unregisterDevice( SoWinDevice* d );
00154
00161 void setBackgroundColor( const SbColor& c );
00162
00166 SbColor getBackgroundColor() const { return m_guiRenderArea->getBackgroundColor(); }
00167
00172 void setBackgroundIndex( int index ) { m_guiRenderArea->setBackgroundIndex( index ); }
00173
00177 int getBackgroundIndex() const { return m_guiRenderArea->getBackgroundIndex(); }
00178
00184 void setColorMap( int startIndex, int num, const SbColor* colors );
00185
00189 void setViewportRegion( const SbViewportRegion& newRegion )
00190 { m_guiRenderArea->setViewportRegion( newRegion ); }
00191
00195 const SbViewportRegion &getViewportRegion() const
00196 { return m_guiRenderArea->getViewportRegion(); }
00197
00207 void setTransparencyType( SoGLRenderAction::TransparencyType type );
00208
00213 SoGLRenderAction::TransparencyType getTransparencyType() const
00214 { return m_guiRenderArea->getTransparencyType(); }
00215
00224 void setFastEditSavePolicy( SoGLRenderAction::FastEditSavePolicy policy,
00225 SbBool fastEditDelayedObjects = FALSE);
00226
00230 SoGLRenderAction::FastEditSavePolicy getFastEditSavePolicy() const
00231 { return m_guiRenderArea->getFastEditSavePolicy(); }
00232
00248 void setInvalidateCacheMode( SoGLRenderAction::InvalidateCacheMode icm );
00249
00253 SoGLRenderAction::InvalidateCacheMode getInvalidateCacheMode();
00254
00262 void setClearBeforeRender( SbBool trueOrFalse, SbBool zbTrueOrFalse = TRUE )
00263 { m_guiRenderArea->setClearBeforeRender( trueOrFalse, zbTrueOrFalse ); }
00264
00268 SbBool isClearBeforeRender() const { return m_guiRenderArea->isClearBeforeRender(); }
00269
00274 SbBool isClearZBufferBeforeRender() const { return m_guiRenderArea->isClearZBufferBeforeRender(); }
00275
00283 void setAutoRedraw( SbBool trueOrFalse );
00284
00289 SbBool isAutoRedraw() const { return m_guiRenderArea->isAutoRedraw(); }
00290
00294 void setRedrawPriority( unsigned long priority ) { m_guiRenderArea->setRedrawPriority(priority); }
00295
00299 unsigned long getRedrawPriority() const { return m_guiRenderArea->getRedrawPriority(); }
00300
00304 static unsigned long getDefaultRedrawPriority() { return SoSceneManager::getDefaultRedrawPriority(); }
00305
00310 void render() { redraw(); }
00311
00316 void scheduleRedraw();
00317
00328 void redrawOnSelectionChange( SoSelection* s );
00329
00367 void setEventCallback( SoWinRenderAreaEventCB* fcn, void* userData = NULL );
00368
00375 void setSceneManager( SoSceneManager* sm );
00376
00383 SoSceneManager* getSceneManager() const { return m_guiRenderArea->getSceneManager(); }
00384
00393 void setGLRenderAction( SoGLRenderAction* ra );
00394
00400 SoGLRenderAction* getGLRenderAction() const { return m_guiRenderArea->getGLRenderAction(); }
00401
00406 const SbGLShareContext getShareContext();
00407
00423 void setPostRenderCallback( SoWinRenderAreaRenderCB* fcn, void* userData = NULL )
00424 { appPostRenderCB = fcn; appPostRenderData = userData; }
00425
00431 SoWinRenderAreaRenderCB* getPostRenderCallback( const void* &userData ) const
00432 { userData = appPostRenderData; return appPostRenderCB; }
00433
00435 void setFloatingColorBuffer( SbBool enable,
00436 FloatColorBufferSize size = FLOAT_16_COLOR_BUFFER );
00437
00439 void getFloatingColorBuffer( SbBool& enable, FloatColorBufferSize& size );
00440
00444 static SbBool isFloatingColorBufferSupported();
00445
00449 void sendEvent( XAnyEvent* anEvent );
00450
00456 virtual void setMPEGRecorder( SoMPEGRenderer* recorder )
00457 { m_guiRenderArea->setMPEGRecorder( recorder ); }
00458
00462 virtual SoMPEGRenderer* getMPEGRecorder() const
00463 { return m_guiRenderArea->getMPEGRecorder(); }
00464
00465 #if 1 SoDEPRECATED
00486 void setAntialiasing( SbBool smoothing, int numPasses );
00487 using SoWinGLWidget::setAntialiasing;
00488 SoDEPRECATED
00493 void getAntialiasing( SbBool& smoothing, int& numPasses) const;
00494
00495 #endif
00497 private:
00498 SoWinRenderArea( SoWidget parent,
00499 const char* name,
00500 SbBool buildInsideParent,
00501 SbBool getMouseInput,
00502 SbBool getKeyboardInput,
00503 SoGuiAlgoViewers* guiAlgos );
00504
00505
00506 SoWinRenderArea( SoWidget parent,
00507 const char* name,
00508 SbBool buildInsideParent,
00509 SbBool getMouseInput,
00510 SbBool getKeyboardInput,
00511 SbBool buildNow,
00512 SbBool sync,
00513 SoGuiAlgoViewers* guiAlgos );
00514
00515
00516 SoWinRenderArea( SoWidget parent,
00517 const char* name,
00518 SbBool buildInsideParent,
00519 SbBool getMouseInput,
00520 SbBool getKeyboardInput,
00521 SbBool buildNow,
00522 SoGuiAlgoViewers* guiAlgos );
00523
00527 SoGuiAlgoViewers* getGuiAlgoViewers() const { return (SoGuiAlgoViewers*)m_guiRenderArea; }
00528
00529 private:
00530
00531 SoGuiRenderArea* getGuiRenderArea() const;
00532
00533 void setStereoMode( SoCamera::StereoMode stMode );
00534 void setStereoElement();
00535
00536 virtual void setDoubleBuffer( SbBool db );
00537
00538 virtual SbBool isInteractive() const;
00539
00540 SoWinRenderArea( SoWidget parent,
00541 const char* name,
00542 SbBool buildInsideParent,
00543 SbBool getMouseInput,
00544 SbBool getKeyboardInput,
00545 SbBool buildNow,
00546 SbBool sync );
00547
00548
00549
00550 float stereoBalance, stereoOffset;
00551 SbBool stereoAbsoluteAdjustments;
00552 SoCamera::StereoMode stereoMode;
00553 SbBool stereoReversed;
00554
00555 private:
00556
00557
00558
00559
00560
00561
00562 SoWinRenderArea( SoWidget parent,
00563 const char* name,
00564 SbBool buildInsideParent,
00565 SbBool getMouseInput,
00566 SbBool getKeyboardInput,
00567 SbBool buildNow );
00568
00569
00570
00571 SoWinRenderArea( SoWidget parent,
00572 const char* name,
00573 SbBool buildInsideParent,
00574 SbBool getMouseInput,
00575 SbBool getKeyboardInput,
00576 SoGuiRenderArea* guiRenderArea );
00577
00578
00579 SoWinRenderArea( SoWidget parent,
00580 const char* name,
00581 SbBool buildInsideParent,
00582 SbBool getMouseInput,
00583 SbBool getKeyboardInput,
00584 SbBool buildNow,
00585 SbBool sync,
00586 SoGuiRenderArea* guiRenderArea );
00587
00588
00589 SoWinRenderArea( SoWidget parent,
00590 const char* name,
00591 SbBool buildInsideParent,
00592 SbBool getMouseInput,
00593 SbBool getKeyboardInput,
00594 SbBool buildNow,
00595 SoGuiRenderArea* guiRenderArea );
00596
00597
00598
00599
00600
00601
00602
00603
00604 virtual void redraw();
00605 virtual void actualRedraw();
00606
00607
00608
00609
00610 virtual void processEvent( XAnyEvent* anyevent );
00611 virtual void initGraphic();
00612 virtual void sizeChanged( const SbVec2s& );
00613 virtual void posChanged( const SbVec2i32&, const SbVec2i32& );
00614 virtual void widgetChanged( SoWidget );
00615
00616 SoWidget buildWidget( SoWidget parent );
00617
00618
00619 virtual SbString getDefaultWidgetName() const;
00620 virtual SbString getDefaultTitle() const;
00621 virtual SbString getDefaultIconTitle() const;
00622
00623
00624 SbPList* m_deviceList;
00625
00626
00627 SoWinRenderAreaEventCB *defaultAppEventHandler;
00628 void *defaultAppEventHandlerData;
00629 SoWinRenderAreaEventCB *appEventHandler;
00630 void *appEventHandlerData;
00631
00632 SbBool invokeAppCB( XAnyEvent* anyevent );
00633 SbBool processInventorEvent( XAnyEvent* anyevent );
00634 const SoEvent* translateAnyEvent( XAnyEvent* anyevent );
00635
00636
00637 SoWinRenderAreaRenderCB *appPostRenderCB;
00638 void *appPostRenderData;
00639
00640 private:
00641
00642 SbBool m_isFloatingPointRendering;
00643 FloatColorBufferSize m_floatingPointRenderingPrecision;
00644
00645 #if defined(__linux__)
00646 XColor* m_mapColors;
00647 int m_mapColorNum;
00648 #endif
00649
00650 SoWinMouse* m_mouseDevice;
00651 SoWinKeyboard* m_keybdDevice;
00652 void reinstallDevices( SoWidget newWidget );
00653
00654 static void selectionChangeCB( void* userData, SoSelection* s );
00655 SoWidget m_deviceWidget;
00656
00657
00658 SbBool m_firstEvent;
00659
00660 private:
00661 static void windowEventCB( SoWidget w, SoWinRenderArea* wra, XAnyEvent* e, Boolean* b );
00662 private:
00663 static void renderCB( void* v, SoSceneManager* sm );
00664
00665 static void visibilityChangeCB( void* pt, SbBool visible );
00666
00667
00668 void constructorCommon( SbBool getMouseInput,
00669 SbBool getKeyboardInput,
00670 SbBool buildNow );
00671
00672
00673 void constructorCommon2( SbBool getMouseInput,
00674 SbBool getKeyboardInput,
00675 SbBool buildNow );
00676
00677 void activate();
00678 void deactivate();
00679
00680 int inRedraw;
00681
00682 SoGuiRenderArea* m_guiRenderArea;
00683
00684
00685
00686
00687
00688 static SbBool s_abortRenderCallback(SoAction*,void*);
00689
00690 SoAntialiasingParameters* m_accumulationParameters;
00691
00692 bool m_firstStdRedraw;
00693 bool m_firstConnectedRedraw;
00694 SoTimerSensor* m_viewerUpdaterSensor;
00695 static void viewerUpdaterCB( void*, SoSensor* );
00696 void updateFirstFrame();
00697
00698 };
00699
00700 #include <Inventor/Win/SoWinEndStrict.h>
00701
00702 #endif
00703
00704
00705