Skip to content

Commit 5a1f768

Browse files
committed
globe plugin fixes:
- implement a compile check to tell apart OSGEARTH 2.0 from 3.0 - fix warnings
1 parent 0c1cd9e commit 5a1f768

8 files changed

+45
-19
lines changed

cmake/FindOSGEARTH.cmake

+16
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,22 @@ SET( OSGEARTH_FOUND "NO" )
9797
IF( OSGEARTH_LIBRARY AND OSGEARTH_INCLUDE_DIR )
9898
SET( OSGEARTH_FOUND "YES" )
9999
SET( OSGEARTH_INCLUDE_DIRS ${OSGEARTH_INCLUDE_DIR} ${OSGEARTH_GEN_INCLUDE_DIR} )
100+
INCLUDE(CheckCXXSourceCompiles)
101+
SET(SAFE_CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES})
102+
SET(SAFE_CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
103+
SET(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${OSGEARTH_INCLUDE_DIR})
104+
SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${OSGEARTHUTIL_LIBRARY})
105+
CHECK_CXX_SOURCE_COMPILES("
106+
#include <osgEarthUtil/Controls>
107+
using namespace osgEarth::Util::Controls;
108+
int main(int argc, char **argv)
109+
{
110+
Container *c;
111+
c->setChildSpacing(0.0);
112+
}
113+
" HAVE_OSGEARTH_CHILD_SPACING)
114+
SET(CMAKE_REQUIRED_INCLUDES ${SAFE_CMAKE_REQUIRED_INCLUDES})
115+
SET(CMAKE_REQUIRED_LIBRARIES ${SAFE_CMAKE_REQUIRED_LIBRARIES})
100116
GET_FILENAME_COMPONENT( OSGEARTH_LIBRARIES_DIR ${OSGEARTH_LIBRARY} PATH )
101117
ENDIF( OSGEARTH_LIBRARY AND OSGEARTH_INCLUDE_DIR )
102118

src/plugins/globe/CMakeLists.txt

+4
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ FIND_PACKAGE(OSG REQUIRED)
55
FIND_PACKAGE(OSGEARTH REQUIRED)
66
FIND_PACKAGE(Threads)
77

8+
IF(HAVE_OSGEARTH_CHILD_SPACING)
9+
ADD_DEFINITIONS(-DHAVE_OSGEARTH_CHILD_SPACING)
10+
ENDIF(HAVE_OSGEARTH_CHILD_SPACING)
11+
812
########################################################
913
# Files
1014

src/plugins/globe/WorldWindOptions

+5-4
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,11 @@ namespace osgEarth { namespace Drivers
4444
//const optional<std::string>& imageURL() const { return _imageURL; }
4545

4646
public:
47-
WorldWindOptions( const TileSourceOptions& opt =TileSourceOptions() ) : TileSourceOptions( opt ),
48-
_maxLOD( 11 ),
49-
_elevationURL( "http://worldwind25.arc.nasa.gov/wwelevation/wwelevation.aspx?T=srtm30pluszip" ),
50-
_imageURL( "http://s0.tileservice.worldwindcentral.com/getTile?" )
47+
WorldWindOptions( const TileSourceOptions& opt =TileSourceOptions() )
48+
: TileSourceOptions( opt )
49+
, _imageURL( "http://s0.tileservice.worldwindcentral.com/getTile?" )
50+
, _elevationURL( "http://worldwind25.arc.nasa.gov/wwelevation/wwelevation.aspx?T=srtm30pluszip" )
51+
, _maxLOD( 11 )
5152
{
5253
setDriver( "worldwind" );
5354
fromConfig( _conf );

src/plugins/globe/globe_plugin.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
Date : 08-Jul-2010
88
Copyright : (C) 2010 by Sourcepole
99
Email : info at sourcepole.ch
10-
/***************************************************************************
10+
***************************************************************************
1111
* *
1212
* This program is free software; you can redistribute it and/or modify *
1313
* it under the terms of the GNU General Public License as published by *
@@ -156,7 +156,7 @@ class QueryCoordinatesHandler : public osgGA::GUIEventHandler
156156
public:
157157
QueryCoordinatesHandler( GlobePlugin* globe, osgEarth::Util::ElevationManager* elevMan,
158158
const osgEarth::SpatialReference* mapSRS )
159-
: mGlobe( globe ), _elevMan( elevMan ), _mapSRS( mapSRS ), _mouseDown( false ) { }
159+
: mGlobe( globe ), _mapSRS( mapSRS ), _elevMan( elevMan ), _mouseDown( false ) { }
160160

161161
bool handle( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa );
162162

@@ -194,8 +194,8 @@ namespace osgEarth
194194
class NavigationControlHandler : public ControlEventHandler
195195
{
196196
public:
197-
virtual void onMouseDown( class Control* control, int mouseButtonMask ) { }
198-
virtual void onClick( class Control* control, int mouseButtonMask, const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa ) { }
197+
virtual void onMouseDown( class Control* control, int mouseButtonMask ) { Q_UNUSED( control ); Q_UNUSED( mouseButtonMask ); }
198+
virtual void onClick( class Control* control, int mouseButtonMask, const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa ) { Q_UNUSED( control ); Q_UNUSED( mouseButtonMask ); Q_UNUSED( ea ); Q_UNUSED( aa ); }
199199
};
200200

201201
class NavigationControl : public ImageControl

src/plugins/globe/globe_plugin_dialog.cpp

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
1-
/*
2-
* $Id$
3-
*/
41
/***************************************************************************
52
* globe_plugin_dialog.cpp - settings dialog for the globe plugin
63
* --------------------------------------
74
* Date : 11-Nov-2010
85
* Copyright : (C) 2010 by Marco Bernasocchi
96
* Email : marco at bernawebdesign.ch
10-
* /***************************************************************************
7+
***************************************************************************
118
* *
129
* This program is free software; you can redistribute it and/or modify *
1310
* it under the terms of the GNU General Public License as published by *
@@ -42,7 +39,8 @@
4239

4340
//constructor
4441
QgsGlobePluginDialog::QgsGlobePluginDialog( QgsOsgViewer* viewer, QWidget* parent, Qt::WFlags fl )
45-
: mViewer( viewer ), QDialog( parent, fl )
42+
: QDialog( parent, fl )
43+
, mViewer( viewer )
4644
{
4745
setupUi( this );
4846
loadStereoConfig(); //values from settings, default values from OSG
@@ -405,6 +403,7 @@ void QgsGlobePluginDialog::on_resetStereoDefaults_clicked()
405403

406404
void QgsGlobePluginDialog::on_comboStereoMode_currentIndexChanged( QString value )
407405
{
406+
Q_UNUSED( value );
408407
setStereoMode();
409408
updateStereoDialog();
410409
}

src/plugins/globe/globe_plugin_dialog.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
Date : 11-Nov-2010
88
Copyright : (C) 2010 by Marco Bernasocchi
99
Email : marco at bernawebdesign.ch
10-
/***************************************************************************
10+
***************************************************************************
1111
* *
1212
* This program is free software; you can redistribute it and/or modify *
1313
* it under the terms of the GNU General Public License as published by *

src/plugins/globe/qgsosgearthtilesource.cpp

+9-5
Original file line numberDiff line numberDiff line change
@@ -36,19 +36,21 @@ QgsOsgEarthTileSource::QgsOsgEarthTileSource( QgisInterface* theQgisInterface, c
3636

3737
void QgsOsgEarthTileSource::initialize( const std::string& referenceURI, const Profile* overrideProfile )
3838
{
39+
Q_UNUSED( referenceURI );
40+
Q_UNUSED( overrideProfile );
41+
3942
setProfile( osgEarth::Registry::instance()->getGlobalGeodeticProfile() );
4043
QgsMapRenderer* mainRenderer = mQGisIface->mapCanvas()->mapRenderer();
4144
mMapRenderer = new QgsMapRenderer();
4245

4346
long epsgGlobe = 4326;
44-
if ( mainRenderer->destinationSrs().epsg() != epsgGlobe )
47+
if ( mainRenderer->destinationCrs().authid().compare( QString( "EPSG:%1" ).arg( epsgGlobe ), Qt::CaseInsensitive ) == 0 )
4548
{
46-
QgsCoordinateReferenceSystem srcCRS;
47-
srcCRS.createFromEpsg( mainRenderer->destinationSrs().epsg() ); //FIXME: crs from canvas or first layer?
49+
QgsCoordinateReferenceSystem srcCRS( mainRenderer->destinationCrs() ); //FIXME: crs from canvas or first layer?
4850
QgsCoordinateReferenceSystem destCRS;
49-
destCRS.createFromEpsg( epsgGlobe );
51+
destCRS.createFromOgcWmsCrs( QString( "EPSG:%1" ).arg( epsgGlobe ) );
5052
//QgsProject::instance()->writeEntry("SpatialRefSys","/ProjectionsEnabled",1);
51-
mMapRenderer->setDestinationSrs( destCRS );
53+
mMapRenderer->setDestinationCrs( destCRS );
5254
mMapRenderer->setProjectionsEnabled( true );
5355
mCoordTranform = new QgsCoordinateTransform( srcCRS, destCRS );
5456
}
@@ -60,6 +62,8 @@ void QgsOsgEarthTileSource::initialize( const std::string& referenceURI, const P
6062

6163
osg::Image* QgsOsgEarthTileSource::createImage( const TileKey& key, ProgressCallback* progress )
6264
{
65+
Q_UNUSED( key );
66+
Q_UNUSED( progress );
6367
osg::ref_ptr<osg::Image> image;
6468
if ( intersects( &key ) )
6569
{

src/plugins/globe/qgsosgearthtilesource.h

+2
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ namespace osgEarth
2828
osg::HeightField* createHeightField( const TileKey* key,
2929
ProgressCallback* progress )
3030
{
31+
Q_UNUSED( key );
32+
Q_UNUSED( progress );
3133
//NI
3234
OE_WARN << "[QGIS] Driver does not support heightfields" << std::endl;
3335
return NULL;

0 commit comments

Comments
 (0)