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 _WIN32
00054 #  include <Inventor/Win/SoWinRenderArea.h>
00055 #else
00056 
00057 #ifndef _SO_XT_RENDER_AREA_H_
00058 #define _SO_XT_RENDER_AREA_H_
00059 
00060 #include <climits>
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 
00137 class  SoXtRenderArea : public SoXtGLWidget
00138 {
00139  public:
00140 
00145   SoXtRenderArea( SoWidget parent = NULL,
00146                   const char* name = NULL,
00147                   SbBool buildInsideParent = TRUE,
00148                   SbBool getMouseInput = TRUE,
00149                   SbBool getKeyboardInput = TRUE );
00153   ~SoXtRenderArea();
00154 
00158   virtual void setSceneGraph( SoNode* newScene );
00159 
00163   virtual SoNode* getSceneGraph();
00164 
00170   void registerDevice( SoXtDevice* d );
00171 
00177   void unregisterDevice( SoXtDevice* d );
00178 
00185   void setBackgroundColor( const SbColor& c );
00186 
00190   SbColor getBackgroundColor() const { return m_guiRenderArea->getBackgroundColor(); }
00191 
00196   void setBackgroundIndex( int index ) { m_guiRenderArea->setBackgroundIndex( index ); }
00197 
00201   int getBackgroundIndex() const { return m_guiRenderArea->getBackgroundIndex(); }
00202 
00207   void setColorMap( int startIndex, int num, const SbColor* colors );
00208 
00212   void setViewportRegion( const SbViewportRegion& newRegion )
00213   { m_guiRenderArea->setViewportRegion( newRegion ); }
00214 
00218   const SbViewportRegion& getViewportRegion() const
00219   { return m_guiRenderArea->getViewportRegion(); }
00220 
00230   void setTransparencyType( SoGLRenderAction::TransparencyType type );
00231 
00236   SoGLRenderAction::TransparencyType  getTransparencyType() const
00237   { return m_guiRenderArea->getTransparencyType(); }
00238 
00247   void setFastEditSavePolicy( SoGLRenderAction::FastEditSavePolicy policy,
00248                               SbBool fastEditDelayedObjects = FALSE);
00249 
00253   SoGLRenderAction::FastEditSavePolicy  getFastEditSavePolicy() const
00254   { return m_guiRenderArea->getFastEditSavePolicy(); }
00255 
00271   void setInvalidateCacheMode( SoGLRenderAction::InvalidateCacheMode icm );
00272 
00276   SoGLRenderAction::InvalidateCacheMode getInvalidateCacheMode();
00277 
00285   void setClearBeforeRender( SbBool trueOrFalse, SbBool zbTrueOrFalse = TRUE )
00286   { m_guiRenderArea->setClearBeforeRender( trueOrFalse, zbTrueOrFalse ); }
00287 
00291   SbBool isClearBeforeRender() const { return m_guiRenderArea->isClearBeforeRender(); }
00292 
00297   SbBool isClearZBufferBeforeRender() const { return m_guiRenderArea->isClearZBufferBeforeRender(); }
00298 
00303   void setAutoRedraw( SbBool trueOrFalse );
00304 
00309   SbBool isAutoRedraw() const { return m_guiRenderArea->isAutoRedraw(); }
00310 
00314   void setRedrawPriority( uint32_t priority ) { m_guiRenderArea->setRedrawPriority(priority); }
00315 
00319   uint32_t getRedrawPriority() const { return m_guiRenderArea->getRedrawPriority(); }
00320 
00324   static uint32_t getDefaultRedrawPriority() { return SoSceneManager::getDefaultRedrawPriority(); }
00325 
00330   void render() { redraw(); }
00331 
00336   void scheduleRedraw();
00337 
00348   void redrawOnSelectionChange( SoSelection* s );
00349 
00361   void setEventCallback( SoXtRenderAreaEventCB* fcn, void* userData = NULL );
00362 
00369   void setSceneManager( SoSceneManager* sm );
00370 
00377   SoSceneManager* getSceneManager() const { return m_guiRenderArea->getSceneManager(); }
00378 
00388   void setGLRenderAction( SoGLRenderAction* ra );
00389 
00393   SoGLRenderAction* getGLRenderAction() const { return m_guiRenderArea->getGLRenderAction(); }
00394 
00399   const SbGLShareContext getShareContext();
00400 
00416   void setPostRenderCallback( SoXtRenderAreaRenderCB* fcn, void* userData = NULL )
00417   { appPostRenderCB = fcn; appPostRenderData = userData; }
00418 
00423   SoXtRenderAreaRenderCB* getPostRenderCallback( const void* &userData ) const
00424   { userData = appPostRenderData; return appPostRenderCB; }
00425 
00440   void setFloatingColorBuffer( SbBool enable, FloatColorBufferSize size = FLOAT_16_COLOR_BUFFER );
00441 
00446   void getFloatingColorBuffer( SbBool& enable, FloatColorBufferSize& size );
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 #if 1             SoDEPRECATED
00485   void setAntialiasing( SbBool smoothing, int numPasses );
00486   using SoXtGLWidget::setAntialiasing;
00487 SoDEPRECATED
00492   void getAntialiasing( SbBool& smoothing, int& numPasses ) const;
00493 
00494 #endif 
00496 private:
00497 
00498   SoXtRenderArea( SoWidget parent,
00499                   const char* name,
00500                   SbBool buildInsideParent,
00501                   SbBool getMouseInput,
00502                   SbBool getKeyboardInput,
00503                   SoGuiAlgoViewers* guiAlgos );
00504 
00505   SoXtRenderArea( SoWidget parent,
00506                   const char* name,
00507                   SbBool buildInsideParent,
00508                   SbBool getMouseInput,
00509                   SbBool getKeyboardInput,
00510                   SbBool buildNow,
00511                   SbBool sync,
00512                   SoGuiAlgoViewers* guiAlgos );
00513 
00514   SoXtRenderArea( SoWidget parent,
00515                   const char* name,
00516                   SbBool buildInsideParent,
00517                   SbBool getMouseInput,
00518                   SbBool getKeyboardInput,
00519                   SbBool buildNow,
00520                   SoGuiAlgoViewers* guiAlgos );
00524   SoGuiAlgoViewers* getGuiAlgoViewers() const { return (SoGuiAlgoViewers*)m_guiRenderArea; }
00525 
00526  private:
00527   void setStereoMode( SoCamera::StereoMode stMode );
00528   void setStereoElement();
00529 
00530   SoGuiRenderArea* getGuiRenderArea() const;
00531 
00532   SbBool isFloatingColorBufferSupported();
00533 
00534   virtual SbBool isInteractive() const;
00535 
00536   SoXtRenderArea();
00537 
00538   SoXtRenderArea( SoWidget parent,
00539                   const char* name,
00540                   SbBool buildInsideParent,
00541                   SbBool getMouseInput,
00542                   SbBool getKeyboardInput,
00543                   SbBool buildNow,
00544                   SbBool sync );
00545 
00546   
00547   
00548   float stereoBalance, stereoOffset;
00549   SbBool stereoAbsoluteAdjustments;
00550   SoCamera::StereoMode stereoMode;
00551   SbBool stereoReversed;
00552 
00553  private:
00554 
00555   
00556   
00557   
00558   
00559 
00560   SoXtRenderArea( SoWidget parent,
00561                   const char* name,
00562                   SbBool buildInsideParent,
00563                   SbBool getMouseInput,
00564                   SbBool getKeyboardInput,
00565                   SbBool buildNow );
00566 
00567   
00568   
00569   SoXtRenderArea( SoWidget parent,
00570                   const char* name,
00571                   SbBool buildInsideParent,
00572                   SbBool getMouseInput,
00573                   SbBool getKeyboardInput,
00574                   SoGuiRenderArea* guiRenderArea );
00575 
00576   SoXtRenderArea( SoWidget parent,
00577                   const char* name,
00578                   SbBool buildInsideParent,
00579                   SbBool getMouseInput,
00580                   SbBool getKeyboardInput,
00581                   SbBool buildNow,
00582                   SbBool sync,
00583                   SoGuiRenderArea* guiRenderArea );
00584 
00585   SoXtRenderArea( SoWidget parent,
00586                   const char* name,
00587                   SbBool buildInsideParent,
00588                   SbBool getMouseInput,
00589                   SbBool getKeyboardInput,
00590                   SbBool buildNow,
00591                   SoGuiRenderArea* guiRenderArea );
00592 
00593   
00594   
00595   
00596   
00597   
00598   
00599   
00600   
00601   virtual void redraw();
00602   virtual void actualRedraw();
00603 
00604   
00605   
00606   
00607   virtual void processEvent( XAnyEvent* anyevent );
00608   virtual void initGraphic();
00609   virtual void sizeChanged( const SbVec2s& );
00610   virtual void posChanged( const SbVec2i32&, const SbVec2i32& );
00611   virtual void widgetChanged( SoWidget w );
00612 
00613   SoWidget buildWidget( SoWidget parent );
00614 
00615   
00616   virtual SbString getDefaultWidgetName() const;
00617   virtual SbString getDefaultTitle() const;
00618   virtual SbString getDefaultIconTitle() const;
00619 
00620   
00621   SbPList* m_deviceList;    
00622 
00623   
00624   SoXtRenderAreaEventCB* defaultAppEventHandler;
00625   void* defaultAppEventHandlerData;
00626   SoXtRenderAreaEventCB* appEventHandler;
00627   void* appEventHandlerData;
00628 
00629   
00630   SbBool invokeAppCB( XAnyEvent* anyevent );
00631   SbBool processInventorEvent( XAnyEvent* anyevent );
00632   const SoEvent* translateAnyEvent( XAnyEvent* anyevent );
00633 
00634   
00635   SoXtRenderAreaRenderCB* appPostRenderCB;
00636   void* appPostRenderData;
00637 
00638 private:
00639   
00640   XColor* m_mapColors; 
00641   int m_mapColorNum; 
00642 
00643   SoXtMouse* m_mouseDevice;
00644   SoXtKeyboard* m_keybdDevice;
00645   void reinstallDevices( SoWidget newWidget );
00646 
00647   static void selectionChangeCB( void* p, SoSelection* s );
00648   SoWidget m_deviceWidget;
00649 
00650   
00651   SbBool m_firstEvent; 
00652   static void windowEventCB( SoWidget w, SoXtRenderArea* p, XAnyEvent* xe, Boolean* b );
00653   static void renderCB( void*  v, SoSceneManager* sm );
00654 
00655   static void visibilityChangeCB( void* pt, SbBool visible );
00656   void activate();             
00657   void deactivate();           
00658 
00659   
00660   void constructorCommon( SbBool getMouseInput, SbBool getKeyboardInput, SbBool buildNow );
00661 
00662   
00663   void constructorCommon2( SbBool getMouseInput,
00664                           SbBool getKeyboardInput,
00665                           SbBool buildNow );
00666 
00667   SbVec2i32 getWindowPosition() { return SbVec2i32( INT_MAX, INT_MAX ); }
00668 
00669   SbConfig* m_vrConfig;
00670   SbBool m_forceRedraw;
00671   SbBool m_forceSyncRedraw;
00672 
00673   ScTracking* m_tracking;
00674 
00675   SoGuiRenderArea* m_guiRenderArea; 
00676 
00677   
00678   
00679   
00680   
00681   static SbBool s_abortRenderCallback(SoAction*,void*);
00682 
00683   SoAntialiasingParameters* m_accumulationParameters;
00684 
00685   bool m_firstStdRedraw;
00686   bool m_firstConnectedRedraw;
00687   SoTimerSensor* m_viewerUpdaterSensor;
00688   static void viewerUpdaterCB( void*, SoSensor* );
00689   void updateFirstFrame();
00690 };
00691 
00692 
00693 #endif 
00694 
00695 #endif
00696 
00697