diff --git a/cmake/FindOSGEARTH.cmake b/cmake/FindOSGEARTH.cmake index 4086fbb3895..bb4e8e9fe24 100644 --- a/cmake/FindOSGEARTH.cmake +++ b/cmake/FindOSGEARTH.cmake @@ -44,6 +44,7 @@ ENDMACRO( FIND_OSGEARTH_INCLUDE THIS_OSGEARTH_INCLUDE_DIR THIS_OSGEARTH_INCLUDE_ FIND_OSGEARTH_INCLUDE( OSGEARTH_GEN_INCLUDE_DIR osgEarth/Common ) FIND_OSGEARTH_INCLUDE( OSGEARTH_INCLUDE_DIR osgEarth/TileSource ) +FIND_OSGEARTH_INCLUDE( OSGEARTH_ELEVATION_QUERY osgEarth/ElevationQuery ) ###### libraries ###### diff --git a/src/plugins/globe/CMakeLists.txt b/src/plugins/globe/CMakeLists.txt index 4a3d6cbf8b6..b5a2afcb088 100644 --- a/src/plugins/globe/CMakeLists.txt +++ b/src/plugins/globe/CMakeLists.txt @@ -9,6 +9,10 @@ IF(HAVE_OSGEARTH_CHILD_SPACING) ADD_DEFINITIONS(-DHAVE_OSGEARTH_CHILD_SPACING) ENDIF(HAVE_OSGEARTH_CHILD_SPACING) +IF(OSGEARTH_ELEVATION_QUERY) + ADD_DEFINITIONS(-DHAVE_OSGEARTH_ELEVATION_QUERY) +ENDIF(OSGEARTH_ELEVATION_QUERY) + ######################################################## # Files diff --git a/src/plugins/globe/globe_plugin.cpp b/src/plugins/globe/globe_plugin.cpp index 95736040287..12838755d6e 100644 --- a/src/plugins/globe/globe_plugin.cpp +++ b/src/plugins/globe/globe_plugin.cpp @@ -311,9 +311,12 @@ void GlobePlugin::run() mOsgViewer->addEventHandler( new FlyToExtentHandler( this ) ); mOsgViewer->addEventHandler( new KeyboardControlHandler( manip, mQGisIface ) ); +#ifdef HAVE_OSGEARTH_ELEVATION_QUERY +#else mOsgViewer->addEventHandler( new QueryCoordinatesHandler( this, mElevationManager, mMapNode->getMap()->getProfile()->getSRS() ) ); +#endif } else { @@ -376,6 +379,8 @@ void GlobePlugin::setupMap() elevationLayersChanged(); // model placement utils +#ifdef HAVE_OSGEARTH_ELEVATION_QUERY +#else mElevationManager = new osgEarth::Util::ElevationManager( mMapNode->getMap() ); mElevationManager->setTechnique( osgEarth::Util::ElevationManager::TECHNIQUE_GEOMETRIC ); mElevationManager->setMaxTilesToCache( 50 ); @@ -398,6 +403,7 @@ void GlobePlugin::setupMap() } } } +#endif } @@ -863,6 +869,8 @@ void GlobePlugin::help() void GlobePlugin::placeNode( osg::Node* node, double lat, double lon, double alt /*= 0.0*/ ) { +#ifdef HAVE_OSGEARTH_ELEVATION_QUERY +#else // get elevation double elevation = 0.0; double resolution = 0.0; @@ -875,6 +883,7 @@ void GlobePlugin::placeNode( osg::Node* node, double lat, double lon, double alt osg::MatrixTransform* mt = new osg::MatrixTransform( mat ); mt->addChild( node ); mRootNode->addChild( mt ); +#endif } void GlobePlugin::copyFolder( QString sourceFolder, QString destFolder ) @@ -1068,6 +1077,8 @@ bool FlyToExtentHandler::handle( const osgGA::GUIEventAdapter& ea, osgGA::GUIAct return false; } +#ifdef HAVE_OSGEARTH_ELEVATION_QUERY +#else bool QueryCoordinatesHandler::handle( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa ) { if ( ea.getEventType() == osgGA::GUIEventAdapter::MOVE ) @@ -1144,6 +1155,7 @@ osg::Vec3d QueryCoordinatesHandler::getCoords( float x, float y, osgViewer::View } return coords; } +#endif /** * Required extern functions needed for every plugin diff --git a/src/plugins/globe/globe_plugin.h b/src/plugins/globe/globe_plugin.h index 93b5bdf9851..ccec54c0250 100644 --- a/src/plugins/globe/globe_plugin.h +++ b/src/plugins/globe/globe_plugin.h @@ -38,8 +38,13 @@ using namespace osgEarth::Util::Controls21; #include using namespace osgEarth::Util::Controls; #endif +#ifdef HAVE_OSGEARTH_ELEVATION_QUERY +#include +#include +#else #include #include +#endif class QAction; class QToolBar; @@ -136,10 +141,17 @@ class GlobePlugin : public QObject, public QgisPlugin osgEarth::Drivers::QgsOsgEarthTileSource* mTileSource; //! Control Canvas ControlCanvas* mControlCanvas; +#ifdef HAVE_OSGEARTH_ELEVATION_QUERY + //! Elevation manager + osgEarth::ElevationQuery* mElevationManager; + //! Object placer + osgEarth::Util::ObjectLocator* mObjectPlacer; +#else //! Elevation manager osgEarth::Util::ElevationManager* mElevationManager; //! Object placer osgEarth::Util::ObjectPlacer* mObjectPlacer; +#endif //! tracks if the globe is open bool mIsGlobeRunning; //! coordinates of the right-clicked point on the globe @@ -164,6 +176,8 @@ class FlyToExtentHandler : public osgGA::GUIEventHandler }; // An event handler that will print out the coordinates at the clicked point +#ifdef HAVE_OSGEARTH_ELEVATION_QUERY +#else class QueryCoordinatesHandler : public osgGA::GUIEventHandler { public: @@ -181,6 +195,7 @@ class QueryCoordinatesHandler : public osgGA::GUIEventHandler osg::ref_ptr _elevMan; bool _mouseDown; }; +#endif class KeyboardControlHandler : public osgGA::GUIEventHandler