Skip to content

Commit 7a96956

Browse files
Marco Bernasocchipka
Marco Bernasocchi
authored andcommitted
added HomeControlHandler
1 parent ab9bc85 commit 7a96956

File tree

2 files changed

+12
-15
lines changed

2 files changed

+12
-15
lines changed

src/plugins/globe/globe_plugin.cpp

+7-10
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ void GlobePlugin::setupMap()
259259
struct PanControlHandler : public NavigationControlHandler
260260
{
261261
PanControlHandler( osgEarthUtil::EarthManipulator* manip, double dx, double dy ) : _manip( manip ), _dx( dx ), _dy( dy ) { }
262-
virtual void onMouseDown( Control* control, int mouseButtonMask )
262+
virtual void onMouseDown( Control* control, int mouseButtonMask, const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa )
263263
{
264264
_manip->pan( _dx, _dy );
265265
}
@@ -272,7 +272,7 @@ struct PanControlHandler : public NavigationControlHandler
272272
struct RotateControlHandler : public NavigationControlHandler
273273
{
274274
RotateControlHandler( osgEarthUtil::EarthManipulator* manip, double dx, double dy ) : _manip( manip ), _dx( dx ), _dy( dy ) { }
275-
virtual void onMouseDown( Control* control, int mouseButtonMask )
275+
virtual void onMouseDown( Control* control, int mouseButtonMask, const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa )
276276
{
277277
if( 0 == _dx && 0 == _dy )
278278
{
@@ -292,7 +292,7 @@ struct RotateControlHandler : public NavigationControlHandler
292292
struct ZoomControlHandler : public NavigationControlHandler
293293
{
294294
ZoomControlHandler( osgEarthUtil::EarthManipulator* manip, double dx, double dy ) : _manip( manip ), _dx( dx ), _dy( dy ) { }
295-
virtual void onMouseDown( Control* control, int mouseButtonMask )
295+
virtual void onMouseDown( Control* control, int mouseButtonMask, const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa )
296296
{
297297
_manip->zoom( _dx, _dy );
298298
}
@@ -302,15 +302,12 @@ struct ZoomControlHandler : public NavigationControlHandler
302302
double _dy;
303303
};
304304

305-
struct HomeControlHandler : public ControlEventHandler
305+
struct HomeControlHandler : public NavigationControlHandler
306306
{
307307
HomeControlHandler( osgEarthUtil::EarthManipulator* manip ) : _manip( manip ) { }
308-
virtual void onClick( Control* control, int mouseButtonMask )
308+
virtual void onMouseDown( Control* control, int mouseButtonMask, const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa )
309309
{
310-
_manip->setRotation( osg::Quat() );
311-
//FIXME: instead of next 2 lines use _manip->home( control->ea, control->aa );
312-
osgEarthUtil::Viewpoint viewpoint( osg::Vec3d( -90, 0, 0.0 ), 0.0, -90.0, 3e7 );
313-
_manip->setViewpoint( viewpoint, 4.0 );
310+
_manip->home( ea, aa );
314311
}
315312
private:
316313
osg::observer_ptr<osgEarthUtil::EarthManipulator> _manip;
@@ -699,7 +696,7 @@ bool NavigationControl::handle( const osgGA::GUIEventAdapter& ea, osgGA::GUIActi
699696
for( ControlEventHandlerList::const_iterator i = _eventHandlers.begin(); i != _eventHandlers.end(); ++i )
700697
{
701698
NavigationControlHandler* handler = dynamic_cast<NavigationControlHandler*>( i->get() );
702-
if( handler ) handler->onMouseDown( this, ea.getButtonMask() );
699+
if( handler ) handler->onMouseDown( this, ea.getButtonMask(), ea, aa );
703700
}
704701
}
705702
return Control::handle( ea, aa, cx );

src/plugins/globe/globe_plugin.h

+5-5
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ class GlobePlugin : public QObject, public QgisPlugin
112112
osgEarthUtil::ObjectPlacer* mObjectPlacer;
113113
};
114114

115-
class FlyToExtentHandler : public osgGA::GUIEventHandler
115+
class FlyToExtentHandler : public osgGA::GUIEventHandler
116116
{
117117
public:
118118
FlyToExtentHandler( GlobePlugin* globe ) : mGlobe ( globe ) { }
@@ -123,7 +123,7 @@ class FlyToExtentHandler : public osgGA::GUIEventHandler
123123
GlobePlugin* mGlobe;
124124
};
125125

126-
class KeyboardControlHandler : public osgGA::GUIEventHandler
126+
class KeyboardControlHandler : public osgGA::GUIEventHandler
127127
{
128128
public:
129129
KeyboardControlHandler( osgEarthUtil::EarthManipulator* manip, QgisInterface *qGisIface ) : _manip(manip), mQGisIface(qGisIface) { }
@@ -137,14 +137,14 @@ class KeyboardControlHandler : public osgGA::GUIEventHandler
137137
QgisInterface *mQGisIface;
138138
};
139139

140-
namespace osgEarthUtil
141-
{
140+
namespace osgEarthUtil
141+
{
142142
namespace Controls2
143143
{
144144
class NavigationControlHandler : public ControlEventHandler
145145
{
146146
public:
147-
virtual void onMouseDown( class Control* control, int mouseButtonMask ) { }
147+
virtual void onMouseDown( class Control* control, int mouseButtonMask, const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa ) { }
148148
};
149149

150150
class NavigationControl : public ImageControl

0 commit comments

Comments
 (0)