Skip to content
Permalink
Browse files

added missing tilt icons added KeyboardControlHandler

  • Loading branch information
Marco Bernasocchi authored and pka committed Nov 26, 2010
1 parent a2a391c commit 9dcb8329f876b0c6380dcf70f473c42544f075d0
@@ -139,8 +139,9 @@ void GlobePlugin::run()
mRootNode->addChild( mControlCanvas );
setupControls();

// add our fly-to handler
// add our handlers
viewer.addEventHandler(new FlyToExtentHandler( manip, mQGisIface ));
viewer.addEventHandler(new KeyboardControlHandler( manip, mQGisIface ));

// add some stock OSG handlers:
viewer.addEventHandler(new osgViewer::StatsHandler());
@@ -550,8 +551,6 @@ void GlobePlugin::copyFolder(QString sourceFolder, QString destFolder)
}
}

// ----------

bool FlyToExtentHandler::handle( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa )
{
if ( ea.getEventType() == ea.KEYDOWN && ea.getKey() == '1' )
@@ -563,10 +562,7 @@ bool FlyToExtentHandler::handle( const osgGA::GUIEventAdapter& ea, osgGA::GUIAct
return false;
}

// ----------

bool
NavigationControl::handle( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa, ControlContext& cx )
bool NavigationControl::handle( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa, ControlContext& cx )
{
switch ( ea.getEventType() )
{
@@ -595,7 +591,113 @@ NavigationControl::handle( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAda
return Control::handle( ea, aa, cx );
}

// ----------
bool KeyboardControlHandler::handle( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa )
{
float deg = 3.14159 / 180;
/*
osgEarthUtil::EarthManipulator::Settings* _manipSettings = _manip->getSettings();
_manipSettings->bindKey(osgEarthUtil::EarthManipulator::ACTION_ZOOM_IN, osgGA::GUIEventAdapter::KEY_Space);
//install default action bindings:
osgEarthUtil::EarthManipulator::ActionOptions options;
_manipSettings->bindKey( osgEarthUtil::EarthManipulator::ACTION_HOME, osgGA::GUIEventAdapter::KEY_Space );
_manipSettings->bindMouse( osgEarthUtil::EarthManipulator::ACTION_PAN, osgGA::GUIEventAdapter::LEFT_MOUSE_BUTTON );
// zoom as you hold the right button:
options.clear();
options.add( osgEarthUtil::EarthManipulator::OPTION_CONTINUOUS, true );
_manipSettings->bindMouse( osgEarthUtil::EarthManipulator::ACTION_ROTATE, osgGA::GUIEventAdapter::RIGHT_MOUSE_BUTTON, 0L, options );
// zoom with the scroll wheel:
_manipSettings->bindScroll( osgEarthUtil::EarthManipulator::ACTION_ZOOM_IN, osgGA::GUIEventAdapter::SCROLL_DOWN );
_manipSettings->bindScroll( osgEarthUtil::EarthManipulator::ACTION_ZOOM_OUT, osgGA::GUIEventAdapter::SCROLL_UP );
// pan around with arrow keys:
_manipSettings->bindKey( osgEarthUtil::EarthManipulator::ACTION_PAN_LEFT, osgGA::GUIEventAdapter::KEY_Left );
_manipSettings->bindKey( osgEarthUtil::EarthManipulator::ACTION_PAN_RIGHT, osgGA::GUIEventAdapter::KEY_Right );
_manipSettings->bindKey( osgEarthUtil::EarthManipulator::ACTION_PAN_UP, osgGA::GUIEventAdapter::KEY_Up );
_manipSettings->bindKey( osgEarthUtil::EarthManipulator::ACTION_PAN_DOWN, osgGA::GUIEventAdapter::KEY_Down );
// double click the left button to zoom in on a point:
options.clear();
options.add( osgEarthUtil::EarthManipulator::OPTION_GOTO_RANGE_FACTOR, 0.4 );
_manipSettings->bindMouseDoubleClick( osgEarthUtil::EarthManipulator::ACTION_GOTO, osgGA::GUIEventAdapter::LEFT_MOUSE_BUTTON, 0L, options );
// double click the right button (or CTRL-left button) to zoom out to a point
options.clear();
options.add( osgEarthUtil::EarthManipulator::OPTION_GOTO_RANGE_FACTOR, 2.5 );
_manipSettings->bindMouseDoubleClick( osgEarthUtil::EarthManipulator::ACTION_GOTO, osgGA::GUIEventAdapter::RIGHT_MOUSE_BUTTON, 0L, options );
_manipSettings->bindMouseDoubleClick( osgEarthUtil::EarthManipulator::ACTION_GOTO, osgGA::GUIEventAdapter::LEFT_MOUSE_BUTTON, osgGA::GUIEventAdapter::MODKEY_CTRL, options );
_manipSettings->setThrowingEnabled( false );
_manipSettings->setLockAzimuthWhilePanning( true );
_manip->applySettings(_manipSettings);
*/

switch(ea.getEventType())
{
case(osgGA::GUIEventAdapter::KEYDOWN):
{
//move map
if (ea.getKey() == '4' )
{
_manip->pan( -0.1, 0 );
}
if (ea.getKey() == '6' )
{
_manip->pan( 0.1, 0 );
}
if (ea.getKey() == '2' )
{
_manip->pan( 0, 0.1 );
}
if (ea.getKey() == '8' )
{
_manip->pan( 0, -0.1 );
}
//rotate
if (ea.getKey() == '/' )
{
_manip->rotate( 1*deg, 0 );
}
if (ea.getKey() == '*' )
{
_manip->rotate( -1*deg, 0 );
}
//tilt
if ( ea.getKey() == '9' )
{
_manip->rotate( 0, 1*deg );
}
if (ea.getKey() == '3' )
{
_manip->rotate( 0, -1*deg );
}
//zoom
if (ea.getKey() == '-' )
{
_manip->zoom( 0, 0.1 );
}
if (ea.getKey() == '+' )
{
_manip->zoom( 0, -0.1 );
}
//reset
if (ea.getKey() == '5' )
{
//_manip->zoom( 0, 1 );
}
break;
}

default:
break;
}
return false;
}

/**
* Required extern functions needed for every plugin
@@ -110,16 +110,30 @@ class GlobePlugin : public QObject, public QgisPlugin
osgEarthUtil::ObjectPlacer* mObjectPlacer;
};

class ControlsHandler : public osgGA::GUIEventHandler
class FlyToExtentHandler : public osgGA::GUIEventHandler
{
public:
ControlsHandler( osgEarthUtil::EarthManipulator* manip, QgisInterface *qGisIface ) : _manip(manip), mQGisIface(qGisIface) { }
FlyToExtentHandler( osgEarthUtil::EarthManipulator* manip, QgisInterface *qGisIface ) : _manip(manip), mQGisIface(qGisIface) { }

bool handle( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa );

private:
osg::observer_ptr<osgEarthUtil::EarthManipulator> _manip;
osgEarthUtil::EarthManipulator::Settings* _manipSettings;

//! Pointer to the QGIS interface object
QgisInterface *mQGisIface;
};

class KeyboardControlHandler : public osgGA::GUIEventHandler
{
public:
KeyboardControlHandler( osgEarthUtil::EarthManipulator* manip, QgisInterface *qGisIface ) : _manip(manip), mQGisIface(qGisIface) { }

bool handle( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa );

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

//! Pointer to the QGIS interface object
QgisInterface *mQGisIface;
};
Binary file not shown.
Binary file not shown.

0 comments on commit 9dcb832

Please sign in to comment.
You can’t perform that action at this time.