00001 #ifndef RenderArea_H 00002 #define RenderArea_H 00003 00004 #include <Inventor/misc/SoRef.h> 00005 #include <Inventor/sys/SoGL.h> 00006 #include <Inventor/actions/SoAction.h> 00007 #include <Inventor/ViewerComponents/SoRenderAreaCore.h> 00008 #include <Inventor/SbColorRGBA.h> 00009 00010 #include <QOpenGLWidget> 00011 00012 #include <Inventor/sys/port.h> 00013 00014 class SoNode; 00015 00031 class QTVIEWERCOMPONENTS_API RenderArea : public QOpenGLWidget, public SiRenderArea, public SiRenderAreaStereo 00032 { 00033 public: 00034 00038 RenderArea( QWidget* parent ); 00039 00041 virtual ~RenderArea(); 00042 00046 virtual void setSceneGraph(SoNode* sceneGraph); 00047 00051 virtual SoNode* getSceneGraph() const; 00052 00057 virtual void setClearPolicy(ClearPolicy policy); 00058 00062 virtual ClearPolicy getClearPolicy() const; 00063 00068 virtual void setClearColor(const SbColorRGBA& color); 00069 00073 virtual SbColorRGBA getClearColor() const; 00074 00079 virtual void setClearDepth(float depth); 00080 00084 virtual float getClearDepth() const; 00085 00089 virtual void setSize(const SbVec2i32& size); 00090 00094 virtual SbVec2i32 getSize() const; 00095 00099 virtual SbEventHandler<RenderEventArg&>& onStartRender(); 00100 00104 virtual void activateStereo( bool activated ); 00105 00109 virtual bool isStereoActivated() const; 00110 00114 virtual void setStereoParameters(SoStereoParameters* parameters); 00115 00119 virtual SoStereoParameters* getStereoParameters() const; 00120 00124 bool isRawStereoAvailable(); 00125 00126 private: 00127 00131 virtual RenderStatus render(); 00132 00138 virtual void initializeGL(); 00139 00147 virtual void resizeGL( int width, int height ); 00148 00155 virtual void paintGL(); 00156 00157 private: 00158 00163 SoRef<SoRenderAreaCore> m_renderAreaCore; 00164 00166 SoNode* m_sceneGraph; 00167 ClearPolicy m_clearPolicy; 00168 SbColorRGBA m_color; 00169 float m_depth; 00170 SbVec2i32 m_size; 00171 bool m_stereo; 00172 00173 00175 struct RenderAreaSaveRestore { 00176 RenderAreaSaveRestore(); 00177 virtual ~RenderAreaSaveRestore(); 00179 SbVec2i32 m_previousRenderingSize; 00181 GLuint m_backupFBOId; 00183 GLuint m_colorTextureId; 00185 GLuint m_depthStencilTextureId; 00187 SoRef<SoGLContext> m_context; 00188 }; 00189 00191 void saveRenderArea(); 00192 00194 void restoreRenderArea(); 00195 00196 RenderAreaSaveRestore m_restoreFBO; 00197 00198 private: 00199 void init(); 00200 }; 00201 00202 #endif // RenderArea_H 00203 00204 00205