From 3d7558c28b96f60e5a0de0eb4751bfa291cf75e1 Mon Sep 17 00:00:00 2001 From: Philippe Renon Date: Thu, 7 Jan 2016 21:36:17 +0100 Subject: [PATCH] LP-29 split osg and osgearth SDKs and make osgearth optional --- Makefile | 6 +- ground/gcs/gcs.pri | 3 - ground/gcs/src/libs/osgearth/copydata.pro | 411 +++++++++--------- .../libs/osgearth/osgQtQuick/OSGCamera.cpp | 37 +- .../libs/osgearth/osgQtQuick/OSGViewport.cpp | 5 +- ground/gcs/src/libs/osgearth/osgearth.cpp | 10 +- ground/gcs/src/libs/osgearth/osgearth.pri | 4 +- ground/gcs/src/libs/osgearth/osgearth.pro | 22 +- .../libs/osgearth/osgearth_dependencies.pri | 69 ++- ground/gcs/src/libs/osgearth/utility.cpp | 168 +++---- ground/gcs/src/libs/osgearth/utility.h | 15 +- make/3rdparty/osgearth/osgearth.mk | 8 +- make/tools.mk | 36 +- 13 files changed, 447 insertions(+), 347 deletions(-) diff --git a/Makefile b/Makefile index 04db0a97a..7184cfab2 100644 --- a/Makefile +++ b/Makefile @@ -147,11 +147,7 @@ include $(ROOT_DIR)/make/tools.mk # We almost need to consider autoconf/automake instead of this ifeq ($(UNAME), Linux) - ifeq ($(ARCH), x86_64) - QT_SPEC := linux-g++-64 - else - QT_SPEC := linux-g++-32 - endif + QT_SPEC := linux-g++ UAVOBJGENERATOR := $(BUILD_DIR)/uavobjgenerator/uavobjgenerator else ifeq ($(UNAME), Darwin) QT_SPEC := macx-g++ diff --git a/ground/gcs/gcs.pri b/ground/gcs/gcs.pri index 75385aa71..150eaca0a 100644 --- a/ground/gcs/gcs.pri +++ b/ground/gcs/gcs.pri @@ -159,7 +159,6 @@ macx { GCS_DOC_PATH = $$GCS_DATA_PATH/doc copydata = 1 copyqt = 1 - copyosg = 1 } else { GCS_APP_TARGET = $$GCS_SMALL_NAME GCS_PATH = $$GCS_BUILD_TREE @@ -185,7 +184,6 @@ macx { GCS_QT_QML_PATH = $$GCS_APP_PATH copyqt = $$copydata - copyosg = $$copydata } else { GCS_QT_BASEPATH = $$GCS_LIBRARY_PATH/qt5 GCS_QT_LIBRARY_PATH = $$GCS_QT_BASEPATH/lib @@ -198,7 +196,6 @@ macx { } else { copyqt = 0 } - copyosg = 1 } } diff --git a/ground/gcs/src/libs/osgearth/copydata.pro b/ground/gcs/src/libs/osgearth/copydata.pro index e28e3d7b9..5e2a24c6f 100644 --- a/ground/gcs/src/libs/osgearth/copydata.pro +++ b/ground/gcs/src/libs/osgearth/copydata.pro @@ -1,200 +1,223 @@ # # copy osg and osgearth libraries and data to build dir # -equals(copyosg, 1) { - OSG_VERSION = 3.4.0 - - linux { - # copy osg libraries - - data_copy.commands += $(MKDIR) $${GCS_LIBRARY_PATH}/osg $$addNewline() - *-64 { - data_copy.commands += $(COPY_DIR) $$shell_quote($$OSG_SDK_DIR/lib64/)* $$shell_quote($$GCS_LIBRARY_PATH/osg/) - } - *-32 { - data_copy.commands += $(COPY_DIR) $$shell_quote($$OSG_SDK_DIR/lib/)* $$shell_quote($$GCS_LIBRARY_PATH/osg/) - } - - # add make target - POST_TARGETDEPS += copydata - - data_copy.target = copydata - QMAKE_EXTRA_TARGETS += data_copy - } - - macx { - - data_copy.commands += $(COPY_DIR) $$shell_quote($$OSG_SDK_DIR/lib/)* $$shell_quote($$GCS_LIBRARY_PATH/) - - # add make target - POST_TARGETDEPS += copydata - - data_copy.target = copydata - QMAKE_EXTRA_TARGETS += data_copy - } - - win32 { - # set debug suffix if needed - #CONFIG(debug, debug|release):DS = "d" - - # copy osg libraries - OSG_LIBS = \ - libcurl-4.dll \ - libfreetype-6.dll \ - libgdal.dll \ - libgeos-3-3-8.dll \ - libgeos_c-1.dll \ - libjpeg-9.dll \ - libpng16-16.dll \ - libproj-0.dll \ - libtiff-5.dll \ - libtiffxx-5.dll \ - zlib1.dll \ - libOpenThreads$${DS}.dll \ - libosg$${DS}.dll \ - libosgAnimation$${DS}.dll \ - libosgDB$${DS}.dll \ - libosgEarth$${DS}.dll \ - libosgEarthAnnotation$${DS}.dll \ - libosgEarthFeatures$${DS}.dll \ - libosgEarthQt$${DS}.dll \ - libosgEarthSymbology$${DS}.dll \ - libosgEarthUtil$${DS}.dll \ - libosgFX$${DS}.dll \ - libosgGA$${DS}.dll \ - libosgManipulator$${DS}.dll \ - libosgParticle$${DS}.dll \ - libosgPresentation$${DS}.dll \ - libosgQt$${DS}.dll \ - libosgShadow$${DS}.dll \ - libosgSim$${DS}.dll \ - libosgTerrain$${DS}.dll \ - libosgText$${DS}.dll \ - libosgUtil$${DS}.dll \ - libosgViewer$${DS}.dll \ - libosgVolume$${DS}.dll \ - libosgWidget$${DS}.dll - for(lib, OSG_LIBS) { - addCopyFileTarget($${lib},$${OSG_SDK_DIR}/bin,$${GCS_APP_PATH}) - } - - OSG_PLUGINS = \ - mingw_osgdb_3dc$${DS}.dll \ - mingw_osgdb_3ds$${DS}.dll \ - mingw_osgdb_ac$${DS}.dll \ - mingw_osgdb_bmp$${DS}.dll \ - mingw_osgdb_bsp$${DS}.dll \ - mingw_osgdb_bvh$${DS}.dll \ - mingw_osgdb_cfg$${DS}.dll \ - mingw_osgdb_curl$${DS}.dll \ - mingw_osgdb_dds$${DS}.dll \ - mingw_osgdb_dot$${DS}.dll \ - mingw_osgdb_dw$${DS}.dll \ - mingw_osgdb_dxf$${DS}.dll \ - mingw_osgdb_earth$${DS}.dll \ - mingw_osgdb_gdal$${DS}.dll \ - mingw_osgdb_glsl$${DS}.dll \ - mingw_osgdb_gz$${DS}.dll \ - mingw_osgdb_hdr$${DS}.dll \ - mingw_osgdb_ive$${DS}.dll \ - mingw_osgdb_jpeg$${DS}.dll \ - mingw_osgdb_kml$${DS}.dll \ - mingw_osgdb_ktx$${DS}.dll \ - mingw_osgdb_logo$${DS}.dll \ - mingw_osgdb_lwo$${DS}.dll \ - mingw_osgdb_lws$${DS}.dll \ - mingw_osgdb_md2$${DS}.dll \ - mingw_osgdb_mdl$${DS}.dll \ - mingw_osgdb_normals$${DS}.dll \ - mingw_osgdb_obj$${DS}.dll \ - mingw_osgdb_ogr$${DS}.dll \ - mingw_osgdb_openflight$${DS}.dll \ - mingw_osgdb_osc$${DS}.dll \ - mingw_osgdb_osg$${DS}.dll \ - mingw_osgdb_osga$${DS}.dll \ - mingw_osgdb_osgearth_agglite$${DS}.dll \ - mingw_osgdb_osgearth_arcgis$${DS}.dll \ - mingw_osgdb_osgearth_arcgis_map_cache$${DS}.dll \ - mingw_osgdb_osgearth_bing$${DS}.dll \ - mingw_osgdb_osgearth_cache_filesystem$${DS}.dll \ - mingw_osgdb_osgearth_colorramp$${DS}.dll \ - mingw_osgdb_osgearth_debug$${DS}.dll \ - mingw_osgdb_osgearth_engine_byo$${DS}.dll \ - mingw_osgdb_osgearth_engine_mp$${DS}.dll \ - mingw_osgdb_osgearth_feature_ogr$${DS}.dll \ - mingw_osgdb_osgearth_feature_tfs$${DS}.dll \ - mingw_osgdb_osgearth_feature_wfs$${DS}.dll \ - mingw_osgdb_osgearth_gdal$${DS}.dll \ - mingw_osgdb_osgearth_label_annotation$${DS}.dll \ - mingw_osgdb_osgearth_mask_feature$${DS}.dll \ - mingw_osgdb_osgearth_model_feature_geom$${DS}.dll \ - mingw_osgdb_osgearth_model_feature_stencil$${DS}.dll \ - mingw_osgdb_osgearth_model_simple$${DS}.dll \ - mingw_osgdb_osgearth_noise$${DS}.dll \ - mingw_osgdb_osgearth_ocean_simple$${DS}.dll \ - mingw_osgdb_osgearth_osg$${DS}.dll \ - mingw_osgdb_osgearth_refresh$${DS}.dll \ - mingw_osgdb_osgearth_scriptengine_javascript$${DS}.dll \ - mingw_osgdb_osgearth_sky_gl$${DS}.dll \ - mingw_osgdb_osgearth_sky_simple$${DS}.dll \ - mingw_osgdb_osgearth_splat_mask$${DS}.dll \ - mingw_osgdb_osgearth_template_matclass$${DS}.dll \ - mingw_osgdb_osgearth_tilecache$${DS}.dll \ - mingw_osgdb_osgearth_tileindex$${DS}.dll \ - mingw_osgdb_osgearth_tileservice$${DS}.dll \ - mingw_osgdb_osgearth_tms$${DS}.dll \ - mingw_osgdb_osgearth_vdatum_egm2008$${DS}.dll \ - mingw_osgdb_osgearth_vdatum_egm84$${DS}.dll \ - mingw_osgdb_osgearth_vdatum_egm96$${DS}.dll \ - mingw_osgdb_osgearth_vpb$${DS}.dll \ - mingw_osgdb_osgearth_wcs$${DS}.dll \ - mingw_osgdb_osgearth_wms$${DS}.dll \ - mingw_osgdb_osgearth_xyz$${DS}.dll \ - mingw_osgdb_osgearth_yahoo$${DS}.dll \ - mingw_osgdb_osgshadow$${DS}.dll \ - mingw_osgdb_osgterrain$${DS}.dll \ - mingw_osgdb_osgtgz$${DS}.dll \ - mingw_osgdb_osgviewer$${DS}.dll \ - mingw_osgdb_p3d$${DS}.dll \ - mingw_osgdb_pic$${DS}.dll \ - mingw_osgdb_ply$${DS}.dll \ - mingw_osgdb_png$${DS}.dll \ - mingw_osgdb_pnm$${DS}.dll \ - mingw_osgdb_pov$${DS}.dll \ - mingw_osgdb_pvr$${DS}.dll \ - mingw_osgdb_revisions$${DS}.dll \ - mingw_osgdb_rgb$${DS}.dll \ - mingw_osgdb_rot$${DS}.dll \ - mingw_osgdb_scale$${DS}.dll \ - mingw_osgdb_serializers_osg$${DS}.dll \ - mingw_osgdb_serializers_osganimation$${DS}.dll \ - mingw_osgdb_serializers_osgfx$${DS}.dll \ - mingw_osgdb_serializers_osgga$${DS}.dll \ - mingw_osgdb_serializers_osgmanipulator$${DS}.dll \ - mingw_osgdb_serializers_osgparticle$${DS}.dll \ - mingw_osgdb_serializers_osgshadow$${DS}.dll \ - mingw_osgdb_serializers_osgsim$${DS}.dll \ - mingw_osgdb_serializers_osgterrain$${DS}.dll \ - mingw_osgdb_serializers_osgtext$${DS}.dll \ - mingw_osgdb_serializers_osgviewer$${DS}.dll \ - mingw_osgdb_serializers_osgvolume$${DS}.dll \ - mingw_osgdb_shp$${DS}.dll \ - mingw_osgdb_stl$${DS}.dll \ - mingw_osgdb_tga$${DS}.dll \ - mingw_osgdb_tgz$${DS}.dll \ - mingw_osgdb_tiff$${DS}.dll \ - mingw_osgdb_trans$${DS}.dll \ - mingw_osgdb_trk$${DS}.dll \ - mingw_osgdb_txf$${DS}.dll \ - mingw_osgdb_txp$${DS}.dll \ - mingw_osgdb_vtf$${DS}.dll \ - mingw_osgdb_x$${DS}.dll \ - mingw_osgdb_zip$${DS}.dll - # copy osg plugins - for(lib, OSG_PLUGINS) { - addCopyFileTarget($${lib},$${OSG_SDK_DIR}/bin/osgPlugins-$${OSG_VERSION},$${GCS_LIBRARY_PATH}/osg/osgPlugins-$${OSG_VERSION}) - } - } +# set debug suffix if needed +#win32:CONFIG(debug, debug|release):DS = "d" +contains(QT_ARCH, x86_64) { + LIB_DIR_NAME = lib64 +} else { + LIB_DIR_NAME = lib +} + +osg:linux { + # copy osg libraries + data_copy.commands += $(MKDIR) $$GCS_LIBRARY_PATH/osg $$addNewline() + data_copy.commands += $(COPY_DIR) $$shell_quote($$OSG_SDK_DIR/$$LIB_DIR_NAME/)* $$shell_quote($$GCS_LIBRARY_PATH/osg/) $$addNewline() +} + +osgearth:linux { + # copy osgearth libraries + data_copy.commands += $(MKDIR) $$GCS_LIBRARY_PATH/osg $$addNewline() + data_copy.commands += $(COPY_DIR) $$shell_quote($$OSGEARTH_SDK_DIR/$$LIB_DIR_NAME/)* $$shell_quote($$GCS_LIBRARY_PATH/osg/) $$addNewline() +} + +osg:macx { + # copy osg libraries + data_copy.commands += $(COPY_DIR) $$shell_quote($$OSG_SDK_DIR/lib/)* $$shell_quote($$GCS_LIBRARY_PATH/) $$addNewline() +} + +osgearth:macx { + # copy osgearth libraries + data_copy.commands += $(COPY_DIR) $$shell_quote($$OSGEARTH_SDK_DIR/lib/)* $$shell_quote($$GCS_LIBRARY_PATH/) $$addNewline() +} + +linux|macx { + # add make target + POST_TARGETDEPS += copydata + + data_copy.target = copydata + QMAKE_EXTRA_TARGETS += data_copy +} + +osg:win32 { + # osg & osgearth dependencies (needs to be split) + OSG_LIBS = \ + libcurl-4.dll \ + libfreetype-6.dll \ + libgdal.dll \ + libgeos-3-3-8.dll \ + libgeos_c-1.dll \ + libjpeg-9.dll \ + libpng16-16.dll \ + libproj-0.dll \ + libtiff-5.dll \ + libtiffxx-5.dll \ + zlib1.dll + + # osg libraries + OSG_LIBS += \ + libOpenThreads$${DS}.dll \ + libosg$${DS}.dll \ + libosgAnimation$${DS}.dll \ + libosgDB$${DS}.dll \ + libosgFX$${DS}.dll \ + libosgGA$${DS}.dll \ + libosgManipulator$${DS}.dll \ + libosgParticle$${DS}.dll \ + libosgPresentation$${DS}.dll \ + libosgQt$${DS}.dll \ + libosgShadow$${DS}.dll \ + libosgSim$${DS}.dll \ + libosgTerrain$${DS}.dll \ + libosgText$${DS}.dll \ + libosgUtil$${DS}.dll \ + libosgViewer$${DS}.dll \ + libosgVolume$${DS}.dll \ + libosgWidget$${DS}.dll + + for(lib, OSG_LIBS) { + addCopyFileTarget($$lib},$${OSG_SDK_DIR}/bin,$${GCS_APP_PATH}) + } + + # osg plugins + OSG_PLUGINS = \ + mingw_osgdb_3dc$${DS}.dll \ + mingw_osgdb_3ds$${DS}.dll \ + mingw_osgdb_ac$${DS}.dll \ + mingw_osgdb_bmp$${DS}.dll \ + mingw_osgdb_bsp$${DS}.dll \ + mingw_osgdb_bvh$${DS}.dll \ + mingw_osgdb_cfg$${DS}.dll \ + mingw_osgdb_curl$${DS}.dll \ + mingw_osgdb_dds$${DS}.dll \ + mingw_osgdb_dot$${DS}.dll \ + mingw_osgdb_dw$${DS}.dll \ + mingw_osgdb_dxf$${DS}.dll \ + mingw_osgdb_gdal$${DS}.dll \ + mingw_osgdb_glsl$${DS}.dll \ + mingw_osgdb_gz$${DS}.dll \ + mingw_osgdb_hdr$${DS}.dll \ + mingw_osgdb_ive$${DS}.dll \ + mingw_osgdb_jpeg$${DS}.dll \ + mingw_osgdb_ktx$${DS}.dll \ + mingw_osgdb_logo$${DS}.dll \ + mingw_osgdb_lwo$${DS}.dll \ + mingw_osgdb_lws$${DS}.dll \ + mingw_osgdb_md2$${DS}.dll \ + mingw_osgdb_mdl$${DS}.dll \ + mingw_osgdb_normals$${DS}.dll \ + mingw_osgdb_obj$${DS}.dll \ + mingw_osgdb_ogr$${DS}.dll \ + mingw_osgdb_openflight$${DS}.dll \ + mingw_osgdb_osc$${DS}.dll \ + mingw_osgdb_osg$${DS}.dll \ + mingw_osgdb_osga$${DS}.dll \ + mingw_osgdb_osgshadow$${DS}.dll \ + mingw_osgdb_osgterrain$${DS}.dll \ + mingw_osgdb_osgtgz$${DS}.dll \ + mingw_osgdb_osgviewer$${DS}.dll \ + mingw_osgdb_p3d$${DS}.dll \ + mingw_osgdb_pic$${DS}.dll \ + mingw_osgdb_ply$${DS}.dll \ + mingw_osgdb_png$${DS}.dll \ + mingw_osgdb_pnm$${DS}.dll \ + mingw_osgdb_pov$${DS}.dll \ + mingw_osgdb_pvr$${DS}.dll \ + mingw_osgdb_revisions$${DS}.dll \ + mingw_osgdb_rgb$${DS}.dll \ + mingw_osgdb_rot$${DS}.dll \ + mingw_osgdb_scale$${DS}.dll \ + mingw_osgdb_shp$${DS}.dll \ + mingw_osgdb_stl$${DS}.dll \ + mingw_osgdb_tga$${DS}.dll \ + mingw_osgdb_tgz$${DS}.dll \ + mingw_osgdb_tiff$${DS}.dll \ + mingw_osgdb_trans$${DS}.dll \ + mingw_osgdb_trk$${DS}.dll \ + mingw_osgdb_txf$${DS}.dll \ + mingw_osgdb_txp$${DS}.dll \ + mingw_osgdb_vtf$${DS}.dll \ + mingw_osgdb_x$${DS}.dll \ + mingw_osgdb_zip$${DS}.dll \ + mingw_osgdb_serializers_osg$${DS}.dll \ + mingw_osgdb_serializers_osganimation$${DS}.dll \ + mingw_osgdb_serializers_osgfx$${DS}.dll \ + mingw_osgdb_serializers_osgga$${DS}.dll \ + mingw_osgdb_serializers_osgmanipulator$${DS}.dll \ + mingw_osgdb_serializers_osgparticle$${DS}.dll \ + mingw_osgdb_serializers_osgshadow$${DS}.dll \ + mingw_osgdb_serializers_osgsim$${DS}.dll \ + mingw_osgdb_serializers_osgterrain$${DS}.dll \ + mingw_osgdb_serializers_osgtext$${DS}.dll \ + mingw_osgdb_serializers_osgviewer$${DS}.dll \ + mingw_osgdb_serializers_osgvolume$${DS}.dll + + for(lib, OSG_PLUGINS) { + addCopyFileTarget($${lib},$${OSG_SDK_DIR}/bin/osgPlugins-$${OSG_VERSION},$${GCS_LIBRARY_PATH}/osg/osgPlugins-$${OSG_VERSION}) + } +} + +osgearth:win32 { + # osgearth libraries + OSGEARTH_LIBS = \ + libosgEarth$${DS}.dll \ + libosgEarthAnnotation$${DS}.dll \ + libosgEarthFeatures$${DS}.dll \ + libosgEarthQt$${DS}.dll \ + libosgEarthSymbology$${DS}.dll \ + libosgEarthUtil$${DS}.dll + + for(lib, OSGEARTH_LIBS) { + addCopyFileTarget($${lib},$${OSGEARTH_SDK_DIR}/bin,$${GCS_APP_PATH}) + } + + # osgearth plugins + OSGEARTH_PLUGINS += \ + mingw_osgdb_earth$${DS}.dll \ + mingw_osgdb_kml$${DS}.dll \ + mingw_osgdb_osgearth_agglite$${DS}.dll \ + mingw_osgdb_osgearth_arcgis$${DS}.dll \ + mingw_osgdb_osgearth_arcgis_map_cache$${DS}.dll \ + mingw_osgdb_osgearth_bing$${DS}.dll \ + mingw_osgdb_osgearth_cache_filesystem$${DS}.dll \ + mingw_osgdb_osgearth_colorramp$${DS}.dll \ + mingw_osgdb_osgearth_debug$${DS}.dll \ + mingw_osgdb_osgearth_engine_byo$${DS}.dll \ + mingw_osgdb_osgearth_engine_mp$${DS}.dll \ + mingw_osgdb_osgearth_feature_ogr$${DS}.dll \ + mingw_osgdb_osgearth_feature_tfs$${DS}.dll \ + mingw_osgdb_osgearth_feature_wfs$${DS}.dll \ + mingw_osgdb_osgearth_gdal$${DS}.dll \ + mingw_osgdb_osgearth_label_annotation$${DS}.dll \ + mingw_osgdb_osgearth_mask_feature$${DS}.dll \ + mingw_osgdb_osgearth_model_feature_geom$${DS}.dll \ + mingw_osgdb_osgearth_model_feature_stencil$${DS}.dll \ + mingw_osgdb_osgearth_model_simple$${DS}.dll \ + mingw_osgdb_osgearth_noise$${DS}.dll \ + mingw_osgdb_osgearth_ocean_simple$${DS}.dll \ + mingw_osgdb_osgearth_osg$${DS}.dll \ + mingw_osgdb_osgearth_refresh$${DS}.dll \ + mingw_osgdb_osgearth_scriptengine_javascript$${DS}.dll \ + mingw_osgdb_osgearth_sky_gl$${DS}.dll \ + mingw_osgdb_osgearth_sky_simple$${DS}.dll \ + mingw_osgdb_osgearth_splat_mask$${DS}.dll \ + mingw_osgdb_osgearth_template_matclass$${DS}.dll \ + mingw_osgdb_osgearth_tilecache$${DS}.dll \ + mingw_osgdb_osgearth_tileindex$${DS}.dll \ + mingw_osgdb_osgearth_tileservice$${DS}.dll \ + mingw_osgdb_osgearth_tms$${DS}.dll \ + mingw_osgdb_osgearth_vdatum_egm2008$${DS}.dll \ + mingw_osgdb_osgearth_vdatum_egm84$${DS}.dll \ + mingw_osgdb_osgearth_vdatum_egm96$${DS}.dll \ + mingw_osgdb_osgearth_vpb$${DS}.dll \ + mingw_osgdb_osgearth_wcs$${DS}.dll \ + mingw_osgdb_osgearth_wms$${DS}.dll \ + mingw_osgdb_osgearth_xyz$${DS}.dll \ + mingw_osgdb_osgearth_yahoo$${DS}.dll + + for(lib, OSGEARTH_PLUGINS) { + addCopyFileTarget($${lib},$${OSGEARTH_SDK_DIR}/bin/osgPlugins-$${OSG_VERSION},$${GCS_LIBRARY_PATH}/osg/osgPlugins-$${OSG_VERSION}) + } } diff --git a/ground/gcs/src/libs/osgearth/osgQtQuick/OSGCamera.cpp b/ground/gcs/src/libs/osgearth/osgQtQuick/OSGCamera.cpp index 0f3f483eb..0877b6296 100644 --- a/ground/gcs/src/libs/osgearth/osgQtQuick/OSGCamera.cpp +++ b/ground/gcs/src/libs/osgearth/osgQtQuick/OSGCamera.cpp @@ -41,10 +41,10 @@ #include -#include -#include +#ifdef USE_OSGEARTH #include #include +#endif #include #include @@ -69,7 +69,7 @@ public: Hidden(OSGCamera *parent) : QObject(parent), sceneData(NULL), manipulatorMode(ManipulatorMode::Default), node(NULL), trackerMode(TrackerMode::NodeCenterAndAzim), trackNode(NULL), - logDepthBufferEnabled(false), logDepthBuffer(NULL), clampToTerrain(false) + logDepthBufferEnabled(false), clampToTerrain(false) { fieldOfView = 90.0; @@ -77,14 +77,20 @@ public: dirty = false; fovDirty = false; + +#ifdef USE_OSGEARTH + logDepthBuffer = NULL; +#endif } ~Hidden() { +#ifdef USE_OSGEARTH if (logDepthBuffer) { delete logDepthBuffer; logDepthBuffer = NULL; } +#endif } bool acceptSceneData(OSGNode *node) @@ -185,6 +191,7 @@ public: cameraUpdateCallback = new CameraUpdateCallback(this); camera->addUpdateCallback(cameraUpdateCallback); +#ifdef USE_OSGEARTH // install log depth buffer if requested if (logDepthBufferEnabled) { qDebug() << "OSGCamera::attach - install logarithmic depth buffer"; @@ -192,6 +199,7 @@ public: logDepthBuffer->setUseFragDepth(true); logDepthBuffer->install(camera); } +#endif dirty = true; fovDirty = true; @@ -214,11 +222,13 @@ public: cameraUpdateCallback = NULL; } +#ifdef USE_OSGEARTH if (logDepthBuffer) { logDepthBuffer->uninstall(camera); delete logDepthBuffer; logDepthBuffer = NULL; } +#endif } void attachManipulator(osgViewer::View *view) @@ -247,10 +257,12 @@ public: break; case ManipulatorMode::Earth: { +#ifdef USE_OSGEARTH qDebug() << "OSGCamera::attachManipulator - use EarthManipulator"; osgEarth::Util::EarthManipulator *em = new osgEarth::Util::EarthManipulator(); em->getSettings()->setThrowingEnabled(true); cm = em; +#endif break; } case ManipulatorMode::Track: @@ -354,6 +366,9 @@ public: // TODO compensate antenna height when source of position is GPS (i.e. subtract antenna height from altitude) ;) // Camera position + osg::Matrix cameraPosition; + +#ifdef USE_OSGEARTH osgEarth::GeoPoint geoPoint = osgQtQuick::toGeoPoint(position); if (clampToTerrain) { if (sceneData) { @@ -366,8 +381,8 @@ public: } } - osg::Matrix cameraPosition; geoPoint.createLocalToWorld(cameraPosition); +#endif // Camera orientation // By default the camera looks toward -Z, we must rotate it so it looks toward Y @@ -399,18 +414,20 @@ public: // for NodeTrackerManipulator TrackerMode::Enum trackerMode; - OSGNode *trackNode; + OSGNode *trackNode; - bool logDepthBufferEnabled; + bool logDepthBufferEnabled; +#ifdef USE_OSGEARTH osgEarth::Util::LogarithmicDepthBuffer *logDepthBuffer; +#endif - bool first; + bool first; // for User manipulator - bool dirty; + bool dirty; - bool clampToTerrain; - bool intoTerrain; + bool clampToTerrain; + bool intoTerrain; QVector3D attitude; QVector3D position; diff --git a/ground/gcs/src/libs/osgearth/osgQtQuick/OSGViewport.cpp b/ground/gcs/src/libs/osgearth/osgQtQuick/OSGViewport.cpp index ae53303d9..18a78ea2e 100644 --- a/ground/gcs/src/libs/osgearth/osgQtQuick/OSGViewport.cpp +++ b/ground/gcs/src/libs/osgearth/osgQtQuick/OSGViewport.cpp @@ -42,7 +42,9 @@ #include #include +#ifdef USE_OSGEARTH #include +#endif #include #include @@ -184,6 +186,7 @@ public: return true; } +#ifdef USE_OSGEARTH // TODO map handling should not be done here osgEarth::MapNode *mapNode = osgEarth::MapNode::findMapNode(node); if (mapNode) { @@ -193,6 +196,7 @@ public: // scene will get light from sky view->setLightingMode(osg::View::NO_LIGHT); } +#endif view->setSceneData(node); @@ -475,7 +479,6 @@ public: { qDebug() << "ViewportRenderer::~ViewportRenderer"; osgQtQuick::openGLContextInfo(QOpenGLContext::currentContext(), "ViewportRenderer::~ViewportRenderer"); - } // This function is the only place when it is safe for the renderer and the item to read and write each others members. diff --git a/ground/gcs/src/libs/osgearth/osgearth.cpp b/ground/gcs/src/libs/osgearth/osgearth.cpp index 883dccb82..7a8be7838 100644 --- a/ground/gcs/src/libs/osgearth/osgearth.cpp +++ b/ground/gcs/src/libs/osgearth/osgearth.cpp @@ -38,11 +38,13 @@ #include #include +#ifdef USE_OSGEARTH #include #include #include #include #include +#endif #include @@ -107,7 +109,7 @@ void OsgEarth::initialize() // force early initialization of osgEarth capabilities // Doing this too early (before main window is displayed) causes rendering glitches (black holes) // Not sure why... See OSGViewport for when it is called (late...) - osgEarth::Registry::capabilities(); + // osgEarth::Registry::capabilities(); displayInfo(); } @@ -127,6 +129,7 @@ void OsgEarth::initializePathes() void OsgEarth::initializeCache() { +#ifdef USE_OSGEARTH QString cachePath = Utils::GetStoragePath() + "osgearth/cache"; osgEarth::Drivers::FileSystemCacheOptions cacheOptions; @@ -148,12 +151,15 @@ void OsgEarth::initializeCache() } else { qWarning() << "OsgEarth::initializeCache - Failed to initialize cache"; } +#endif // ifdef USE_OSGEARTH } void OsgEarth::displayInfo() { qDebug() << "Using osg version :" << osgGetVersion(); +#ifdef USE_OSGEARTH qDebug() << "Using osgEarth version :" << osgEarthGetVersion(); +#endif // library file path list osgDB::FilePathList &libraryFilePathList = osgDB::Registry::instance()->getLibraryFilePathList(); @@ -181,7 +187,9 @@ void OsgEarth::displayInfo() qDebug() << "Platform supports threaded OpenGL:" << threadedOpenGL; #endif +#ifdef USE_OSGEARTH osgQtQuick::capabilitiesInfo(osgEarth::Registry::capabilities()); +#endif } void QtNotifyHandler::notify(osg::NotifySeverity severity, const char *message) diff --git a/ground/gcs/src/libs/osgearth/osgearth.pri b/ground/gcs/src/libs/osgearth/osgearth.pri index 5a995f4f6..aa8db7927 100644 --- a/ground/gcs/src/libs/osgearth/osgearth.pri +++ b/ground/gcs/src/libs/osgearth/osgearth.pri @@ -1,5 +1,7 @@ exists( $(OSG_SDK_DIR) ) { - CONFIG += osg DEFINES += USE_OSG LIBS *= -l$$qtLibraryName(GCSOsgEarth) } +exists( $(OSGEARTH_SDK_DIR) ) { + DEFINES += USE_OSGEARTH +} diff --git a/ground/gcs/src/libs/osgearth/osgearth.pro b/ground/gcs/src/libs/osgearth/osgearth.pro index ddee7c751..5083a7add 100644 --- a/ground/gcs/src/libs/osgearth/osgearth.pro +++ b/ground/gcs/src/libs/osgearth/osgearth.pro @@ -2,6 +2,16 @@ TEMPLATE = lib TARGET = GCSOsgEarth DEFINES += OSGEARTH_LIBRARY +OSG_VERSION = 3.4.0 + +CONFIG += osg +DEFINES += USE_OSG + +exists( $(OSGEARTH_SDK_DIR) ) { + CONFIG += osgearth + DEFINES += USE_OSGEARTH +} + #DEFINES += OSG_USE_QT_PRIVATE QT += widgets opengl qml quick @@ -44,9 +54,7 @@ HEADERS += \ osgQtQuick/OSGCubeNode.hpp \ osgQtQuick/OSGTextNode.hpp \ osgQtQuick/OSGFileNode.hpp \ - osgQtQuick/OSGModelNode.hpp \ osgQtQuick/OSGBackgroundNode.hpp \ - osgQtQuick/OSGSkyNode.hpp \ osgQtQuick/OSGCamera.hpp \ osgQtQuick/OSGViewport.hpp @@ -57,10 +65,16 @@ SOURCES += \ osgQtQuick/OSGCubeNode.cpp \ osgQtQuick/OSGTextNode.cpp \ osgQtQuick/OSGFileNode.cpp \ - osgQtQuick/OSGModelNode.cpp \ osgQtQuick/OSGBackgroundNode.cpp \ - osgQtQuick/OSGSkyNode.cpp \ osgQtQuick/OSGCamera.cpp \ osgQtQuick/OSGViewport.cpp +osgearth:HEADERS += \ + osgQtQuick/OSGModelNode.hpp \ + osgQtQuick/OSGSkyNode.hpp + +osgearth:SOURCES += \ + osgQtQuick/OSGModelNode.cpp \ + osgQtQuick/OSGSkyNode.cpp + include(copydata.pro) diff --git a/ground/gcs/src/libs/osgearth/osgearth_dependencies.pri b/ground/gcs/src/libs/osgearth/osgearth_dependencies.pri index 3002dbe9f..c1c84b3b8 100644 --- a/ground/gcs/src/libs/osgearth/osgearth_dependencies.pri +++ b/ground/gcs/src/libs/osgearth/osgearth_dependencies.pri @@ -1,46 +1,45 @@ # osg and osgearth emit a lot of unused parameter warnings... QMAKE_CXXFLAGS += -Wno-unused-parameter -OSG_SDK_DIR = $$clean_path($$(OSG_SDK_DIR)) -message(Using osg from here: $$OSG_SDK_DIR) +# set debug suffix if needed +#win32:CONFIG(debug, debug|release):DS = "d" -INCLUDEPATH += $$OSG_SDK_DIR/include +contains(QT_ARCH, x86_64) { + LIB_DIR_NAME = lib64 +} else { + LIB_DIR_NAME = lib +} -linux { - exists( $$OSG_SDK_DIR/lib64 ) { - LIBS += -L$$OSG_SDK_DIR/lib64 - } else { - LIBS += -L$$OSG_SDK_DIR/lib +osg { + OSG_SDK_DIR = $$clean_path($$(OSG_SDK_DIR)) + message(Using osg from here: $$OSG_SDK_DIR) + + INCLUDEPATH += $$OSG_SDK_DIR/include + + linux|macx { + LIBS += -L$$OSG_SDK_DIR/$$LIB_DIR_NAME + LIBS +=-lOpenThreads -losg -losgUtil -losgDB -losgGA -losgFX -losgViewer -losgText -losgQt } - LIBS +=-lOpenThreads - LIBS += -losg -losgUtil -losgDB -losgGA -losgFX -losgViewer -losgText - LIBS += -losgEarth -losgEarthUtil -losgEarthFeatures -losgEarthSymbology -losgEarthAnnotation - LIBS += -losgQt -losgEarthQt + win32 { + LIBS += -L$$OSG_SDK_DIR/lib + LIBS += -lOpenThreads$DS -losg$DS -losgUtil$DS -losgDB$DS -losgGA$DS -losgFX$DS -losgViewer$DS -losgText$DS -losgQt$DS + } } -macx { - LIBS += -L$$OSG_SDK_DIR/lib +osgearth { + OSGEARTH_SDK_DIR = $$clean_path($$(OSGEARTH_SDK_DIR)) + message(Using osgearth from here: $$OSGEARTH_SDK_DIR) - LIBS += -lOpenThreads - LIBS += -losg -losgUtil -losgDB -losgGA -losgFX -losgViewer -losgText - LIBS += -losgEarth -losgEarthUtil -losgEarthFeatures -losgEarthSymbology -losgEarthAnnotation - LIBS += -losgQt -losgEarthQt -} - -win32 { - LIBS += -L$$OSG_SDK_DIR/lib - - #CONFIG(release, debug|release) { - LIBS += -lOpenThreads - LIBS += -losg -losgUtil -losgDB -losgGA -losgFX -losgViewer -losgText - LIBS += -losgEarth -losgEarthUtil -losgEarthFeatures -losgEarthSymbology -losgEarthAnnotation - LIBS += -losgQt -losgEarthQt - #} - #CONFIG(debug, debug|release) { - # LIBS += -lOpenThreadsd - # LIBS += -losgd -losgUtild -losgDBd -losgGAd -losgFXd -losgViewerd -losgTextd - # LIBS += -losgEarthd -losgEarthUtild -losgEarthFeaturesd -losgEarthSymbologyd -losgEarthAnnotationd - # LIBS += -losgQtd -losgEarthQtd - #} + INCLUDEPATH += $$OSGEARTH_SDK_DIR/include + + linux|macx { + LIBS += -L$$OSGEARTH_SDK_DIR/$$LIB_DIR_NAME + LIBS += -losgEarth -losgEarthUtil -losgEarthFeatures -losgEarthSymbology -losgEarthAnnotation -losgEarthQt + } + + win32 { + LIBS += -L$$OSGEARTH_SDK_DIR/lib + LIBS += -losgEarth$DS -losgEarthUtil$DS -losgEarthFeatures$DS -losgEarthSymbology$DS -losgEarthAnnotation$DS -losgEarthQt$DS + } } diff --git a/ground/gcs/src/libs/osgearth/utility.cpp b/ground/gcs/src/libs/osgearth/utility.cpp index 5ed516fab..43482ffbf 100644 --- a/ground/gcs/src/libs/osgearth/utility.cpp +++ b/ground/gcs/src/libs/osgearth/utility.cpp @@ -42,6 +42,7 @@ #include #include +#include #include #include #include @@ -55,11 +56,12 @@ #include #include +#ifdef USE_OSGEARTH #include -#include #include #include #include +#endif #include #include @@ -76,7 +78,7 @@ public: public: virtual void operator()(osg::Node *node, osg::NodeVisitor *nv) { - osgUtil::CullVisitor *cv = osgEarth::Culling::asCullVisitor(nv); + osgUtil::CullVisitor *cv = 0; // osgEarth::Culling::asCullVisitor(nv); if (cv) { OSG_DEBUG << "****** Node:" << node << " " << node->getName() << std::endl; @@ -250,40 +252,6 @@ int QtKeyboardMap::remapKey(QKeyEvent *event) return itr->second; } -osgEarth::GeoPoint toGeoPoint(const QVector3D &position) -{ - osgEarth::GeoPoint geoPoint(osgEarth::SpatialReference::get("wgs84"), - position.x(), position.y(), position.z(), osgEarth::ALTMODE_ABSOLUTE); - - return geoPoint; -} - -bool clampGeoPoint(osgEarth::GeoPoint &geoPoint, float offset, osgEarth::MapNode *mapNode) -{ - if (!mapNode) { - qWarning() << "Utility::clampGeoPoint - null map node"; - return false; - } - - // establish an elevation query interface based on the features' SRS. - osgEarth::ElevationQuery eq(mapNode->getMap()); - // qDebug() << "Utility::clampGeoPoint - SRS :" << QString::fromStdString(mapNode->getMap()->getSRS()->getName()); - - bool clamped = false; - double elevation; - if (eq.getElevation(geoPoint, elevation, 0.0)) { - clamped = ((geoPoint.z() - offset) < elevation); - if (clamped) { - qDebug() << "Utility::clampGeoPoint - clamping" << geoPoint.z() - offset << "/" << elevation; - geoPoint.z() = elevation + offset; - } - } else { - qDebug() << "Utility::clampGeoPoint - failed to get elevation"; - } - - return clamped; -} - QSurfaceFormat traitsToFormat(const osg::GraphicsContext::Traits *traits) { QSurfaceFormat format(QSurfaceFormat::defaultFormat()); @@ -395,44 +363,6 @@ void traitsInfo(const osg::GraphicsContext::Traits &traits) // qDebug().nospace() << "swapInterval : " << traits.swapInterval(); } -void capabilitiesInfo(const osgEarth::Capabilities &caps) -{ - qDebug().nospace() << "capabilities ----------------------------------------"; - - qDebug().nospace() << "Vendor : " << QString::fromStdString(caps.getVendor()); - qDebug().nospace() << "Version : " << QString::fromStdString(caps.getVersion()); - qDebug().nospace() << "Renderer : " << QString::fromStdString(caps.getRenderer()); - - qDebug().nospace() << "GLSL supported : " << caps.supportsGLSL(); - qDebug().nospace() << "GLSL version : " << caps.getGLSLVersionInt(); - - qDebug().nospace() << "GLES : " << caps.isGLES(); - - qDebug().nospace() << "Num Processors : " << caps.getNumProcessors(); - - qDebug().nospace() << "MaxFFPTextureUnits : " << caps.getMaxFFPTextureUnits(); - qDebug().nospace() << "MaxGPUTextureUnits : " << caps.getMaxGPUTextureUnits(); - qDebug().nospace() << "MaxGPUAttribs : " << caps.getMaxGPUAttribs(); - qDebug().nospace() << "MaxTextureSize : " << caps.getMaxTextureSize(); - qDebug().nospace() << "MaxLights : " << caps.getMaxLights(); - qDebug().nospace() << "DepthBufferBits : " << caps.getDepthBufferBits(); - qDebug().nospace() << "TextureArrays : " << caps.supportsTextureArrays(); - qDebug().nospace() << "Texture3D : " << caps.supportsTexture3D(); - qDebug().nospace() << "MultiTexture : " << caps.supportsMultiTexture(); - qDebug().nospace() << "StencilWrap : " << caps.supportsStencilWrap(); - qDebug().nospace() << "TwoSidedStencil : " << caps.supportsTwoSidedStencil(); - qDebug().nospace() << "Texture2DLod : " << caps.supportsTexture2DLod(); - qDebug().nospace() << "MipmappedTextureUpdates : " << caps.supportsMipmappedTextureUpdates(); - qDebug().nospace() << "DepthPackedStencilBuffer : " << caps.supportsDepthPackedStencilBuffer(); - qDebug().nospace() << "OcclusionQuery : " << caps.supportsOcclusionQuery(); - qDebug().nospace() << "DrawInstanced : " << caps.supportsDrawInstanced(); - qDebug().nospace() << "UniformBufferObjects : " << caps.supportsUniformBufferObjects(); - qDebug().nospace() << "NonPowerOfTwoTextures : " << caps.supportsNonPowerOfTwoTextures(); - qDebug().nospace() << "MaxUniformBlockSize : " << caps.getMaxUniformBlockSize(); - qDebug().nospace() << "PreferDisplayListsForStaticGeometry : " << caps.preferDisplayListsForStaticGeometry(); - qDebug().nospace() << "FragDepthWrite : " << caps.supportsFragDepthWrite(); -} - QString formatProfileName(QSurfaceFormat::OpenGLContextProfile profile) { switch (profile) { @@ -499,26 +429,110 @@ QString getUsageString(osgViewer::CompositeViewer *viewer) return getUsageString(applicationUsage); } +#ifdef USE_OSGEARTH +osgEarth::GeoPoint toGeoPoint(const QVector3D &position) +{ + osgEarth::GeoPoint geoPoint(osgEarth::SpatialReference::get("wgs84"), + position.x(), position.y(), position.z(), osgEarth::ALTMODE_ABSOLUTE); + + return geoPoint; +} + +bool clampGeoPoint(osgEarth::GeoPoint &geoPoint, float offset, osgEarth::MapNode *mapNode) +{ + if (!mapNode) { + qWarning() << "Utility::clampGeoPoint - null map node"; + return false; + } + + // establish an elevation query interface based on the features' SRS. + osgEarth::ElevationQuery eq(mapNode->getMap()); + // qDebug() << "Utility::clampGeoPoint - SRS :" << QString::fromStdString(mapNode->getMap()->getSRS()->getName()); + + bool clamped = false; + double elevation; + if (eq.getElevation(geoPoint, elevation, 0.0)) { + clamped = ((geoPoint.z() - offset) < elevation); + if (clamped) { + qDebug() << "Utility::clampGeoPoint - clamping" << geoPoint.z() - offset << "/" << elevation; + geoPoint.z() = elevation + offset; + } + } else { + qDebug() << "Utility::clampGeoPoint - failed to get elevation"; + } + + return clamped; +} + +void capabilitiesInfo(const osgEarth::Capabilities &caps) +{ + qDebug().nospace() << "capabilities ----------------------------------------"; + + qDebug().nospace() << "Vendor : " << QString::fromStdString(caps.getVendor()); + qDebug().nospace() << "Version : " << QString::fromStdString(caps.getVersion()); + qDebug().nospace() << "Renderer : " << QString::fromStdString(caps.getRenderer()); + + qDebug().nospace() << "GLSL supported : " << caps.supportsGLSL(); + qDebug().nospace() << "GLSL version : " << caps.getGLSLVersionInt(); + + qDebug().nospace() << "GLES : " << caps.isGLES(); + + qDebug().nospace() << "Num Processors : " << caps.getNumProcessors(); + + qDebug().nospace() << "MaxFFPTextureUnits : " << caps.getMaxFFPTextureUnits(); + qDebug().nospace() << "MaxGPUTextureUnits : " << caps.getMaxGPUTextureUnits(); + qDebug().nospace() << "MaxGPUAttribs : " << caps.getMaxGPUAttribs(); + qDebug().nospace() << "MaxTextureSize : " << caps.getMaxTextureSize(); + qDebug().nospace() << "MaxLights : " << caps.getMaxLights(); + qDebug().nospace() << "DepthBufferBits : " << caps.getDepthBufferBits(); + qDebug().nospace() << "TextureArrays : " << caps.supportsTextureArrays(); + qDebug().nospace() << "Texture3D : " << caps.supportsTexture3D(); + qDebug().nospace() << "MultiTexture : " << caps.supportsMultiTexture(); + qDebug().nospace() << "StencilWrap : " << caps.supportsStencilWrap(); + qDebug().nospace() << "TwoSidedStencil : " << caps.supportsTwoSidedStencil(); + qDebug().nospace() << "Texture2DLod : " << caps.supportsTexture2DLod(); + qDebug().nospace() << "MipmappedTextureUpdates : " << caps.supportsMipmappedTextureUpdates(); + qDebug().nospace() << "DepthPackedStencilBuffer : " << caps.supportsDepthPackedStencilBuffer(); + qDebug().nospace() << "OcclusionQuery : " << caps.supportsOcclusionQuery(); + qDebug().nospace() << "DrawInstanced : " << caps.supportsDrawInstanced(); + qDebug().nospace() << "UniformBufferObjects : " << caps.supportsUniformBufferObjects(); + qDebug().nospace() << "NonPowerOfTwoTextures : " << caps.supportsNonPowerOfTwoTextures(); + qDebug().nospace() << "MaxUniformBlockSize : " << caps.getMaxUniformBlockSize(); + qDebug().nospace() << "PreferDisplayListsForStaticGeometry : " << caps.preferDisplayListsForStaticGeometry(); + qDebug().nospace() << "FragDepthWrite : " << caps.supportsFragDepthWrite(); +} +#endif // ifdef USE_OSGEARTH + void registerTypes() { int maj = 1, min = 0; // @uri osgQtQuick qmlRegisterType("OsgQtQuick", maj, min, "OSGNode"); + qmlRegisterType("OsgQtQuick", maj, min, "OSGGroup"); + qmlRegisterType("OsgQtQuick", maj, min, "OSGFileNode"); qmlRegisterType("OsgQtQuick", maj, min, "OptimizeMode"); + qmlRegisterType("OsgQtQuick", maj, min, "OSGTransformNode"); + qmlRegisterType("OsgQtQuick", maj, min, "OSGTextNode"); + qmlRegisterType("OsgQtQuick", maj, min, "OSGCubeNode"); + + qmlRegisterType("OsgQtQuick", maj, min, "OSGBackgroundNode"); + qmlRegisterType("OsgQtQuick", maj, min, "OSGViewport"); qmlRegisterType("OsgQtQuick", maj, min, "UpdateMode"); - qmlRegisterType("OsgQtQuick", maj, min, "OSGModelNode"); - qmlRegisterType("OsgQtQuick", maj, min, "OSGSkyNode"); - qmlRegisterType("OsgQtQuick", maj, min, "OSGBackgroundNode"); qmlRegisterType("OsgQtQuick", maj, min, "OSGCamera"); qmlRegisterType("OsgQtQuick", maj, min, "ManipulatorMode"); qmlRegisterType("OsgQtQuick", maj, min, "TrackerMode"); + +#ifdef USE_OSGEARTH + qmlRegisterType("OsgQtQuick", maj, min, "OSGModelNode"); + qmlRegisterType("OsgQtQuick", maj, min, "OSGSkyNode"); +#endif } } // namespace osgQtQuick diff --git a/ground/gcs/src/libs/osgearth/utility.h b/ground/gcs/src/libs/osgearth/utility.h index 5ca27268e..02175a868 100644 --- a/ground/gcs/src/libs/osgearth/utility.h +++ b/ground/gcs/src/libs/osgearth/utility.h @@ -33,8 +33,6 @@ #include #include -#include - #include #include #include @@ -59,10 +57,13 @@ class Text; class Font; } // namespace osgText +#ifdef USE_OSGEARTH namespace osgEarth { class Capabilities; +class GeoPoint; class MapNode; } // namespace osgEarth +#endif QT_BEGIN_NAMESPACE class QFont; @@ -129,15 +130,11 @@ osgText::Text *createText(const osg::Vec3 &pos, float size, osgText::Font *font = 0); -osgEarth::GeoPoint toGeoPoint(const QVector3D &position); -bool clampGeoPoint(osgEarth::GeoPoint &geoPoint, float offset, osgEarth::MapNode *mapNode); - QSurfaceFormat traitsToFormat(const osg::GraphicsContext::Traits *traits); void formatToTraits(const QSurfaceFormat & format, osg::GraphicsContext::Traits *traits); void formatInfo(const QSurfaceFormat & format); void traitsInfo(const osg::GraphicsContext::Traits & traits); -void capabilitiesInfo(const osgEarth::Capabilities & caps); void openGLContextInfo(QOpenGLContext *context, const char *at); QString formatProfileName(QSurfaceFormat::OpenGLContextProfile profile); @@ -146,6 +143,12 @@ QString formatSwapBehaviorName(QSurfaceFormat::SwapBehavior swapBehavior); QString getUsageString(osgViewer::Viewer *viewer); QString getUsageString(osgViewer::CompositeViewer *viewer); +#ifdef USE_OSGEARTH +osgEarth::GeoPoint toGeoPoint(const QVector3D &position); +bool clampGeoPoint(osgEarth::GeoPoint &geoPoint, float offset, osgEarth::MapNode *mapNode); +void capabilitiesInfo(const osgEarth::Capabilities & caps); +#endif + void registerTypes(); } // namespace osgQtQuick diff --git a/make/3rdparty/osgearth/osgearth.mk b/make/3rdparty/osgearth/osgearth.mk index 664afa602..ddbea9a43 100644 --- a/make/3rdparty/osgearth/osgearth.mk +++ b/make/3rdparty/osgearth/osgearth.mk @@ -246,9 +246,7 @@ endif OSGEARTH_NAME := $(OSG_NAME_PREFIX)$(OSGEARTH_NAME)$(OSG_NAME_SUFIX) OSGEARTH_SRC_DIR := $(ROOT_DIR)/3rdparty/osgearth OSGEARTH_BUILD_DIR := $(BUILD_DIR)/3rdparty/$(OSGEARTH_NAME) -# osgearth will be installed into osg (there is an official option to do that but it seems broken on mingw) -#OSGEARTH_INSTALL_DIR := $(BUILD_DIR)/3rdparty/install/$(OSGEARTH_NAME) -OSGEARTH_INSTALL_DIR := $(OSG_INSTALL_DIR) +OSGEARTH_INSTALL_DIR := $(BUILD_DIR)/3rdparty/install/$(OSGEARTH_NAME) OSGEARTH_PATCH_FILE := $(ROOT_DIR)/make/3rdparty/osgearth/osgearth-$(OSGEARTH_VERSION).patch .PHONY: osgearth @@ -326,7 +324,7 @@ clean_all_osgearth: clean_osgearth .PHONY: all_osg ifeq ($(UNAME), Windows) -all_osg: prepare_osg prepare_osgearth osg osgearth install_win_osg package_osg +all_osg: prepare_osg prepare_osgearth osg osgearth install_win_osg package_osg package_osgearth else -all_osg: prepare_osg prepare_osgearth osg osgearth package_osg +all_osg: prepare_osg prepare_osgearth osg osgearth package_osg package_osgearth endif diff --git a/make/tools.mk b/make/tools.mk index 881813c99..058569b3f 100644 --- a/make/tools.mk +++ b/make/tools.mk @@ -92,11 +92,13 @@ ifeq ($(UNAME), Linux) QT_SDK_MD5_URL := http://download.qt.io/official_releases/qt/5.5/5.5.1/qt-opensource-linux-x64-5.5.1.run.md5 QT_SDK_ARCH := gcc_64 OSG_URL := http://librepilot.github.io/tools/osg-3.4-linux-x64-qt-5.5.1.tar.gz + OSGEARTH_URL := http://librepilot.github.io/tools/osgearth-2.7-linux-x64-qt-5.5.1.tar.gz else QT_SDK_URL := http://download.qt.io/official_releases/qt/5.5/5.5.1/qt-opensource-linux-x86-5.5.1.run QT_SDK_MD5_URL := http://download.qt.io/official_releases/qt/5.5/5.5.1/qt-opensource-linux-x86-5.5.1.run.md5 QT_SDK_ARCH := gcc OSG_URL := http://librepilot.github.io/tools/osg-3.4-linux-x86-qt-5.5.1.tar.gz + OSGEARTH_URL := http://librepilot.github.io/tools/osgearth-2.7-linux-x86-qt-5.5.1.tar.gz endif UNCRUSTIFY_URL := http://librepilot.github.io/tools/uncrustify-0.60.tar.gz DOXYGEN_URL := http://librepilot.github.io/tools/doxygen-1.8.3.1.src.tar.gz @@ -109,6 +111,7 @@ else ifeq ($(UNAME), Darwin) UNCRUSTIFY_URL := http://librepilot.github.io/tools/uncrustify-0.60.tar.gz DOXYGEN_URL := http://librepilot.github.io/tools/doxygen-1.8.3.1.src.tar.gz OSG_URL := http://librepilot.github.io/tools/osg-3.4-clang_64-qt-5.5.1.tar.gz + OSGEARTH_URL := http://librepilot.github.io/tools/osgearth-2.7-clang_64-qt-5.5.1.tar.gz else ifeq ($(UNAME), Windows) QT_SDK_URL := http://download.qt.io/official_releases/qt/5.5/5.5.1/qt-opensource-windows-x86-mingw492-5.5.1.exe QT_SDK_MD5_URL := http://download.qt.io/official_releases/qt/5.5/5.5.1/qt-opensource-windows-x86-mingw492-5.5.1.exe.md5 @@ -123,6 +126,7 @@ else ifeq ($(UNAME), Windows) CMAKE_MD5_URL := http://librepilot.github.io/tools/cmake-2.8.12.2-win32-x86.zip.md5 MSYS_URL := http://librepilot.github.io/tools/MSYS-1.0.11.zip OSG_URL := http://librepilot.github.io/tools/osg-3.4-mingw492_32-qt-5.5.1.tar.gz + OSGEARTH_URL := http://librepilot.github.io/tools/osgearth-2.7-mingw492_32-qt-5.5.1.tar.gz endif GTEST_URL := http://librepilot.github.io/tools/gtest-1.6.0.zip @@ -138,12 +142,15 @@ OSG_TOOLS_DIR := $(TOOLS_DIR) ifeq ($(UNAME), Linux) ifeq ($(ARCH), x86_64) - OSG_SDK_DIR := $(OSG_TOOLS_DIR)/osg-3.4-linux-x64-qt-5.5.1 + OSG_SDK_DIR := $(OSG_TOOLS_DIR)/osg-3.4-linux-x64-qt-5.5.1 + OSGEARTH_SDK_DIR := $(OSG_TOOLS_DIR)/osgearth-2.7-linux-x64-qt-5.5.1 else - OSG_SDK_DIR := $(OSG_TOOLS_DIR)/osg-3.4-linux-x86-qt-5.5.1 + OSG_SDK_DIR := $(OSG_TOOLS_DIR)/osg-3.4-linux-x86-qt-5.5.1 + OSGEARTH_SDK_DIR := $(OSG_TOOLS_DIR)/osgearth-2.7-linux-x86-qt-5.5.1 endif else ifeq ($(UNAME), Darwin) - OSG_SDK_DIR := $(OSG_TOOLS_DIR)/osg-3.4-clang_64-qt-5.5.1 + OSG_SDK_DIR := $(OSG_TOOLS_DIR)/osg-3.4-clang_64-qt-5.5.1 + OSGEARTH_SDK_DIR := $(OSG_TOOLS_DIR)/osgearth-2.7-clang_64-qt-5.5.1 else ifeq ($(UNAME), Windows) MINGW_DIR := $(QT_SDK_DIR)/Tools/$(QT_SDK_ARCH) # When changing PYTHON_DIR, you must also update it in ground/gcs/src/python.pri @@ -156,6 +163,7 @@ else ifeq ($(UNAME), Windows) CMAKE_DIR := $(TOOLS_DIR)/cmake-2.8.12.2-win32-x86 MSYS_DIR := $(TOOLS_DIR)/msys OSG_SDK_DIR := $(OSG_TOOLS_DIR)/osg-3.4-mingw492_32-qt-5.5.1 + OSGEARTH_SDK_DIR := $(OSG_TOOLS_DIR)/osgearth-2.7-mingw492_32-qt-5.5.1 endif QT_SDK_PREFIX := $(QT_SDK_DIR) @@ -168,7 +176,7 @@ QT_SDK_PREFIX := $(QT_SDK_DIR) BUILD_SDK_TARGETS := arm_sdk qt_sdk osg ifeq ($(UNAME), Windows) - BUILD_SDK_TARGETS += sdl nsis mesawin openssl ccache + BUILD_SDK_TARGETS += sdl osgearth nsis mesawin openssl ccache endif ALL_SDK_TARGETS := $(BUILD_SDK_TARGETS) gtest uncrustify doxygen @@ -915,7 +923,25 @@ endif .PHONY: osg_version osg_version: -$(V1) $(ECHO) "`$(OSG_SDK_DIR)/bin/osgversion`" - -$(V1) $(ECHO) "`$(OSG_SDK_DIR)/bin/osgearth_version`" + +############################## +# +# osgearth +# +############################## + +$(eval $(call TOOL_INSTALL_TEMPLATE,osgearth,$(OSGEARTH_SDK_DIR),$(OSGEARTH_URL),,$(notdir $(OSGEARTH_URL)))) + +ifeq ($(shell [ -d "$(OSGEARTH_SDK_DIR)" ] && $(ECHO) "exists"), exists) + export OSGEARTH_SDK_DIR := $(OSGEARTH_SDK_DIR) +else + # not installed, hope it's in the path... + $(info $(EMPTY) WARNING $(call toprel, $(OSGEARTH_SDK_DIR)) not found (make osgearth_install), using system PATH) +endif + +.PHONY: osgearth_version +osgearth_version: + -$(V1) $(ECHO) "`$(OSGEARTH_SDK_DIR)/bin/osgearth_version`" ############################## #