Re: [osg-users] problem zooming using mouse middle scroll in trackballmanipulator
Hi, I solved the question as below: void AdapterWidget::wheelEvent(QWheelEvent * event) { float delta = event-delta() / 8.0; if( delta==0 )return; osgGA::GUIEventAdapter* ea = _gw-getEventQueue()-createEvent(); ea-setTime( _gw-getEventQueue()-getTime() ); ea-setX( event-x() ); ea-setY( event-y() ); ea-setEventType( osgGA::GUIEventAdapter::SCROLL ); if( event-orientation() == Qt::Vertical ) { if( delta0 ){ ea-setScrollingMotionDelta(0.0, delta); ea-setScrollingMotion( osgGA::GUIEventAdapter::SCROLL_UP ); } else{ ea-setScrollingMotionDelta(0.0, -delta); ea-setScrollingMotion( osgGA::GUIEventAdapter::SCROLL_DOWN ); } } else { if( delta0 ){ ea-setScrollingMotionDelta(delta, 0.0); ea-setScrollingMotion( osgGA::GUIEventAdapter::SCROLL_LEFT ); } else{ ea-setScrollingMotionDelta(-delta, 0.0); ea-setScrollingMotion( osgGA::GUIEventAdapter::SCROLL_RIGHT ); } } _gw-getEventQueue()-addEvent(ea); } class MyManipulator: public osgGA::MatrixManipulator bool MyManipulator::handle(const osgGA::GUIEventAdapter ea, osgGA::GUIActionAdapter us) { switch(ea.getEventType()){ case( osgGA::GUIEventAdapter::SCROLL ):{ osgGA::GUIEventAdapter::ScrollingMotion sm = ea.getScrollingMotion(); switch( sm ){ case osgGA::GUIEventAdapter::SCROLL_UP : // do zoom out return true case osgGA::GUIEventAdapter::SCROLL_DOWN : // do zoom in return true; default : break; } } .. } } you can try it, good luck! 2008/5/6 Srikanth Bemineni [EMAIL PROTECTED]: I am experimenting with the osgQTviewer.I am not able to zoom in when the mouse wheel is scrolled.I am using trackballmanipulator.I am not able to find a good documentation about camera manipulators.Even the Reference doc doesn't mention the explanation of manipulators. AdapterWidget::AdapterWidget( ViewerQT *source ,QWidget * parent, const char * name, const QGLWidget * shareWidget, WindowFlags f): #if USE_QT4 QGLWidget(parent, shareWidget, f) #else QGLWidget(parent, name, shareWidget, f) #endif { m_source = source; resize( 800 ,600 ); /* To Remove this */ /* * // create the window to draw to. * */ osg::ref_ptrosg::GraphicsContext::Traits traits = new osg::GraphicsContext::Traits; traits-x = 200; traits-y = 200; traits-width = 800; traits-height = 600; traits-windowDecoration = true; traits-doubleBuffer = true; traits-sharedContext = 0; osg::ref_ptrosg::GraphicsContext gc = osg::GraphicsContext::createGraphicsContext(traits.get()); _gw = new osgViewer::GraphicsWindowEmbedded(traits.get()); #if USE_QT4 setFocusPolicy(Qt::ClickFocus); #else setFocusPolicy(QWidget::ClickFocus); #endif } .. ... all the other event handling ... void AdapterWidget::mouseMoveEvent( QMouseEvent* event ) { _gw-getEventQueue()-mouseMotion(event-x(), event-y()); } void AdapterWidget::wheelEvent( QWheelEvent *event ) { //m_source-wheelEvent( event ); if( event-delta() 0 ) _gw-getEventQueue()-mouseScroll(osgGA::GUIEventAdapter::SCROLL_UP ); else _gw-getEventQueue()-mouseScroll(osgGA::GUIEventAdapter::SCROLL_DOWN ); } ViewerQT:: ViewerQT(QWidget * parent, const char * name, const QGLWidget * shareWidget , WindowFlags f ): AdapterWidget( this , parent, name, shareWidget, f ) { znear = 1.0f; zfar = 1.0f; getCamera()-setViewport(new osg::Viewport(0,0,width(),height())); //getCamera()-setProjectionMatrixAsPerspective(30.0f, static_castdouble(width())/static_castdouble(height()), 1.0f, 1.0f); getCamera()-setGraphicsContext(getGraphicsWindow()); /* To Remove*/ osg::ref_ptrosgGA::StateSetManipulator statesetManipulator = new osgGA::StateSetManipulator(getCamera()-getStateSet()); addEventHandler(statesetManipulator.get()); /*to remove end*/ addEventHandler(new PickHandler()); setThreadingModel(osgViewer::Viewer::SingleThreaded); connect(_timer, SIGNAL(timeout()), this, SLOT(updateGL())); _timer.start(10); _manipulator = new osgGA::TrackballManipulator; setCameraManipulator(_manipulator); coutMinimum distance _manipulator-getMinimumDistance()endl; coutHomepostion compute_manipulator-getAutoComputeHomePosition()endl; //_manipulator-setAutoComputeHomePosition(false); _manipulator-setMinimumDistance(1000); osg::Vec3d eye; osg::Vec3d center; osg::Vec3d up; _manipulator-getHomePosition( eye , center , up ); coutx y z eye.x()eye.y()eye.z()endl; coutx y z center.x()center.y()center.z()endl; coutx y z up.x()up.y()up.z()endl; } void ViewerQT:: VwheelEvent( QWheelEvent *event
Re: [osg-users] problem zooming using mouse middle scroll in trackballmanipulator
On Tue, May 6, 2008 at 6:05 PM, Srikanth Bemineni [EMAIL PROTECTED] wrote: Hi, Can somebody please reply to the below question. Is there a CJM or Postscript output support in Openscenegraph No, its a scene graph for doing 3D rendering. If you want hard copy output then you'll need to take a screen image snapshot then pass this image data to a tool that provides the hard copy output support. BTW, when asking a new questions about a different topic please use a new thread as this makes it much easier for people to follow. Robert. ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] problem zooming using mouse middle scroll in trackballmanipulator
Hi Srikanth, The osgGA camera manipulators don't currently check the scroll wheel at all. They are all open source so if you need this feature just dive into the implementation and add them and then send me the changes so we can get it merged with SVN. Robert. On Mon, May 5, 2008 at 11:46 PM, Srikanth Bemineni [EMAIL PROTECTED] wrote: I am experimenting with the osgQTviewer.I am not able to zoom in when the mouse wheel is scrolled.I am using trackballmanipulator.I am not able to find a good documentation about camera manipulators.Even the Reference doc doesn't mention the explanation of manipulators. AdapterWidget::AdapterWidget( ViewerQT *source ,QWidget * parent, const char * name, const QGLWidget * shareWidget, WindowFlags f): #if USE_QT4 QGLWidget(parent, shareWidget, f) #else QGLWidget(parent, name, shareWidget, f) #endif { m_source = source; resize( 800 ,600 ); /* To Remove this */ /* * // create the window to draw to. * */ osg::ref_ptrosg::GraphicsContext::Traits traits = new osg::GraphicsContext::Traits; traits-x = 200; traits-y = 200; traits-width = 800; traits-height = 600; traits-windowDecoration = true; traits-doubleBuffer = true; traits-sharedContext = 0; osg::ref_ptrosg::GraphicsContext gc = osg::GraphicsContext::createGraphicsContext(traits.get()); _gw = new osgViewer::GraphicsWindowEmbedded(traits.get()); #if USE_QT4 setFocusPolicy(Qt::ClickFocus); #else setFocusPolicy(QWidget::ClickFocus); #endif } .. ... all the other event handling ... void AdapterWidget::mouseMoveEvent( QMouseEvent* event ) { _gw-getEventQueue()-mouseMotion(event-x(), event-y()); } void AdapterWidget::wheelEvent( QWheelEvent *event ) { //m_source-wheelEvent( event ); if( event-delta() 0 ) _gw-getEventQueue()-mouseScroll(osgGA::GUIEventAdapter::SCROLL_UP ); else _gw-getEventQueue()-mouseScroll(osgGA::GUIEventAdapter::SCROLL_DOWN ); } ViewerQT:: ViewerQT(QWidget * parent, const char * name, const QGLWidget * shareWidget , WindowFlags f ): AdapterWidget( this , parent, name, shareWidget, f ) { znear = 1.0f; zfar = 1.0f; getCamera()-setViewport(new osg::Viewport(0,0,width(),height())); //getCamera()-setProjectionMatrixAsPerspective(30.0f, static_castdouble(width())/static_castdouble(height()), 1.0f, 1.0f); getCamera()-setGraphicsContext(getGraphicsWindow()); /* To Remove*/ osg::ref_ptrosgGA::StateSetManipulator statesetManipulator = new osgGA::StateSetManipulator(getCamera()-getStateSet()); addEventHandler(statesetManipulator.get()); /*to remove end*/ addEventHandler(new PickHandler()); setThreadingModel(osgViewer::Viewer::SingleThreaded); connect(_timer, SIGNAL(timeout()), this, SLOT(updateGL())); _timer.start(10); _manipulator = new osgGA::TrackballManipulator; setCameraManipulator(_manipulator); coutMinimum distance _manipulator-getMinimumDistance()endl; coutHomepostion compute_manipulator-getAutoComputeHomePosition()endl; //_manipulator-setAutoComputeHomePosition(false); _manipulator-setMinimumDistance(1000); osg::Vec3d eye; osg::Vec3d center; osg::Vec3d up; _manipulator-getHomePosition( eye , center , up ); coutx y z eye.x()eye.y()eye.z()endl; coutx y z center.x()center.y()center.z()endl; coutx y z up.x()up.y()up.z()endl; } void ViewerQT:: VwheelEvent( QWheelEvent *event ) { coutevent-delta()endl; if( event-delta() 0 ) { znear = znear + 120.0f; } else { if( (znear - 120) = 1.0 ) { znear = znear - 120; } } } void ViewerQT:: paintGL() { osg::Vec3d eye; osg::Vec3d center; osg::Vec3d up; _manipulator-getHomePosition( eye , center , up ); couteye x y z eye.x() eye.y() eye.z()endl; coutcenter x y z center.x() center.y() center.z()endl; coutup x y z up.x() up.y() up.z()endl; frame(); } and this is how I am creating the Viewer window. I tried to move the perspective view. I tried to translate the camera matrix. I tried to set the home positon but none of the above things seems to work in moving the camera or zooming.I am new to opengl and open scene graph any guide would be really helpful. Thank You -- With Regards Srikanth Bemineni Geotrace Technologies 281-497-8440 extn 228 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] problem zooming using mouse middle scroll in trackballmanipulator
Hi, Can somebody please reply to the below question. Is there a CJM or Postscript output support in Openscenegraph Srikanth Srikanth Bemineni wrote: I am experimenting with the osgQTviewer.I am not able to zoom in when the mouse wheel is scrolled.I am using trackballmanipulator.I am not able to find a good documentation about camera manipulators.Even the Reference doc doesn't mention the explanation of manipulators. AdapterWidget::AdapterWidget( ViewerQT *source ,QWidget * parent, const char * name, const QGLWidget * shareWidget, WindowFlags f): #if USE_QT4 QGLWidget(parent, shareWidget, f) #else QGLWidget(parent, name, shareWidget, f) #endif { m_source = source; resize( 800 ,600 ); /* To Remove this */ /* * // create the window to draw to. * */ osg::ref_ptrosg::GraphicsContext::Traits traits = new osg::GraphicsContext::Traits; traits-x = 200; traits-y = 200; traits-width = 800; traits-height = 600; traits-windowDecoration = true; traits-doubleBuffer = true; traits-sharedContext = 0; osg::ref_ptrosg::GraphicsContext gc = osg::GraphicsContext::createGraphicsContext(traits.get()); _gw = new osgViewer::GraphicsWindowEmbedded(traits.get()); #if USE_QT4 setFocusPolicy(Qt::ClickFocus); #else setFocusPolicy(QWidget::ClickFocus); #endif } .. ... all the other event handling ... void AdapterWidget::mouseMoveEvent( QMouseEvent* event ) { _gw-getEventQueue()-mouseMotion(event-x(), event-y()); } void AdapterWidget::wheelEvent( QWheelEvent *event ) { //m_source-wheelEvent( event ); if( event-delta() 0 ) _gw-getEventQueue()-mouseScroll(osgGA::GUIEventAdapter::SCROLL_UP ); else _gw-getEventQueue()-mouseScroll(osgGA::GUIEventAdapter::SCROLL_DOWN ); } ViewerQT:: ViewerQT(QWidget * parent, const char * name, const QGLWidget * shareWidget , WindowFlags f ): AdapterWidget( this , parent, name, shareWidget, f ) { znear = 1.0f; zfar = 1.0f; getCamera()-setViewport(new osg::Viewport(0,0,width(),height())); //getCamera()-setProjectionMatrixAsPerspective(30.0f, static_castdouble(width())/static_castdouble(height()), 1.0f, 1.0f); getCamera()-setGraphicsContext(getGraphicsWindow()); /* To Remove*/ osg::ref_ptrosgGA::StateSetManipulator statesetManipulator = new osgGA::StateSetManipulator(getCamera()-getStateSet()); addEventHandler(statesetManipulator.get()); /*to remove end*/ addEventHandler(new PickHandler()); setThreadingModel(osgViewer::Viewer::SingleThreaded); connect(_timer, SIGNAL(timeout()), this, SLOT(updateGL())); _timer.start(10); _manipulator = new osgGA::TrackballManipulator; setCameraManipulator(_manipulator); coutMinimum distance _manipulator-getMinimumDistance()endl; coutHomepostion compute_manipulator-getAutoComputeHomePosition()endl; //_manipulator-setAutoComputeHomePosition(false); _manipulator-setMinimumDistance(1000); osg::Vec3d eye; osg::Vec3d center; osg::Vec3d up; _manipulator-getHomePosition( eye , center , up ); coutx y z eye.x()eye.y()eye.z()endl; coutx y z center.x()center.y()center.z()endl; coutx y z up.x()up.y()up.z()endl; } void ViewerQT:: VwheelEvent( QWheelEvent *event ) { coutevent-delta()endl; if( event-delta() 0 ) { znear = znear + 120.0f; } else { if( (znear - 120) = 1.0 ) { znear = znear - 120; } } } void ViewerQT:: paintGL() { osg::Vec3d eye; osg::Vec3d center; osg::Vec3d up; _manipulator-getHomePosition( eye , center , up ); couteye x y z eye.x() eye.y() eye.z()endl; coutcenter x y z center.x() center.y() center.z()endl; coutup x y z up.x() up.y() up.z()endl; frame(); } and this is how I am creating the Viewer window. I tried to move the perspective view. I tried to translate the camera matrix. I tried to set the home positon but none of the above things seems to work in moving the camera or zooming.I am new to opengl and open scene graph any guide would be really helpful. Thank You -- With Regards Srikanth Bemineni Geotrace Technologies 281-497-8440 extn 228 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org