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 <climits>
00032
00033 #include <Inventor/SbColor.h>
00034 #include <Inventor/sensors/SoNodeSensor.h>
00035 #include <Inventor/SoSceneManager.h>
00036 #include <Inventor/Win/SoWinGLWidget.h>
00037 #include <Inventor/actions/SoGLRenderAction.h>
00038
00039 #include <Inventor/nodes/SoCamera.h>
00040 #include <Inventor/elements/SoStereoElement.h>
00041 #include <Inventor/nodes/SoFullSceneAntialiasing.h>
00042 #include <Inventor/SbElapsedTime.h>
00043
00044
00045 #include <Inventor/Gui/SoGuiRenderArea.h>
00046
00047 class SoHandleEventAction;
00048 class SoWinDevice;
00049 class SoNode;
00050 class SoWinMouse;
00051 class SoWinKeyboard;
00052 class SoSelection;
00053 class SoWinRenderArea;
00054 class SoGuiAlgoViewers;
00055 class SoAntialiasingParameters;
00056
00060 typedef SbBool SoWinRenderAreaEventCB( void* userData, XAnyEvent* anyevent );
00061
00065 typedef SbBool SoWinRenderAreaRenderCB( void* userData, SoWinRenderArea* rendArea );
00066
00068
00069
00070
00071
00072
00074
00109 class SoWinRenderArea : public SoWinGLWidget
00110 {
00111 public:
00112
00121 SoWinRenderArea( SoWidget parent = NULL,
00122 const char* name = NULL,
00123 SbBool buildInsideParent = TRUE,
00124 SbBool getMouseInput = TRUE,
00125 SbBool getKeyboardInput = TRUE );
00129 ~SoWinRenderArea();
00130
00136 virtual void setSceneGraph( SoNode *newScene );
00137
00141 virtual SoNode* getSceneGraph();
00142
00149 void registerDevice( SoWinDevice* d );
00156 void unregisterDevice( SoWinDevice* d );
00157
00164 void setBackgroundColor( const SbColor& c );
00165
00169 SbColor getBackgroundColor() const { return m_guiRenderArea->getBackgroundColor(); }
00170
00175 void setBackgroundIndex( int index ) { m_guiRenderArea->setBackgroundIndex( index ); }
00176
00180 int getBackgroundIndex() const { return m_guiRenderArea->getBackgroundIndex(); }
00181
00187 void setColorMap( int startIndex, int num, const SbColor* colors );
00188
00192 void setViewportRegion( const SbViewportRegion& newRegion )
00193 { m_guiRenderArea->setViewportRegion( newRegion ); }
00194
00198 const SbViewportRegion &getViewportRegion() const
00199 { return m_guiRenderArea->getViewportRegion(); }
00200
00210 void setTransparencyType( SoGLRenderAction::TransparencyType type );
00211
00216 SoGLRenderAction::TransparencyType getTransparencyType() const
00217 { return m_guiRenderArea->getTransparencyType(); }
00218
00227 void setFastEditSavePolicy( SoGLRenderAction::FastEditSavePolicy policy,
00228 SbBool fastEditDelayedObjects = FALSE);
00229
00233 SoGLRenderAction::FastEditSavePolicy getFastEditSavePolicy() const
00234 { return m_guiRenderArea->getFastEditSavePolicy(); }
00235
00251 void setInvalidateCacheMode( SoGLRenderAction::InvalidateCacheMode icm );
00252
00256 SoGLRenderAction::InvalidateCacheMode getInvalidateCacheMode();
00257
00265 void setClearBeforeRender( SbBool trueOrFalse, SbBool zbTrueOrFalse = TRUE )
00266 { m_guiRenderArea->setClearBeforeRender( trueOrFalse, zbTrueOrFalse ); }
00267
00271 SbBool isClearBeforeRender() const { return m_guiRenderArea->isClearBeforeRender(); }
00272
00277 SbBool isClearZBufferBeforeRender() const { return m_guiRenderArea->isClearZBufferBeforeRender(); }
00278
00286 void setAutoRedraw( SbBool trueOrFalse );
00287
00292 SbBool isAutoRedraw() const { return m_guiRenderArea->isAutoRedraw(); }
00293
00297 void setRedrawPriority( unsigned long priority ) { m_guiRenderArea->setRedrawPriority(priority); }
00298
00302 unsigned long getRedrawPriority() const { return m_guiRenderArea->getRedrawPriority(); }
00303
00307 static unsigned long getDefaultRedrawPriority() { return SoSceneManager::getDefaultRedrawPriority(); }
00308
00313 void render() { redraw(); }
00314
00319 void scheduleRedraw();
00320
00331 void redrawOnSelectionChange( SoSelection* s );
00332
00370 void setEventCallback( SoWinRenderAreaEventCB* fcn, void* userData = NULL );
00371
00378 void setSceneManager( SoSceneManager* sm );
00379
00386 SoSceneManager* getSceneManager() const { return m_guiRenderArea->getSceneManager(); }
00387
00397 void setGLRenderAction( SoGLRenderAction* ra );
00398
00402 SoGLRenderAction* getGLRenderAction() const { return m_guiRenderArea->getGLRenderAction(); }
00403
00408 const SbGLShareContext getShareContext();
00409
00425 void setPostRenderCallback( SoWinRenderAreaRenderCB* fcn, void* userData = NULL )
00426 { appPostRenderCB = fcn; appPostRenderData = userData; }
00427
00433 SoWinRenderAreaRenderCB* getPostRenderCallback( const void* &userData ) const
00434 { userData = appPostRenderData; return appPostRenderCB; }
00435
00437 void setFloatingColorBuffer( SbBool enable,
00438 FloatColorBufferSize size = FLOAT_16_COLOR_BUFFER );
00439
00441 void getFloatingColorBuffer( SbBool& enable, FloatColorBufferSize& size );
00442
00446 static SbBool isFloatingColorBufferSupported();
00447
00451 void sendEvent( XAnyEvent* anEvent );
00452
00458 virtual void setMPEGRecorder( SoMPEGRenderer* recorder )
00459 { m_guiRenderArea->setMPEGRecorder( recorder ); }
00460
00464 virtual SoMPEGRenderer* getMPEGRecorder() const
00465 { return m_guiRenderArea->getMPEGRecorder(); }
00466
00467 private:
00468 SoWinRenderArea( SoWidget parent,
00469 const char* name,
00470 SbBool buildInsideParent,
00471 SbBool getMouseInput,
00472 SbBool getKeyboardInput,
00473 SoGuiAlgoViewers* guiAlgos );
00474
00475
00476 SoWinRenderArea( SoWidget parent,
00477 const char* name,
00478 SbBool buildInsideParent,
00479 SbBool getMouseInput,
00480 SbBool getKeyboardInput,
00481 SbBool buildNow,
00482 SbBool sync,
00483 SoGuiAlgoViewers* guiAlgos );
00484
00485
00486 SoWinRenderArea( SoWidget parent,
00487 const char* name,
00488 SbBool buildInsideParent,
00489 SbBool getMouseInput,
00490 SbBool getKeyboardInput,
00491 SbBool buildNow,
00492 SoGuiAlgoViewers* guiAlgos );
00493
00497 SoGuiAlgoViewers* getGuiAlgoViewers() const { return (SoGuiAlgoViewers*)m_guiRenderArea; }
00498
00499 private:
00500
00501 SoGuiRenderArea* getGuiRenderArea() const;
00502
00503 void setStereoMode( SoCamera::StereoMode stMode );
00504 void setStereoElement();
00505
00506 virtual void setDoubleBuffer( SbBool db );
00507
00508 virtual SbBool isInteractive() const;
00509
00510 SoWinRenderArea( SoWidget parent,
00511 const char* name,
00512 SbBool buildInsideParent,
00513 SbBool getMouseInput,
00514 SbBool getKeyboardInput,
00515 SbBool buildNow,
00516 SbBool sync );
00517
00518
00519
00520 float stereoBalance, stereoOffset;
00521 SbBool stereoAbsoluteAdjustments;
00522 SoCamera::StereoMode stereoMode;
00523 SbBool stereoReversed;
00524
00525 private:
00526
00527
00528
00529
00530
00531
00532 SoWinRenderArea( SoWidget parent,
00533 const char* name,
00534 SbBool buildInsideParent,
00535 SbBool getMouseInput,
00536 SbBool getKeyboardInput,
00537 SbBool buildNow );
00538
00539
00540
00541 SoWinRenderArea( SoWidget parent,
00542 const char* name,
00543 SbBool buildInsideParent,
00544 SbBool getMouseInput,
00545 SbBool getKeyboardInput,
00546 SoGuiRenderArea* guiRenderArea );
00547
00548
00549 SoWinRenderArea( SoWidget parent,
00550 const char* name,
00551 SbBool buildInsideParent,
00552 SbBool getMouseInput,
00553 SbBool getKeyboardInput,
00554 SbBool buildNow,
00555 SbBool sync,
00556 SoGuiRenderArea* guiRenderArea );
00557
00558
00559 SoWinRenderArea( SoWidget parent,
00560 const char* name,
00561 SbBool buildInsideParent,
00562 SbBool getMouseInput,
00563 SbBool getKeyboardInput,
00564 SbBool buildNow,
00565 SoGuiRenderArea* guiRenderArea );
00566
00567
00568
00569
00570
00571
00572
00573
00574 virtual void redraw();
00575 virtual void actualRedraw();
00576
00577
00578
00579
00580 virtual void processEvent( XAnyEvent* anyevent );
00581 virtual void initGraphic();
00582 virtual void sizeChanged( const SbVec2s& );
00583 virtual void posChanged( const SbVec2i32&, const SbVec2i32& );
00584 virtual void widgetChanged( SoWidget );
00585
00586 SoWidget buildWidget( SoWidget parent );
00587
00588
00589 virtual SbString getDefaultWidgetName() const;
00590 virtual SbString getDefaultTitle() const;
00591 virtual SbString getDefaultIconTitle() const;
00592
00593
00594 SbPList* m_deviceList;
00595
00596
00597 SoWinRenderAreaEventCB *defaultAppEventHandler;
00598 void *defaultAppEventHandlerData;
00599 SoWinRenderAreaEventCB *appEventHandler;
00600 void *appEventHandlerData;
00601
00602 SbBool invokeAppCB( XAnyEvent* anyevent );
00603 SbBool processInventorEvent( XAnyEvent* anyevent );
00604 const SoEvent* translateAnyEvent( XAnyEvent* anyevent );
00605
00606
00607 SoWinRenderAreaRenderCB *appPostRenderCB;
00608 void *appPostRenderData;
00609
00610 private:
00611
00612 SbBool m_isFloatingPointRendering;
00613 FloatColorBufferSize m_floatingPointRenderingPrecision;
00614
00615 #if defined(__linux__)
00616 XColor* m_mapColors;
00617 int m_mapColorNum;
00618 #endif
00619
00620 SoWinMouse* m_mouseDevice;
00621 SoWinKeyboard* m_keybdDevice;
00622 void reinstallDevices( SoWidget newWidget );
00623
00624 static void selectionChangeCB( void* userData, SoSelection* s );
00625 SoWidget m_deviceWidget;
00626
00627
00628 SbBool m_firstEvent;
00629
00630 private:
00631 static void windowEventCB( SoWidget w, SoWinRenderArea* wra, XAnyEvent* e, Boolean* b );
00632 private:
00633 static void renderCB( void* v, SoSceneManager* sm );
00634
00635 static void visibilityChangeCB( void* pt, SbBool visible );
00636
00637
00638 void constructorCommon( SbBool getMouseInput,
00639 SbBool getKeyboardInput,
00640 SbBool buildNow );
00641
00642
00643 void constructorCommon2( SbBool getMouseInput,
00644 SbBool getKeyboardInput,
00645 SbBool buildNow );
00646
00647 void activate();
00648 void deactivate();
00649
00650 SbVec2i32 getWindowPosition() { return SbVec2i32( INT_MAX, INT_MAX ); }
00651
00652 int inRedraw;
00653
00654 SoGuiRenderArea* m_guiRenderArea;
00655
00656
00657
00658
00659
00660 static SbBool s_abortRenderCallback(SoAction*,void*);
00661
00662 SoAntialiasingParameters* m_accumulationParameters;
00663
00664 bool m_firstStdRedraw;
00665 bool m_firstConnectedRedraw;
00666 SoTimerSensor* m_viewerUpdaterSensor;
00667 static void viewerUpdaterCB( void*, SoSensor* );
00668 void updateFirstFrame();
00669
00670 };
00671
00672 #include <Inventor/Win/SoWinEndStrict.h>
00673
00674 #endif
00675
00676
00677