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 #ifndef _SO_QT_RENDERAREA_
00028 #define _SO_QT_RENDERAREA_
00029
00030 #include <QtOpenGL/QGLColormap>
00031
00032 #include <Inventor/Qt/OivQtCompat.h>
00033 #include <Inventor/Qt/SoQtGLWidget.h>
00034
00035 #include <Inventor/SbColor.h>
00036 #include <Inventor/SoSceneManager.h>
00037 #include <Inventor/actions/SoGLRenderAction.h>
00038 #include <Inventor/nodes/SoCamera.h>
00039 #include <Inventor/SbElapsedTime.h>
00040
00041 #include <Inventor/Gui/SoGuiRenderArea.h>
00042
00043 class SoSelection;
00044 class SoQtDevice;
00045 class SoNode;
00046 class SoQtMouse;
00047 class SoQtKeyboard;
00048 class SoQtRenderArea;
00049 class SoGuiAlgoViewers;
00050 class SoTimerSensor;
00051 class SoAntialiasingParameters;
00052
00056 typedef SbBool SoQtRenderAreaEventCB( void* userData, QEvent* anyevent );
00057
00061 typedef SbBool SoQtRenderAreaRenderCB( void* userData, SoQtRenderArea* rendArea );
00062
00122 class SoQtRenderArea : public SoQtGLWidget
00123 {
00124 Q_OBJECT
00125
00126 public:
00131 SoQtRenderArea( QWidget* parent = NULL,
00132 const char* name = NULL,
00133 SbBool buildInsideParent = TRUE,
00134 SbBool getMouseInput = TRUE,
00135 SbBool getKeyboardInput = TRUE );
00139 ~SoQtRenderArea();
00140
00144 virtual void setSceneGraph( SoNode* newScene );
00145
00149 virtual SoNode* getSceneGraph();
00150
00156 void registerDevice( SoQtDevice* d );
00157
00163 void unregisterDevice( SoQtDevice* d );
00164
00172 void setBackgroundColor( const SbColor& c );
00173
00177 const SbColor& getBackgroundColor() const { return m_guiRenderArea->getBackgroundColor(); }
00178
00183 void setBackgroundIndex( int index ) { m_guiRenderArea->setBackgroundIndex( index ); }
00184
00188 int getBackgroundIndex() const { return m_guiRenderArea->getBackgroundIndex(); }
00189
00194 void setColorMap( QGLColormap* cmap );
00195
00199 void setViewportRegion( const SbViewportRegion& newRegion )
00200 { m_guiRenderArea->setViewportRegion( newRegion ); }
00201
00205 const SbViewportRegion &getViewportRegion() const
00206 { return m_guiRenderArea->getViewportRegion(); }
00207
00217 void setTransparencyType( SoGLRenderAction::TransparencyType type );
00218
00223 SoGLRenderAction::TransparencyType getTransparencyType() const
00224 { return m_guiRenderArea->getTransparencyType(); }
00225
00234 void setFastEditSavePolicy( SoGLRenderAction::FastEditSavePolicy policy,
00235 SbBool fastEditDelayedObjects = FALSE);
00236
00240 SoGLRenderAction::FastEditSavePolicy getFastEditSavePolicy() const
00241 { return m_guiRenderArea->getFastEditSavePolicy(); }
00242
00259 void setSortedTrianglesSortFrequency( int angle );
00260
00265 int getSortedTrianglesSortFrequency();
00266
00279 void setSortedTrianglesNumCaches( int numCaches );
00280
00284 int getSortedTrianglesNumCaches();
00285
00301 void setInvalidateCacheMode( SoGLRenderAction::InvalidateCacheMode icm );
00302
00306 SoGLRenderAction::InvalidateCacheMode getInvalidateCacheMode();
00307
00315 void setClearBeforeRender( SbBool trueOrFalse, SbBool zbTrueOrFalse = TRUE )
00316 { m_guiRenderArea->setClearBeforeRender( trueOrFalse, zbTrueOrFalse ); }
00317
00321 SbBool isClearBeforeRender() const { return m_guiRenderArea->isClearBeforeRender(); }
00322
00327 SbBool isClearZBufferBeforeRender() const { return m_guiRenderArea->isClearZBufferBeforeRender(); }
00328
00336 void setAutoRedraw( SbBool trueOrFalse );
00337
00342 SbBool isAutoRedraw() const { return m_guiRenderArea->isAutoRedraw(); }
00343
00347 void setRedrawPriority( uint32_t priority ) { m_guiRenderArea->setRedrawPriority( priority ); }
00348
00352 uint32_t getRedrawPriority() const { return m_guiRenderArea->getRedrawPriority(); }
00353
00357 static uint32_t getDefaultRedrawPriority() { return SoSceneManager::getDefaultRedrawPriority(); }
00358
00363 void render() { redraw(); }
00364
00369 void scheduleRedraw();
00370
00381 void redrawOnSelectionChange( SoSelection* s );
00382
00394 void setEventCallback( SoQtRenderAreaEventCB *fcn, void* userData = NULL );
00395
00402 void setSceneManager( SoSceneManager* sm );
00403
00410 SoSceneManager* getSceneManager() const { return m_guiRenderArea->getSceneManager(); }
00411
00420 void setGLRenderAction( SoGLRenderAction* ra );
00421
00427 SoGLRenderAction* getGLRenderAction() const { return m_guiRenderArea->getGLRenderAction(); }
00428
00429 #if 1 SoDEPRECATED
00435 void setOverlaySceneGraph( SoNode* newScene );
00436 SoDEPRECATED
00442 SoNode* getOverlaySceneGraph() { return m_guiRenderArea->getOverlaySceneGraph(); }
00443 SoDEPRECATED
00449 void setOverlayBackgroundIndex( int index ) { m_guiRenderArea->setOverlayBackgroundIndex( index ); }
00450 SoDEPRECATED
00455 int getOverlayBackgroundIndex() const { return m_guiRenderArea->getOverlayBackgroundIndex(); }
00456 SoDEPRECATED
00462 void setOverlayColorMap( QGLColormap* cmap );
00463 SoDEPRECATED
00469 void setClearBeforeOverlayRender( SbBool trueOrFalse )
00470 {
00471 m_guiRenderArea->setClearBeforeOverlayRender( trueOrFalse );
00472 }
00473 SoDEPRECATED
00478 SbBool isClearBeforeOverlayRender() const { return m_guiRenderArea->isClearBeforeOverlayRender(); }
00479 SoDEPRECATED
00485 void renderOverlay() { redrawOverlay(); }
00486 SoDEPRECATED
00492 void scheduleOverlayRedraw();
00493 SoDEPRECATED
00505 void redrawOverlayOnSelectionChange( SoSelection* s );
00506 SoDEPRECATED
00514 void setOverlaySceneManager( SoSceneManager* sm ) { m_guiRenderArea->setOverlaySceneManager( sm ); }
00515 SoDEPRECATED
00523 SoSceneManager* getOverlaySceneManager() const { return m_guiRenderArea->getOverlaySceneManager(); }
00524 SoDEPRECATED
00529 void setOverlayGLRenderAction( SoGLRenderAction* ra ) { m_guiRenderArea->setOverlayGLRenderAction( ra ); }
00530 SoDEPRECATED
00535 SoGLRenderAction* getOverlayGLRenderAction() const { return m_guiRenderArea->getOverlayGLRenderAction(); }
00536 #endif
00545 const SbGLShareContext getShareContext();
00546
00562 void setPostRenderCallback( SoQtRenderAreaRenderCB *fcn, void* userData = NULL )
00563 { appPostRenderCB = fcn; appPostRenderData = userData; }
00564
00569 SoQtRenderAreaRenderCB *getPostRenderCallback( const void* &userData ) const
00570 { userData = appPostRenderData; return appPostRenderCB; }
00571
00585 void setFloatingColorBuffer( SbBool enable,
00586 FloatColorBufferSize size = FLOAT_16_COLOR_BUFFER );
00587
00591 void getFloatingColorBuffer( SbBool& enable, FloatColorBufferSize& size );
00592
00596 static SbBool isFloatingColorBufferSupported();
00597
00601 void sendEvent( QEvent* anEvent );
00602
00608 virtual void setMPEGRecorder( SoMPEGRenderer* recorder )
00609 { m_guiRenderArea->setMPEGRecorder( recorder ); }
00610
00614 virtual SoMPEGRenderer* getMPEGRecorder() const
00615 { return m_guiRenderArea->getMPEGRecorder(); }
00616
00617 #if 1 SoDEPRECATED
00620 void setColorMap( int startIndex, int num, const SbColor* colors );
00621 SoDEPRECATED
00623 void setOverlayColorMap( int startIndex, int num, const SbColor* colors );
00624
00625 #endif
00627 #if 1 SoDEPRECATED
00648 void setAntialiasing( SbBool smoothing, int numPasses );
00649
00650 using SoQtGLWidget::setAntialiasing;
00651 SoDEPRECATED
00656 void getAntialiasing( SbBool& smoothing, int& numPasses) const;
00657
00658 #endif
00661 private:
00662 SoQtRenderArea( QWidget* parent,
00663 const char* name,
00664 SbBool buildInsideParent,
00665 SbBool getMouseInput,
00666 SbBool getKeyboardInput,
00667 SoGuiAlgoViewers* guiAlgos );
00668
00669 SoQtRenderArea( QWidget* parent,
00670 const char* name,
00671 SbBool buildInsideParent,
00672 SbBool getMouseInput,
00673 SbBool getKeyboardInput,
00674 SbBool buildNow,
00675 SbBool sync,
00676 SoGuiAlgoViewers* guiAlgos );
00677
00678 SoQtRenderArea( QWidget* parent,
00679 const char* name,
00680 SbBool buildInsideParent,
00681 SbBool getMouseInput,
00682 SbBool getKeyboardInput,
00683 SbBool buildNow,
00684 SoGuiAlgoViewers* guiAlgos );
00685
00689 SoGuiAlgoViewers* getGuiAlgoViewers() const { return (SoGuiAlgoViewers*)m_guiRenderArea; }
00690
00691 private:
00692 SoGuiRenderArea* getGuiRenderArea() const;
00693
00694 void setStereoMode( SoCamera::StereoMode stMode );
00695 void setStereoElement();
00696 virtual SbBool isInteractive() const;
00697 void redrawCleanUp();
00698
00699 SoQtRenderArea( QWidget* parent,
00700 const char* name,
00701 SbBool buildInsideParent,
00702 SbBool getMouseInput,
00703 SbBool getKeyboardInput,
00704 SbBool buildNow,
00705 SbBool sync );
00706
00707
00708 float stereoBalance, stereoOffset;
00709 SbBool stereoAbsoluteAdjustments;
00710 SoCamera::StereoMode stereoMode;
00711 SbBool stereoReversed;
00712
00713 private:
00714
00715
00716
00717
00718
00719
00720 SoQtRenderArea( QWidget* parent,
00721 const char* name,
00722 SbBool buildInsideParent,
00723 SbBool getMouseInput,
00724 SbBool getKeyboardInput,
00725 SbBool buildNow );
00726
00727
00728
00729 SoQtRenderArea( QWidget* parent,
00730 const char* name,
00731 SbBool buildInsideParent,
00732 SbBool getMouseInput,
00733 SbBool getKeyboardInput,
00734 SoGuiRenderArea* guiRenderArea );
00735
00736 SoQtRenderArea( QWidget* parent,
00737 const char* name,
00738 SbBool buildInsideParent,
00739 SbBool getMouseInput,
00740 SbBool getKeyboardInput,
00741 SbBool buildNow,
00742 SbBool sync,
00743 SoGuiRenderArea* guiRenderArea );
00744
00745 SoQtRenderArea( QWidget* parent,
00746 const char* name,
00747 SbBool buildInsideParent,
00748 SbBool getMouseInput,
00749 SbBool getKeyboardInput,
00750 SbBool buildNow,
00751 SoGuiRenderArea* guiRenderArea );
00752
00753
00754
00755
00756
00757
00758
00759
00760 virtual void redraw();
00761 virtual void actualRedraw();
00762 #if 1 SoDEPRECATED
00764 virtual void redrawOverlay();SoDEPRECATED
00766 virtual void actualOverlayRedraw();
00767 #endif
00769 //
00770
00771
00772 virtual void processEvent( QEvent* anyevent );
00773 virtual void initGraphic();
00774 #if 1 SoDEPRECATED
00776 virtual void initOverlayGraphic();
00777 #endif
00778 virtual void sizeChanged( const SbVec2s& );
00779 virtual void posChanged( const SbVec2i32&, const SbVec2i32& );
00780 virtual void widgetChanged( QWidget* w );
00781
00782 QWidget* buildWidget(QWidget* parent);
00783
00784
00785 virtual SbString getDefaultWidgetName() const;
00786 virtual SbString getDefaultTitle() const;
00787 virtual SbString getDefaultIconTitle() const;
00788
00789
00790 SbPList* m_deviceList;
00791
00792
00793 static void renderCB( void* v, SoSceneManager* sm );
00794 #if 1 SoDEPRECATED
00796 static void renderOverlayCB( void* v, SoSceneManager* sm );
00797 #endif
00799 // application event callbacks variables
00800 SoQtRenderAreaEventCB *defaultAppEventHandler;
00801 void *defaultAppEventHandlerData;
00802 SoQtRenderAreaEventCB *appEventHandler;
00803 void *appEventHandlerData;
00804
00805
00806 SbBool invokeAppCB( QEvent* anyevent );
00807 SbBool processInventorEvent( QEvent* anyevent );
00808 const SoEvent* translateAnyEvent( QEvent* anyevent );
00809
00810
00811 SoQtRenderAreaRenderCB *appPostRenderCB;
00812 void *appPostRenderData;
00813
00814
00815 SbBool m_isFloatingPointRendering;
00816 FloatColorBufferSize m_floatingPointRenderingPrecision;
00817
00818
00819 void onFocusEvent(SbBool hasFocus);
00820
00821 SoINTERNAL private:
00822 SbBool m_runOnce;
00823
00824 private:
00825
00826
00827 #if defined(sun) || defined(__linux__)
00828 XColorPointer m_mapColors, m_overlayMapColors;
00829 int m_mapColorNum, m_overlayMapColorNum;
00830 #endif
00831
00832 SoQtMouse* m_mouseDevice;
00833 SoQtKeyboard* m_keybdDevice;
00834 void reinstallDevices( QWidget* newWidget );
00835
00836 static void selectionChangeCB( void* userData, SoSelection* s );
00837 static void overlaySelectionChangeCB( void* userData, SoSelection* s );
00838 QWidget* m_deviceWidget;
00839
00840 SbBool m_firstEvent;
00841
00842 void activate();
00843 void deactivate();
00844
00845
00846 void constructorCommon( SbBool getMouseInput,
00847 SbBool getKeyboardInput,
00848 SbBool buildNow );
00849
00850 void constructorCommon2( SbBool getMouseInput,
00851 SbBool getKeyboardInput,
00852 SbBool buildNow );
00853
00854 SbVec2i32 getWindowPosition();
00855
00856 QPoint m_oldPos;
00857 QSize m_oldSize;
00858 QSize m_minimumSize;
00859 QSize m_maximumSize;
00860
00861 SoGuiRenderArea* m_guiRenderArea;
00862
00863
00864
00865
00866
00867 static SbBool s_abortRenderCallback(SoAction*,void*);
00868
00869 bool m_firstStdRedraw;
00870 bool m_firstConnectedRedraw;
00871 SoTimerSensor* m_viewerUpdaterSensor;
00872 static void viewerUpdaterCB( void*, SoSensor* );
00873 void updateFirstFrame();
00874
00875 SoAntialiasingParameters* m_accumulationParameters;
00876
00877 private Q_SLOTS:
00878 void visibilityChangeCB( SbBool visible );
00879
00880 };
00881
00882
00883 #endif // _SO_QT_RENDERAREA_
00884
00885
00886