Hi,

I have AdapterWidget embedded in my Qt main window. Instance of it is called 
"vis". This is the relevant code:

Code:
MainWindow::MainWindow(QWidget *parent)
:QMainWindow(parent)
{
        setupUi(this);
        
        osg::ref_ptr<osgGA::KeySwitchMatrixManipulator> keyswitchManipulator = 
new osgGA::KeySwitchMatrixManipulator;
        osgGA::FlightManipulator* flightManipulator = new 
osgGA::FlightManipulator();
        keyswitchManipulator->addMatrixManipulator( '1', "Trackball", new 
osgGA::TrackballManipulator() );
        keyswitchManipulator->addMatrixManipulator( '2', "Flight", 
flightManipulator );

        vis->setCameraManipulator( keyswitchManipulator.get() );
        vis->addEventHandler(new osgViewer::StatsHandler);
        vis->getCamera()->setClearColor(osg::Vec4(0.5f,0.5f,1.0f,0.0f)); 
//1.0f,1.0f,1.0f,1.0f //alpha makes no difference
}

AdapterWidget::AdapterWidget( QWidget * parent, const char * name, const 
QGLWidget * shareWidget, WindowFlags f)
        :QGLWidget(parent, shareWidget, f)
{
    _gw = new osgViewer::GraphicsWindowEmbedded(0,0,width(),height());
    setFocusPolicy(Qt::ClickFocus);
}

ViewerQT::ViewerQT(QWidget * parent, const char * name, const QGLWidget * 
shareWidget, WindowFlags f):
    AdapterWidget( parent, name, shareWidget, f )
{
    getCamera()->setViewport(new osg::Viewport(0,0,width(),height()));
    getCamera()->setProjectionMatrixAsPerspective(30.0f, 
static_cast<double>(width())/static_cast<double>(height()), 1.0f, 10000.0f);
    getCamera()->setGraphicsContext(getGraphicsWindow());

    connect(&_timer, SIGNAL(timeout()), this, SLOT(updateGL()));
    _timer.start(10);
}



Thank you!

Cheers,
Dženan

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=30785#30785





_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to