Skip to content

Commit

Permalink
Optional use of external osgEarthQt
Browse files Browse the repository at this point in the history
  • Loading branch information
pka committed Oct 19, 2012
1 parent a3097b4 commit be75044
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 11 deletions.
4 changes: 4 additions & 0 deletions CMakeLists.txt
Expand Up @@ -95,6 +95,10 @@ SET (WITH_GLOBE FALSE CACHE BOOL "Determines whether Globe plugin should be buil
IF (WITH_GLOBE)
SET(QT_USE_QTOPENGL 1)
FIND_PACKAGE(OSGEARTH REQUIRED)
IF (OSGEARTHQT_LIBRARY)
# following variable is used in qgsconfig.h
SET(HAVE_OSGEARTHQT TRUE)
ENDIF (OSGEARTHQT_LIBRARY)
ENDIF (WITH_GLOBE)

# Compile flag. Make it possible to turn it off.
Expand Down
2 changes: 2 additions & 0 deletions cmake_templates/qgsconfig.h.in
Expand Up @@ -38,5 +38,7 @@

#cmakedefine HAVE_TOUCH

#cmakedefine HAVE_OSGEARTHQT

#endif

23 changes: 19 additions & 4 deletions src/plugins/globe/CMakeLists.txt
Expand Up @@ -17,6 +17,13 @@ SET (globe_plugin_SRCS
qgsosgearthtilesource.cpp
globe_plugin_dialog.cpp
)
IF (NOT HAVE_OSGEARTHQT)
SET(globe_plugin_SRCS
${globe_plugin_SRCS}
osgEarthQt/ViewerWidget.cpp
osgEarthUtil/Controls.cpp
)
ENDIF (NOT HAVE_OSGEARTHQT)

SET (globe_plugin_UIS
globe_plugin_dialog_guibase.ui
Expand Down Expand Up @@ -49,6 +56,17 @@ INCLUDE_DIRECTORIES(
..
)

SET (OSGEARTH_LIBS
${OSGEARTH_LIBRARY}
${OSGEARTHFEATURES_LIBRARY}
${OSGEARTHUTIL_LIBRARY}
)
IF (HAVE_OSGEARTHQT)
SET(OSGEARTH_LIBS
${OSGEARTH_LIBS}
${OSGEARTHQT_LIBRARY}
)
ENDIF (HAVE_OSGEARTHQT)
TARGET_LINK_LIBRARIES(globeplugin
qgis_core
qgis_gui
Expand All @@ -59,10 +77,7 @@ TARGET_LINK_LIBRARIES(globeplugin
${OSG_LIBRARY}
${OSGQT_LIBRARY}
${OSGVIEWER_LIBRARY}
${OSGEARTH_LIBRARY}
${OSGEARTHFEATURES_LIBRARY}
${OSGEARTHUTIL_LIBRARY}
${OSGEARTHQT_LIBRARY}
${OSGEARTH_LIBS}
${OPENTHREADS_LIBRARY}
)

Expand Down
7 changes: 4 additions & 3 deletions src/plugins/globe/globe_plugin.cpp
Expand Up @@ -19,8 +19,11 @@
#include "globe_plugin.h"
#include "globe_plugin_dialog.h"
#include "qgsosgearthtilesource.h"
#ifdef HAVE_OSGEARTHQT
#include <osgEarthQt/ViewerWidget>
//#include "osgEarthQt/ViewerWidget"
#else
#include "osgEarthQt/ViewerWidget"
#endif

#include <cmath>

Expand Down Expand Up @@ -60,8 +63,6 @@

using namespace osgEarth::Drivers;
using namespace osgEarth::Util;
using namespace osgEarth::Util::Controls;
//using namespace osgEarth::Util::Controls21;

#define MOVE_OFFSET 0.05

Expand Down
21 changes: 17 additions & 4 deletions src/plugins/globe/globe_plugin.h
Expand Up @@ -19,16 +19,25 @@
#ifndef QGS_GLOBE_PLUGIN_H
#define QGS_GLOBE_PLUGIN_H

#include "../qgisplugin.h"
#include "qgsconfig.h"
#include "qgisplugin.h"
#include "qgsosgearthtilesource.h"
#include "globe_plugin_dialog.h"
#include <QObject>
#include <osgViewer/Viewer>
#include <osgEarth/MapNode>
#include <osgEarth/ImageLayer>
#include <osgEarthUtil/EarthManipulator>
#ifndef HAVE_OSGEARTHQT //use backported controls if osgEarth <= 2.1
#define USE_BACKPORTED_CONTROLS
#endif
#ifdef USE_BACKPORTED_CONTROLS
#include "osgEarthUtil/Controls"
using namespace osgEarth::Util::Controls21;
#else
#include <osgEarthUtil/Controls>
//#include "osgEarthUtil/Controls"
using namespace osgEarth::Util::Controls;
#endif
#include <osgEarthUtil/ElevationManager>
#include <osgEarthUtil/ObjectPlacer>

Expand Down Expand Up @@ -126,7 +135,7 @@ class GlobePlugin : public QObject, public QgisPlugin
//! Tile source
osgEarth::Drivers::QgsOsgEarthTileSource* mTileSource;
//! Control Canvas
osgEarth::Util::Controls::ControlCanvas* mControlCanvas;
ControlCanvas* mControlCanvas;
//! Elevation manager
osgEarth::Util::ElevationManager* mElevationManager;
//! Object placer
Expand Down Expand Up @@ -193,7 +202,11 @@ namespace osgEarth
{
namespace Util
{
namespace Controls
#ifdef USE_BACKPORTED_CONTROLS
namespace Controls21
#else
namespace Controls
#endif
{
class NavigationControlHandler : public ControlEventHandler
{
Expand Down

0 comments on commit be75044

Please sign in to comment.