Skip to content

Commit 9dcb832

Browse files
Marco Bernasocchipka
Marco Bernasocchi
authored andcommitted
added missing tilt icons added KeyboardControlHandler
1 parent a2a391c commit 9dcb832

File tree

4 files changed

+127
-11
lines changed

4 files changed

+127
-11
lines changed

src/plugins/globe/globe_plugin.cpp

+110-8
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,9 @@ void GlobePlugin::run()
139139
mRootNode->addChild( mControlCanvas );
140140
setupControls();
141141

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

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

553-
// ----------
554-
555554
bool FlyToExtentHandler::handle( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa )
556555
{
557556
if ( ea.getEventType() == ea.KEYDOWN && ea.getKey() == '1' )
@@ -563,10 +562,7 @@ bool FlyToExtentHandler::handle( const osgGA::GUIEventAdapter& ea, osgGA::GUIAct
563562
return false;
564563
}
565564

566-
// ----------
567-
568-
bool
569-
NavigationControl::handle( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa, ControlContext& cx )
565+
bool NavigationControl::handle( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa, ControlContext& cx )
570566
{
571567
switch ( ea.getEventType() )
572568
{
@@ -595,7 +591,113 @@ NavigationControl::handle( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAda
595591
return Control::handle( ea, aa, cx );
596592
}
597593

598-
// ----------
594+
bool KeyboardControlHandler::handle( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa )
595+
{
596+
float deg = 3.14159 / 180;
597+
/*
598+
osgEarthUtil::EarthManipulator::Settings* _manipSettings = _manip->getSettings();
599+
_manipSettings->bindKey(osgEarthUtil::EarthManipulator::ACTION_ZOOM_IN, osgGA::GUIEventAdapter::KEY_Space);
600+
//install default action bindings:
601+
osgEarthUtil::EarthManipulator::ActionOptions options;
602+
603+
_manipSettings->bindKey( osgEarthUtil::EarthManipulator::ACTION_HOME, osgGA::GUIEventAdapter::KEY_Space );
604+
605+
_manipSettings->bindMouse( osgEarthUtil::EarthManipulator::ACTION_PAN, osgGA::GUIEventAdapter::LEFT_MOUSE_BUTTON );
606+
607+
// zoom as you hold the right button:
608+
options.clear();
609+
options.add( osgEarthUtil::EarthManipulator::OPTION_CONTINUOUS, true );
610+
_manipSettings->bindMouse( osgEarthUtil::EarthManipulator::ACTION_ROTATE, osgGA::GUIEventAdapter::RIGHT_MOUSE_BUTTON, 0L, options );
611+
612+
// zoom with the scroll wheel:
613+
_manipSettings->bindScroll( osgEarthUtil::EarthManipulator::ACTION_ZOOM_IN, osgGA::GUIEventAdapter::SCROLL_DOWN );
614+
_manipSettings->bindScroll( osgEarthUtil::EarthManipulator::ACTION_ZOOM_OUT, osgGA::GUIEventAdapter::SCROLL_UP );
615+
616+
// pan around with arrow keys:
617+
_manipSettings->bindKey( osgEarthUtil::EarthManipulator::ACTION_PAN_LEFT, osgGA::GUIEventAdapter::KEY_Left );
618+
_manipSettings->bindKey( osgEarthUtil::EarthManipulator::ACTION_PAN_RIGHT, osgGA::GUIEventAdapter::KEY_Right );
619+
_manipSettings->bindKey( osgEarthUtil::EarthManipulator::ACTION_PAN_UP, osgGA::GUIEventAdapter::KEY_Up );
620+
_manipSettings->bindKey( osgEarthUtil::EarthManipulator::ACTION_PAN_DOWN, osgGA::GUIEventAdapter::KEY_Down );
621+
622+
// double click the left button to zoom in on a point:
623+
options.clear();
624+
options.add( osgEarthUtil::EarthManipulator::OPTION_GOTO_RANGE_FACTOR, 0.4 );
625+
_manipSettings->bindMouseDoubleClick( osgEarthUtil::EarthManipulator::ACTION_GOTO, osgGA::GUIEventAdapter::LEFT_MOUSE_BUTTON, 0L, options );
626+
627+
// double click the right button (or CTRL-left button) to zoom out to a point
628+
options.clear();
629+
options.add( osgEarthUtil::EarthManipulator::OPTION_GOTO_RANGE_FACTOR, 2.5 );
630+
_manipSettings->bindMouseDoubleClick( osgEarthUtil::EarthManipulator::ACTION_GOTO, osgGA::GUIEventAdapter::RIGHT_MOUSE_BUTTON, 0L, options );
631+
_manipSettings->bindMouseDoubleClick( osgEarthUtil::EarthManipulator::ACTION_GOTO, osgGA::GUIEventAdapter::LEFT_MOUSE_BUTTON, osgGA::GUIEventAdapter::MODKEY_CTRL, options );
632+
633+
_manipSettings->setThrowingEnabled( false );
634+
_manipSettings->setLockAzimuthWhilePanning( true );
635+
636+
_manip->applySettings(_manipSettings);
637+
638+
*/
639+
640+
switch(ea.getEventType())
641+
{
642+
case(osgGA::GUIEventAdapter::KEYDOWN):
643+
{
644+
//move map
645+
if (ea.getKey() == '4' )
646+
{
647+
_manip->pan( -0.1, 0 );
648+
}
649+
if (ea.getKey() == '6' )
650+
{
651+
_manip->pan( 0.1, 0 );
652+
}
653+
if (ea.getKey() == '2' )
654+
{
655+
_manip->pan( 0, 0.1 );
656+
}
657+
if (ea.getKey() == '8' )
658+
{
659+
_manip->pan( 0, -0.1 );
660+
}
661+
//rotate
662+
if (ea.getKey() == '/' )
663+
{
664+
_manip->rotate( 1*deg, 0 );
665+
}
666+
if (ea.getKey() == '*' )
667+
{
668+
_manip->rotate( -1*deg, 0 );
669+
}
670+
//tilt
671+
if ( ea.getKey() == '9' )
672+
{
673+
_manip->rotate( 0, 1*deg );
674+
}
675+
if (ea.getKey() == '3' )
676+
{
677+
_manip->rotate( 0, -1*deg );
678+
}
679+
//zoom
680+
if (ea.getKey() == '-' )
681+
{
682+
_manip->zoom( 0, 0.1 );
683+
}
684+
if (ea.getKey() == '+' )
685+
{
686+
_manip->zoom( 0, -0.1 );
687+
}
688+
//reset
689+
if (ea.getKey() == '5' )
690+
{
691+
//_manip->zoom( 0, 1 );
692+
}
693+
break;
694+
}
695+
696+
default:
697+
break;
698+
}
699+
return false;
700+
}
599701

600702
/**
601703
* Required extern functions needed for every plugin

src/plugins/globe/globe_plugin.h

+17-3
Original file line numberDiff line numberDiff line change
@@ -110,16 +110,30 @@ class GlobePlugin : public QObject, public QgisPlugin
110110
osgEarthUtil::ObjectPlacer* mObjectPlacer;
111111
};
112112

113-
class ControlsHandler : public osgGA::GUIEventHandler
113+
class FlyToExtentHandler : public osgGA::GUIEventHandler
114114
{
115115
public:
116-
ControlsHandler( osgEarthUtil::EarthManipulator* manip, QgisInterface *qGisIface ) : _manip(manip), mQGisIface(qGisIface) { }
116+
FlyToExtentHandler( osgEarthUtil::EarthManipulator* manip, QgisInterface *qGisIface ) : _manip(manip), mQGisIface(qGisIface) { }
117117

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

120120
private:
121121
osg::observer_ptr<osgEarthUtil::EarthManipulator> _manip;
122-
osgEarthUtil::EarthManipulator::Settings* _manipSettings;
122+
123+
//! Pointer to the QGIS interface object
124+
QgisInterface *mQGisIface;
125+
};
126+
127+
class KeyboardControlHandler : public osgGA::GUIEventHandler
128+
{
129+
public:
130+
KeyboardControlHandler( osgEarthUtil::EarthManipulator* manip, QgisInterface *qGisIface ) : _manip(manip), mQGisIface(qGisIface) { }
131+
132+
bool handle( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa );
133+
134+
private:
135+
osg::observer_ptr<osgEarthUtil::EarthManipulator> _manip;
136+
123137
//! Pointer to the QGIS interface object
124138
QgisInterface *mQGisIface;
125139
};
826 Bytes
Loading
824 Bytes
Loading

0 commit comments

Comments
 (0)