Skip to content

Commit

Permalink
testing how to get key bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
Marco Bernasocchi authored and pka committed Jul 5, 2011
1 parent 06f8409 commit bc1ca62
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 5 deletions.
51 changes: 48 additions & 3 deletions src/plugins/globe/globe_plugin.cpp
Expand Up @@ -106,9 +106,9 @@ void GlobePlugin::initGui()

struct MyClickHandler : public ControlEventHandler
{
void onClick( Control* control, int mouseButtonMask )
void onClick( Control* control, int mouseButtonMask)
{
OE_NOTICE << "Thank you for clicking on " << typeid(control).name() << mouseButtonMask
OE_NOTICE << "Thank you for clicking on " << typeid(control).name()
<< std::endl;
}
};
Expand Down Expand Up @@ -508,13 +508,58 @@ void GlobePlugin::copyFolder(QString sourceFolder, QString destFolder)
}

bool FlyToExtentHandler::handle( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa )
{
{
float deg = 3.14159 / 180;

//this should be the way to implement this I think, but it segfaults...
//TODO: put this in the correct place, here is ok for now to test
//_manipSettings.bindKey(osgEarthUtil::EarthManipulator::ACTION_ZOOM_IN, osgGA::GUIEventAdapter::KEY_Page_Up);
//_manip->applySettings( _manipSettings );


if ( ea.getEventType() == ea.KEYDOWN && ea.getKey() == '1' )

{
QgsPoint center = mQGisIface->mapCanvas()->extent().center();
osgEarthUtil::Viewpoint viewpoint( osg::Vec3d( center.x(), center.y(), 0.0 ), 0.0, -90.0, 1e4 );
_manip->setViewpoint( viewpoint, 4.0 );
}


/*if ( ea.getEventType() == ea.KEYDOWN && ea.getKey() == '4' )
{
_manip->pan(-1,0);
}
if ( ea.getEventType() == ea.KEYDOWN && ea.getKey() == '6' )
{
_manip->pan(1,0);
}
if ( ea.getEventType() == ea.KEYDOWN && ea.getKey() == '8' )
{
_manip->pan(0,1);
}
if ( ea.getEventType() == ea.KEYDOWN && ea.getKey() == '2' )
{
_manip->pan(0,-1);
}
if ( ea.getEventType() == ea.KEYDOWN && ea.getKey() == '+' )
{
_manip->rotate(0,1*deg);
}
*/
if ( ea.getEventType() == ea.KEYDOWN && ea.getKey() == '-' )
{
_manip->rotate(0,-1*deg);
}
if ( ea.getEventType() == ea.KEYDOWN && ea.getKey() == '/' )
{
_manip->rotate(1*deg,0);
}
if ( ea.getEventType() == ea.KEYDOWN && ea.getKey() == '*' )
{
_manip->rotate(-1*deg,0);
}

return false;
}

Expand Down
3 changes: 1 addition & 2 deletions src/plugins/globe/globe_plugin.h
Expand Up @@ -119,10 +119,9 @@ class FlyToExtentHandler : public osgGA::GUIEventHandler

private:
osg::observer_ptr<osgEarthUtil::EarthManipulator> _manip;

//osgEarthUtil::EarthManipulator::Settings* _manipSettings;
//! Pointer to the QGIS interface object
QgisInterface *mQGisIface;
};


#endif // QGS_GLOBE_PLUGIN_H

0 comments on commit bc1ca62

Please sign in to comment.