On 8.5.2013 7:04, Sujan Dasmahapatra wrote:
I am trying to implement a mouse press event with QT and OSG but
unable to do it. Pls help.
Below is my ViewerWidget class which is derived from QWidget and
osg::CompositeViewer......In the constructor I got gView which is a
osg::GLWidget, I am trying override mousePressEvent but when I click
message not coming. What I am doing wrong pls help..
[snip]
osg::Camera* ViewerWidget::createCamera( int x, int y, int w, int h,
const std::string& name, bool windowDecoration )
{
osg::DisplaySettings* ds = osg::DisplaySettings::instance().get();
osg::ref_ptr<osg::GraphicsContext::Traits> traits = new
osg::GraphicsContext::Traits;
traits->windowName = name;
traits->windowDecoration = windowDecoration;
traits->x = x;
traits->y = y;
traits->width = w;
traits->height = h;
traits->doubleBuffer = true;
traits->alpha = ds->getMinimumNumAlphaBits();
traits->stencil = ds->getMinimumNumStencilBits();
traits->sampleBuffers = ds->getMultiSamples();
traits->samples = ds->getNumMultiSamples();
osg::ref_ptr<osg::Camera> camera = new osg::Camera;
camera->setGraphicsContext( new
osgQt::GraphicsWindowQt(traits.get()) );
camera->setClearColor( osg::Vec4(0.2, 0.2, 0.6, 1.0) );
camera->setViewport( new osg::Viewport(0, 0, traits->width,
traits->height) );
camera->setProjectionMatrixAsPerspective(
30.0f,
static_cast<double>(traits->width)/static_cast<double>(traits->height), 1.0f,
10000.0f );
return camera.release();
}
I don't know why this code didn't crash, I think it should. Anyway, you
should create an instance of the CSGraphicsView somewhere within
createCamera:
CSGraphicsView* gView = new CSGraphicsView;
gView->setGeometry(x, y, w, h);
traits->inheritedWindowData = new osgQt::GraphicsWindowQt::WindowData(
gView );
...
or you can pass an instance of the CSGraphicsView to the
osgQt::GraphicsWindowQt constructor.
Robert Milharcic
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org