Optional use of external osgEarthQt

This commit is contained in:
Pirmin Kalberer 2012-10-19 00:53:40 +02:00
parent a3097b4a27
commit be7504459e
5 changed files with 46 additions and 11 deletions

View File

@ -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.

View File

@ -38,5 +38,7 @@
#cmakedefine HAVE_TOUCH
#cmakedefine HAVE_OSGEARTHQT
#endif

View File

@ -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
@ -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
@ -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}
)

View File

@ -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>
@ -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

View File

@ -19,7 +19,8 @@
#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>
@ -27,8 +28,16 @@
#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>
@ -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
@ -193,7 +202,11 @@ namespace osgEarth
{
namespace Util
{
namespace Controls
#ifdef USE_BACKPORTED_CONTROLS
namespace Controls21
#else
namespace Controls
#endif
{
class NavigationControlHandler : public ControlEventHandler
{