00001 #ifndef RenderArea_H 00002 #define RenderArea_H 00003 00004 #include <Inventor/sys/port.h> 00005 00006 #if defined(_WIN32) && !defined(OIV_DISABLE_AUTOLINK) && !defined(QtViewerComponents_EXPORTS) 00007 # if !defined(__QT_VIEWER_COMPONENTS_LIB) 00008 # if defined(_DEBUG) 00009 # define __QT_VIEWER_COMPONENTS_LIB "fei_inventor_QtViewerComponentsD.lib" 00010 # else 00011 # define __QT_VIEWER_COMPONENTS_LIB "fei_inventor_QtViewerComponents.lib" 00012 # endif 00013 # endif 00014 # pragma comment(lib, __QT_VIEWER_COMPONENTS_LIB) 00015 #endif 00016 00017 #include <QWindow> 00018 00019 #include <Inventor/misc/SoRef.h> 00020 #include <Inventor/sys/SoGL.h> 00021 #include <Inventor/ViewerComponents/SoRenderAreaCore.h> 00022 #include <Inventor/actions/SoAction.h> 00023 #include <Inventor/SbColorRGBA.h> 00024 00025 #include <Inventor/sys/port.h> 00026 00027 class SoNode; 00028 class QOpenGLPaintDevice; 00029 00045 class QTVIEWERCOMPONENTS_API RenderArea : public QWindow, public SiRenderArea, public SiRenderAreaStereo, public SiRenderAreaAntialiasing, public SiRenderAreaStillSuperSampling 00046 { 00047 public: 00051 RenderArea( QWidget* parent ); 00052 00054 virtual ~RenderArea(); 00055 00059 virtual void setSceneGraph( SoNode* sceneGraph ); 00060 00064 virtual SoNode* getSceneGraph() const; 00065 00070 virtual void setClearPolicy( ClearPolicy policy ); 00071 00075 virtual ClearPolicy getClearPolicy() const; 00076 00081 virtual void setClearColor( const SbColorRGBA& color ); 00082 00086 virtual SbColorRGBA getClearColor() const; 00087 00092 virtual void setClearDepth( float depth ); 00093 00097 virtual float getClearDepth() const; 00098 00102 virtual void setSize( const SbVec2i32& size ); 00103 00107 virtual SbVec2i32 getSize() const; 00108 00112 virtual void setGLRenderAction( SoGLRenderAction* glAction ); 00113 00118 virtual SoGLRenderAction* getGLRenderAction() const; 00119 00124 virtual void setTransparencyType( SoGLRenderAction::TransparencyType type); 00125 00129 virtual SoGLRenderAction::TransparencyType getTransparencyType() const; 00130 00135 virtual void setAntialiasingMode( SoSceneManager::AntialiasingMode mode ) override; 00136 00140 virtual SoSceneManager::AntialiasingMode getAntialiasingMode() const override; 00141 00147 virtual void setAntialiasingQuality( float quality ) override; 00148 00152 virtual float getAntialiasingQuality() const override; 00153 00161 virtual void setStillSuperSamplingQuality( float quality ) override; 00162 00166 virtual float getStillSuperSamplingQuality() const override; 00167 00175 virtual void setStillSuperSamplingDelay( unsigned int delay ) override; 00176 00180 virtual unsigned int getStillSuperSamplingDelay() const override; 00181 00185 virtual SbEventHandler<RenderEventArg&>& onStartRender(); 00186 00190 virtual void activateStereo( bool activated ); 00191 00198 virtual bool isStereoActivated() const; 00199 00206 virtual void setStereoParameters( SoStereoParameters* parameters ); 00207 00211 virtual SoStereoParameters* getStereoParameters() const; 00212 00216 bool isRawStereoAvailable(); 00217 00218 QWidget* 00219 getContainerWidget() 00220 { 00221 return m_containerWidget; 00222 } 00223 00224 private: 00231 virtual RenderStatus render(); 00232 00236 virtual bool event( QEvent* e ); 00237 00243 virtual void initializeGL(); 00244 00252 virtual void resizeEvent( QResizeEvent* e ); 00253 00257 virtual void exposeEvent( QExposeEvent* e ); 00258 00259 private: 00264 SoRef<SoRenderAreaCore> m_renderAreaCore; 00265 00267 SoNode* m_sceneGraph; 00268 ClearPolicy m_clearPolicy; 00269 SbColorRGBA m_color; 00270 float m_depth; 00271 SbVec2i32 m_size; 00272 bool m_stereo; 00273 00274 00276 SoGLRenderAction* m_glRenderAction; 00277 00281 SoGLRenderAction::TransparencyType m_transparencyType; 00282 00286 SoSceneManager::AntialiasingMode m_antialiasingMode; 00287 00291 float m_antialiasingQuality; 00292 00296 unsigned int m_stillAntialiasingDelay; 00297 00301 float m_stillAntialiasingQuality; 00302 00304 QWidget* m_containerWidget; 00305 00307 struct RenderAreaSaveRestore 00308 { 00309 RenderAreaSaveRestore(); 00310 virtual ~RenderAreaSaveRestore(); 00312 SbVec2i32 m_previousRenderingSize; 00314 GLuint m_backupFBOId; 00316 GLuint m_colorTextureId; 00318 GLuint m_depthStencilTextureId; 00320 SoRef<SoGLContext> m_context; 00321 }; 00322 00323 #if 1 SoDEPRECATED 00326 void saveRenderArea() {} 00327 SoDEPRECATED 00330 void restoreRenderArea() {} 00331 #endif 00333 private: 00334 void init(); 00335 00336 bool m_needInitGL; 00337 SoRef<SoGLContext> m_context; 00338 QOpenGLContext* m_qtContext; 00339 QOpenGLPaintDevice* m_device; 00340 }; 00341 00342 #endif // RenderArea_H 00343