Skip to content

Commit

Permalink
added HomeControlHandler
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 ab9bc85 commit 7a96956
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 15 deletions.
17 changes: 7 additions & 10 deletions src/plugins/globe/globe_plugin.cpp
Expand Up @@ -259,7 +259,7 @@ void GlobePlugin::setupMap()
struct PanControlHandler : public NavigationControlHandler
{
PanControlHandler( osgEarthUtil::EarthManipulator* manip, double dx, double dy ) : _manip( manip ), _dx( dx ), _dy( dy ) { }
virtual void onMouseDown( Control* control, int mouseButtonMask )
virtual void onMouseDown( Control* control, int mouseButtonMask, const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa )
{
_manip->pan( _dx, _dy );
}
Expand All @@ -272,7 +272,7 @@ struct PanControlHandler : public NavigationControlHandler
struct RotateControlHandler : public NavigationControlHandler
{
RotateControlHandler( osgEarthUtil::EarthManipulator* manip, double dx, double dy ) : _manip( manip ), _dx( dx ), _dy( dy ) { }
virtual void onMouseDown( Control* control, int mouseButtonMask )
virtual void onMouseDown( Control* control, int mouseButtonMask, const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa )
{
if( 0 == _dx && 0 == _dy )
{
Expand All @@ -292,7 +292,7 @@ struct RotateControlHandler : public NavigationControlHandler
struct ZoomControlHandler : public NavigationControlHandler
{
ZoomControlHandler( osgEarthUtil::EarthManipulator* manip, double dx, double dy ) : _manip( manip ), _dx( dx ), _dy( dy ) { }
virtual void onMouseDown( Control* control, int mouseButtonMask )
virtual void onMouseDown( Control* control, int mouseButtonMask, const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa )
{
_manip->zoom( _dx, _dy );
}
Expand All @@ -302,15 +302,12 @@ struct ZoomControlHandler : public NavigationControlHandler
double _dy;
};

struct HomeControlHandler : public ControlEventHandler
struct HomeControlHandler : public NavigationControlHandler
{
HomeControlHandler( osgEarthUtil::EarthManipulator* manip ) : _manip( manip ) { }
virtual void onClick( Control* control, int mouseButtonMask )
virtual void onMouseDown( Control* control, int mouseButtonMask, const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa )
{
_manip->setRotation( osg::Quat() );
//FIXME: instead of next 2 lines use _manip->home( control->ea, control->aa );
osgEarthUtil::Viewpoint viewpoint( osg::Vec3d( -90, 0, 0.0 ), 0.0, -90.0, 3e7 );
_manip->setViewpoint( viewpoint, 4.0 );
_manip->home( ea, aa );
}
private:
osg::observer_ptr<osgEarthUtil::EarthManipulator> _manip;
Expand Down Expand Up @@ -699,7 +696,7 @@ bool NavigationControl::handle( const osgGA::GUIEventAdapter& ea, osgGA::GUIActi
for( ControlEventHandlerList::const_iterator i = _eventHandlers.begin(); i != _eventHandlers.end(); ++i )
{
NavigationControlHandler* handler = dynamic_cast<NavigationControlHandler*>( i->get() );
if( handler ) handler->onMouseDown( this, ea.getButtonMask() );
if( handler ) handler->onMouseDown( this, ea.getButtonMask(), ea, aa );
}
}
return Control::handle( ea, aa, cx );
Expand Down
10 changes: 5 additions & 5 deletions src/plugins/globe/globe_plugin.h
Expand Up @@ -112,7 +112,7 @@ class GlobePlugin : public QObject, public QgisPlugin
osgEarthUtil::ObjectPlacer* mObjectPlacer;
};

class FlyToExtentHandler : public osgGA::GUIEventHandler
class FlyToExtentHandler : public osgGA::GUIEventHandler
{
public:
FlyToExtentHandler( GlobePlugin* globe ) : mGlobe ( globe ) { }
Expand All @@ -123,7 +123,7 @@ class FlyToExtentHandler : public osgGA::GUIEventHandler
GlobePlugin* mGlobe;
};

class KeyboardControlHandler : public osgGA::GUIEventHandler
class KeyboardControlHandler : public osgGA::GUIEventHandler
{
public:
KeyboardControlHandler( osgEarthUtil::EarthManipulator* manip, QgisInterface *qGisIface ) : _manip(manip), mQGisIface(qGisIface) { }
Expand All @@ -137,14 +137,14 @@ class KeyboardControlHandler : public osgGA::GUIEventHandler
QgisInterface *mQGisIface;
};

namespace osgEarthUtil
{
namespace osgEarthUtil
{
namespace Controls2
{
class NavigationControlHandler : public ControlEventHandler
{
public:
virtual void onMouseDown( class Control* control, int mouseButtonMask ) { }
virtual void onMouseDown( class Control* control, int mouseButtonMask, const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa ) { }
};

class NavigationControl : public ImageControl
Expand Down

0 comments on commit 7a96956

Please sign in to comment.