Skip to content

Commit 1436056

Browse files
committedApr 8, 2013
Globe: Fix compilation with osgearth 2.4
1 parent 7a79ebc commit 1436056

File tree

4 files changed

+32
-0
lines changed

4 files changed

+32
-0
lines changed
 

‎cmake/FindOSGEARTH.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ ENDMACRO( FIND_OSGEARTH_INCLUDE THIS_OSGEARTH_INCLUDE_DIR THIS_OSGEARTH_INCLUDE_
4444

4545
FIND_OSGEARTH_INCLUDE( OSGEARTH_GEN_INCLUDE_DIR osgEarth/Common )
4646
FIND_OSGEARTH_INCLUDE( OSGEARTH_INCLUDE_DIR osgEarth/TileSource )
47+
FIND_OSGEARTH_INCLUDE( OSGEARTH_ELEVATION_QUERY osgEarth/ElevationQuery )
4748

4849
###### libraries ######
4950

‎src/plugins/globe/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ IF(HAVE_OSGEARTH_CHILD_SPACING)
99
ADD_DEFINITIONS(-DHAVE_OSGEARTH_CHILD_SPACING)
1010
ENDIF(HAVE_OSGEARTH_CHILD_SPACING)
1111

12+
IF(OSGEARTH_ELEVATION_QUERY)
13+
ADD_DEFINITIONS(-DHAVE_OSGEARTH_ELEVATION_QUERY)
14+
ENDIF(OSGEARTH_ELEVATION_QUERY)
15+
1216
########################################################
1317
# Files
1418

‎src/plugins/globe/globe_plugin.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,9 +311,12 @@ void GlobePlugin::run()
311311
mOsgViewer->addEventHandler( new FlyToExtentHandler( this ) );
312312
mOsgViewer->addEventHandler( new KeyboardControlHandler( manip, mQGisIface ) );
313313

314+
#ifdef HAVE_OSGEARTH_ELEVATION_QUERY
315+
#else
314316
mOsgViewer->addEventHandler( new QueryCoordinatesHandler( this, mElevationManager,
315317
mMapNode->getMap()->getProfile()->getSRS() )
316318
);
319+
#endif
317320
}
318321
else
319322
{
@@ -376,6 +379,8 @@ void GlobePlugin::setupMap()
376379
elevationLayersChanged();
377380

378381
// model placement utils
382+
#ifdef HAVE_OSGEARTH_ELEVATION_QUERY
383+
#else
379384
mElevationManager = new osgEarth::Util::ElevationManager( mMapNode->getMap() );
380385
mElevationManager->setTechnique( osgEarth::Util::ElevationManager::TECHNIQUE_GEOMETRIC );
381386
mElevationManager->setMaxTilesToCache( 50 );
@@ -398,6 +403,7 @@ void GlobePlugin::setupMap()
398403
}
399404
}
400405
}
406+
#endif
401407

402408
}
403409

@@ -863,6 +869,8 @@ void GlobePlugin::help()
863869

864870
void GlobePlugin::placeNode( osg::Node* node, double lat, double lon, double alt /*= 0.0*/ )
865871
{
872+
#ifdef HAVE_OSGEARTH_ELEVATION_QUERY
873+
#else
866874
// get elevation
867875
double elevation = 0.0;
868876
double resolution = 0.0;
@@ -875,6 +883,7 @@ void GlobePlugin::placeNode( osg::Node* node, double lat, double lon, double alt
875883
osg::MatrixTransform* mt = new osg::MatrixTransform( mat );
876884
mt->addChild( node );
877885
mRootNode->addChild( mt );
886+
#endif
878887
}
879888

880889
void GlobePlugin::copyFolder( QString sourceFolder, QString destFolder )
@@ -1068,6 +1077,8 @@ bool FlyToExtentHandler::handle( const osgGA::GUIEventAdapter& ea, osgGA::GUIAct
10681077
return false;
10691078
}
10701079

1080+
#ifdef HAVE_OSGEARTH_ELEVATION_QUERY
1081+
#else
10711082
bool QueryCoordinatesHandler::handle( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa )
10721083
{
10731084
if ( ea.getEventType() == osgGA::GUIEventAdapter::MOVE )
@@ -1144,6 +1155,7 @@ osg::Vec3d QueryCoordinatesHandler::getCoords( float x, float y, osgViewer::View
11441155
}
11451156
return coords;
11461157
}
1158+
#endif
11471159

11481160
/**
11491161
* Required extern functions needed for every plugin

‎src/plugins/globe/globe_plugin.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,13 @@ using namespace osgEarth::Util::Controls21;
3838
#include <osgEarthUtil/Controls>
3939
using namespace osgEarth::Util::Controls;
4040
#endif
41+
#ifdef HAVE_OSGEARTH_ELEVATION_QUERY
42+
#include <osgEarth/ElevationQuery>
43+
#include <osgEarthUtil/ObjectLocator>
44+
#else
4145
#include <osgEarthUtil/ElevationManager>
4246
#include <osgEarthUtil/ObjectPlacer>
47+
#endif
4348

4449
class QAction;
4550
class QToolBar;
@@ -136,10 +141,17 @@ class GlobePlugin : public QObject, public QgisPlugin
136141
osgEarth::Drivers::QgsOsgEarthTileSource* mTileSource;
137142
//! Control Canvas
138143
ControlCanvas* mControlCanvas;
144+
#ifdef HAVE_OSGEARTH_ELEVATION_QUERY
145+
//! Elevation manager
146+
osgEarth::ElevationQuery* mElevationManager;
147+
//! Object placer
148+
osgEarth::Util::ObjectLocator* mObjectPlacer;
149+
#else
139150
//! Elevation manager
140151
osgEarth::Util::ElevationManager* mElevationManager;
141152
//! Object placer
142153
osgEarth::Util::ObjectPlacer* mObjectPlacer;
154+
#endif
143155
//! tracks if the globe is open
144156
bool mIsGlobeRunning;
145157
//! coordinates of the right-clicked point on the globe
@@ -164,6 +176,8 @@ class FlyToExtentHandler : public osgGA::GUIEventHandler
164176
};
165177

166178
// An event handler that will print out the coordinates at the clicked point
179+
#ifdef HAVE_OSGEARTH_ELEVATION_QUERY
180+
#else
167181
class QueryCoordinatesHandler : public osgGA::GUIEventHandler
168182
{
169183
public:
@@ -181,6 +195,7 @@ class QueryCoordinatesHandler : public osgGA::GUIEventHandler
181195
osg::ref_ptr<osgEarth::Util::ElevationManager> _elevMan;
182196
bool _mouseDown;
183197
};
198+
#endif
184199

185200

186201
class KeyboardControlHandler : public osgGA::GUIEventHandler

0 commit comments

Comments
 (0)
Please sign in to comment.