Skip to content

Commit

Permalink
Globe: Fix compilation with osgearth 2.4
Browse files Browse the repository at this point in the history
  • Loading branch information
pka committed Apr 8, 2013
1 parent 7a79ebc commit 1436056
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 0 deletions.
1 change: 1 addition & 0 deletions cmake/FindOSGEARTH.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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 ######

Expand Down
4 changes: 4 additions & 0 deletions src/plugins/globe/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
12 changes: 12 additions & 0 deletions src/plugins/globe/globe_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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 );
Expand All @@ -398,6 +403,7 @@ void GlobePlugin::setupMap()
}
}
}
#endif

}

Expand Down Expand Up @@ -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;
Expand All @@ -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 )
Expand Down Expand Up @@ -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 )
Expand Down Expand Up @@ -1144,6 +1155,7 @@ osg::Vec3d QueryCoordinatesHandler::getCoords( float x, float y, osgViewer::View
}
return coords;
}
#endif

/**
* Required extern functions needed for every plugin
Expand Down
15 changes: 15 additions & 0 deletions src/plugins/globe/globe_plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,13 @@ using namespace osgEarth::Util::Controls21;
#include <osgEarthUtil/Controls>
using namespace osgEarth::Util::Controls;
#endif
#ifdef HAVE_OSGEARTH_ELEVATION_QUERY
#include <osgEarth/ElevationQuery>
#include <osgEarthUtil/ObjectLocator>
#else
#include <osgEarthUtil/ElevationManager>
#include <osgEarthUtil/ObjectPlacer>
#endif

class QAction;
class QToolBar;
Expand Down Expand Up @@ -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
Expand All @@ -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:
Expand All @@ -181,6 +195,7 @@ class QueryCoordinatesHandler : public osgGA::GUIEventHandler
osg::ref_ptr<osgEarth::Util::ElevationManager> _elevMan;
bool _mouseDown;
};
#endif


class KeyboardControlHandler : public osgGA::GUIEventHandler
Expand Down

0 comments on commit 1436056

Please sign in to comment.