robertosfield wrote:
> 
> The osgViewer classes are built around not having any event handlers
> by default and it's the application developers responsibility to add
> these to their applications, so it's not a case of working out how to
> block events but rather just adding the event handlers you need.  The
> only exceptions to this rule is the escape key handling setting done -
> which is on by default but can be switched off, and the
> TrackballManipulator that is added as fallback if no other camera
> manipulator is attached when you call Viewer::run().
> 
> Robert.
> 


I thought so too, but even as I did not add any key event handlers, my Qt 
elements jump around the screen as I press anything! Could it be something 
about Qt? The thing is Qt is all fine while it's in screen mode, I mean, when I 
use Qt forms etc -- but when I put it inside OSG scene as 3d-model, things 
start to happen.

Here is code, how I create button and put it on scene:

Code:
 
    QWidget* widget = 0;
    widget = new QWidget;
    widget->setLayout(new QVBoxLayout);
    QPushButton* button = new MyButton(buttonText);
    button->setFixedSize(width-30,height-10);
    widget->layout()->addWidget(button);
 //   widget->setGeometry(0, 0, 800,600);
    QGraphicsScene* graphicsScene = 0;
    osg::ref_ptr<osgQt::QWidgetImage> widgetImage = new 
osgQt::QWidgetImage(widget);
#if (QT_VERSION >= QT_VERSION_CHECK(4, 5, 0))
    widgetImage->getQWidget()->setAttribute(Qt::WA_TranslucentBackground);
#endif
      widgetImage->getQGraphicsViewAdapter()->setBackgroundColor(QColor(0, 0, 
0, 0));
    graphicsScene = widgetImage->getQGraphicsViewAdapter()->getQGraphicsScene();
    osg::Camera* camera = 0;
    osg::Geometry* quad = osg::createTexturedQuadGeometry(osg::Vec3(0,0,0), 
osg::Vec3(1,0,0), osg::Vec3(0,1,0), 1, 1);


    osg::StateSet* stateset = quad->getOrCreateStateSet();
    stateset->setMode(GL_BLEND,osg::StateAttribute::ON);
    osg::Geode* geode = new osg::Geode;
    geode->addDrawable(quad);

    osg::MatrixTransform* mt = new osg::MatrixTransform;

    osg::Texture2D* texture = new osg::Texture2D(widgetImage.get());
    texture->setResizeNonPowerOfTwoHint(false);
    texture->setFilter(osg::Texture::MIN_FILTER,osg::Texture::LINEAR);
    texture->setWrap(osg::Texture::WRAP_S, osg::Texture::CLAMP_TO_EDGE);
    texture->setWrap(osg::Texture::WRAP_T, osg::Texture::CLAMP_TO_EDGE);
    mt->getOrCreateStateSet()->setTextureAttributeAndModes(0, texture, 
osg::StateAttribute::ON);

    osgViewer::InteractiveImageHandler* handler;

        camera = new osg::Camera;
        camera->setProjectionResizePolicy(osg::Camera::FIXED);
        camera->setProjectionMatrix(osg::Matrix::ortho2D(0,1,0,1));
        //camera->setProjectionMatrixAsOrtho2D(0,1280,0,1024);
        camera->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
        camera->setViewMatrix(osg::Matrix::identity());
        camera->setClearMask(GL_DEPTH_BUFFER_BIT);
        camera->setRenderOrder(osg::Camera::POST_RENDER);
        camera->addChild(geode);
        camera->setViewport(x,y,width,height);


        mt->addChild(camera);

        handler = new osgViewer::InteractiveImageHandler(widgetImage.get(), 
texture, camera);

    mt->getOrCreateStateSet()->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
    mt->getOrCreateStateSet()->setMode(GL_BLEND, osg::StateAttribute::ON);
    mt->getOrCreateStateSet()->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
    mt->getOrCreateStateSet()->setAttribute(new osg::Program);

    osg::Group* overlay = new osg::Group;
    overlay->addChild(mt);
    quad->setEventCallback(handler);
    quad->setCullCallback(handler);
    scene->addChild(overlay);




Anyway, the thing I was looking for is some blocker for any keyboard press, 
maybe even not through OSG but in whole C++ windows application? Like, you 
know, a firewall for key events so I could "open ports" only for those I need?

Thanks for your time![/code]

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





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

Reply via email to