15 #ifndef ADAPTERWIDGET_H
16 #define ADAPTERWIDGET_H
21 #include <osgViewer/Viewer>
28 AdapterWidget ( QWidget * parent = 0,
const char * name = 0,
const QGLWidget * shareWidget = 0);
32 osgViewer::GraphicsWindow* getGraphicsWindow() {
return _gw.get(); }
33 const osgViewer::GraphicsWindow* getGraphicsWindow()
const {
return _gw.get(); }
41 virtual void resizeGL (
int width,
int height );
42 virtual void keyPressEvent ( QKeyEvent* event );
43 virtual void keyReleaseEvent ( QKeyEvent* event );
44 virtual void mousePressEvent ( QMouseEvent* event );
45 virtual void mouseReleaseEvent ( QMouseEvent* event );
46 virtual void mouseMoveEvent ( QMouseEvent* event );
49 osg::ref_ptr<osgViewer::GraphicsWindowEmbedded> _gw;
56 ViewerQT ( QWidget * parent = 0,
const char * name = 0,
const QGLWidget * shareWidget = 0) :
AdapterWidget ( parent, name, shareWidget)
58 getCamera()->setViewport (
new osg::Viewport ( 0,0,width(),height() ) );
59 getCamera()->setProjectionMatrixAsPerspective ( 30.0f, static_cast<double> ( width() ) /static_cast<double> ( height() ), 1.0f, 10000.0f );
60 QColor bg = palette().window().color();
61 getCamera()->setClearColor(osg::Vec4(bg.redF(), bg.greenF(), bg.blueF(), 0.0));
62 getCamera()->setClearMask(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
63 getCamera()->setGraphicsContext ( getGraphicsWindow() );
65 setThreadingModel ( osgViewer::Viewer::SingleThreaded );
67 connect ( &_timer, SIGNAL ( timeout() ),
this, SLOT ( updateGL() ) );
70 virtual void showEvent(QShowEvent *)
75 virtual void paintGL()
Definition: AdapterWidget.h:53