diff --git a/CMakeLists.txt b/CMakeLists.txt index 37555e28ed7..69fca1d2899 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -247,16 +247,6 @@ IF(WITH_CORE) SET (WITH_GEOREFERENCER TRUE CACHE BOOL "Determines whether GeoReferencer plugin should be built") - SET (WITH_GLOBE FALSE CACHE BOOL "Determines whether Globe plugin should be built") - 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) - SET (WITH_THREAD_LOCAL TRUE CACHE BOOL "Determines whether std::thread_local should be used") MARK_AS_ADVANCED(WITH_THREAD_LOCAL) @@ -746,9 +736,6 @@ IF (WITH_CORE) # path for framework references when running from build directory # changed later to reference in-app resources upon install SET (CMAKE_INSTALL_NAME_DIR ${CMAKE_BINARY_DIR}/output/lib) - IF (WITH_GLOBE) - SET (OSG_PLUGINS_PATH "" CACHE PATH "Path to OSG plugins for bundling") - ENDIF (WITH_GLOBE) # recent cmakes force SDKs, recent SDKs don't have user symlinks # need to find non-system frameworks # cmake bug #0007250 - CMAKE_SHARED_LINKER_FLAGS ignored when creating diff --git a/cmake/FindOSGEARTH.cmake b/cmake/FindOSGEARTH.cmake deleted file mode 100644 index d134c71a099..00000000000 --- a/cmake/FindOSGEARTH.cmake +++ /dev/null @@ -1,132 +0,0 @@ -# This module defines - -# OSGEARTH_LIBRARY -# OSGEARTH_FOUND, if false, do not try to link to osg -# OSGEARTH_INCLUDE_DIRS, where to find the headers -# OSGEARTH_INCLUDE_DIR, where to find the source headers -# OSGEARTH_GEN_INCLUDE_DIR, where to find the generated headers - -# to use this module, set variables to point to the osg build -# directory, and source directory, respectively -# OSGEARTHDIR or OSGEARTH_SOURCE_DIR: osg source directory, typically OpenSceneGraph -# OSGEARTH_DIR or OSGEARTH_BUILD_DIR: osg build directory, place in which you've -# built osg via cmake - -# Header files are presumed to be included like -# #include -# #include - -###### headers ###### - -MACRO( FIND_OSGEARTH_INCLUDE THIS_OSGEARTH_INCLUDE_DIR THIS_OSGEARTH_INCLUDE_FILE ) - -FIND_PATH( ${THIS_OSGEARTH_INCLUDE_DIR} ${THIS_OSGEARTH_INCLUDE_FILE} - PATHS - ${OSGEARTH_DIR} - $ENV{OSGEARTH_SOURCE_DIR} - $ENV{OSGEARTHDIR} - $ENV{OSGEARTH_DIR} - $ENV{OSGEO4W_ROOT} - $ENV{LIB_DIR} - /usr/local/ - /usr/ - /sw/ # Fink - /opt/local/ # DarwinPorts - /opt/csw/ # Blastwave - /opt/ - [HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;OSGEARTH_ROOT]/ - ~/Library/Frameworks - /Library/Frameworks - PATH_SUFFIXES - /include/ -) - -ENDMACRO( FIND_OSGEARTH_INCLUDE THIS_OSGEARTH_INCLUDE_DIR THIS_OSGEARTH_INCLUDE_FILE ) - -FIND_OSGEARTH_INCLUDE( OSGEARTH_GEN_INCLUDE_DIR osgEarth/Common ) -FIND_OSGEARTH_INCLUDE( OSGEARTH_INCLUDE_DIR osgEarth/TileSource ) -FIND_OSGEARTH_INCLUDE( OSGEARTH_ELEVATION_QUERY osgEarth/ElevationQuery ) - -###### libraries ###### - -MACRO( FIND_OSGEARTH_LIBRARY MYLIBRARY ) - -FIND_LIBRARY(${MYLIBRARY} - NAMES - ${ARGN} - PATHS - ${OSGEARTH_DIR} - $ENV{OSGEARTH_BUILD_DIR} - $ENV{OSGEARTH_DIR} - $ENV{OSGEARTHDIR} - $ENV{OSGEARTH_ROOT} - $ENV{OSGEO4W_ROOT} - ~/Library/Frameworks - /Library/Frameworks - $ENV{LIB_DIR} - /usr/local - /usr - /sw - /opt/local - /opt/csw - /opt - [HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;OSGEARTH_ROOT]/lib - /usr/freeware - PATH_SUFFIXES - /lib/ - /lib64/ - /build/lib/ - /build/lib64/ - /Build/lib/ - /Build/lib64/ - ) - -ENDMACRO(FIND_OSGEARTH_LIBRARY LIBRARY LIBRARYNAME) - -FIND_OSGEARTH_LIBRARY( OSGEARTH_LIBRARY osgEarth ) -FIND_OSGEARTH_LIBRARY( OSGEARTH_LIBRARY_DEBUG osgEarthd ) - -FIND_OSGEARTH_LIBRARY( OSGEARTHUTIL_LIBRARY osgEarthUtil ) -FIND_OSGEARTH_LIBRARY( OSGEARTHUTIL_LIBRARY_DEBUG osgEarthUtild ) - -FIND_OSGEARTH_LIBRARY( OSGEARTHFEATURES_LIBRARY osgEarthFeatures ) -FIND_OSGEARTH_LIBRARY( OSGEARTHFEATURES_LIBRARY_DEBUG osgEarthFeaturesd ) - -FIND_OSGEARTH_LIBRARY( OSGEARTHSYMBOLOGY_LIBRARY osgEarthSymbology ) -FIND_OSGEARTH_LIBRARY( OSGEARTHSYMBOLOGY_LIBRARY_DEBUG osgEarthSymbologyd ) - -FIND_OSGEARTH_LIBRARY( OSGEARTHQT_LIBRARY osgEarthQt5 osgEarthQt) -FIND_OSGEARTH_LIBRARY( OSGEARTHQT_LIBRARY_DEBUG osgEarthQtd osgEarthQt5d) - -FIND_OSGEARTH_LIBRARY( OSGEARTHANNOTATION_LIBRARY osgEarthAnnotation ) -FIND_OSGEARTH_LIBRARY( OSGEARTHANNOTATION_LIBRARY_DEBUG osgEarthAnnotationd ) - - -SET( OSGEARTH_FOUND "NO" ) -IF( OSGEARTH_LIBRARY AND OSGEARTH_INCLUDE_DIR ) - SET( OSGEARTH_FOUND "YES" ) - SET( OSGEARTH_INCLUDE_DIRS ${OSGEARTH_INCLUDE_DIR} ${OSGEARTH_GEN_INCLUDE_DIR} ) - INCLUDE(CheckCXXSourceCompiles) - SET(SAFE_CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES}) - SET(SAFE_CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES}) - SET(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${OSGEARTH_INCLUDE_DIR}) - SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${OSGEARTHUTIL_LIBRARY}) - IF(APPLE) - # no extra LDFLAGS used in link test, may fail in OS X SDK - SET(CMAKE_REQUIRED_LIBRARIES "-F/Library/Frameworks" ${CMAKE_REQUIRED_LIBRARIES}) - ENDIF(APPLE) - CHECK_CXX_SOURCE_COMPILES(" -#include -using namespace osgEarth::Util::Controls; -int main(int argc, char **argv) -{ - Container *c; - c->setChildSpacing(0.0); -} -" HAVE_OSGEARTH_CHILD_SPACING) - SET(CMAKE_REQUIRED_INCLUDES ${SAFE_CMAKE_REQUIRED_INCLUDES}) - SET(CMAKE_REQUIRED_LIBRARIES ${SAFE_CMAKE_REQUIRED_LIBRARIES}) - GET_FILENAME_COMPONENT( OSGEARTH_LIBRARIES_DIR ${OSGEARTH_LIBRARY} PATH ) -ENDIF( OSGEARTH_LIBRARY AND OSGEARTH_INCLUDE_DIR ) - - diff --git a/cmake_templates/qgsconfig.h.in b/cmake_templates/qgsconfig.h.in index 5d3ff599f4b..028172bf264 100644 --- a/cmake_templates/qgsconfig.h.in +++ b/cmake_templates/qgsconfig.h.in @@ -43,7 +43,6 @@ #endif #define QT_PLUGINS_DIR "${QT_PLUGINS_DIR}" -#define OSG_PLUGINS_PATH "${OSG_PLUGINS_PATH}" #cmakedefine USING_NMAKE @@ -55,8 +54,6 @@ #cmakedefine HAVE_ORACLE -#cmakedefine HAVE_OSGEARTHQT - #cmakedefine SERVER_SKIP_ECW #cmakedefine HAVE_SERVER_PYTHON_PLUGINS diff --git a/debian/rules b/debian/rules index b9cb8f037b9..de509f0be9d 100755 --- a/debian/rules +++ b/debian/rules @@ -92,7 +92,6 @@ CMAKE_OPTS := \ -DWITH_APIDOC=TRUE \ -DGENERATE_QHP=TRUE \ -DWITH_CUSTOM_WIDGETS=TRUE \ - -DWITH_GLOBE=FALSE \ -DWITH_SERVER=TRUE \ -DWITH_SERVER_PLUGINS=TRUE \ -DWITH_QWTPOLAR=FALSE \ diff --git a/mac/CMakeLists.txt b/mac/CMakeLists.txt index 645c9295af3..612239cc7ce 100644 --- a/mac/CMakeLists.txt +++ b/mac/CMakeLists.txt @@ -8,8 +8,6 @@ IF (APPLE AND QGIS_MACAPP_BUNDLE GREATER -1) INSTALL (SCRIPT ${CMAKE_BINARY_DIR}/mac/0qgis.cmake) IF (QGIS_MACAPP_BUNDLE GREATER 0) # start with Qt - CONFIGURE_FILE (cmake/1osg.cmake.in 1osg.cmake @ONLY) - INSTALL (SCRIPT ${CMAKE_BINARY_DIR}/mac/1osg.cmake) CONFIGURE_FILE (cmake/1qt.cmake.in 1qt.cmake @ONLY) INSTALL (SCRIPT ${CMAKE_BINARY_DIR}/mac/1qt.cmake) IF (QGIS_MACAPP_BUNDLE GREATER 1) diff --git a/mac/cmake/0vars.cmake.in b/mac/cmake/0vars.cmake.in index bce03c49c4d..c42526af2dc 100644 --- a/mac/cmake/0vars.cmake.in +++ b/mac/cmake/0vars.cmake.in @@ -41,7 +41,6 @@ SET (QGIS_DATA_SUBDIR_REV "@QGIS_DATA_SUBDIR_REV@") SET (QGIS_SERVER_MODULE_SUBDIR "@QGIS_SERVER_MODULE_SUBDIR@") # optional components -SET (WITH_GLOBE "@WITH_GLOBE@") SET (WITH_GRASS "@WITH_GRASS@") SET (WITH_SERVER "@WITH_SERVER@") SET (WITH_POSTGRESQL "@WITH_POSTGRESQL@") diff --git a/mac/cmake/1osg.cmake.in b/mac/cmake/1osg.cmake.in deleted file mode 100644 index a5a8f5aea1f..00000000000 --- a/mac/cmake/1osg.cmake.in +++ /dev/null @@ -1,116 +0,0 @@ -# 1osg - bundle OSG & osgEarth frameworks -# ! cmakecache vars not available to external scripts -# so we configure it first to do substitutions -# make sure to use @varname@ - -# kill boolean warnings -CMAKE_POLICY (SET CMP0012 NEW) - -IF (@OSGEARTH_FOUND@) - -INCLUDE ("@CMAKE_BINARY_DIR@/mac/0vars.cmake") -INCLUDE ("@CMAKE_SOURCE_DIR@/cmake/MacBundleMacros.cmake") - -SET (OSG_PLUGINS_PATH "@OSG_PLUGINS_PATH@") - -# list of osg frameworks to bundle - -SET (OSGLIST OpenThreads osg osgAnimation osgDB osgGA osgViewer osgEarth osgEarthAnnotation osgEarthFeatures osgEarthSymbology osgEarthUtil osgFX osgManipulator osgParticle osgPresentation osgShadow osgSim osgTerrain osgText osgUtil osgVolume osgWidget) -IF (@HAVE_OSGEARTHQT@) - SET (OSGLIST ${OSGLIST} osgQt osgEarthQt) -ENDIF (@HAVE_OSGEARTHQT@) -#SET (PYOSGLIST future python bindings?) -MYMESSAGE ("OSG list: ${OSGLIST}") - -# extract OSG framework path from OSGEARTH_LIBRARY, assume all in same prefix - -STRING (REPLACE "/osgEarth.framework" "" OSG_FW_DIR "@OSGEARTH_LIBRARY@") - -### copy OSG - -MESSAGE (STATUS "Copying OSG and osgEarth...") - -# osg frameworks -FOREACH (OFW ${OSGLIST}) - IF (NOT IS_DIRECTORY "${QFWDIR}/${OFW}.framework") - COPY_FRAMEWORK("${OSG_FW_DIR}" ${OFW} "${QFWDIR}") - ENDIF () -ENDFOREACH (OFW) - -# osg plugins - -IF (OSG_PLUGINS_PATH) - FILE (GLOB OSGPLUGLIST RELATIVE ${OSG_PLUGINS_PATH} ${OSG_PLUGINS_PATH}/*.so) - EXECUTE_PROCESS (COMMAND mkdir -p "${QPLUGDIR}/../osgPlugins") - FOREACH (OP ${OSGPLUGLIST}) - EXECUTE_PROCESS (COMMAND ditto ${QARCHS} "${OSG_PLUGINS_PATH}/${OP}" "${QPLUGDIR}/../osgPlugins/${OP}") - ENDFOREACH (OP) -ENDIF () - - -# update lib paths - -MESSAGE (STATUS "Updating OSG library paths...") - -FOREACH (OFW ${OSGLIST}) - # get install names from installed in case bundled copy already changed - # from a previous install attempt - GET_INSTALL_NAME ("${OSG_FW_DIR}/${OFW}.framework/${OFW}" ${OFW}.framework OO) - SET (OFW_CHG "${OO}") - SET (OFW_CHG_TO "${ATEXECUTABLE}/@QGIS_FW_SUBDIR@/${OFW}.framework/${OFW}") - # qgis app - INSTALLNAMETOOL_CHANGE ("${OFW_CHG}" "${OFW_CHG_TO}" "${QAPPDIR}/${QGIS_APP_NAME}") - - SET (LIBPOST "${OFW}.framework/${OFW}") - # osg frameworks - IF (@OSX_HAVE_LOADERPATH@) - SET (OFW_CHG_TO "${ATLOADER}/../../../${LIBPOST}") - ENDIF () - FOREACH (OF ${OSGLIST}) - INSTALLNAMETOOL_CHANGE ("${OFW_CHG}" "${OFW_CHG_TO}" "${QFWDIR}/${OF}.framework/${OF}") - ENDFOREACH (OF) - # osg plugins - IF (@OSX_HAVE_LOADERPATH@) - SET (OFW_CHG_TO "${ATLOADER}/@QGIS_PLUGIN_SUBDIR_REV@/@QGIS_FW_SUBDIR@/${LIBPOST}") - ENDIF () - FOREACH (OP ${OSGPLUGLIST}) - INSTALLNAMETOOL_CHANGE ("${OFW_CHG}" "${OFW_CHG_TO}" "${QPLUGDIR}/../osgPlugins/${OP}") - ENDFOREACH (OP) - # globe plugin - INSTALLNAMETOOL_CHANGE ("${OFW_CHG}" "${OFW_CHG_TO}" "${QPLUGDIR}/libglobeplugin.so") -ENDFOREACH (OFW) - -IF (@HAVE_OSGEARTHQT@) - SET (OSGLIST ${OSGLIST} osgQt osgEarthQt) -ENDIF (@HAVE_OSGEARTHQT@) - -# osgEarth exernal libs (2.4+, e.g. tinyxml) -GET_INSTALL_NAME ("${QFWDIR}/osgEarth.framework/osgEarth" "libtinyxml" TINY) -# MESSAGE (STATUS "libtinyxml path: ${TINY}") -IF (EXISTS "${TINY}") - SET (TINY_CHG "${TINY}") - SET (TINY_CHG_TO "${ATEXECUTABLE}/@QGIS_LIB_SUBDIR@/libtinyxml.dylib") - EXECUTE_PROCESS (COMMAND ditto ${QARCHS} "${TINY_CHG}" "${QLIBDIR}/libtinyxml.dylib") - - # osg frameworks - FOREACH (OF ${OSGLIST}) - INSTALLNAMETOOL_CHANGE ("${TINY_CHG}" "${TINY_CHG_TO}" "${QFWDIR}/${OF}.framework/${OF}") - ENDFOREACH (OF) - # osg plugins - FOREACH (OP ${OSGPLUGLIST}) - INSTALLNAMETOOL_CHANGE ("${TINY_CHG}" "${TINY_CHG_TO}" "${QPLUGDIR}/../osgPlugins/${OP}") - ENDFOREACH (OP) - # globe plugin - INSTALLNAMETOOL_CHANGE ("${TINY_CHG}" "${TINY_CHG_TO}" "${QPLUGDIR}/libglobeplugin.so") -ENDIF () - -GET_INSTALL_NAME ("${OSG_PLUGINS_PATH}/osgdb_kml.so" "libminizip" MINI) -# MESSAGE (STATUS "libminizip path: ${MINI}") -IF (EXISTS "${MINI}") - SET (MINI_CHG "${MINI}") - SET (MINI_CHG_TO "${ATEXECUTABLE}/@QGIS_LIB_SUBDIR@/libminizip.dylib") - EXECUTE_PROCESS (COMMAND ditto ${QARCHS} "${MINI_CHG}" "${QLIBDIR}/libminizip.dylib") - INSTALLNAMETOOL_CHANGE ("${MINI_CHG}" "${MINI_CHG_TO}" "${QPLUGDIR}/../osgPlugins/osgdb_kml.so") -ENDIF () - -ENDIF (@OSGEARTH_FOUND@) diff --git a/mac/cmake/1qt.cmake.in b/mac/cmake/1qt.cmake.in index 5aa8feca618..d071834a179 100644 --- a/mac/cmake/1qt.cmake.in +++ b/mac/cmake/1qt.cmake.in @@ -34,11 +34,6 @@ IF(@WITH_3D@) SET (PYQTLIST ${PYQTLIST} Qt3DCore Qt3DRender Qt3DInput Qt3DLogic Qt3DExtras QtGamepad) ENDIF () -IF(@WITH_GLOBE@) - SET (QTLISTQG ${QTLISTQG} QtOpenGL) - SET (PYQTLIST ${PYQTLIST} QtOpenGL) -ENDIF () - # add Qsci.so, if available IF (@QSCI_FOUND@) SET (PYQTLIST ${PYQTLIST} Qsci) @@ -482,15 +477,6 @@ FOREACH (QFW ${QTLISTQG}) ENDIF () INSTALLNAMETOOL_CHANGE ("${QFW_CHG}" "${QFW_CHG_TO}" "${QFWDIR}/${_qca_libname}.framework/${_qca_libname}") ENDIF (ISLIB) - # osgEarthQt - IF (@HAVE_OSGEARTHQT@) - IF (@OSX_HAVE_LOADERPATH@) - SET (QFW_CHG_TO "${ATLOADER}/../../../${LIBPOST}") - ENDIF () - FOREACH (OSGFW osgQt osgEarthQt) - INSTALLNAMETOOL_CHANGE ("${QFW_CHG}" "${QFW_CHG_TO}" "${QFWDIR}/${OSGFW}.framework/${OSGFW}") - ENDFOREACH (OSGFW) - ENDIF (@HAVE_OSGEARTHQT@) # QScintilla2 IF (@OSX_HAVE_LOADERPATH@) SET (QFW_CHG_TO "${ATLOADER}/${QGIS_LIB_SUBDIR_REV}/${QGIS_FW_SUBDIR}/${LIBPOST}") @@ -504,10 +490,6 @@ FOREACH (QFW ${QTLISTQG}) FOREACH (qca_plugin ${QCA_PLUGINS}) INSTALLNAMETOOL_CHANGE ("${QFW_CHG}" "${QFW_CHG_TO}" "${QPLUGDIR}/../crypto/libqca-${qca_plugin}.dylib") ENDFOREACH () - # osg qfont plugin - IF (@HAVE_OSGEARTHQT@) - INSTALLNAMETOOL_CHANGE ("${QFW_CHG}" "${QFW_CHG_TO}" "${QPLUGDIR}/../osgPlugins/osgdb_qfont.so") - ENDIF (@HAVE_OSGEARTHQT@) FOREACH (QI qgif;qico;qjpeg;qsvg;qtiff) INSTALLNAMETOOL_CHANGE ("${QFW_CHG}" "${QFW_CHG_TO}" "${QPLUGDIR}/../imageformats/lib${QI}.dylib") ENDFOREACH (QI) diff --git a/ms-windows/cygwin/package.sh b/ms-windows/cygwin/package.sh index 7fbbdaa9e3b..17394da75a8 100644 --- a/ms-windows/cygwin/package.sh +++ b/ms-windows/cygwin/package.sh @@ -27,12 +27,10 @@ cmake -D BUILDNAME="cygwin" \ -D WITH_SPATIALITE=TRUE \ -D WITH_QSPATIALITE=TRUE \ -D WITH_SERVER=TRUE \ - -D WITH_GLOBE=TRUE \ -D WITH_ORACLE=FALSE \ -D CMAKE_LEGACY_CYGWIN_WIN32=0 \ -D PYUIC4_PROGRAM=/usr/lib/python2.7/site-packages/PyQt4/pyuic4 \ -D PYRCC4_PROGRAM=/usr/lib/python2.7/site-packages/PyQt4/pyrcc4.exe \ - -D WITH_GLOBE=NO \ -D ENABLE_TESTS=YES \ -D CMAKE_INSTALL_PREFIX=/usr \ -D WITH_CUSTOM_WIDGETS=TRUE \ diff --git a/ms-windows/osgeo4w/package-nightly.cmd b/ms-windows/osgeo4w/package-nightly.cmd index 6cb87d76020..89796e7ab5f 100644 --- a/ms-windows/osgeo4w/package-nightly.cmd +++ b/ms-windows/osgeo4w/package-nightly.cmd @@ -127,7 +127,6 @@ cmake -G "%CMAKEGEN%" ^ -D WITH_3D=TRUE ^ -D WITH_GRASS7=TRUE ^ -D GRASS_PREFIX7=%GRASS_PREFIX:\=/% ^ - -D WITH_GLOBE=FALSE ^ -D WITH_ORACLE=TRUE ^ -D WITH_CUSTOM_WIDGETS=TRUE ^ -D CMAKE_BUILD_TYPE=%BUILDCONF% ^ diff --git a/ms-windows/osgeo4w/package.cmd b/ms-windows/osgeo4w/package.cmd index 382eefa0854..68607f07052 100644 --- a/ms-windows/osgeo4w/package.cmd +++ b/ms-windows/osgeo4w/package.cmd @@ -130,7 +130,6 @@ cmake -G "%CMAKEGEN%" ^ -D WITH_3D=TRUE ^ -D WITH_GRASS7=TRUE ^ -D GRASS_PREFIX7=%GRASS_PREFIX:\=/% ^ - -D WITH_GLOBE=FALSE ^ -D WITH_ORACLE=TRUE ^ -D WITH_CUSTOM_WIDGETS=TRUE ^ -D CMAKE_BUILD_TYPE=%BUILDCONF% ^ diff --git a/src/plugins/CMakeLists.txt b/src/plugins/CMakeLists.txt index 7cf43f402bf..31925f77620 100644 --- a/src/plugins/CMakeLists.txt +++ b/src/plugins/CMakeLists.txt @@ -21,10 +21,6 @@ IF (WITH_GEOREFERENCER) ADD_SUBDIRECTORY(georeferencer) ENDIF (WITH_GEOREFERENCER) -IF (WITH_GLOBE) - ADD_SUBDIRECTORY(globe) -ENDIF (WITH_GLOBE) - IF (CUSTOM_PLUGINS) ADD_SUBDIRECTORY(${CUSTOM_PLUGINS}) ENDIF (CUSTOM_PLUGINS) diff --git a/src/plugins/globe/CMakeLists.txt b/src/plugins/globe/CMakeLists.txt deleted file mode 100644 index 6d68c74d23e..00000000000 --- a/src/plugins/globe/CMakeLists.txt +++ /dev/null @@ -1,108 +0,0 @@ -# set path to additional CMake modules -SET(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules ${CMAKE_MODULE_PATH}) - -FIND_PACKAGE(OSG REQUIRED) -FIND_PACKAGE(OSGEARTH REQUIRED) -FIND_PACKAGE(Qt5OpenGL REQUIRED) - -######################################################## -# Files - -SET (GLOBE_PLUGIN_SRCS - globe_plugin.cpp - qgsglobetilesource.cpp - qgsglobeplugindialog.cpp - qgsglobevectorlayerproperties.cpp - qgsglobefeatureidentify.cpp - qgsglobefrustumhighlight.cpp - qgsglobewidget.cpp -) - -SET (GLOBE_PLUGIN_UIS - qgsglobeplugindialog.ui - qgsglobevectorlayerpropertiespage.ui -) - -SET (GLOBE_PLUGIN_MOC_HDRS - globe_plugin.h - qgsglobeplugindialog.h - qgsglobevectorlayerproperties.h - qgsglobetilesource.h - qgsglobewidget.h -) - -SET (GLOBE_PLUGIN_HDRS - qgsglobevectorlayerproperties.h - qgsglobefeatureidentify.h - qgsglobefrustumhighlight.h -) - -SET (GLOBE_PLUGIN_RCCS globe_plugin.qrc) - -######################################################## -# Build - -IF(WIN32) - ADD_DEFINITIONS(-DGLOBE_EXPORT=${DLLEXPORT}) -ELSE(WIN32) - ADD_DEFINITIONS(-DGLOBE_EXPORT=) -ENDIF(WIN32) - -QT5_WRAP_UI (GLOBE_PLUGIN_UIS_H ${GLOBE_PLUGIN_UIS}) - -QT5_WRAP_CPP (GLOBE_PLUGIN_MOC_SRCS ${GLOBE_PLUGIN_MOC_HDRS}) - -ADD_LIBRARY (globeplugin MODULE ${GLOBE_PLUGIN_SRCS} ${GLOBE_PLUGIN_MOC_SRCS} ${GLOBE_PLUGIN_RCCS} ${GLOBE_PLUGIN_UIS_H} ${GLOBE_PLUGIN_HDRS}) -INCLUDE_DIRECTORIES( - ${CMAKE_CURRENT_BINARY_DIR} - ${Qt5OpenGL_INCLUDE_DIRS} - ${OSGEARTH_INCLUDE_DIR} - ${OSG_INCLUDE_DIR} - ${GEOS_INCLUDE_DIR} - ${SIP_INCLUDE_DIR} - ../../core - ../../core/expression - ../../core/geometry - ../../core/metadata - ../../core/raster - ../../gui - .. - ${CMAKE_BINARY_DIR}/src/core - ${CMAKE_BINARY_DIR}/src/gui - ${CMAKE_SOURCE_DIR}/external - ${CMAKE_SOURCE_DIR}/external/nlohmann -) - -TARGET_LINK_LIBRARIES(globeplugin - qgis_core - qgis_gui - Qt5::OpenGL - ${OSGDB_LIBRARY} - ${OSGGA_LIBRARY} - ${OSGUTIL_LIBRARY} - ${OSG_LIBRARY} - ${OSGQT_LIBRARY} - ${OSGVIEWER_LIBRARY} - ${OSGEARTH_LIBRARY} - ${OSGEARTHANNOTATION_LIBRARY} - ${OSGEARTHFEATURES_LIBRARY} - ${OSGEARTHUTIL_LIBRARY} - ${OSGEARTHSYMBOLOGY_LIBRARY} - ${OSGEARTHQT_LIBRARY} - ${OPENTHREADS_LIBRARY} -) - -ADD_SUBDIRECTORY(featuresource) - -######################################################## -# Install - -INSTALL(TARGETS globeplugin - RUNTIME DESTINATION ${QGIS_PLUGIN_DIR} - LIBRARY DESTINATION ${QGIS_PLUGIN_DIR}) - -INSTALL (FILES images/world.tif - DESTINATION ${QGIS_DATA_DIR}/globe) - -INSTALL (DIRECTORY images/gui - DESTINATION ${QGIS_DATA_DIR}/globe) diff --git a/src/plugins/globe/CMakeModules/FindOSG.cmake b/src/plugins/globe/CMakeModules/FindOSG.cmake deleted file mode 100644 index c7ea888d7b6..00000000000 --- a/src/plugins/globe/CMakeModules/FindOSG.cmake +++ /dev/null @@ -1,125 +0,0 @@ -# This module defines - -# OSG_LIBRARY -# OSG_FOUND, if false, do not try to link to osg -# OSG_INCLUDE_DIRS, where to find the headers -# OSG_INCLUDE_DIR, where to find the source headers -# OSG_GEN_INCLUDE_DIR, where to find the generated headers - -# to use this module, set variables to point to the osg build -# directory, and source directory, respectively -# OSGDIR or OSG_SOURCE_DIR: osg source directory, typically OpenSceneGraph -# OSG_DIR or OSG_BUILD_DIR: osg build directory, place in which you've -# built osg via cmake - -# Header files are presumed to be included like -# #include -# #include - -###### headers ###### - -MACRO( FIND_OSG_INCLUDE THIS_OSG_INCLUDE_DIR THIS_OSG_INCLUDE_FILE ) - -FIND_PATH( ${THIS_OSG_INCLUDE_DIR} ${THIS_OSG_INCLUDE_FILE} - PATHS - ${OSG_DIR} - $ENV{OSG_SOURCE_DIR} - $ENV{OSGDIR} - $ENV{OSG_DIR} - /usr/local/ - /usr/ - /sw/ # Fink - /opt/local/ # DarwinPorts - /opt/csw/ # Blastwave - /opt/ - [HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;OSG_ROOT]/ - ~/Library/Frameworks - /Library/Frameworks - PATH_SUFFIXES - /include/ -) - -ENDMACRO( FIND_OSG_INCLUDE THIS_OSG_INCLUDE_DIR THIS_OSG_INCLUDE_FILE ) - -FIND_OSG_INCLUDE( OSG_GEN_INCLUDE_DIR osg/Config ) -FIND_OSG_INCLUDE( OSG_INCLUDE_DIR osg/Node ) - -###### libraries ###### - -MACRO( FIND_OSG_LIBRARY MYLIBRARY MYLIBRARYNAME ) - -FIND_LIBRARY(${MYLIBRARY} - NAMES - ${MYLIBRARYNAME} - PATHS - ${OSG_DIR} - $ENV{OSG_BUILD_DIR} - $ENV{OSG_DIR} - $ENV{OSGDIR} - $ENV{OSG_ROOT} - $ENV{OSGEO4W_ROOT} - ~/Library/Frameworks - /Library/Frameworks - /usr/local - /usr - /sw - /opt/local - /opt/csw - /opt - [HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;OSG_ROOT]/lib - /usr/freeware - PATH_SUFFIXES - /lib/ - /lib64/ - /build/lib/ - /build/lib64/ - /Build/lib/ - /Build/lib64/ - ) - -ENDMACRO(FIND_OSG_LIBRARY LIBRARY LIBRARYNAME) - -FIND_OSG_LIBRARY( OSG_LIBRARY osg ) -FIND_OSG_LIBRARY( OSG_LIBRARY_DEBUG osgd) - -FIND_OSG_LIBRARY( OSGUTIL_LIBRARY osgUtil ) -FIND_OSG_LIBRARY( OSGUTIL_LIBRARY_DEBUG osgUtild) - -FIND_OSG_LIBRARY( OSGDB_LIBRARY osgDB ) -FIND_OSG_LIBRARY( OSGDB_LIBRARY_DEBUG osgDBd) - -FIND_OSG_LIBRARY( OSGTEXT_LIBRARY osgText ) -FIND_OSG_LIBRARY( OSGTEXT_LIBRARY_DEBUG osgTextd ) - -FIND_OSG_LIBRARY( OSGTERRAIN_LIBRARY osgTerrain ) -FIND_OSG_LIBRARY( OSGTERRAIN_LIBRARY_DEBUG osgTerraind ) - -FIND_OSG_LIBRARY( OSGFX_LIBRARY osgFX ) -FIND_OSG_LIBRARY( OSGFX_LIBRARY_DEBUG osgFXd ) - -FIND_OSG_LIBRARY( OSGSIM_LIBRARY osgSim ) -FIND_OSG_LIBRARY( OSGSIM_LIBRARY_DEBUG osgSimd ) - -FIND_OSG_LIBRARY( OSGVIEWER_LIBRARY osgViewer ) -FIND_OSG_LIBRARY( OSGVIEWER_LIBRARY_DEBUG osgViewerd ) - -FIND_OSG_LIBRARY( OSGGA_LIBRARY osgGA ) -FIND_OSG_LIBRARY( OSGGA_LIBRARY_DEBUG osgGAd ) - -FIND_OSG_LIBRARY( OSGQT_LIBRARY osgQt5 osgQt ) -FIND_OSG_LIBRARY( OSGQT_LIBRARY_DEBUG osgQt5d osgQtd ) - -FIND_OSG_LIBRARY( OSGWIDGET_LIBRARY osgWidget ) -FIND_OSG_LIBRARY( OSGWIDGET_LIBRARY_DEBUG osgWidgetd ) - -FIND_OSG_LIBRARY( OPENTHREADS_LIBRARY OpenThreads ) -FIND_OSG_LIBRARY( OPENTHREADS_LIBRARY_DEBUG OpenThreadsd ) - -SET( OSG_FOUND "NO" ) -IF( OSG_LIBRARY AND OSG_INCLUDE_DIR ) - SET( OSG_FOUND "YES" ) - SET( OSG_INCLUDE_DIRS ${OSG_INCLUDE_DIR} ${OSG_GEN_INCLUDE_DIR} ) - GET_FILENAME_COMPONENT( OSG_LIBRARIES_DIR ${OSG_LIBRARY} PATH ) -ENDIF( OSG_LIBRARY AND OSG_INCLUDE_DIR ) - - diff --git a/src/plugins/globe/CMakeModules/FindOpenThreads.cmake b/src/plugins/globe/CMakeModules/FindOpenThreads.cmake deleted file mode 100644 index 5c857cbfd22..00000000000 --- a/src/plugins/globe/CMakeModules/FindOpenThreads.cmake +++ /dev/null @@ -1,185 +0,0 @@ -# OpenThreads is a C++ based threading library. Its largest userbase -# seems to OpenSceneGraph so you might notice I accept OSGDIR as an -# environment path. -# I consider this part of the Findosg* suite used to find OpenSceneGraph -# components. -# Each component is separate and you must opt in to each module. -# -# Locate OpenThreads -# This module defines -# OPENTHREADS_LIBRARY -# OPENTHREADS_FOUND, if false, do not try to link to OpenThreads -# OPENTHREADS_INCLUDE_DIR, where to find the headers -# -# $OPENTHREADS_DIR is an environment variable that would -# correspond to the ./configure --prefix=$OPENTHREADS_DIR -# used in building osg. -# -# Created by Eric Wing. - -# Header files are presumed to be included like -# #include - -# To make it easier for one-step automated configuration/builds, -# we leverage environmental paths. This is preferable -# to the -DVAR=value switches because it insulates the -# users from changes we may make in this script. -# It also offers a little more flexibility than setting -# the CMAKE_*_PATH since we can target specific components. -# However, the default CMake behavior will search system paths -# before anything else. This is problematic in the cases -# where you have an older (stable) version installed, but -# are trying to build a newer version. -# CMake doesn't offer a nice way to globally control this behavior -# so we have to do a nasty "double FIND_" in this module. -# The first FIND disables the CMAKE_ search paths and only checks -# the environmental paths. -# If nothing is found, then the second find will search the -# standard install paths. -# Explicit -DVAR=value arguments should still be able to override everything. -# Note: We have added an additional check for ${CMAKE_PREFIX_PATH}. -# This is not an official CMake variable, but one we are proposing be -# added to CMake. Be warned that this may go away or the variable name -# may change. - -FIND_PATH(OPENTHREADS_INCLUDE_DIR OpenThreads/Thread - $ENV{OPENTHREADS_INCLUDE_DIR} - $ENV{OPENTHREADS_DIR}/include - $ENV{OPENTHREADS_DIR} - $ENV{OSG_INCLUDE_DIR} - $ENV{OSG_DIR}/include - $ENV{OSG_DIR} - NO_DEFAULT_PATH -) - -IF(NOT OPENTHREADS_INCLUDE_DIR) - FIND_PATH(OPENTHREADS_INCLUDE_DIR OpenThreads/Thread - PATHS ${CMAKE_PREFIX_PATH} # Unofficial: We are proposing this. - PATH_SUFFIXES include - ) -ENDIF(NOT OPENTHREADS_INCLUDE_DIR) - -IF(NOT OPENTHREADS_INCLUDE_DIR) - FIND_PATH(OPENTHREADS_INCLUDE_DIR OpenThreads/Thread - ~/Library/Frameworks - /Library/Frameworks - /usr/local/include - /usr/include - /sw/include # Fink - /opt/local/include # DarwinPorts - /opt/csw/include # Blastwave - /opt/include - [HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;OpenThreads_ROOT]/include - [HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;OSG_ROOT]/include - ) -ENDIF(NOT OPENTHREADS_INCLUDE_DIR) - - -FIND_LIBRARY(OPENTHREADS_LIBRARY - NAMES OpenThreads OpenThreadsWin32 - PATHS - $ENV{OPENTHREADS_LIBRARY_DIR} - $ENV{OPENTHREADS_DIR}/lib64 - $ENV{OPENTHREADS_DIR}/lib - $ENV{OPENTHREADS_DIR} - $ENV{OSG_LIBRARY_DIR} - $ENV{OSG_DIR}/lib64 - $ENV{OSG_DIR}/lib - $ENV{OSG_DIR} - NO_DEFAULT_PATH -) - -IF(NOT OPENTHREADS_LIBRARY) - FIND_LIBRARY(OPENTHREADS_LIBRARY - NAMES OpenThreads OpenThreadsWin32 - PATHS ${CMAKE_PREFIX_PATH} # Unofficial: We are proposing this. - PATH_SUFFIXES lib64 lib - ) -ENDIF(NOT OPENTHREADS_LIBRARY) - -IF(NOT OPENTHREADS_LIBRARY) - FIND_LIBRARY(OPENTHREADS_LIBRARY - NAMES OpenThreads OpenThreadsWin32 - PATHS - ~/Library/Frameworks - /Library/Frameworks - /usr/local/lib64 - /usr/local/lib - /usr/lib64 - /usr/lib - /sw/lib64 - /sw/lib - /opt/local/lib64 - /opt/local/lib - /opt/csw/lib64 - /opt/csw/lib - /opt/lib64 - /opt/lib - [HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;OpenThreads_ROOT]/lib - [HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;OSG_ROOT]/lib - ) -ENDIF(NOT OPENTHREADS_LIBRARY) - - -FIND_LIBRARY(OPENTHREADS_LIBRARY_DEBUG - NAMES OpenThreadsd OpenThreadsWin32d - PATHS - $ENV{OPENTHREADS_DEBUG_LIBRARY_DIR} - $ENV{OPENTHREADS_LIBRARY_DIR} - $ENV{OPENTHREADS_DIR}/lib64 - $ENV{OPENTHREADS_DIR}/lib - $ENV{OPENTHREADS_DIR} - $ENV{OSG_LIBRARY_DIR} - $ENV{OSG_DIR}/lib64 - $ENV{OSG_DIR}/lib - $ENV{OSG_DIR} - ${CMAKE_PREFIX_PATH}/lib64 - ${CMAKE_PREFIX_PATH}/lib - ${CMAKE_PREFIX_PATH} - NO_DEFAULT_PATH -) - -IF(NOT OPENTHREADS_LIBRARY_DEBUG) - FIND_LIBRARY(OPENTHREADS_LIBRARY_DEBUG - NAMES OpenThreadsd OpenThreadsWin32d - PATHS ${CMAKE_PREFIX_PATH} # Unofficial: We are proposing this. - PATH_SUFFIXES lib64 lib - ) -ENDIF(NOT OPENTHREADS_LIBRARY_DEBUG) - -IF(NOT OPENTHREADS_LIBRARY_DEBUG) - FIND_LIBRARY(OPENTHREADS_LIBRARY_DEBUG - NAMES OpenThreadsd OpenThreadsWin32d - PATHS - /usr/local/lib64 - /usr/local/lib - /usr/lib64 - /usr/lib - /sw/lib64 - /sw/lib - /opt/local/lib64 - /opt/local/lib - /opt/csw/lib64 - /opt/csw/lib - /opt/lib64 - /opt/lib - [HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;OpenThreads_ROOT]/lib - [HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;OSG_ROOT]/lib - ) -ENDIF(NOT OPENTHREADS_LIBRARY_DEBUG) - - -IF(OPENTHREADS_LIBRARY) - IF(NOT OPENTHREADS_LIBRARY_DEBUG) - #MESSAGE("-- Warning Debug OpenThreads not found, using: ${OPENTHREADS_LIBRARY}") - #SET(OPENTHREADS_LIBRARY_DEBUG "${OPENTHREADS_LIBRARY}") - SET(OPENTHREADS_LIBRARY_DEBUG "${OPENTHREADS_LIBRARY}" CACHE FILEPATH "Debug version of OpenThreads Library (use regular version if not available)" FORCE) - ENDIF(NOT OPENTHREADS_LIBRARY_DEBUG) -ENDIF(OPENTHREADS_LIBRARY) - -SET(OPENTHREADS_FOUND "NO") -IF(OPENTHREADS_INCLUDE_DIR AND OPENTHREADS_LIBRARY) - SET(OPENTHREADS_FOUND "YES") - # MESSAGE("-- Found OpenThreads: "${OPENTHREADS_LIBRARY}) -ENDIF(OPENTHREADS_INCLUDE_DIR AND OPENTHREADS_LIBRARY) - diff --git a/src/plugins/globe/CMakeModules/ModuleInstallOsgEarthDriverIncludes.cmake b/src/plugins/globe/CMakeModules/ModuleInstallOsgEarthDriverIncludes.cmake deleted file mode 100644 index 403f850b860..00000000000 --- a/src/plugins/globe/CMakeModules/ModuleInstallOsgEarthDriverIncludes.cmake +++ /dev/null @@ -1,11 +0,0 @@ -# Required Vars: -# ${LIB_NAME} -# ${LIB_PUBLIC_HEADERS} - -SET(INSTALL_INCDIR include) - -# FIXME: Do not run for OS X framework -INSTALL( - FILES ${LIB_PUBLIC_HEADERS} - DESTINATION ${INSTALL_INCDIR}/osgEarthDrivers/${LIB_NAME} -) diff --git a/src/plugins/globe/CMakeModules/OsgEarthMacroUtils.cmake b/src/plugins/globe/CMakeModules/OsgEarthMacroUtils.cmake deleted file mode 100644 index 239ab4b0603..00000000000 --- a/src/plugins/globe/CMakeModules/OsgEarthMacroUtils.cmake +++ /dev/null @@ -1,361 +0,0 @@ -####################################################################################################### -# macro to detect osg version and setup variables accordingly -####################################################################################################### -MACRO(DETECT_OSG_VERSION) - - OPTION(APPEND_OPENSCENEGRAPH_VERSION "Append the OSG version number to the osgPlugins directory" ON) - - # detect if osgversion can be found - FIND_PROGRAM(OSG_VERSION_EXE NAMES osgversion) - IF(OSG_VERSION_EXE AND NOT OPENSCENEGRAPH_MAJOR_VERSION AND NOT OPENSCENEGRAPH_MINOR_VERSION AND NOT OPENSCENEGRAPH_PATCH_VERSION) - #MESSAGE("OSGVERSION IS AT ${OSG_VERSION_EXE}") - # get parameters out of the osgversion - EXECUTE_PROCESS(COMMAND ${OSG_VERSION_EXE} --major-number OUTPUT_VARIABLE OPENSCENEGRAPH_MAJOR_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE) - EXECUTE_PROCESS(COMMAND ${OSG_VERSION_EXE} --minor-number OUTPUT_VARIABLE OPENSCENEGRAPH_MINOR_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE) - EXECUTE_PROCESS(COMMAND ${OSG_VERSION_EXE} --patch-number OUTPUT_VARIABLE OPENSCENEGRAPH_PATCH_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE) - EXECUTE_PROCESS(COMMAND ${OSG_VERSION_EXE} Matrix::value_type OUTPUT_VARIABLE OSG_USE_FLOAT_MATRIX OUTPUT_STRIP_TRAILING_WHITESPACE) - EXECUTE_PROCESS(COMMAND ${OSG_VERSION_EXE} Plane::value_type OUTPUT_VARIABLE OSG_USE_FLOAT_PLANE OUTPUT_STRIP_TRAILING_WHITESPACE) - EXECUTE_PROCESS(COMMAND ${OSG_VERSION_EXE} BoundingSphere::value_type OUTPUT_VARIABLE OSG_USE_FLOAT_BOUNDINGSPHERE OUTPUT_STRIP_TRAILING_WHITESPACE) - EXECUTE_PROCESS(COMMAND ${OSG_VERSION_EXE} BoundingBox::value_type OUTPUT_VARIABLE OSG_USE_FLOAT_BOUNDINGBOX OUTPUT_STRIP_TRAILING_WHITESPACE) - - # setup version numbers if we have osgversion - SET(OPENSCENEGRAPH_MAJOR_VERSION "${OPENSCENEGRAPH_MAJOR_VERSION}" CACHE STRING "OpenSceneGraph major version number") - SET(OPENSCENEGRAPH_MINOR_VERSION "${OPENSCENEGRAPH_MINOR_VERSION}" CACHE STRING "OpenSceneGraph minor version number") - SET(OPENSCENEGRAPH_PATCH_VERSION "${OPENSCENEGRAPH_PATCH_VERSION}" CACHE STRING "OpenSceneGraph patch version number") - SET(OPENSCENEGRAPH_SOVERSION "${OPENSCENEGRAPH_SOVERSION}" CACHE STRING "OpenSceneGraph so version number") - - # just debug info - #MESSAGE(STATUS "Detected OpenSceneGraph v${OPENSCENEGRAPH_VERSION}.") - - # setup float and double definitions - IF(OSG_USE_FLOAT_MATRIX MATCHES "float") - ADD_DEFINITIONS(-DOSG_USE_FLOAT_MATRIX) - ENDIF(OSG_USE_FLOAT_MATRIX MATCHES "float") - IF(OSG_USE_FLOAT_PLANE MATCHES "float") - ADD_DEFINITIONS(-DOSG_USE_FLOAT_PLANE) - ENDIF(OSG_USE_FLOAT_PLANE MATCHES "float") - IF(OSG_USE_FLOAT_BOUNDINGSPHERE MATCHES "double") - ADD_DEFINITIONS(-DOSG_USE_DOUBLE_BOUNDINGSPHERE) - ENDIF(OSG_USE_FLOAT_BOUNDINGSPHERE MATCHES "double") - IF(OSG_USE_FLOAT_BOUNDINGBOX MATCHES "double") - ADD_DEFINITIONS(-DOSG_USE_DOUBLE_BOUNDINGBOX) - ENDIF(OSG_USE_FLOAT_BOUNDINGBOX MATCHES "double") - - ENDIF(OSG_VERSION_EXE AND NOT OPENSCENEGRAPH_MAJOR_VERSION AND NOT OPENSCENEGRAPH_MINOR_VERSION AND NOT OPENSCENEGRAPH_PATCH_VERSION) - - #Initialize the version numbers to being empty. If they were set by osgversion, they will be left alone - SET(OPENSCENEGRAPH_MAJOR_VERSION "" CACHE STRING "OpenSceneGraph major version number") - SET(OPENSCENEGRAPH_MINOR_VERSION "" CACHE STRING "OpenSceneGraph minor version number") - SET(OPENSCENEGRAPH_PATCH_VERSION "" CACHE STRING "OpenSceneGraph patch version number") - SET(OPENSCENEGRAPH_SOVERSION "" CACHE STRING "OpenSceneGraph so version number") - - if (OPENSCENEGRAPH_MAJOR_VERSION AND NOT OPENSCENEGRAPH_MINOR_VERSION STREQUAL "" AND NOT OPENSCENEGRAPH_PATCH_VERSION STREQUAL "") - SET(OPENSCENEGRAPH_VERSION ${OPENSCENEGRAPH_MAJOR_VERSION}.${OPENSCENEGRAPH_MINOR_VERSION}.${OPENSCENEGRAPH_PATCH_VERSION}) - else (OPENSCENEGRAPH_MAJOR_VERSION AND NOT OPENSCENEGRAPH_MINOR_VERSION STREQUAL "" AND NOT OPENSCENEGRAPH_PATCH_VERSION STREQUAL "") - #MESSAGE("osgversion was found at ${OSG_VERSION_EXE} but failed to run") - SET(OPENSCENEGRAPH_VERSION) - endif (OPENSCENEGRAPH_MAJOR_VERSION AND NOT OPENSCENEGRAPH_MINOR_VERSION STREQUAL "" AND NOT OPENSCENEGRAPH_PATCH_VERSION STREQUAL "") - - MARK_AS_ADVANCED(OPENSCENEGRAPH_VERSION) - - - IF (APPEND_OPENSCENEGRAPH_VERSION AND OPENSCENEGRAPH_VERSION) - SET(OSG_PLUGINS "osgPlugins-${OPENSCENEGRAPH_VERSION}" CACHE STRING "" FORCE) - MESSAGE(STATUS "Plugins will be installed under osgPlugins-${OPENSCENEGRAPH_VERSION} directory.") - else (APPEND_OPENSCENEGRAPH_VERSION AND OPENSCENEGRAPH_VERSION) - SET(OSG_PLUGINS CACHE STRING "" FORCE) - ENDIF(APPEND_OPENSCENEGRAPH_VERSION AND OPENSCENEGRAPH_VERSION) - - MARK_AS_ADVANCED(OSG_PLUGINS) - - #MESSAGE("OSG_PLUGINS=${OSG_PLUGINS}") - -ENDMACRO(DETECT_OSG_VERSION) - - - -####################################################################################################### -# macro for linking libraries that come from Findxxxx commands, so there is a variable that contains the -# full path of the library name. in order to differentiate release and debug, this macro get the -# NAME of the variables, so the macro gets as arguments the target name and the following list of parameters -# is intended as a list of variable names each one containing the path of the libraries to link to -# The existence of a variable name with _DEBUG appended is tested and, in case it's value is used -# for linking to when in debug mode -# the content of this library for linking when in debugging -####################################################################################################### - - -MACRO(LINK_WITH_VARIABLES TRGTNAME) - FOREACH(varname ${ARGN}) - IF(${varname}_DEBUG) - TARGET_LINK_LIBRARIES(${TRGTNAME} optimized "${${varname}}" debug "${${varname}_DEBUG}") - ELSE(${varname}_DEBUG) - TARGET_LINK_LIBRARIES(${TRGTNAME} "${${varname}}" ) - ENDIF(${varname}_DEBUG) - ENDFOREACH(varname) -ENDMACRO(LINK_WITH_VARIABLES TRGTNAME) - -MACRO(LINK_INTERNAL TRGTNAME) - IF(${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} GREATER 4) - TARGET_LINK_LIBRARIES(${TRGTNAME} ${ARGN}) - ELSE(${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} GREATER 4) - FOREACH(LINKLIB ${ARGN}) - IF(MSVC AND OSG_MSVC_VERSIONED_DLL) - #when using versioned names, the .dll name differ from .lib name, there is a problem with that: - #CMake 2.4.7, at least seem to use PREFIX instead of IMPORT_PREFIX for computing linkage info to use into projects, - # so we full path name to specify linkage, this prevent automatic inferencing of dependencies, so we add explicit depemdencies - #to library targets used - TARGET_LINK_LIBRARIES(${TRGTNAME} optimized "${OUTPUT_LIBDIR}/${LINKLIB}${CMAKE_RELEASE_POSTFIX}.lib" debug "${OUTPUT_LIBDIR}/${LINKLIB}${CMAKE_DEBUG_POSTFIX}.lib") - ADD_DEPENDENCIES(${TRGTNAME} ${LINKLIB}) - ELSE(MSVC AND OSG_MSVC_VERSIONED_DLL) - TARGET_LINK_LIBRARIES(${TRGTNAME} optimized "${LINKLIB}${CMAKE_RELEASE_POSTFIX}" debug "${LINKLIB}${CMAKE_DEBUG_POSTFIX}") - ENDIF(MSVC AND OSG_MSVC_VERSIONED_DLL) - ENDFOREACH(LINKLIB) - ENDIF(${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} GREATER 4) -ENDMACRO(LINK_INTERNAL TRGTNAME) - -MACRO(LINK_EXTERNAL TRGTNAME) - FOREACH(LINKLIB ${ARGN}) - TARGET_LINK_LIBRARIES(${TRGTNAME} "${LINKLIB}" ) - ENDFOREACH(LINKLIB) -ENDMACRO(LINK_EXTERNAL TRGTNAME) - - -####################################################################################################### -# macro for common setup of core libraries: it links OPENGL_LIBRARIES in undifferentiated mode -####################################################################################################### - -MACRO(LINK_CORELIB_DEFAULT CORELIB_NAME) - LINK_EXTERNAL(${CORELIB_NAME} ${OPENGL_LIBRARIES}) - LINK_WITH_VARIABLES(${CORELIB_NAME} OPENTHREADS_LIBRARY) - IF(OSGEARTH_SONAMES) - SET_TARGET_PROPERTIES(${CORELIB_NAME} PROPERTIES VERSION ${OSGEARTH_VERSION} SOVERSION ${OSGEARTH_SOVERSION}) - ENDIF(OSGEARTH_SONAMES) -ENDMACRO(LINK_CORELIB_DEFAULT CORELIB_NAME) - - -####################################################################################################### -# macro for common setup of plugins, examples and applications it expect some variables to be set: -# either within the local CMakeLists or higher in hierarchy -# TARGET_NAME is the name of the folder and of the actually .exe or .so or .dll -# TARGET_TARGETNAME is the name of the target, this get built out of a prefix, if present and TARGET_TARGETNAME -# TARGET_SRC are the sources of the target -# TARGET_H are the eventual headers of the target -# TARGET_LIBRARIES are the libraries to link to that are internal to the project and have d suffix for debug -# TARGET_EXTERNAL_LIBRARIES are external libraries and are not differentiated with d suffix -# TARGET_LABEL is the label IDE should show up for targets -########################################################################################################## - -MACRO(SETUP_LINK_LIBRARIES) - ###################################################################### - # - # This set up the libraries to link to, it assumes there are two variable: one common for a group of examples or plagins - # kept in the variable TARGET_COMMON_LIBRARIES and an example or plugin specific kept in TARGET_ADDED_LIBRARIES - # they are combined in a single list checked for unicity - # the suffix ${CMAKE_DEBUG_POSTFIX} is used for differentiating optimized and debug - # - # a second variable TARGET_EXTERNAL_LIBRARIES hold the list of libraries not differentiated between debug and optimized - ################################################################################## - SET(TARGET_LIBRARIES ${TARGET_COMMON_LIBRARIES}) - - FOREACH(LINKLIB ${TARGET_ADDED_LIBRARIES}) - SET(TO_INSERT TRUE) - FOREACH (value ${TARGET_COMMON_LIBRARIES}) - IF (${value} STREQUAL ${LINKLIB}) - SET(TO_INSERT FALSE) - ENDIF (${value} STREQUAL ${LINKLIB}) - ENDFOREACH (value ${TARGET_COMMON_LIBRARIES}) - IF(TO_INSERT) - LIST(APPEND TARGET_LIBRARIES ${LINKLIB}) - ENDIF(TO_INSERT) - ENDFOREACH(LINKLIB) - -# FOREACH(LINKLIB ${TARGET_LIBRARIES}) -# TARGET_LINK_LIBRARIES(${TARGET_TARGETNAME} optimized ${LINKLIB} debug "${LINKLIB}${CMAKE_DEBUG_POSTFIX}") -# ENDFOREACH(LINKLIB) - LINK_INTERNAL(${TARGET_TARGETNAME} ${TARGET_LIBRARIES}) - - FOREACH(LINKLIB ${TARGET_EXTERNAL_LIBRARIES}) - TARGET_LINK_LIBRARIES(${TARGET_TARGETNAME} ${LINKLIB}) - ENDFOREACH(LINKLIB) - IF(TARGET_LIBRARIES_VARS) - LINK_WITH_VARIABLES(${TARGET_TARGETNAME} ${TARGET_LIBRARIES_VARS}) - ENDIF(TARGET_LIBRARIES_VARS) -ENDMACRO(SETUP_LINK_LIBRARIES) - -############################################################################################ -# this is the common set of command for all the plugins - - -MACRO(SETUP_PLUGIN PLUGIN_NAME) - - SET(TARGET_NAME ${PLUGIN_NAME} ) - - #MESSAGE("in -->SETUP_PLUGIN<-- ${TARGET_NAME}-->${TARGET_SRC} <--> ${TARGET_H}<--") - - SOURCE_GROUP( "Header Files" FILES ${TARGET_H} ) - - ## we have set up the target label and targetname by taking into account global prfix (osgdb_) - - IF(NOT TARGET_TARGETNAME) - SET(TARGET_TARGETNAME "${TARGET_DEFAULT_PREFIX}${TARGET_NAME}") - ENDIF(NOT TARGET_TARGETNAME) - IF(NOT TARGET_LABEL) - SET(TARGET_LABEL "${TARGET_DEFAULT_LABEL_PREFIX} ${TARGET_NAME}") - ENDIF(NOT TARGET_LABEL) - -# here we use the command to generate the library - - IF (DYNAMIC_OSGEARTH) - ADD_LIBRARY(${TARGET_TARGETNAME} MODULE ${TARGET_SRC} ${TARGET_H}) - ELSE (DYNAMIC_OSGEARTH) - ADD_LIBRARY(${TARGET_TARGETNAME} STATIC ${TARGET_SRC} ${TARGET_H}) - ENDIF(DYNAMIC_OSGEARTH) - - #not sure if needed, but for plugins only msvc need the d suffix - IF(NOT MSVC) - IF(NOT UNIX) - SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES DEBUG_POSTFIX "") - ENDIF(NOT UNIX) - ENDIF(NOT MSVC) - SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES PROJECT_LABEL "${TARGET_LABEL}") - - SETUP_LINK_LIBRARIES() - -#the installation path are differentiated for win32 that install in bib versus other architecture that install in lib${LIB_POSTFIX}/${VPB_PLUGINS} - IF(WIN32) - INSTALL(TARGETS ${TARGET_TARGETNAME} RUNTIME DESTINATION bin ARCHIVE DESTINATION lib/${OSG_PLUGINS} LIBRARY DESTINATION bin/${OSG_PLUGINS} ) - - #Install to the OSG_DIR as well - IF(OSGEARTH_INSTALL_TO_OSG_DIR AND OSG_DIR) - INSTALL(TARGETS ${TARGET_TARGETNAME} RUNTIME DESTINATION ${OSG_DIR}/bin/${OSG_PLUGINS} LIBRARY DESTINATION ${OSG_DIR}/bin/${OSG_PLUGINS} ) - ENDIF(OSGEARTH_INSTALL_TO_OSG_DIR AND OSG_DIR) - - ELSE(WIN32) - INSTALL(TARGETS ${TARGET_TARGETNAME} RUNTIME DESTINATION bin ARCHIVE DESTINATION lib${LIB_POSTFIX}/${OSG_PLUGINS} LIBRARY DESTINATION lib${LIB_POSTFIX}/${OSG_PLUGINS} ) - - #Install to the OSG_DIR as well - IF(OSGEARTH_INSTALL_TO_OSG_DIR AND OSG_DIR) - INSTALL(TARGETS ${TARGET_TARGETNAME} RUNTIME DESTINATION ${OSG_DIR}/bin LIBRARY DESTINATION lib${LIB_POSTFIX}/bin) - ENDIF(OSGEARTH_INSTALL_TO_OSG_DIR AND OSG_DIR) - - ENDIF(WIN32) - -#finally, set up the solution folder -gw - SET_PROPERTY(TARGET ${TARGET_TARGETNAME} PROPERTY FOLDER "Plugins") - -ENDMACRO(SETUP_PLUGIN) - - -################################################################################################################# -# this is the macro for example and application setup -########################################################### - -MACRO(SETUP_EXE IS_COMMANDLINE_APP) - #MESSAGE("in -->SETUP_EXE<-- ${TARGET_NAME}-->${TARGET_SRC} <--> ${TARGET_H}<--") - IF(NOT TARGET_TARGETNAME) - SET(TARGET_TARGETNAME "${TARGET_DEFAULT_PREFIX}${TARGET_NAME}") - ENDIF(NOT TARGET_TARGETNAME) - IF(NOT TARGET_LABEL) - SET(TARGET_LABEL "${TARGET_DEFAULT_LABEL_PREFIX} ${TARGET_NAME}") - ENDIF(NOT TARGET_LABEL) - - IF(${IS_COMMANDLINE_APP}) - - ADD_EXECUTABLE(${TARGET_TARGETNAME} ${TARGET_SRC} ${TARGET_H}) - - ELSE(${IS_COMMANDLINE_APP}) - - IF(APPLE) - # SET(MACOSX_BUNDLE_LONG_VERSION_STRING "${VIRTUALPLANETBUILDER_MAJOR_VERSION}.${VIRTUALPLANETBUILDER_MINOR_VERSION}.${VIRTUALPLANETBUILDER_PATCH_VERSION}") - # Short Version is the "marketing version". It is the version - # the user sees in an information panel. - SET(MACOSX_BUNDLE_SHORT_VERSION_STRING "${OSGEARTH_MAJOR_VERSION}.${OSGEARTH_MINOR_VERSION}.${OSGEARTH_PATCH_VERSION}") - # Bundle version is the version the OS looks at. - SET(MACOSX_BUNDLE_BUNDLE_VERSION "${OSGEARTH_MAJOR_VERSION}.${OSGEARTH_MINOR_VERSION}.${OSGEARTH__PATCH_VERSION}") - SET(MACOSX_BUNDLE_GUI_IDENTIFIER "org.osgearth.${TARGET_TARGETNAME}" ) - SET(MACOSX_BUNDLE_BUNDLE_NAME "${TARGET_NAME}" ) - # SET(MACOSX_BUNDLE_ICON_FILE "myicon.icns") - # SET(MACOSX_BUNDLE_COPYRIGHT "") - # SET(MACOSX_BUNDLE_INFO_STRING "Info string, localized?") - ENDIF(APPLE) - - IF(WIN32) - IF (REQUIRE_WINMAIN_FLAG) - SET(PLATFORM_SPECIFIC_CONTROL WIN32) - ENDIF(REQUIRE_WINMAIN_FLAG) - ENDIF(WIN32) - - IF(APPLE) - IF(VPB_BUILD_APPLICATION_BUNDLES) - SET(PLATFORM_SPECIFIC_CONTROL MACOSX_BUNDLE) - ENDIF(VPB_BUILD_APPLICATION_BUNDLES) - ENDIF(APPLE) - - ADD_EXECUTABLE(${TARGET_TARGETNAME} ${PLATFORM_SPECIFIC_CONTROL} ${TARGET_SRC} ${TARGET_H}) - - ENDIF(${IS_COMMANDLINE_APP}) - - SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES PROJECT_LABEL "${TARGET_LABEL}") - SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES OUTPUT_NAME ${TARGET_NAME}) - SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES DEBUG_OUTPUT_NAME "${TARGET_NAME}${CMAKE_DEBUG_POSTFIX}") - SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES RELEASE_OUTPUT_NAME "${TARGET_NAME}${CMAKE_RELEASE_POSTFIX}") - SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES RELWITHDEBINFO_OUTPUT_NAME "${TARGET_NAME}${CMAKE_RELWITHDEBINFO_POSTFIX}") - SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES MINSIZEREL_OUTPUT_NAME "${TARGET_NAME}${CMAKE_MINSIZEREL_POSTFIX}") - - SETUP_LINK_LIBRARIES() - -ENDMACRO(SETUP_EXE) - -# Takes optional second argument (is_commandline_app?) in ARGV1 -MACRO(SETUP_APPLICATION APPLICATION_NAME) - - SET(TARGET_NAME ${APPLICATION_NAME} ) - - IF(${ARGC} GREATER 1) - SET(IS_COMMANDLINE_APP ${ARGV1}) - ELSE(${ARGC} GREATER 1) - SET(IS_COMMANDLINE_APP 0) - ENDIF(${ARGC} GREATER 1) - - SETUP_EXE(${IS_COMMANDLINE_APP}) - - INSTALL(TARGETS ${TARGET_TARGETNAME} RUNTIME DESTINATION bin ) - #Install to the OSG_DIR as well - IF(OSGEARTH_INSTALL_TO_OSG_DIR AND OSG_DIR) - INSTALL(TARGETS ${TARGET_TARGETNAME} RUNTIME DESTINATION ${OSG_DIR}/bin) - ENDIF(OSGEARTH_INSTALL_TO_OSG_DIR AND OSG_DIR) - - SET_PROPERTY(TARGET ${TARGET_TARGETNAME} PROPERTY FOLDER "Samples") - -ENDMACRO(SETUP_APPLICATION) - -MACRO(SETUP_COMMANDLINE_APPLICATION APPLICATION_NAME) - - SETUP_APPLICATION(${APPLICATION_NAME} 1) - -ENDMACRO(SETUP_COMMANDLINE_APPLICATION) - -# Takes optional second argument (is_commandline_app?) in ARGV1 -MACRO(SETUP_EXAMPLE EXAMPLE_NAME) - - SET(TARGET_NAME ${EXAMPLE_NAME} ) - - IF(${ARGC} GREATER 1) - SET(IS_COMMANDLINE_APP ${ARGV1}) - ELSE(${ARGC} GREATER 1) - SET(IS_COMMANDLINE_APP 0) - ENDIF(${ARGC} GREATER 1) - - SETUP_EXE(${IS_COMMANDLINE_APP}) - - INSTALL(TARGETS ${TARGET_TARGETNAME} RUNTIME DESTINATION share/OpenSceneGraph/bin ) - -ENDMACRO(SETUP_EXAMPLE) - - -MACRO(SETUP_COMMANDLINE_EXAMPLE EXAMPLE_NAME) - - SETUP_EXAMPLE(${EXAMPLE_NAME} 1) - -ENDMACRO(SETUP_COMMANDLINE_EXAMPLE) diff --git a/src/plugins/globe/featuresource/CMakeLists.txt b/src/plugins/globe/featuresource/CMakeLists.txt deleted file mode 100644 index 9aa7b900976..00000000000 --- a/src/plugins/globe/featuresource/CMakeLists.txt +++ /dev/null @@ -1,50 +0,0 @@ -################################################### -# osgEarth plugin -################################################### - -SET(OSGEARTH_PLUGIN_PREFIX "") -SET(LIB_POSTFIX ${LIB_SUFFIX}) -SET(DYNAMIC_OSGEARTH "ON" ) -SET(OSGEARTH_USER_DEFINED_DYNAMIC_OR_STATIC "SHARED") - -# SET(CMAKE_SHARED_MODULE_PREFIX ${OSGEARTH_PLUGIN_PREFIX}) -SET(TARGET_DEFAULT_PREFIX "osgdb_") -SET(TARGET_DEFAULT_LABEL_PREFIX "Plugin") - -INCLUDE( OsgEarthMacroUtils ) - -SET(TARGET_SRC - qgsglobefeaturesource.cpp -) - -SET (TARGET_MOC_HDRS - qgsglobefeaturesource.h -) - -SET(TARGET_HDRS - qgsglobefeaturecursor.h - qgsglobefeatureoptions.h - qgsglobefeatureutils.h -) - -QT5_WRAP_CPP(TARGET_MOC_SRCS ${TARGET_MOC_HDRS}) - -SET(TARGET_SRC ${TARGET_SRC} ${TARGET_MOC_SRCS}) - -SET(TARGET_COMMON_LIBRARIES ${TARGET_COMMON_LIBRARIES} - qgis_core - qgis_gui - ${OSGDB_LIBRARY} - ${OSG_LIBRARY} - ${OSGEARTH_LIBRARY} - ${OSGEARTHFEATURES_LIBRARY} - ${OSGEARTHSYMBOLOGY_LIBRARY} - ${OSGEARTHUTIL_LIBRARY} - ${OPENTHREADS_LIBRARY} -) -SETUP_PLUGIN(osgearth_feature_qgis) - -# to install public driver includes: -SET(LIB_NAME feature_qgis) -SET(LIB_PUBLIC_HEADERS ${TARGET_HDRS} ${TARGET_MOC_HDRS}) -INCLUDE(ModuleInstallOsgEarthDriverIncludes OPTIONAL) diff --git a/src/plugins/globe/featuresource/qgsglobefeaturecursor.h b/src/plugins/globe/featuresource/qgsglobefeaturecursor.h deleted file mode 100644 index c45ede7511d..00000000000 --- a/src/plugins/globe/featuresource/qgsglobefeaturecursor.h +++ /dev/null @@ -1,65 +0,0 @@ -/*************************************************************************** - qgsglobefeaturecursor.h - -------------------------------------- - Date : 11.7.2013 - Copyright : (C) 2013 Matthias Kuhn - Email : matthias dot kuhn at gmx dot ch - *************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ - -#ifndef QGSGLOBEFEATURECURSOR_H -#define QGSGLOBEFEATURECURSOR_H - -#include -#include "qgsfeature.h" -#include "qgsfeatureiterator.h" - -#include "qgsglobefeatureutils.h" - - -class QgsGlobeFeatureCursor : public osgEarth::Features::FeatureCursor -{ - public: - QgsGlobeFeatureCursor( QgsVectorLayer *layer, const QgsFeatureIterator &iterator ) - : mIterator( iterator ) - , mLayer( layer ) - { - mIterator.nextFeature( mFeature ); - } - - bool hasMore() const override - { - return mFeature.isValid(); - } - - osgEarth::Features::Feature *nextFeature() override - { - if ( mFeature.isValid() ) - { - osgEarth::Features::Feature *feat = QgsGlobeFeatureUtils::featureFromQgsFeature( mLayer, mFeature ); - mIterator.nextFeature( mFeature ); - return feat; - } - else - { - QgsDebugMsg( QStringLiteral( "WARNING: Returning NULL feature to osgEarth" ) ); - return NULL; - } - } - - private: - QgsFeatureIterator mIterator; - QgsVectorLayer *mLayer = nullptr; - // Cached feature which will be returned next. - // Always contains the next feature which will be returned - // (Because hasMore() needs to know if we are able to return a next feature) - QgsFeature mFeature; -}; - -#endif // QGSGLOBEFEATURECURSOR_H diff --git a/src/plugins/globe/featuresource/qgsglobefeatureoptions.h b/src/plugins/globe/featuresource/qgsglobefeatureoptions.h deleted file mode 100644 index 1270587b5f6..00000000000 --- a/src/plugins/globe/featuresource/qgsglobefeatureoptions.h +++ /dev/null @@ -1,81 +0,0 @@ -/* -*-c++-*- */ -/* - * osgEarth is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see - */ -#ifndef QGSGLOBEFEATUREOPTIONS_H -#define QGSGLOBEFEATUREOPTIONS_H - -#include -#include - -class QgsVectorLayer; - -class QgsGlobeFeatureOptions : public osgEarth::Features::FeatureSourceOptions // NO EXPORT; header only -{ - private: - template - class RefPtr : public osg::Referenced - { - public: - RefPtr( T *ptr ) : mPtr( ptr ) {} - T *ptr() { return mPtr; } - - private: - T *mPtr = nullptr; - }; - - public: - QgsGlobeFeatureOptions( const ConfigOptions &opt = ConfigOptions() ) - : osgEarth::Features::FeatureSourceOptions( opt ) - { - // Call the driver declared as "osgearth_feature_qgis" - setDriver( "qgis" ); - fromConfig( _conf ); - } - - osgEarth::Config getConfig() const override - { - osgEarth::Config conf = osgEarth::Features::FeatureSourceOptions::getConfig(); - conf.updateIfSet( "layerId", mLayerId ); - conf.updateNonSerializable( "layer", new RefPtr< QgsVectorLayer >( mLayer ) ); - return conf; - } - - osgEarth::optional &layerId() { return mLayerId; } - const osgEarth::optional &layerId() const { return mLayerId; } - - QgsVectorLayer *layer() const { return mLayer; } - void setLayer( QgsVectorLayer *layer ) { mLayer = layer; } - - protected: - void mergeConfig( const osgEarth::Config &conf ) override - { - osgEarth::Features::FeatureSourceOptions::mergeConfig( conf ); - fromConfig( conf ); - } - - private: - void fromConfig( const osgEarth::Config &conf ) - { - conf.getIfSet( "layerId", mLayerId ); - RefPtr< QgsVectorLayer > *layer_ptr = conf.getNonSerializable< RefPtr< QgsVectorLayer > >( "layer" ); - mLayer = layer_ptr ? layer_ptr->ptr() : 0; - } - - osgEarth::optional mLayerId; - QgsVectorLayer *mLayer = nullptr; -}; - -#endif // QGSGLOBEFEATUREOPTIONS_H - diff --git a/src/plugins/globe/featuresource/qgsglobefeaturesource.cpp b/src/plugins/globe/featuresource/qgsglobefeaturesource.cpp deleted file mode 100644 index f59462d46df..00000000000 --- a/src/plugins/globe/featuresource/qgsglobefeaturesource.cpp +++ /dev/null @@ -1,176 +0,0 @@ -/*************************************************************************** - qgsglobefeaturesource.cpp - --------------------- - begin : May 2016 - copyright : (C) 2016 by Sandro Mani - email : smani at sourcepole dot ch - *************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ - -#include -#include - -#include -#include -#include -#include -#include -#include "qgsvectorlayer.h" - -#include "qgsglobefeaturecursor.h" -#include "qgsglobefeatureutils.h" -#include "qgsglobefeaturesource.h" - - -QgsGlobeFeatureSource::QgsGlobeFeatureSource( const QgsGlobeFeatureOptions &options ) - : mOptions( options ) - , mLayer( 0 ) -#if OSGEARTH_VERSION_LESS_THAN(2, 8, 0) - , mProfile( 0 ) -#endif -{ -} - -#if OSGEARTH_VERSION_GREATER_OR_EQUAL(2, 8, 0) -osgEarth::Status QgsGlobeFeatureSource::initialize( const osgDB::Options *dbOptions ) -{ -#else -void QgsGlobeFeatureSource::initialize( const osgDB::Options *dbOptions ) -{ -#endif - Q_UNUSED( dbOptions ) - mLayer = mOptions.layer(); - - connect( mLayer, SIGNAL( attributeValueChanged( QgsFeatureId, int, QVariant ) ), this, SLOT( attributeValueChanged( QgsFeatureId, int, QVariant ) ) ); - connect( mLayer, SIGNAL( geometryChanged( QgsFeatureId, QgsGeometry ) ), this, SLOT( geometryChanged( QgsFeatureId, QgsGeometry ) ) ); - - // create the profile - osgEarth::SpatialReference *ref = osgEarth::SpatialReference::create( mLayer->crs().toWkt().toStdString() ); - if ( 0 == ref ) - { - std::cout << "Cannot find the spatial reference" << std::endl; -#if OSGEARTH_VERSION_GREATER_OR_EQUAL(2, 8, 0) - return osgEarth::Status( osgEarth::Status::ConfigurationError ); -#else - return; -#endif - } - QgsRectangle ext = mLayer->extent(); - osgEarth::GeoExtent geoext( ref, ext.xMinimum(), ext.yMinimum(), ext.xMaximum(), ext.yMaximum() ); - mSchema = QgsGlobeFeatureUtils::schemaForFields( mLayer->fields() ); -#if OSGEARTH_VERSION_GREATER_OR_EQUAL(2, 8, 0) - setFeatureProfile( new osgEarth::Features::FeatureProfile( geoext ) ); - return osgEarth::Status( osgEarth::Status::NoError ); -#else - mProfile = new osgEarth::Features::FeatureProfile( geoext ); -#endif -} - -osgEarth::Features::FeatureCursor *QgsGlobeFeatureSource::createFeatureCursor( const osgEarth::Symbology::Query &query ) -{ - QgsFeatureRequest request; - - if ( query.expression().isSet() ) - { - QgsDebugMsg( QString( "Ignoring query expression '%1'" ). arg( query.expression().value().c_str() ) ); - } - - if ( query.bounds().isSet() ) - { - QgsRectangle bounds( query.bounds()->xMin(), query.bounds()->yMin(), query.bounds()->xMax(), query.bounds()->yMax() ); - request.setFilterRect( bounds ); - } - - QgsFeatureIterator it = mLayer->getFeatures( request ); - return new QgsGlobeFeatureCursor( mLayer, it ); -} - -osgEarth::Features::Feature *QgsGlobeFeatureSource::getFeature( osgEarth::Features::FeatureID fid ) -{ - QgsFeature feat; - mLayer->getFeatures( QgsFeatureRequest().setFilterFid( fid ) ).nextFeature( feat ); - osgEarth::Features::Feature *feature = QgsGlobeFeatureUtils::featureFromQgsFeature( mLayer, feat ); - FeatureMap_t::iterator it = mFeatures.find( fid ); - if ( it == mFeatures.end() ) - { - mFeatures.insert( std::make_pair( fid, osg::observer_ptr( feature ) ) ); - } - else - { - it->second = osg::observer_ptr( feature ); - } - return feature; -} - -osgEarth::Features::Geometry::Type QgsGlobeFeatureSource::getGeometryType() const -{ - switch ( mLayer->geometryType() ) - { - case QgsWkbTypes::PointGeometry: - return osgEarth::Features::Geometry::TYPE_POINTSET; - - case QgsWkbTypes::LineGeometry: - return osgEarth::Features::Geometry::TYPE_LINESTRING; - - case QgsWkbTypes::PolygonGeometry: - return osgEarth::Features::Geometry::TYPE_POLYGON; - - default: - return osgEarth::Features::Geometry::TYPE_UNKNOWN; - } - - return osgEarth::Features::Geometry::TYPE_UNKNOWN; -} - -int QgsGlobeFeatureSource::getFeatureCount() const -{ - return mLayer->featureCount(); -} - -void QgsGlobeFeatureSource::attributeValueChanged( const QgsFeatureId &featureId, int idx, const QVariant &value ) -{ - FeatureMap_t::iterator it = mFeatures.find( featureId ); - if ( it != mFeatures.end() ) - { - osgEarth::Features::Feature *feature = it->second.get(); - QgsGlobeFeatureUtils::setFeatureField( feature, mLayer->fields().at( idx ), value ); - } -} - -void QgsGlobeFeatureSource::geometryChanged( const QgsFeatureId &featureId, const QgsGeometry &geometry ) -{ - FeatureMap_t::iterator it = mFeatures.find( featureId ); - if ( it != mFeatures.end() ) - { - osgEarth::Features::Feature *feature = it->second.get(); - feature->setGeometry( QgsGlobeFeatureUtils::geometryFromQgsGeometry( geometry ) ); - } -} - - -class QgsGlobeFeatureSourceFactory : public osgEarth::Features::FeatureSourceDriver -{ - public: - QgsGlobeFeatureSourceFactory() - { - supportsExtension( "osgearth_feature_qgis", "QGIS feature driver for osgEarth" ); - } - - osgDB::ReaderWriter::ReadResult readObject( const std::string &file_name, const osgDB::Options *options ) const override - { - // this function seems to be called for every plugin - // we declare supporting the special extension "osgearth_feature_qgis" - if ( !acceptsExtension( osgDB::getLowerCaseFileExtension( file_name ) ) ) - return osgDB::ReaderWriter::ReadResult::FILE_NOT_HANDLED; - - return osgDB::ReaderWriter::ReadResult( new QgsGlobeFeatureSource( getFeatureSourceOptions( options ) ) ); - } -}; - -REGISTER_OSGPLUGIN( osgearth_feature_qgis, QgsGlobeFeatureSourceFactory ) diff --git a/src/plugins/globe/featuresource/qgsglobefeaturesource.h b/src/plugins/globe/featuresource/qgsglobefeaturesource.h deleted file mode 100644 index fc04f93165b..00000000000 --- a/src/plugins/globe/featuresource/qgsglobefeaturesource.h +++ /dev/null @@ -1,73 +0,0 @@ -/*************************************************************************** - qgsglobefeaturesource.h - --------------------- - begin : May 2016 - copyright : (C) 2016 by Sandro Mani - email : smani at sourcepole dot ch - *************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ - -#ifndef QGSGLOBEFEATURESOURCE_H -#define QGSGLOBEFEATURESOURCE_H - -#include -#include -#include - -#include "qgsglobefeatureoptions.h" -#include "qgsfeatureid.h" -#include "qgsgeometry.h" - -class QgsGlobeFeatureSource : public QObject, public osgEarth::Features::FeatureSource -{ - Q_OBJECT - public: - QgsGlobeFeatureSource( const QgsGlobeFeatureOptions &options = osgEarth::Features::ConfigOptions() ); - - osgEarth::Features::FeatureCursor *createFeatureCursor( const osgEarth::Symbology::Query &query = osgEarth::Symbology::Query() ) override; - - int getFeatureCount() const override; - osgEarth::Features::Feature *getFeature( osgEarth::Features::FeatureID fid ) override; - osgEarth::Features::Geometry::Type getGeometryType() const override; - - QgsVectorLayer *layer() const { return mLayer; } - - const char *className() const override { return "QGISFeatureSource"; } - const char *libraryName() const override { return "QGIS"; } - -#if OSGEARTH_VERSION_GREATER_OR_EQUAL(2, 8, 0) - osgEarth::Status initialize( const osgDB::Options *dbOptions ); -#else - void initialize( const osgDB::Options *dbOptions ); -#endif - - protected: -#if OSGEARTH_VERSION_LESS_THAN(2, 8, 0) - const osgEarth::Features::FeatureProfile *createFeatureProfile() override { return mProfile; } -#endif - const osgEarth::Features::FeatureSchema &getSchema() const override { return mSchema; } - - ~QgsGlobeFeatureSource() {} - - private: - QgsGlobeFeatureOptions mOptions; - QgsVectorLayer *mLayer = nullptr; -#if OSGEARTH_VERSION_LESS_THAN(2, 8, 0) - osgEarth::Features::FeatureProfile *mProfile = nullptr; -#endif - osgEarth::Features::FeatureSchema mSchema; - typedef std::map > FeatureMap_t; - FeatureMap_t mFeatures; - - private slots: - void attributeValueChanged( const QgsFeatureId &featureId, int idx, const QVariant &value ); - void geometryChanged( const QgsFeatureId &featureId, const QgsGeometry &geometry ); -}; - -#endif // QGSGLOBEFEATURESOURCE_H diff --git a/src/plugins/globe/featuresource/qgsglobefeatureutils.h b/src/plugins/globe/featuresource/qgsglobefeatureutils.h deleted file mode 100644 index 943206c2732..00000000000 --- a/src/plugins/globe/featuresource/qgsglobefeatureutils.h +++ /dev/null @@ -1,254 +0,0 @@ -/*************************************************************************** - qgsglobefeatureutils.h - -------------------------------------- - Date : 11.7.2013 - Copyright : (C) 2013 Matthias Kuhn - Email : matthias dot kuhn at gmx dot ch - *************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ - -#ifndef QGSGLOBEFEATUREUTILS_H -#define QGSGLOBEFEATUREUTILS_H - -#include -#include - -#include "qgsfield.h" -#include "qgsgeometry.h" -#include "qgsmultipoint.h" -#include "qgsmultilinestring.h" -#include "qgsmultipolygon.h" -#include "qgspolygon.h" -#include "qgslinestring.h" - -class QgsGlobeFeatureUtils -{ - public: - static inline QgsPoint qgsPointFromPoint( const osg::Vec3d &pt ) - { - return QgsPoint( QgsWkbTypes::PointZ, pt.x(), pt.y(), pt.z() ); - } - - static inline osg::Vec3d pointFromQgsPoint( const QgsPoint &pt ) - { - return osg::Vec3d( pt.x(), pt.y(), pt.z() ); - } - - static inline osgEarth::Features::LineString *lineStringFromQgsLineString( const QgsLineString *lineString ) - { - QgsLineString *linearString = lineString->curveToLine(); - osgEarth::Features::LineString *retLineString = new osgEarth::Features::LineString(); - for ( int iVtx = 0, nVtx = linearString->vertexCount(); iVtx < nVtx; ++iVtx ) - { - retLineString->push_back( pointFromQgsPoint( linearString->vertexAt( QgsVertexId( 0, 0, iVtx ) ) ) ); - } - delete linearString; - return retLineString; - } - - static inline osgEarth::Features::Polygon *polygonFromQgsPolygon( const QgsPolygon *polygon ) - { - QgsPolygon *linearPolygon = polygon->toPolygon(); - // a ring for osg earth is open (first point != last point) - // an outer ring is oriented CCW, an inner ring is oriented CW - osgEarth::Features::Polygon *retPoly = new osgEarth::Features::Polygon(); - - // the outer ring - for ( int iVtx = 0, nVtx = linearPolygon->vertexCount( 0, 0 ); iVtx < nVtx; ++iVtx ) - { - retPoly->push_back( pointFromQgsPoint( linearPolygon->vertexAt( QgsVertexId( 0, 0, iVtx ) ) ) ); - } - retPoly->rewind( osgEarth::Symbology::Ring::ORIENTATION_CCW ); - - for ( int iRing = 1, nRings = linearPolygon->ringCount( 0 ); iRing < nRings; ++iRing ) - { - osgEarth::Features::Ring *innerRing = new osgEarth::Features::Ring(); - for ( int iVtx = 0, nVtx = linearPolygon->vertexCount( 0, iRing ); iVtx < nVtx; ++iVtx ) - { - innerRing->push_back( pointFromQgsPoint( linearPolygon->vertexAt( QgsVertexId( 0, iRing, iVtx ) ) ) ); - } - innerRing->rewind( osgEarth::Symbology::Ring::ORIENTATION_CW ); - retPoly->getHoles().push_back( osg::ref_ptr( innerRing ) ); - } - delete linearPolygon; - return retPoly; - } - - static inline osgEarth::Features::Geometry *geometryFromQgsGeometry( const QgsGeometry &geom ) - { -#if 0 - // test srid - std::cout << "geom = " << &geom << std::endl; - std::cout << "wkb = " << geom.asWkb() << std::endl; - uint32_t srid; - memcpy( &srid, geom.asWkb() + 2 + sizeof( void * ), sizeof( uint32_t ) ); - std::cout << "srid = " << srid << std::endl; -#endif - - switch ( QgsWkbTypes::flatType( geom.constGet()->wkbType() ) ) - { - case QgsWkbTypes::Point: - { - osgEarth::Features::PointSet *pointSet = new osgEarth::Features::PointSet(); - pointSet->push_back( pointFromQgsPoint( *static_cast( geom.constGet() ) ) ); - return pointSet; - } - - case QgsWkbTypes::MultiPoint: - { - osgEarth::Features::PointSet *pointSet = new osgEarth::Features::PointSet(); - const QgsMultiPoint *multiPoint = static_cast( geom.constGet() ); - for ( int i = 0, n = multiPoint->numGeometries(); i < n; ++i ) - { - pointSet->push_back( pointFromQgsPoint( *static_cast( multiPoint->geometryN( i ) ) ) ); - } - return pointSet; - } - - case QgsWkbTypes::LineString: - case QgsWkbTypes::CircularString: - case QgsWkbTypes::CompoundCurve: - { - return lineStringFromQgsLineString( static_cast( geom.constGet() ) ); - } - - case QgsWkbTypes::MultiLineString: - { - osgEarth::Features::MultiGeometry *multiGeometry = new osgEarth::Features::MultiGeometry(); - const QgsMultiLineString *multiLineString = static_cast( geom.constGet() ); - for ( int i = 0, n = multiLineString->numGeometries(); i < n; ++i ) - { - multiGeometry->getComponents().push_back( lineStringFromQgsLineString( static_cast( multiLineString->geometryN( i ) ) ) ); - } - return multiGeometry; - } - - case QgsWkbTypes::Polygon: - case QgsWkbTypes::CurvePolygon: - { - return polygonFromQgsPolygon( static_cast( geom.constGet() ) ); - } - - case QgsWkbTypes::MultiPolygon: - { - osgEarth::Features::MultiGeometry *multiGeometry = new osgEarth::Features::MultiGeometry(); - const QgsMultiPolygon *multiPolygon = static_cast( geom.constGet() ); - for ( int i = 0, n = multiPolygon->numGeometries(); i < n; ++i ) - { - multiGeometry->getComponents().push_back( polygonFromQgsPolygon( static_cast( multiPolygon->geometryN( i ) ) ) ); - } - return multiGeometry; - } - - default: - break; - } - return 0; - } - - static osgEarth::Features::Feature *featureFromQgsFeature( QgsVectorLayer *layer, QgsFeature &feat ) - { - osgEarth::Features::Geometry *nGeom = geometryFromQgsGeometry( feat.geometry() ); - osgEarth::SpatialReference *ref = osgEarth::SpatialReference::create( layer->crs().toWkt().toStdString() ); - osgEarth::Features::Feature *retFeat = new osgEarth::Features::Feature( nGeom, ref, osgEarth::Style(), feat.id() ); - - const QgsFields fields = layer->fields(); - const QgsAttributes &attrs = feat.attributes(); - - for ( int idx = 0, numFlds = fields.size(); idx < numFlds; ++idx ) - { - setFeatureField( retFeat, fields.at( idx ), attrs[idx] ); - } - retFeat->setUserValue( "qgisLayerId", layer->id().toStdString() ); - - return retFeat; - } - - static void setFeatureField( osgEarth::Features::Feature *feature, const QgsField &field, const QVariant &value ) - { - std::string name = field.name().toStdString(); - switch ( field.type() ) - { - case QVariant::Bool: - if ( !value.isNull() ) - feature->set( name, value.toBool() ); - else - feature->setNull( name, osgEarth::Features::ATTRTYPE_BOOL ); - - break; - - case QVariant::Int: - case QVariant::UInt: - case QVariant::LongLong: - case QVariant::ULongLong: - if ( !value.isNull() ) - feature->set( name, value.toInt() ); - else - feature->setNull( name, osgEarth::Features::ATTRTYPE_INT ); - - break; - - case QVariant::Double: - if ( !value.isNull() ) - feature->set( name, value.toDouble() ); - else - feature->setNull( name, osgEarth::Features::ATTRTYPE_DOUBLE ); - - break; - - case QVariant::Char: - case QVariant::String: - default: - if ( !value.isNull() ) - feature->set( name, value.toString().toStdString() ); - else - feature->setNull( name, osgEarth::Features::ATTRTYPE_STRING ); - - break; - } - } - - static osgEarth::Features::FeatureSchema schemaForFields( const QgsFields &fields ) - { - osgEarth::Features::FeatureSchema schema; - - for ( int idx = 0, numFlds = fields.size(); idx < numFlds; ++idx ) - { - const QgsField &fld = fields.at( idx ); - std::string name = fld.name().toStdString(); - - switch ( fld.type() ) - { - case QVariant::Bool: - schema.insert( std::make_pair( name, osgEarth::Features::ATTRTYPE_BOOL ) ); - break; - - case QVariant::Int: - case QVariant::UInt: - case QVariant::LongLong: - case QVariant::ULongLong: - schema.insert( std::make_pair( name, osgEarth::Features::ATTRTYPE_INT ) ); - break; - - case QVariant::Double: - schema.insert( std::make_pair( name, osgEarth::Features::ATTRTYPE_DOUBLE ) ); - break; - - case QVariant::Char: - case QVariant::String: - default: - schema.insert( std::make_pair( name, osgEarth::Features::ATTRTYPE_STRING ) ); - break; - } - } - return schema; - } -}; - -#endif // QGSGLOBEFEATUREUTILS_H diff --git a/src/plugins/globe/globe_plugin.cpp b/src/plugins/globe/globe_plugin.cpp deleted file mode 100644 index cf145fc97e7..00000000000 --- a/src/plugins/globe/globe_plugin.cpp +++ /dev/null @@ -1,1303 +0,0 @@ -/*************************************************************************** - globe_plugin.cpp - - Globe Plugin - a QGIS plugin - -------------------------------------- - Date : 08-Jul-2010 - Copyright : (C) 2010 by Sourcepole - Email : info at sourcepole.ch - *************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ - -#include "globe_plugin.h" -#include "qgsglobeplugindialog.h" -#include "qgsglobefeatureidentify.h" -#include "qgsglobefrustumhighlight.h" -#include "qgsglobetilesource.h" -#include "qgsglobevectorlayerproperties.h" -#include "qgsglobewidget.h" -#include "featuresource/qgsglobefeatureoptions.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include -#include - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#if OSGEARTH_VERSION_GREATER_OR_EQUAL(2, 8, 0) -#include -#endif -#include -#include -#include -#include -#include -#if OSGEARTH_VERSION_LESS_THAN( 2, 6, 0 ) -#include -#else -#include -#endif -#include -#include -#include -#include - -#if OSGEARTH_VERSION_GREATER_OR_EQUAL( 2, 2, 0 ) -#include -#endif -#if OSGEARTH_VERSION_GREATER_OR_EQUAL( 2, 5, 0 ) -#include -#endif -#include -#include -#include - -#define MOVE_OFFSET 0.05 - -static const QString sName = QObject::tr( "Globe" ); -static const QString sDescription = QObject::tr( "Overlay data on a 3D globe" ); -static const QString sCategory = QObject::tr( "Plugins" ); -static const QString sPluginVersion = QObject::tr( "Version 1.0" ); -static const QgisPlugin::PluginType sPluginType = QgisPlugin::UI; -static const QString sIcon = ":/globe/icon.svg"; -static const QString sExperimental = QString( "false" ); - - -class NavigationControlHandler : public osgEarth::Util::Controls::ControlEventHandler -{ - public: - virtual void onMouseDown() { } - virtual void onClick( const osgGA::GUIEventAdapter & /*ea*/, osgGA::GUIActionAdapter & /*aa*/ ) {} -}; - -class ZoomControlHandler : public NavigationControlHandler -{ - public: - ZoomControlHandler( osgEarth::Util::EarthManipulator *manip, double dx, double dy ) - : _manip( manip ), _dx( dx ), _dy( dy ) { } - void onMouseDown() override - { - _manip->zoom( _dx, _dy ); - } - private: - osg::observer_ptr _manip; - double _dx; - double _dy; -}; - -class HomeControlHandler : public NavigationControlHandler -{ - public: - HomeControlHandler( osgEarth::Util::EarthManipulator *manip ) : _manip( manip ) { } - void onClick( const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &aa ) override - { - _manip->home( ea, aa ); - } - private: - osg::observer_ptr _manip; -}; - -class SyncExtentControlHandler : public NavigationControlHandler -{ - public: - SyncExtentControlHandler( GlobePlugin *globe ) : mGlobe( globe ) { } - void onClick( const osgGA::GUIEventAdapter & /*ea*/, osgGA::GUIActionAdapter & /*aa*/ ) override - { - mGlobe->syncExtent(); - } - private: - GlobePlugin *mGlobe = nullptr; -}; - -class PanControlHandler : public NavigationControlHandler -{ - public: - PanControlHandler( osgEarth::Util::EarthManipulator *manip, double dx, double dy ) : _manip( manip ), _dx( dx ), _dy( dy ) { } - void onMouseDown() override - { - _manip->pan( _dx, _dy ); - } - private: - osg::observer_ptr _manip; - double _dx; - double _dy; -}; - -class RotateControlHandler : public NavigationControlHandler -{ - public: - RotateControlHandler( osgEarth::Util::EarthManipulator *manip, double dx, double dy ) : _manip( manip ), _dx( dx ), _dy( dy ) { } - void onMouseDown() override - { - if ( 0 == _dx && 0 == _dy ) - _manip->setRotation( osg::Quat() ); - else - _manip->rotate( _dx, _dy ); - } - private: - osg::observer_ptr _manip; - double _dx; - double _dy; -}; - -// An event handler that will print out the coordinates at the clicked point -class QueryCoordinatesHandler : public osgGA::GUIEventHandler -{ - public: - QueryCoordinatesHandler( GlobePlugin *globe ) : mGlobe( globe ) { } - - bool handle( const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &aa ) - { - if ( ea.getEventType() == osgGA::GUIEventAdapter::MOVE ) - { - osgViewer::View *view = static_cast( aa.asView() ); - osgUtil::LineSegmentIntersector::Intersections hits; - if ( view->computeIntersections( ea.getX(), ea.getY(), hits ) ) - { - osgEarth::GeoPoint isectPoint; - isectPoint.fromWorld( mGlobe->mapNode()->getMapSRS()->getGeodeticSRS(), hits.begin()->getWorldIntersectPoint() ); - mGlobe->showCurrentCoordinates( isectPoint ); - } - } - return false; - } - - private: - GlobePlugin *mGlobe = nullptr; -}; - -class KeyboardControlHandler : public osgGA::GUIEventHandler -{ - public: - KeyboardControlHandler( osgEarth::Util::EarthManipulator *manip ) : _manip( manip ) { } - - bool handle( const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &aa ) override; - - private: - osg::observer_ptr _manip; -}; - -class NavigationControl : public osgEarth::Util::Controls::ImageControl -{ - public: - NavigationControl( osg::Image *image = 0 ) : ImageControl( image ), mMousePressed( false ) {} - - protected: - bool handle( const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &aa, osgEarth::Util::Controls::ControlContext &cx ) override; - - private: - bool mMousePressed; -}; - - -GlobePlugin::GlobePlugin( QgisInterface *qgisInterface ) - : QgisPlugin( sName, sDescription, sCategory, sPluginVersion, sPluginType ) - , mQGisIface( qgisInterface ) - , mViewerWidget( 0 ) - , mDockWidget( 0 ) - , mSettingsDialog( 0 ) - , mSelectedLat( 0. ) - , mSelectedLon( 0. ) - , mSelectedElevation( 0. ) - , mLayerPropertiesFactory( 0 ) -{ -#ifdef Q_OS_MACX - // update path to osg plugins on Mac OS X - if ( !getenv( "OSG_LIBRARY_PATH" ) ) - { - // OSG_PLUGINS_PATH value set by CMake option - QString ogsPlugins( OSG_PLUGINS_PATH ); - QString bundlePlugins = QgsApplication::pluginPath() + "/../osgPlugins"; - if ( QFile::exists( bundlePlugins ) ) - { - // add internal osg plugin path if bundled osg - ogsPlugins = bundlePlugins; - } - if ( QFile::exists( ogsPlugins ) ) - { - osgDB::Registry::instance()->setLibraryFilePathList( QDir::cleanPath( ogsPlugins ).toStdString() ); - } - } -#endif -} - -GlobePlugin::~GlobePlugin() {} - -void GlobePlugin::initGui() -{ - - mSettingsDialog = new QgsGlobePluginDialog( mQGisIface->mainWindow(), QgsGuiUtils::ModalDialogFlags ); - connect( mSettingsDialog, SIGNAL( settingsApplied() ), this, SLOT( applySettings() ) ); - - mActionToggleGlobe = new QAction( QIcon( ":/globe/globe.png" ), tr( "Launch Globe" ), this ); - mActionToggleGlobe->setCheckable( true ); - mQGisIface->addToolBarIcon( mActionToggleGlobe ); - mQGisIface->addPluginToMenu( tr( "&Globe" ), mActionToggleGlobe ); - - mLayerPropertiesFactory = new QgsGlobeLayerPropertiesFactory( this ); - mQGisIface->registerMapLayerConfigWidgetFactory( mLayerPropertiesFactory ); - - connect( mActionToggleGlobe, SIGNAL( triggered( bool ) ), this, SLOT( setGlobeEnabled( bool ) ) ); - connect( mLayerPropertiesFactory, SIGNAL( layerSettingsChanged( QgsMapLayer * ) ), this, SLOT( layerChanged( QgsMapLayer * ) ) ); - connect( this, SIGNAL( xyCoordinates( const QgsPointXY & ) ), mQGisIface->mapCanvas(), SIGNAL( xyCoordinates( const QgsPointXY & ) ) ); - connect( mQGisIface->mainWindow(), SIGNAL( projectRead() ), this, SLOT( projectRead() ) ); -} - -void GlobePlugin::run() -{ - if ( mViewerWidget != 0 ) - { - return; - } -#ifdef GLOBE_SHOW_TILE_STATS - QgsGlobeTileStatistics *tileStats = new QgsGlobeTileStatistics(); - connect( tileStats, SIGNAL( changed( int, int ) ), this, SLOT( updateTileStats( int, int ) ) ); -#endif - QgsSettings settings; - -// osgEarth::setNotifyLevel( osg::DEBUG_INFO ); - - mOsgViewer = new osgViewer::Viewer(); - mOsgViewer->setThreadingModel( osgViewer::Viewer::SingleThreaded ); - mOsgViewer->setRunFrameScheme( osgViewer::Viewer::ON_DEMAND ); - // Set camera manipulator with default home position - osgEarth::Util::EarthManipulator *manip = new osgEarth::Util::EarthManipulator(); - mOsgViewer->setCameraManipulator( manip ); - osgEarth::Util::Viewpoint viewpoint; - viewpoint.focalPoint() = osgEarth::GeoPoint( osgEarth::SpatialReference::get( "wgs84" ), 0., 0., 0. ); - viewpoint.heading() = 0.; - viewpoint.pitch() = -90.; - viewpoint.range() = 2e7; - - manip->setHomeViewpoint( viewpoint, 1. ); - manip->home( 0 ); - - setupProxy(); - - // Tile stats label - mStatsLabel = new osgEarth::Util::Controls::LabelControl( "", 10 ); - mStatsLabel->setPosition( 0, 0 ); - osgEarth::Util::Controls::ControlCanvas::get( mOsgViewer )->addControl( mStatsLabel.get() ); - - mDockWidget = new QgsGlobeWidget( mQGisIface, mQGisIface->mainWindow() ); - connect( mDockWidget, SIGNAL( destroyed( QObject * ) ), this, SLOT( reset() ) ); - connect( mDockWidget, SIGNAL( layersChanged() ), this, SLOT( updateLayers() ) ); - connect( mDockWidget, SIGNAL( showSettings() ), this, SLOT( showSettings() ) ); - connect( mDockWidget, SIGNAL( refresh() ), this, SLOT( rebuildQGISLayer() ) ); - connect( mDockWidget, SIGNAL( syncExtent() ), this, SLOT( syncExtent() ) ); - mQGisIface->addDockWidget( Qt::RightDockWidgetArea, mDockWidget ); - - if ( getenv( "GLOBE_MAPXML" ) ) - { - char *mapxml = getenv( "GLOBE_MAPXML" ); - QgsDebugMsg( mapxml ); - osg::Node *node = osgDB::readNodeFile( mapxml ); - if ( !node ) - { - QgsDebugMsg( "Failed to load earth file " ); - return; - } - mMapNode = osgEarth::MapNode::findMapNode( node ); - mRootNode = new osg::Group(); - mRootNode->addChild( node ); - } - else - { - QString cacheDirectory = settings.value( "cache/directory" ).toString(); - if ( cacheDirectory.isEmpty() ) - cacheDirectory = QgsApplication::qgisSettingsDirPath() + "cache"; - osgEarth::Drivers::FileSystemCacheOptions cacheOptions; - cacheOptions.rootPath() = cacheDirectory.toStdString(); - - osgEarth::MapOptions mapOptions; - mapOptions.cache() = cacheOptions; - osgEarth::Map *map = new osgEarth::Map( /*mapOptions*/ ); - - // The MapNode will render the Map object in the scene graph. - osgEarth::MapNodeOptions mapNodeOptions; - mMapNode = new osgEarth::MapNode( map, mapNodeOptions ); - - mRootNode = new osg::Group(); - mRootNode->addChild( mMapNode ); - - osgEarth::Registry::instance()->unRefImageDataAfterApply() = false; - - // Add draped layer - osgEarth::TileSourceOptions opts; - opts.L2CacheSize() = 0; -#if OSGEARTH_VERSION_LESS_THAN( 2, 9, 0 ) - opts.tileSize() = 128; -#endif - mTileSource = new QgsGlobeTileSource( mQGisIface->mapCanvas(), opts ); -#if OSGEARTH_VERSION_GREATER_OR_EQUAL( 2, 9, 0 ) - mTileSource->open(); -#endif - - osgEarth::ImageLayerOptions options( "QGIS" ); - options.driver()->L2CacheSize() = 0; -#if OSGEARTH_VERSION_GREATER_OR_EQUAL( 2, 9, 0 ) - options.tileSize() = 128; -#endif - options.cachePolicy() = osgEarth::CachePolicy::USAGE_NO_CACHE; - mQgisMapLayer = new osgEarth::ImageLayer( options, mTileSource ); - map->addImageLayer( mQgisMapLayer ); - - - // Create the frustum highlight callback - mFrustumHighlightCallback = new QgsGlobeFrustumHighlightCallback( - mOsgViewer, mMapNode->getTerrain(), mQGisIface->mapCanvas(), QColor( 0, 0, 0, 50 ) ); - } - - mRootNode->addChild( osgEarth::Util::Controls::ControlCanvas::get( mOsgViewer ) ); - - mOsgViewer->setSceneData( mRootNode ); - - mOsgViewer->addEventHandler( new QueryCoordinatesHandler( this ) ); - mOsgViewer->addEventHandler( new KeyboardControlHandler( manip ) ); - mOsgViewer->addEventHandler( new osgViewer::StatsHandler() ); - mOsgViewer->addEventHandler( new osgViewer::WindowSizeHandler() ); - mOsgViewer->addEventHandler( new osgGA::StateSetManipulator( mOsgViewer->getCamera()->getOrCreateStateSet() ) ); - mOsgViewer->getCamera()->addCullCallback( new osgEarth::Util::AutoClipPlaneCullCallback( mMapNode ) ); - - // osgEarth benefits from pre-compilation of GL objects in the pager. In newer versions of - // OSG, this activates OSG's IncrementalCompileOpeartion in order to avoid frame breaks. - mOsgViewer->getDatabasePager()->setDoPreCompile( true ); - - mViewerWidget = new osgEarth::QtGui::ViewerWidget( mOsgViewer ); - QGLFormat glf = QGLFormat::defaultFormat(); -#if OSGEARTH_VERSION_GREATER_OR_EQUAL( 2, 9, 0 ) - glf.setVersion( 3, 3 ); - glf.setProfile( QGLFormat::CoreProfile ); -#endif - if ( settings.value( "/Plugin-Globe/anti-aliasing", true ).toBool() && - settings.value( "/Plugin-Globe/anti-aliasing-level", "" ).toInt() > 0 ) - { - glf.setSampleBuffers( true ); - glf.setSamples( settings.value( "/Plugin-Globe/anti-aliasing-level", "" ).toInt() ); - } - mViewerWidget->setFormat( glf ); - - mDockWidget->setWidget( mViewerWidget ); - mViewerWidget->setParent( mDockWidget ); - - mFeatureQueryToolIdentifyCb = new QgsGlobeFeatureIdentifyCallback( mQGisIface->mapCanvas() ); - mFeatureQueryTool = new osgEarth::Util::FeatureQueryTool(); - mFeatureQueryTool->addChild( mMapNode ); - mFeatureQueryTool->setDefaultCallback( mFeatureQueryToolIdentifyCb.get() ); - - setupControls(); - // FIXME: Workaround for OpenGL errors, in some manner related to the SkyNode, - // which appear when launching the globe a second time: - // Delay applySettings one event loop iteration, i.e. one update call of the GL canvas - QTimer *timer = new QTimer(); - QTimer *timer2 = new QTimer(); - connect( timer, SIGNAL( timeout() ), timer, SLOT( deleteLater() ) ); - connect( timer2, SIGNAL( timeout() ), timer2, SLOT( deleteLater() ) ); - connect( timer, SIGNAL( timeout() ), this, SLOT( applySettings() ) ); - connect( timer2, SIGNAL( timeout() ), this, SLOT( updateLayers() ) ); - timer->start( 0 ); - timer2->start( 100 ); -} - -void GlobePlugin::showSettings() -{ - mSettingsDialog->exec(); -} - -void GlobePlugin::projectRead() -{ - setGlobeEnabled( false ); // Hide globe when new projects loaded, on some systems it is very slow loading a new project with globe enabled - mSettingsDialog->readProjectSettings(); - applyProjectSettings(); -} - -void GlobePlugin::applySettings() -{ - if ( !mOsgViewer ) - { - return; - } - - osgEarth::Util::EarthManipulator *manip = dynamic_cast( mOsgViewer->getCameraManipulator() ); - osgEarth::Util::EarthManipulator::Settings *settings = manip->getSettings(); - settings->setScrollSensitivity( mSettingsDialog->getScrollSensitivity() ); - if ( !mSettingsDialog->getInvertScrollWheel() ) - { - settings->bindScroll( osgEarth::Util::EarthManipulator::ACTION_ZOOM_IN, osgGA::GUIEventAdapter::SCROLL_UP ); - settings->bindScroll( osgEarth::Util::EarthManipulator::ACTION_ZOOM_OUT, osgGA::GUIEventAdapter::SCROLL_DOWN ); - } - else - { - settings->bindScroll( osgEarth::Util::EarthManipulator::ACTION_ZOOM_OUT, osgGA::GUIEventAdapter::SCROLL_UP ); - settings->bindScroll( osgEarth::Util::EarthManipulator::ACTION_ZOOM_IN, osgGA::GUIEventAdapter::SCROLL_DOWN ); - } - - // Advanced settings - enableFrustumHighlight( mSettingsDialog->getFrustumHighlighting() ); - enableFeatureIdentification( mSettingsDialog->getFeatureIdenification() ); - - applyProjectSettings(); -} - -void GlobePlugin::applyProjectSettings() -{ - if ( mOsgViewer && !getenv( "GLOBE_MAPXML" ) ) - { - // Imagery settings - QList imageryDataSources = mSettingsDialog->getImageryDataSources(); - if ( imageryDataSources != mImagerySources ) - { - mImagerySources = imageryDataSources; - QgsDebugMsg( "imageryLayersChanged: Globe Running, executing" ); - osg::ref_ptr map = mMapNode->getMap(); - - // Remove image layers - osgEarth::ImageLayerVector list; -#if OSGEARTH_VERSION_GREATER_OR_EQUAL( 2, 9, 0 ) - map->getLayers( list ); -#else - map->getImageLayers( list ); -#endif - for ( osgEarth::ImageLayerVector::iterator i = list.begin(); i != list.end(); ++i ) - { - if ( *i != mQgisMapLayer ) - map->removeImageLayer( *i ); - } - if ( !list.empty() ) - { - mOsgViewer->getDatabasePager()->clear(); - } - - // Add image layers - for ( const QgsGlobePluginDialog::LayerDataSource &datasource : mImagerySources ) - { - osgEarth::ImageLayer *layer = 0; - if ( "Raster" == datasource.type ) - { - osgEarth::Drivers::GDALOptions options; - options.url() = datasource.uri.toStdString(); - layer = new osgEarth::ImageLayer( datasource.uri.toStdString(), options ); - } - else if ( "TMS" == datasource.type ) - { - osgEarth::Drivers::TMSOptions options; - options.url() = datasource.uri.toStdString(); - layer = new osgEarth::ImageLayer( datasource.uri.toStdString(), options ); - } - else if ( "WMS" == datasource.type ) - { - osgEarth::Drivers::WMSOptions options; - options.url() = datasource.uri.toStdString(); - layer = new osgEarth::ImageLayer( datasource.uri.toStdString(), options ); - } - map->insertImageLayer( layer, 0 ); - } - } - - // Elevation settings - QList elevationDataSources = mSettingsDialog->getElevationDataSources(); - if ( elevationDataSources != mElevationSources ) - { - mElevationSources = elevationDataSources; - QgsDebugMsg( "elevationLayersChanged: Globe Running, executing" ); - osg::ref_ptr map = mMapNode->getMap(); - - // Remove elevation layers - osgEarth::ElevationLayerVector list; -#if OSGEARTH_VERSION_GREATER_OR_EQUAL( 2, 9, 0 ) - map->getLayers( list ); -#else - map->getElevationLayers( list ); -#endif - for ( osgEarth::ElevationLayerVector::iterator i = list.begin(); i != list.end(); ++i ) - { - map->removeElevationLayer( *i ); - } - if ( !list.empty() ) - { - mOsgViewer->getDatabasePager()->clear(); - } - - // Add elevation layers - for ( const QgsGlobePluginDialog::LayerDataSource &datasource : mElevationSources ) - { - osgEarth::ElevationLayer *layer = 0; - if ( "Raster" == datasource.type ) - { - osgEarth::Drivers::GDALOptions options; - options.interpolation() = osgEarth::Drivers::INTERP_NEAREST; - options.url() = datasource.uri.toStdString(); - layer = new osgEarth::ElevationLayer( datasource.uri.toStdString(), options ); - } - else if ( "TMS" == datasource.type ) - { - osgEarth::Drivers::TMSOptions options; - options.url() = datasource.uri.toStdString(); - layer = new osgEarth::ElevationLayer( datasource.uri.toStdString(), options ); - } - map->addElevationLayer( layer ); - } - } -#if OSGEARTH_VERSION_GREATER_OR_EQUAL( 2, 5, 0 ) - double verticalScaleValue = mSettingsDialog->getVerticalScale(); - if ( !mVerticalScale.get() || mVerticalScale->getScale() != verticalScaleValue ) - { - mMapNode->getTerrainEngine()->removeEffect( mVerticalScale ); - mVerticalScale = new osgEarth::Util::VerticalScale(); - mVerticalScale->setScale( verticalScaleValue ); - mMapNode->getTerrainEngine()->addEffect( mVerticalScale ); - } -#endif - - // Sky settings - if ( mSettingsDialog->getSkyEnabled() ) - { - // Create if not yet done - if ( !mSkyNode.get() ) - { - mSkyNode = osgEarth::Util::SkyNode::create( mMapNode ); - mSkyNode->attach( mOsgViewer ); - mRootNode->addChild( mSkyNode ); - // Insert sky between root and map - mSkyNode->addChild( mMapNode ); - mRootNode->removeChild( mMapNode ); - } - - mSkyNode->setLighting( mSettingsDialog->getSkyAutoAmbience() ? osg::StateAttribute::ON : osg::StateAttribute::OFF ); - double ambient = mSettingsDialog->getSkyMinAmbient(); - mSkyNode->getSunLight()->setAmbient( osg::Vec4( ambient, ambient, ambient, 1 ) ); - - QDateTime dateTime = mSettingsDialog->getSkyDateTime(); - mSkyNode->setDateTime( osgEarth::DateTime( - dateTime.date().year(), - dateTime.date().month(), - dateTime.date().day(), - dateTime.time().hour() + dateTime.time().minute() / 60.0 ) ); - } - else if ( mSkyNode != 0 ) - { - mRootNode->addChild( mMapNode ); - mSkyNode->removeChild( mMapNode ); - mRootNode->removeChild( mSkyNode ); - mSkyNode = 0; - } - } -} - -QgsRectangle GlobePlugin::getQGISLayerExtent() const -{ - QList extents = mLayerExtents.values(); - QgsRectangle fullExtent = extents.isEmpty() ? QgsRectangle() : extents.front(); - for ( int i = 1, n = extents.size(); i < n; ++i ) - { - if ( !extents[i].isNull() ) - fullExtent.combineExtentWith( extents[i] ); - } - return fullExtent; -} - -void GlobePlugin::showCurrentCoordinates( const osgEarth::GeoPoint &geoPoint ) -{ - osg::Vec3d pos = geoPoint.vec3d(); - emit xyCoordinates( QgsCoordinateTransform( QgsCoordinateReferenceSystem( geoEpsgCrsAuthId() ), mQGisIface->mapCanvas()->mapSettings().destinationCrs(), QgsProject::instance()->transformContext() ).transform( QgsPointXY( pos.x(), pos.y() ) ) ); -} - -void GlobePlugin::setSelectedCoordinates( const osg::Vec3d &coords ) -{ - mSelectedLon = coords.x(); - mSelectedLat = coords.y(); - mSelectedElevation = coords.z(); - emit newCoordinatesSelected( QgsPointXY( mSelectedLon, mSelectedLat ) ); -} - -osg::Vec3d GlobePlugin::getSelectedCoordinates() -{ - return osg::Vec3d( mSelectedLon, mSelectedLat, mSelectedElevation ); -} - -void GlobePlugin::syncExtent() -{ - const QgsMapSettings &mapSettings = mQGisIface->mapCanvas()->mapSettings(); - QgsRectangle extent = mQGisIface->mapCanvas()->extent(); - - long epsgGlobe = 4326; - QgsCoordinateReferenceSystem globeCrs; - globeCrs.createFromOgcWmsCrs( QString( "EPSG:%1" ).arg( epsgGlobe ) ); - - // transform extent to WGS84 - if ( mapSettings.destinationCrs().authid().compare( QString( "EPSG:%1" ).arg( epsgGlobe ), Qt::CaseInsensitive ) != 0 ) - { - QgsCoordinateReferenceSystem srcCRS( mapSettings.destinationCrs() ); - extent = QgsCoordinateTransform( srcCRS, globeCrs, QgsProject::instance()->transformContext() ).transformBoundingBox( extent ); - } - - QgsDistanceArea dist; - dist.setSourceCrs( globeCrs, QgsProject::instance()->transformContext() ); - dist.setEllipsoid( "WGS84" ); - - QgsPointXY ll = QgsPointXY( extent.xMinimum(), extent.yMinimum() ); - QgsPointXY ul = QgsPointXY( extent.xMinimum(), extent.yMaximum() ); - double height = dist.measureLine( ll, ul ); -// double height = dist.computeDistanceBearing( ll, ul ); - - double camViewAngle = 30; - double camDistance = height / tan( camViewAngle * osg::PI / 180 ); //c = b*cotan(B(rad)) -#if OSGEARTH_VERSION_LESS_THAN(2, 7, 0) - osgEarth::Util::Viewpoint viewpoint( osg::Vec3d( extent.center().x(), extent.center().y(), 0.0 ), 0.0, -90.0, camDistance ); -#else - osgEarth::Util::Viewpoint viewpoint; - viewpoint.focalPoint() = osgEarth::GeoPoint( osgEarth::SpatialReference::get( "wgs84" ), extent.center().x(), extent.center().y(), 0.0 ); - viewpoint.heading() = 0.0; - viewpoint.pitch() = -90.0; - viewpoint.range() = camDistance; -#endif - - OE_NOTICE << "map extent: " << height << " camera distance: " << camDistance << std::endl; - - osgEarth::Util::EarthManipulator *manip = dynamic_cast( mOsgViewer->getCameraManipulator() ); - manip->setRotation( osg::Quat() ); - manip->setViewpoint( viewpoint, 4.0 ); -} - -void GlobePlugin::addControl( osgEarth::Util::Controls::Control *control, int x, int y, int w, int h, osgEarth::Util::Controls::ControlEventHandler *handler ) -{ - control->setPosition( x, y ); - control->setHeight( h ); - control->setWidth( w ); - control->addEventHandler( handler ); - osgEarth::Util::Controls::ControlCanvas::get( mOsgViewer )->addControl( control ); -} - -void GlobePlugin::addImageControl( const std::string &imgPath, int x, int y, osgEarth::Util::Controls::ControlEventHandler *handler ) -{ - osg::Image *image = osgDB::readImageFile( imgPath ); - osgEarth::Util::Controls::ImageControl *control = new NavigationControl( image ); - control->setPosition( x, y ); - control->setWidth( image->s() ); - control->setHeight( image->t() ); - if ( handler ) - control->addEventHandler( handler ); - osgEarth::Util::Controls::ControlCanvas::get( mOsgViewer )->addControl( control ); -} - -void GlobePlugin::setupControls() -{ - std::string imgDir = QDir::cleanPath( QgsApplication::pkgDataPath() + "/globe/gui" ).toStdString(); - if ( QgsApplication::isRunningFromBuildDir() ) - { - imgDir = QDir::cleanPath( QgsApplication::buildSourcePath() + "/src/plugins/globe/images/gui" ).toStdString(); - } - osgEarth::Util::EarthManipulator *manip = dynamic_cast( mOsgViewer->getCameraManipulator() ); - - // Rotate and tiltcontrols - int imgLeft = 16; - int imgTop = 20; - addImageControl( imgDir + "/YawPitchWheel.png", 16, 20 ); - addControl( new NavigationControl, imgLeft, imgTop + 18, 20, 22, new RotateControlHandler( manip, -MOVE_OFFSET, 0 ) ); - addControl( new NavigationControl, imgLeft + 36, imgTop + 18, 20, 22, new RotateControlHandler( manip, MOVE_OFFSET, 0 ) ); - addControl( new NavigationControl, imgLeft + 20, imgTop + 18, 16, 22, new RotateControlHandler( manip, 0, 0 ) ); - addControl( new NavigationControl, imgLeft + 20, imgTop, 24, 19, new RotateControlHandler( manip, 0, -MOVE_OFFSET ) ); - addControl( new NavigationControl, imgLeft + 16, imgTop + 36, 24, 19, new RotateControlHandler( manip, 0, MOVE_OFFSET ) ); - - // Move controls - imgTop = 80; - addImageControl( imgDir + "/MoveWheel.png", imgLeft, imgTop ); - addControl( new NavigationControl, imgLeft, imgTop + 18, 20, 22, new PanControlHandler( manip, MOVE_OFFSET, 0 ) ); - addControl( new NavigationControl, imgLeft + 36, imgTop + 18, 20, 22, new PanControlHandler( manip, -MOVE_OFFSET, 0 ) ); - addControl( new NavigationControl, imgLeft + 20, imgTop, 24, 19, new PanControlHandler( manip, 0, -MOVE_OFFSET ) ); - addControl( new NavigationControl, imgLeft + 16, imgTop + 36, 24, 19, new PanControlHandler( manip, 0, MOVE_OFFSET ) ); - addControl( new NavigationControl, imgLeft + 20, imgTop + 18, 16, 22, new HomeControlHandler( manip ) ); - - // Zoom controls - imgLeft = 28; - imgTop = imgTop + 62; - addImageControl( imgDir + "/button-background.png", imgLeft, imgTop ); - addImageControl( imgDir + "/zoom-in.png", imgLeft + 3, imgTop + 2, new ZoomControlHandler( manip, 0, -MOVE_OFFSET ) ); - addImageControl( imgDir + "/zoom-out.png", imgLeft + 3, imgTop + 29, new ZoomControlHandler( manip, 0, MOVE_OFFSET ) ); -} - -void GlobePlugin::setupProxy() -{ - QgsSettings settings; - settings.beginGroup( "proxy" ); - if ( settings.value( "/proxyEnabled" ).toBool() ) - { - osgEarth::ProxySettings proxySettings( settings.value( "/proxyHost" ).toString().toStdString(), - settings.value( "/proxyPort" ).toInt() ); - if ( !settings.value( "/proxyUser" ).toString().isEmpty() ) - { - QString auth = settings.value( "/proxyUser" ).toString() + ":" + settings.value( "/proxyPassword" ).toString(); - qputenv( "OSGEARTH_CURL_PROXYAUTH", auth.toLocal8Bit() ); - } - //TODO: settings.value("/proxyType") - //TODO: URL exclusions - osgEarth::HTTPClient::setProxySettings( proxySettings ); - } - settings.endGroup(); -} - -void GlobePlugin::refreshQGISMapLayer( const QgsRectangle &dirtyRect ) -{ - if ( mTileSource ) - { - mOsgViewer->getDatabasePager()->clear(); - mTileSource->refresh( dirtyRect ); - mOsgViewer->requestRedraw(); - } -} - -void GlobePlugin::updateTileStats( int queued, int tot ) -{ - if ( mStatsLabel ) - mStatsLabel->setText( QString( "Queued tiles: %1\nTot tiles: %2" ).arg( queued ).arg( tot ).toStdString() ); -} - -void GlobePlugin::addModelLayer( QgsVectorLayer *vLayer, QgsGlobeVectorLayerConfig *layerConfig ) -{ - QgsGlobeFeatureOptions featureOpt; - featureOpt.setLayer( vLayer ); - osgEarth::Style style; - - QgsRenderContext ctx; - if ( !vLayer->renderer()->symbols( ctx ).isEmpty() ) - { - for ( QgsSymbol *sym : vLayer->renderer()->symbols( ctx ) ) - { - if ( sym->type() == QgsSymbol::Line ) - { - osgEarth::LineSymbol *ls = style.getOrCreateSymbol(); - QColor color = sym->color(); - ls->stroke()->color() = osg::Vec4f( color.redF(), color.greenF(), color.blueF(), color.alphaF() * vLayer->opacity() ); - ls->stroke()->width() = 1.0f; - } - else if ( sym->type() == QgsSymbol::Fill ) - { - // TODO access border color, etc. - osgEarth::PolygonSymbol *poly = style.getOrCreateSymbol(); - QColor color = sym->color(); - poly->fill()->color() = osg::Vec4f( color.redF(), color.greenF(), color.blueF(), color.alphaF() * vLayer->opacity() ); - style.addSymbol( poly ); - } - } - } - else - { - osgEarth::PolygonSymbol *poly = style.getOrCreateSymbol(); - poly->fill()->color() = osg::Vec4f( 1.f, 0, 0, vLayer->opacity() ); - style.addSymbol( poly ); - osgEarth::LineSymbol *ls = style.getOrCreateSymbol(); - ls->stroke()->color() = osg::Vec4f( 1.f, 0, 0, vLayer->opacity() ); - ls->stroke()->width() = 1.0f; - } - - osgEarth::AltitudeSymbol *altitudeSymbol = style.getOrCreateSymbol(); - altitudeSymbol->clamping() = layerConfig->altitudeClamping; - altitudeSymbol->technique() = layerConfig->altitudeTechnique; - altitudeSymbol->binding() = layerConfig->altitudeBinding; - altitudeSymbol->verticalOffset() = layerConfig->verticalOffset; - altitudeSymbol->verticalScale() = layerConfig->verticalScale; - altitudeSymbol->clampingResolution() = layerConfig->clampingResolution; - style.addSymbol( altitudeSymbol ); - - if ( layerConfig->extrusionEnabled ) - { - osgEarth::ExtrusionSymbol *extrusionSymbol = style.getOrCreateSymbol(); - bool extrusionHeightOk = false; - float extrusionHeight = layerConfig->extrusionHeight.toFloat( &extrusionHeightOk ); - if ( extrusionHeightOk ) - { - extrusionSymbol->height() = extrusionHeight; - } - else - { - extrusionSymbol->heightExpression() = layerConfig->extrusionHeight.toStdString(); - } - - extrusionSymbol->flatten() = layerConfig->extrusionFlatten; - extrusionSymbol->wallGradientPercentage() = layerConfig->extrusionWallGradient; - style.addSymbol( extrusionSymbol ); - } - - if ( layerConfig->labelingEnabled ) - { - osgEarth::TextSymbol *textSymbol = style.getOrCreateSymbol(); - textSymbol->declutter() = layerConfig->labelingDeclutter; - QgsPalLayerSettings lyr = vLayer->labeling()->settings(); - textSymbol->content() = QString( "[%1]" ).arg( lyr.fieldName ).toStdString(); - textSymbol->font() = lyr.format().font().family().toStdString(); - textSymbol->size() = lyr.format().font().pointSize(); - textSymbol->alignment() = osgEarth::TextSymbol::ALIGN_CENTER_TOP; - osgEarth::Stroke stroke; - QColor bufferColor = lyr.format().buffer().color(); - stroke.color() = osgEarth::Symbology::Color( bufferColor.redF(), bufferColor.greenF(), bufferColor.blueF(), bufferColor.alphaF() ); - textSymbol->halo() = stroke; - textSymbol->haloOffset() = lyr.format().buffer().size(); - } - - osgEarth::RenderSymbol *renderSymbol = style.getOrCreateSymbol(); - renderSymbol->lighting() = layerConfig->lightingEnabled; - renderSymbol->backfaceCulling() = false; - style.addSymbol( renderSymbol ); - - osgEarth::Drivers::FeatureGeomModelOptions geomOpt; - geomOpt.featureOptions() = featureOpt; - geomOpt.styles() = new osgEarth::StyleSheet(); - geomOpt.styles()->addStyle( style ); - - geomOpt.featureIndexing() = osgEarth::Features::FeatureSourceIndexOptions(); - -#if 0 - FeatureDisplayLayout layout; - layout.tileSizeFactor() = 45.0; - layout.addLevel( FeatureLevel( 0.0f, 200000.0f ) ); - geomOpt.layout() = layout; -#endif - - osgEarth::ModelLayerOptions modelOptions( vLayer->id().toStdString(), geomOpt ); - - osgEarth::ModelLayer *nLayer = new osgEarth::ModelLayer( modelOptions ); - - mMapNode->getMap()->addModelLayer( nLayer ); -} - -void GlobePlugin::updateLayers() -{ - if ( mOsgViewer ) - { - // Get previous full extent - QgsRectangle dirtyExtent = getQGISLayerExtent(); - mLayerExtents.clear(); - - QList drapedLayers; - QStringList selectedLayerIds = mDockWidget->getSelectedLayerIds(); - - // Disconnect any previous repaintRequested signals - for ( QgsMapLayer *mapLayer : mTileSource->layers() ) - { - if ( mapLayer ) - disconnect( mapLayer, SIGNAL( repaintRequested() ), this, SLOT( layerChanged() ) ); - if ( qobject_cast( mapLayer ) ) - disconnect( static_cast( mapLayer ), SIGNAL( layerTransparencyChanged( int ) ), this, SLOT( layerChanged() ) ); - } - osgEarth::ModelLayerVector modelLayers; -#if OSGEARTH_VERSION_GREATER_OR_EQUAL( 2, 9, 0 ) - mMapNode->getMap()->getLayers( modelLayers ); -#else - mMapNode->getMap()->getModelLayers( modelLayers ); -#endif - for ( const osg::ref_ptr &modelLayer : modelLayers ) - { - QgsMapLayer *mapLayer = QgsProject::instance()->mapLayer( QString::fromStdString( modelLayer->getName() ) ); - if ( mapLayer ) - disconnect( mapLayer, SIGNAL( repaintRequested() ), this, SLOT( layerChanged() ) ); - if ( qobject_cast( mapLayer ) ) - disconnect( static_cast( mapLayer ), SIGNAL( layerTransparencyChanged( int ) ), this, SLOT( layerChanged() ) ); - if ( !selectedLayerIds.contains( QString::fromStdString( modelLayer->getName() ) ) ) - mMapNode->getMap()->removeModelLayer( modelLayer ); - } - - for ( const QString &layerId : selectedLayerIds ) - { - QgsMapLayer *mapLayer = QgsProject::instance()->mapLayer( layerId ); - connect( mapLayer, SIGNAL( repaintRequested() ), this, SLOT( layerChanged() ) ); - - QgsGlobeVectorLayerConfig *layerConfig = 0; - if ( qobject_cast( mapLayer ) ) - { - layerConfig = QgsGlobeVectorLayerConfig::getConfig( static_cast( mapLayer ) ); - connect( static_cast( mapLayer ), SIGNAL( layerTransparencyChanged( int ) ), this, SLOT( layerChanged() ) ); - } - - if ( layerConfig && ( layerConfig->renderingMode == QgsGlobeVectorLayerConfig::RenderingModeModelSimple || layerConfig->renderingMode == QgsGlobeVectorLayerConfig::RenderingModeModelAdvanced ) ) - { -#if OSGEARTH_VERSION_GREATER_OR_EQUAL( 2, 9, 0 ) - if ( !mMapNode->getMap()->getLayerByName( mapLayer->id().toStdString() ) ) -#else - if ( !mMapNode->getMap()->getModelLayerByName( mapLayer->id().toStdString() ) ) -#endif - addModelLayer( static_cast( mapLayer ), layerConfig ); - } - else - { - drapedLayers.append( mapLayer ); - QgsRectangle extent = QgsCoordinateTransform( mapLayer->crs(), QgsCoordinateReferenceSystem( geoEpsgCrsAuthId() ), QgsProject::instance()->transformContext() ).transform( mapLayer->extent() ); - mLayerExtents.insert( mapLayer->id(), extent ); - } - } - - mTileSource->setLayers( drapedLayers ); - QgsRectangle newExtent = getQGISLayerExtent(); - if ( dirtyExtent.isNull() ) - dirtyExtent = newExtent; - else if ( !newExtent.isNull() ) - dirtyExtent.combineExtentWith( newExtent ); - refreshQGISMapLayer( dirtyExtent ); - } -} - -void GlobePlugin::layerChanged( QgsMapLayer *mapLayer ) -{ - if ( !mapLayer ) - { - mapLayer = qobject_cast( QObject::sender() ); - } - if ( mapLayer->isEditable() ) - { - return; - } - if ( mMapNode ) - { - QgsGlobeVectorLayerConfig *layerConfig = 0; - if ( qobject_cast( mapLayer ) ) - { - layerConfig = QgsGlobeVectorLayerConfig::getConfig( static_cast( mapLayer ) ); - } - - if ( layerConfig && ( layerConfig->renderingMode == QgsGlobeVectorLayerConfig::RenderingModeModelSimple || layerConfig->renderingMode == QgsGlobeVectorLayerConfig::RenderingModeModelAdvanced ) ) - { - // If was previously a draped layer, refresh the draped layer - if ( mTileSource->layers().contains( mapLayer ) ) - { - QList layers = mTileSource->layers(); - layers.removeAll( mapLayer ); - mTileSource->setLayers( layers ); - QgsRectangle dirtyExtent = mLayerExtents[mapLayer->id()]; - mLayerExtents.remove( mapLayer->id() ); - refreshQGISMapLayer( dirtyExtent ); - } -#if OSGEARTH_VERSION_GREATER_OR_EQUAL( 2, 9, 0 ) - mMapNode->getMap()->removeLayer( mMapNode->getMap()->getLayerByName( mapLayer->id().toStdString() ) ); -#else - mMapNode->getMap()->removeModelLayer( mMapNode->getMap()->getModelLayerByName( mapLayer->id().toStdString() ) ); -#endif - addModelLayer( static_cast( mapLayer ), layerConfig ); - } - else - { - // Re-insert into layer set if necessary - if ( !mTileSource->layers().contains( mapLayer ) ) - { - QList layers; - for ( const QString &layerId : mDockWidget->getSelectedLayerIds() ) - { -#if OSGEARTH_VERSION_GREATER_OR_EQUAL( 2, 9, 0 ) - if ( ! mMapNode->getMap()->getLayerByName( layerId.toStdString() ) ) -#else - if ( ! mMapNode->getMap()->getModelLayerByName( layerId.toStdString() ) ) -#endif - { - QgsMapLayer *layer = QgsProject::instance()->mapLayer( layerId ); - if ( layer ) - { - layers.append( layer ); - } - } - } - mTileSource->setLayers( layers ); - QgsRectangle extent = QgsCoordinateTransform( mapLayer->crs(), QgsCoordinateReferenceSystem( geoEpsgCrsAuthId() ), QgsProject::instance()->transformContext() ).transform( mapLayer->extent() ); - mLayerExtents.insert( mapLayer->id(), extent ); - } - // Remove any model layer of that layer, in case one existed -#if OSGEARTH_VERSION_GREATER_OR_EQUAL( 2, 9, 0 ) - mMapNode->getMap()->removeLayer( mMapNode->getMap()->getLayerByName( mapLayer->id().toStdString() ) ); -#else - mMapNode->getMap()->removeModelLayer( mMapNode->getMap()->getModelLayerByName( mapLayer->id().toStdString() ) ); -#endif - QgsRectangle layerExtent = QgsCoordinateTransform( mapLayer->crs(), QgsCoordinateReferenceSystem( geoEpsgCrsAuthId() ), QgsProject::instance()->transformContext() ).transform( mapLayer->extent() ); - QgsRectangle dirtyExtent = layerExtent; - if ( mLayerExtents.contains( mapLayer->id() ) ) - { - if ( dirtyExtent.isNull() ) - dirtyExtent = mLayerExtents[mapLayer->id()]; - else if ( !mLayerExtents[mapLayer->id()].isNull() ) - dirtyExtent.combineExtentWith( mLayerExtents[mapLayer->id()] ); - } - mLayerExtents[mapLayer->id()] = layerExtent; - refreshQGISMapLayer( dirtyExtent ); - } - } -} - -void GlobePlugin::rebuildQGISLayer() -{ - if ( mMapNode ) - { - mMapNode->getMap()->removeImageLayer( mQgisMapLayer ); - mLayerExtents.clear(); - - osgEarth::TileSourceOptions opts; - opts.L2CacheSize() = 0; -#if OSGEARTH_VERSION_LESS_THAN( 2, 9, 0 ) - opts.tileSize() = 128; -#endif - mTileSource = new QgsGlobeTileSource( mQGisIface->mapCanvas(), opts ); -#if OSGEARTH_VERSION_GREATER_OR_EQUAL( 2, 9, 0 ) - mTileSource->open(); -#endif - - osgEarth::ImageLayerOptions options( "QGIS" ); - options.driver()->L2CacheSize() = 0; -#if OSGEARTH_VERSION_GREATER_OR_EQUAL( 2, 9, 0 ) - options.tileSize() = 128; -#endif - options.cachePolicy() = osgEarth::CachePolicy::USAGE_NO_CACHE; - mQgisMapLayer = new osgEarth::ImageLayer( options, mTileSource ); - mMapNode->getMap()->addImageLayer( mQgisMapLayer ); - updateLayers(); - } -} - -void GlobePlugin::setGlobeEnabled( bool enabled ) -{ - if ( enabled ) - { - run(); - } - else if ( mDockWidget ) - { - mDockWidget->close(); // triggers reset - } -} - -void GlobePlugin::reset() -{ - mStatsLabel = 0; - mActionToggleGlobe->blockSignals( true ); - mActionToggleGlobe->setChecked( false ); - mActionToggleGlobe->blockSignals( false ); - mMapNode->getMap()->removeImageLayer( mQgisMapLayer ); // abort any rendering - mTileSource->waitForFinished(); - mOsgViewer = 0; - mMapNode = 0; - mRootNode = 0; - mSkyNode = 0; - mBaseLayer = 0; - mBaseLayerUrl.clear(); - mQgisMapLayer = 0; - mTileSource = 0; - mVerticalScale = 0; - mFrustumHighlightCallback = 0; - mFeatureQueryToolIdentifyCb = 0; -#if OSGEARTH_VERSION_LESS_THAN(2, 7, 0) - mFeatureQueryToolHighlightCb = 0; -#endif - mFeatureQueryTool = 0; - mViewerWidget = 0; - mDockWidget = 0; - mImagerySources.clear(); - mElevationSources.clear(); - mLayerExtents.clear(); -#ifdef GLOBE_SHOW_TILE_STATS - disconnect( QgsGlobeTileStatistics::instance(), SIGNAL( changed( int, int ) ), this, SLOT( updateTileStats( int, int ) ) ); - delete QgsGlobeTileStatistics::instance(); -#endif -} - -void GlobePlugin::unload() -{ - if ( mDockWidget ) - { - disconnect( mDockWidget, SIGNAL( destroyed( QObject * ) ), this, SLOT( reset() ) ); - delete mDockWidget; - reset(); - } - mQGisIface->removePluginMenu( tr( "&Globe" ), mActionToggleGlobe ); - mQGisIface->removeToolBarIcon( mActionToggleGlobe ); - mQGisIface->unregisterMapLayerConfigWidgetFactory( mLayerPropertiesFactory ); - delete mLayerPropertiesFactory; - mLayerPropertiesFactory = 0; - delete mSettingsDialog; - mSettingsDialog = 0; - - disconnect( this, SIGNAL( xyCoordinates( const QgsPointXY & ) ), - mQGisIface->mapCanvas(), SIGNAL( xyCoordinates( const QgsPointXY & ) ) ); -} - -void GlobePlugin::enableFrustumHighlight( bool status ) -{ - if ( status ) - mMapNode->getTerrainEngine()->addUpdateCallback( mFrustumHighlightCallback ); - else - mMapNode->getTerrainEngine()->removeUpdateCallback( mFrustumHighlightCallback ); -} - -void GlobePlugin::enableFeatureIdentification( bool status ) -{ - if ( status ) - mOsgViewer->addEventHandler( mFeatureQueryTool ); - else - mOsgViewer->removeEventHandler( mFeatureQueryTool ); -} - -bool NavigationControl::handle( const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &aa, osgEarth::Util::Controls::ControlContext &cx ) -{ - if ( ea.getEventType() == osgGA::GUIEventAdapter::PUSH ) - { - mMousePressed = true; - } - else if ( ea.getEventType() == osgGA::GUIEventAdapter::FRAME && mMousePressed ) - { - float canvasY = cx._vp->height() - ( ea.getY() - cx._view->getCamera()->getViewport()->y() ); - float canvasX = ea.getX() - cx._view->getCamera()->getViewport()->x(); - - if ( intersects( canvasX, canvasY ) ) - { - for ( osgEarth::Util::Controls::ControlEventHandlerList::const_iterator i = _eventHandlers.begin(); i != _eventHandlers.end(); ++i ) - { - NavigationControlHandler *handler = dynamic_cast( i->get() ); - if ( handler ) - { - handler->onMouseDown(); - } - } - } - else - { - mMousePressed = false; - } - } - else if ( ea.getEventType() == osgGA::GUIEventAdapter::RELEASE ) - { - for ( osgEarth::Util::Controls::ControlEventHandlerList::const_iterator i = _eventHandlers.begin(); i != _eventHandlers.end(); ++i ) - { - NavigationControlHandler *handler = dynamic_cast( i->get() ); - if ( handler ) - { - handler->onClick( ea, aa ); - } - } - mMousePressed = false; - } - return Control::handle( ea, aa, cx ); -} - -bool KeyboardControlHandler::handle( const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &aa ) -{ - if ( ea.getEventType() == osgGA::GUIEventAdapter::KEYDOWN ) - { - //move map - if ( ea.getKey() == '4' ) - _manip->pan( -MOVE_OFFSET, 0 ); - else if ( ea.getKey() == '6' ) - _manip->pan( MOVE_OFFSET, 0 ); - else if ( ea.getKey() == '2' ) - _manip->pan( 0, MOVE_OFFSET ); - else if ( ea.getKey() == '8' ) - _manip->pan( 0, -MOVE_OFFSET ); - //rotate - else if ( ea.getKey() == '/' ) - _manip->rotate( MOVE_OFFSET, 0 ); - else if ( ea.getKey() == '*' ) - _manip->rotate( -MOVE_OFFSET, 0 ); - //tilt - else if ( ea.getKey() == '9' ) - _manip->rotate( 0, MOVE_OFFSET ); - else if ( ea.getKey() == '3' ) - _manip->rotate( 0, -MOVE_OFFSET ); - //zoom - else if ( ea.getKey() == '-' ) - _manip->zoom( 0, MOVE_OFFSET ); - else if ( ea.getKey() == '+' ) - _manip->zoom( 0, -MOVE_OFFSET ); - //reset - else if ( ea.getKey() == '5' ) - _manip->home( ea, aa ); - } - return false; -} - -/** - * Required extern functions needed for every plugin - * These functions can be called prior to creating an instance - * of the plugin class - */ -// Class factory to return a new instance of the plugin class -QGISEXTERN QgisPlugin *classFactory( QgisInterface *qgisInterfacePointer ) -{ - return new GlobePlugin( qgisInterfacePointer ); -} -// Return the name of the plugin - note that we do not user class members as -// the class may not yet be insantiated when this method is called. -QGISEXTERN QString name() -{ - return sName; -} - -// Return the description -QGISEXTERN QString description() -{ - return sDescription; -} - -// Return the category -QGISEXTERN QString category() -{ - return sCategory; -} - -// Return the type (either UI or MapLayer plugin) -QGISEXTERN int type() -{ - return sPluginType; -} - -// Return the version number for the plugin -QGISEXTERN QString version() -{ - return sPluginVersion; -} - -// Return the icon -QGISEXTERN QString icon() -{ - return sIcon; -} - -// Return the experimental status for the plugin -QGISEXTERN QString experimental() -{ - return sExperimental; -} - -// Delete ourself -QGISEXTERN void unload( QgisPlugin *pluginPointer ) -{ - delete pluginPointer; -} diff --git a/src/plugins/globe/globe_plugin.h b/src/plugins/globe/globe_plugin.h deleted file mode 100644 index 165bb304dc6..00000000000 --- a/src/plugins/globe/globe_plugin.h +++ /dev/null @@ -1,180 +0,0 @@ -/*************************************************************************** - globe.h - - Globe Plugin - a QGIS plugin - -------------------------------------- - Date : 08-Jul-2010 - Copyright : (C) 2010 by Sourcepole - Email : info at sourcepole.ch - *************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ - -#ifndef QGS_GLOBE_PLUGIN_H -#define QGS_GLOBE_PLUGIN_H - -#include "qgisplugin.h" -#include -#include -#include - -#include "qgsglobeplugindialog.h" -#include "qgsrectangle.h" - -class QAction; -class QDateTime; -class QDockWidget; -class QgsAnnotationItem; -class QgsGlobeAnnotation; -class QgsGlobeLayerPropertiesFactory; -class QgsGlobePluginDialog; -class QgsGlobeWidget; -class QgsMapLayer; -class QgsPointXY; -class QgsRectangle; -class QgsGlobeFrustumHighlightCallback; -class QgsGlobeFeatureIdentifyCallback; -class QgsGlobeTileSource; -class QgsGlobeVectorLayerConfig; - -namespace osg -{ - class Group; - class Vec3d; -} -namespace osgViewer { class Viewer; } - -namespace osgEarth -{ - class GeoPoint; - class GeoExtent; - class ImageLayer; - class MapNode; - namespace Annotation { class PlaceNode; } - namespace QtGui { class ViewerWidget; } - namespace Util - { - class FeatureHighlightCallback; - class FeatureQueryTool; - class SkyNode; - class VerticalScale; - namespace Controls - { - class Control; - class ControlEventHandler; - class LabelControl; - } - } -} - - -class GLOBE_EXPORT GlobePlugin : public QObject, public QgisPlugin -{ - Q_OBJECT - - public: - GlobePlugin( QgisInterface *qgisInterface ); - ~GlobePlugin(); - - //! init the gui - void initGui() override; - //! unload the plugin - void unload() override; - - //! Enable or disable frustum highlight - void enableFrustumHighlight( bool statu ); - //! Enable or disable feature identification - void enableFeatureIdentification( bool status ); - - //! Sets the globe coordinates of a user right-click on the globe - void setSelectedCoordinates( const osg::Vec3d &coords ); - //! Gets a coordinates vector - osg::Vec3d getSelectedCoordinates(); - //! emits signal with current mouse coordinates - void showCurrentCoordinates( const osgEarth::GeoPoint &geoPoint ); - //! Gets longitude of user right click - double getSelectedLon() const { return mSelectedLon; } - //! Gets latitude of user right click - double getSelectedLat() const { return mSelectedLat; } - //! Gets elevation of user right click - double getSelectedElevation() { return mSelectedElevation; } - - //! Gets the OSG viewer - osgViewer::Viewer *osgViewer() { return mOsgViewer; } - //! Gets OSG map node - osgEarth::MapNode *mapNode() { return mMapNode; } - - QgisInterface *qgisIface() const { return mQGisIface; } - - public slots: - void run(); - void updateLayers(); - void showSettings(); - void syncExtent(); - - private: - QgisInterface *mQGisIface = nullptr; - - QAction *mActionToggleGlobe = nullptr; - osgEarth::QtGui::ViewerWidget *mViewerWidget = nullptr; - QgsGlobeWidget *mDockWidget = nullptr; - QgsGlobePluginDialog *mSettingsDialog = nullptr; - - QString mBaseLayerUrl; - QList mImagerySources; - QList mElevationSources; - double mSelectedLat, mSelectedLon, mSelectedElevation; - - osg::ref_ptr mOsgViewer; - osg::ref_ptr mMapNode; - osg::ref_ptr mRootNode; - osg::ref_ptr mSkyNode; - osg::ref_ptr mBaseLayer; - osg::ref_ptr mQgisMapLayer; - osg::ref_ptr mTileSource; - QMap mLayerExtents; - osg::ref_ptr mVerticalScale; - - //! Creates additional pages in the layer properties for adjusting 3D properties - QgsGlobeLayerPropertiesFactory *mLayerPropertiesFactory = nullptr; - osg::ref_ptr mFrustumHighlightCallback; - osg::ref_ptr mFeatureQueryToolIdentifyCb; - // TODO: How to port highlight to 2.7.0? -#if OSGEARTH_VERSION_LESS_THAN(2, 7, 0) - osg::ref_ptr mFeatureQueryToolHighlightCb; -#endif - osg::ref_ptr mFeatureQueryTool; - osg::ref_ptr mStatsLabel; - - void setupProxy(); - void addControl( osgEarth::Util::Controls::Control *control, int x, int y, int w, int h, osgEarth::Util::Controls::ControlEventHandler *handler ); - void addImageControl( const std::string &imgPath, int x, int y, osgEarth::Util::Controls::ControlEventHandler *handler = 0 ); - void addModelLayer( QgsVectorLayer *mapLayer, QgsGlobeVectorLayerConfig *layerConfig ); - void setupControls(); - void applyProjectSettings(); - QgsRectangle getQGISLayerExtent() const; - - private slots: - void setGlobeEnabled( bool enabled ); - void reset(); - void projectRead(); - void applySettings(); - void layerChanged( QgsMapLayer *mapLayer = 0 ); - void rebuildQGISLayer(); - void refreshQGISMapLayer( const QgsRectangle &dirtyRect ); - void updateTileStats( int queued, int tot ); - - signals: - //! emits current mouse position - void xyCoordinates( const QgsPointXY &p ); - //! emits position of right click on globe - void newCoordinatesSelected( const QgsPointXY &p ); -}; - -#endif // QGS_GLOBE_PLUGIN_H diff --git a/src/plugins/globe/globe_plugin.qrc b/src/plugins/globe/globe_plugin.qrc deleted file mode 100644 index d66d6210db5..00000000000 --- a/src/plugins/globe/globe_plugin.qrc +++ /dev/null @@ -1,6 +0,0 @@ - - - images/globe.png - images/icon.svg - - diff --git a/src/plugins/globe/images/globe.png b/src/plugins/globe/images/globe.png deleted file mode 100644 index 8da10ab82b3..00000000000 Binary files a/src/plugins/globe/images/globe.png and /dev/null differ diff --git a/src/plugins/globe/images/gui/MoveWheel.png b/src/plugins/globe/images/gui/MoveWheel.png deleted file mode 100644 index 29438d896a8..00000000000 Binary files a/src/plugins/globe/images/gui/MoveWheel.png and /dev/null differ diff --git a/src/plugins/globe/images/gui/YawPitchWheel.png b/src/plugins/globe/images/gui/YawPitchWheel.png deleted file mode 100644 index d6dab909f99..00000000000 Binary files a/src/plugins/globe/images/gui/YawPitchWheel.png and /dev/null differ diff --git a/src/plugins/globe/images/gui/button-background-single.png b/src/plugins/globe/images/gui/button-background-single.png deleted file mode 100644 index 5b9bf77a963..00000000000 Binary files a/src/plugins/globe/images/gui/button-background-single.png and /dev/null differ diff --git a/src/plugins/globe/images/gui/button-background.png b/src/plugins/globe/images/gui/button-background.png deleted file mode 100644 index 6049495ad42..00000000000 Binary files a/src/plugins/globe/images/gui/button-background.png and /dev/null differ diff --git a/src/plugins/globe/images/gui/refresh-view.png b/src/plugins/globe/images/gui/refresh-view.png deleted file mode 100644 index 23e759891b7..00000000000 Binary files a/src/plugins/globe/images/gui/refresh-view.png and /dev/null differ diff --git a/src/plugins/globe/images/gui/settings.png b/src/plugins/globe/images/gui/settings.png deleted file mode 100644 index f2240961744..00000000000 Binary files a/src/plugins/globe/images/gui/settings.png and /dev/null differ diff --git a/src/plugins/globe/images/gui/sync-extent.png b/src/plugins/globe/images/gui/sync-extent.png deleted file mode 100644 index 6849f41d04a..00000000000 Binary files a/src/plugins/globe/images/gui/sync-extent.png and /dev/null differ diff --git a/src/plugins/globe/images/gui/zoom-home.png b/src/plugins/globe/images/gui/zoom-home.png deleted file mode 100644 index ed024c0ee5d..00000000000 Binary files a/src/plugins/globe/images/gui/zoom-home.png and /dev/null differ diff --git a/src/plugins/globe/images/gui/zoom-in.png b/src/plugins/globe/images/gui/zoom-in.png deleted file mode 100644 index 873c8193b3a..00000000000 Binary files a/src/plugins/globe/images/gui/zoom-in.png and /dev/null differ diff --git a/src/plugins/globe/images/gui/zoom-out.png b/src/plugins/globe/images/gui/zoom-out.png deleted file mode 100644 index 1653433d5cb..00000000000 Binary files a/src/plugins/globe/images/gui/zoom-out.png and /dev/null differ diff --git a/src/plugins/globe/images/icon.svg b/src/plugins/globe/images/icon.svg deleted file mode 100644 index d008d7899d2..00000000000 --- a/src/plugins/globe/images/icon.svg +++ /dev/null @@ -1,143 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - diff --git a/src/plugins/globe/images/originals/gui/move-down.png b/src/plugins/globe/images/originals/gui/move-down.png deleted file mode 100644 index cc07216457a..00000000000 Binary files a/src/plugins/globe/images/originals/gui/move-down.png and /dev/null differ diff --git a/src/plugins/globe/images/originals/gui/move-left.png b/src/plugins/globe/images/originals/gui/move-left.png deleted file mode 100644 index 96a42b20985..00000000000 Binary files a/src/plugins/globe/images/originals/gui/move-left.png and /dev/null differ diff --git a/src/plugins/globe/images/originals/gui/move-right.png b/src/plugins/globe/images/originals/gui/move-right.png deleted file mode 100644 index cd80a00be49..00000000000 Binary files a/src/plugins/globe/images/originals/gui/move-right.png and /dev/null differ diff --git a/src/plugins/globe/images/originals/gui/move-up.png b/src/plugins/globe/images/originals/gui/move-up.png deleted file mode 100644 index 4cc30df0855..00000000000 Binary files a/src/plugins/globe/images/originals/gui/move-up.png and /dev/null differ diff --git a/src/plugins/globe/images/originals/gui/refresh-view.png b/src/plugins/globe/images/originals/gui/refresh-view.png deleted file mode 100644 index 7b58a186de3..00000000000 Binary files a/src/plugins/globe/images/originals/gui/refresh-view.png and /dev/null differ diff --git a/src/plugins/globe/images/originals/gui/rotate-ccw.png b/src/plugins/globe/images/originals/gui/rotate-ccw.png deleted file mode 100644 index 145abe01c6c..00000000000 Binary files a/src/plugins/globe/images/originals/gui/rotate-ccw.png and /dev/null differ diff --git a/src/plugins/globe/images/originals/gui/rotate-cw.png b/src/plugins/globe/images/originals/gui/rotate-cw.png deleted file mode 100644 index c064d11bb56..00000000000 Binary files a/src/plugins/globe/images/originals/gui/rotate-cw.png and /dev/null differ diff --git a/src/plugins/globe/images/originals/gui/rotate-reset.png b/src/plugins/globe/images/originals/gui/rotate-reset.png deleted file mode 100644 index 4cc30df0855..00000000000 Binary files a/src/plugins/globe/images/originals/gui/rotate-reset.png and /dev/null differ diff --git a/src/plugins/globe/images/originals/gui/sync-extent.png b/src/plugins/globe/images/originals/gui/sync-extent.png deleted file mode 100644 index 51265e71242..00000000000 Binary files a/src/plugins/globe/images/originals/gui/sync-extent.png and /dev/null differ diff --git a/src/plugins/globe/images/originals/gui/tilt-down.png b/src/plugins/globe/images/originals/gui/tilt-down.png deleted file mode 100644 index cc07216457a..00000000000 Binary files a/src/plugins/globe/images/originals/gui/tilt-down.png and /dev/null differ diff --git a/src/plugins/globe/images/originals/gui/tilt-up.png b/src/plugins/globe/images/originals/gui/tilt-up.png deleted file mode 100644 index 4cc30df0855..00000000000 Binary files a/src/plugins/globe/images/originals/gui/tilt-up.png and /dev/null differ diff --git a/src/plugins/globe/images/originals/gui/zoom-home.png b/src/plugins/globe/images/originals/gui/zoom-home.png deleted file mode 100644 index f019bc7ee12..00000000000 Binary files a/src/plugins/globe/images/originals/gui/zoom-home.png and /dev/null differ diff --git a/src/plugins/globe/images/originals/gui/zoom-in.png b/src/plugins/globe/images/originals/gui/zoom-in.png deleted file mode 100644 index 3373e25f4f2..00000000000 Binary files a/src/plugins/globe/images/originals/gui/zoom-in.png and /dev/null differ diff --git a/src/plugins/globe/images/originals/gui/zoom-out.png b/src/plugins/globe/images/originals/gui/zoom-out.png deleted file mode 100644 index 411f0f7bb66..00000000000 Binary files a/src/plugins/globe/images/originals/gui/zoom-out.png and /dev/null differ diff --git a/src/plugins/globe/images/world.tif b/src/plugins/globe/images/world.tif deleted file mode 100644 index 8e72bf645cb..00000000000 Binary files a/src/plugins/globe/images/world.tif and /dev/null differ diff --git a/src/plugins/globe/qgsglobefeatureidentify.cpp b/src/plugins/globe/qgsglobefeatureidentify.cpp deleted file mode 100644 index 73806918c8b..00000000000 --- a/src/plugins/globe/qgsglobefeatureidentify.cpp +++ /dev/null @@ -1,87 +0,0 @@ -/*************************************************************************** - qgsglobefeatureidentify.cpp - -------------------------------------- - Date : 27.10.2013 - Copyright : (C) 2013 Matthias Kuhn - Email : matthias dot kuhn at gmx dot ch - *************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ - -#include "qgsglobefeatureidentify.h" -#include "qgsmapcanvas.h" -#include "qgsproject.h" -#include "qgsrubberband.h" -#include "qgsvectorlayer.h" -#include "qgslogger.h" -#include "featuresource/qgsglobefeaturesource.h" - -#include -#include - -QgsGlobeFeatureIdentifyCallback::QgsGlobeFeatureIdentifyCallback( QgsMapCanvas *mapCanvas ) - : mCanvas( mapCanvas ) - , mRubberBand( new QgsRubberBand( mapCanvas, QgsWkbTypes::PolygonGeometry ) ) -{ - QColor color( Qt::green ); - color.setAlpha( 190 ); - - mRubberBand->setColor( color ); -} - -QgsGlobeFeatureIdentifyCallback::~QgsGlobeFeatureIdentifyCallback() -{ - mCanvas->scene()->removeItem( mRubberBand ); - delete mRubberBand; -} - -#if OSGEARTH_VERSION_LESS_THAN(2, 7, 0) -void QgsGlobeFeatureIdentifyCallback::onHit( osgEarth::Features::FeatureSourceIndexNode *index, osgEarth::Features::FeatureID fid, const EventArgs & /*args*/ ) -{ - QgsGlobeFeatureSource *globeSource = dynamic_cast( index->getFeatureSource() ); - if ( globeSource ) - { - QgsVectorLayer *lyr = globeSource->layer(); - -#else -void QgsGlobeFeatureIdentifyCallback::onHit( osgEarth::ObjectID id ) -{ - osgEarth::Features::FeatureIndex *index = osgEarth::Registry::objectIndex()->get( id ); - osgEarth::Features::Feature *feature = index->getFeature( id ); - osgEarth::Features::FeatureID fid = feature->getFID(); - std::string layerId; - if ( feature->getUserValue( "qgisLayerId", layerId ) ) - { - QgsVectorLayer *lyr = QgsProject::instance()->mapLayer( QString::fromStdString( layerId ) ); -#endif - if ( lyr ) - { - QgsFeature feat; - lyr->getFeatures( QgsFeatureRequest().setFilterFid( fid ) ).nextFeature( feat ); - - if ( feat.isValid() ) - mRubberBand->setToGeometry( feat.geometry(), lyr ); - else - mRubberBand->reset( QgsWkbTypes::PolygonGeometry ); - } - } - else - { - QgsDebugMsg( "Clicked feature was not on a QGIS layer" ); - } - -} - -#if OSGEARTH_VERSION_LESS_THAN(2, 7, 0) -void QgsGlobeFeatureIdentifyCallback::onMiss( const EventArgs &/*args*/ ) -#else -void QgsGlobeFeatureIdentifyCallback::onMiss() -#endif -{ - mRubberBand->reset( QgsWkbTypes::PolygonGeometry ); -} diff --git a/src/plugins/globe/qgsglobefeatureidentify.h b/src/plugins/globe/qgsglobefeatureidentify.h deleted file mode 100644 index 65ac3745c44..00000000000 --- a/src/plugins/globe/qgsglobefeatureidentify.h +++ /dev/null @@ -1,48 +0,0 @@ -/*************************************************************************** - qgsglobefeatureidentify.h - -------------------------------------- - Date : 27.10.2013 - Copyright : (C) 2013 Matthias Kuhn - Email : matthias dot kuhn at gmx dot ch - *************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ - -#ifndef QGSGLOBEFEATUREIDENTIFY_H -#define QGSGLOBEFEATUREIDENTIFY_H - -#include -#include - -class QgsMapCanvas; -class QgsRubberBand; - -#if OSGEARTH_VERSION_LESS_THAN(2, 7, 0) -class QgsGlobeFeatureIdentifyCallback : public osgEarth::Util::FeatureQueryTool::Callback -#else -class QgsGlobeFeatureIdentifyCallback : public osgEarth::Picker::Callback -#endif -{ - public: - QgsGlobeFeatureIdentifyCallback( QgsMapCanvas *mapCanvas ); - ~QgsGlobeFeatureIdentifyCallback(); - -#if OSGEARTH_VERSION_LESS_THAN(2, 7, 0) - void onHit( osgEarth::Features::FeatureSourceIndexNode *index, osgEarth::Features::FeatureID fid, const EventArgs &args ) override; - void onMiss( const EventArgs &args ) override; -#else - void onHit( osgEarth::ObjectID id ) override; - void onMiss() override; -#endif - - private: - QgsMapCanvas *mCanvas = nullptr; - QgsRubberBand *mRubberBand = nullptr; -}; - -#endif // QGSGLOBEFEATUREIDENTIFY_H diff --git a/src/plugins/globe/qgsglobefrustumhighlight.cpp b/src/plugins/globe/qgsglobefrustumhighlight.cpp deleted file mode 100644 index b70df03023f..00000000000 --- a/src/plugins/globe/qgsglobefrustumhighlight.cpp +++ /dev/null @@ -1,68 +0,0 @@ -/*************************************************************************** - qgsglobefrustumhighlight.cpp - -------------------------------------- - Date : 27.10.2013 - Copyright : (C) 2013 Matthias Kuhn - Email : matthias dot kuhn at gmx dot ch - *************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ - -#include -#include -#include -#include -#include - -#include "qgsglobefrustumhighlight.h" - -QgsGlobeFrustumHighlightCallback::QgsGlobeFrustumHighlightCallback( osg::View *view, osgEarth::Terrain *terrain, QgsMapCanvas *mapCanvas, QColor color ) - : osg::Callback() - , mView( view ) - , mTerrain( terrain ) - , mRubberBand( new QgsRubberBand( mapCanvas, QgsWkbTypes::PolygonGeometry ) ) - , mSrs( osgEarth::SpatialReference::create( mapCanvas->mapSettings().destinationCrs().toWkt().toStdString() ) ) -{ - mRubberBand->setColor( color ); -} - -QgsGlobeFrustumHighlightCallback::~QgsGlobeFrustumHighlightCallback() -{ - delete mRubberBand; -} - -bool QgsGlobeFrustumHighlightCallback::run( osg::Object *object, osg::Object *data ) -{ - osg::Node *node = dynamic_cast( object ); - osg::NodeVisitor *nv = dynamic_cast( data ); - if ( node && nv ) - { - const osg::Viewport::value_type &width = mView->getCamera()->getViewport()->width(); - const osg::Viewport::value_type &height = mView->getCamera()->getViewport()->height(); - - osg::Vec3d corners[4]; - - mTerrain->getWorldCoordsUnderMouse( mView, 0, 0, corners[0] ); - mTerrain->getWorldCoordsUnderMouse( mView, 0, height - 1, corners[1] ); - mTerrain->getWorldCoordsUnderMouse( mView, width - 1, height - 1, corners[2] ); - mTerrain->getWorldCoordsUnderMouse( mView, width - 1, 0, corners[3] ); - - mRubberBand->reset( QgsWkbTypes::PolygonGeometry ); - for ( int i = 0; i < 4; i++ ) - { - osg::Vec3d localCoords; - mSrs->transformFromWorld( corners[i], localCoords ); - mRubberBand->addPoint( QgsPointXY( localCoords.x(), localCoords.y() ) ); - } - return true; - } - else - { - return traverse( object, data ); - } -} diff --git a/src/plugins/globe/qgsglobefrustumhighlight.h b/src/plugins/globe/qgsglobefrustumhighlight.h deleted file mode 100644 index 48f9a56c443..00000000000 --- a/src/plugins/globe/qgsglobefrustumhighlight.h +++ /dev/null @@ -1,44 +0,0 @@ -/*************************************************************************** - qgsglobefrustumhighlight.h - -------------------------------------- - Date : 27.10.2013 - Copyright : (C) 2013 Matthias Kuhn - Email : matthias dot kuhn at gmx dot ch - *************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ - -#ifndef QGSGLOBEFRUSTUMHIGHLIGHT_H -#define QGSGLOBEFRUSTUMHIGHLIGHT_H - -#include - -class QgsRubberBand; -namespace osg { class View; } -namespace osgEarth -{ - class Terrain; - class SpatialReference; -} - -struct QgsGlobeFrustumHighlightCallback : public osg::Callback -{ - public: - QgsGlobeFrustumHighlightCallback( osg::View *view, osgEarth::Terrain *terrain, QgsMapCanvas *mapCanvas, QColor color ); - ~QgsGlobeFrustumHighlightCallback(); - - bool run( osg::Object *object, osg::Object *data ) override; - - private: - osg::View *mView = nullptr; - osgEarth::Terrain *mTerrain = nullptr; - QgsRubberBand *mRubberBand = nullptr; - osgEarth::SpatialReference *mSrs = nullptr; -}; - -#endif // QGSGLOBEFRUSTUMHIGHLIGHT_H diff --git a/src/plugins/globe/qgsglobeplugindialog.cpp b/src/plugins/globe/qgsglobeplugindialog.cpp deleted file mode 100644 index cdf2f32988f..00000000000 --- a/src/plugins/globe/qgsglobeplugindialog.cpp +++ /dev/null @@ -1,551 +0,0 @@ -/*************************************************************************** -* qgsglobeplugindialog.cpp - settings dialog for the globe plugin -* -------------------------------------- -* Date : 11-Nov-2010 -* Copyright : (C) 2010 by Marco Bernasocchi -* Email : marco at bernawebdesign.ch -*************************************************************************** -* * -* This program is free software; you can redistribute it and/or modify * -* it under the terms of the GNU General Public License as published by * -* the Free Software Foundation; either version 2 of the License, or * -* (at your option) any later version. * -* * -***************************************************************************/ - -#include "qgsglobeplugindialog.h" -#include "globe_plugin.h" - -#include "qgsapplication.h" -#include "qgsnetworkaccessmanager.h" -#include "qgsproject.h" -#include "qgslogger.h" -#include "qgssettings.h" - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -QgsGlobePluginDialog::QgsGlobePluginDialog( QWidget *parent, Qt::WFlags fl ) - : QDialog( parent, fl ) -{ - setupUi( this ); - - QMenu *addImageryMenu = new QMenu( this ); - - QMenu *tmsImageryMenu = new QMenu( this ); - tmsImageryMenu->addAction( "Readymap: NASA BlueMarble Imagery", this, SLOT( addTMSImagery() ) )->setData( "http://readymap.org/readymap/tiles/1.0.0/1/" ); - tmsImageryMenu->addAction( "Readymap: NASA BlueMarble, ocean only", this, SLOT( addTMSImagery() ) )->setData( "http://readymap.org/readymap/tiles/1.0.0/2/" ); - tmsImageryMenu->addAction( "Readymap: High resolution insets from various world locations", this, SLOT( addTMSImagery() ) )->setData( "http://readymap.org/readymap/tiles/1.0.0/3/" ); - tmsImageryMenu->addAction( "Readymap: Global Land Cover Facility 15m Landsat", this, SLOT( addTMSImagery() ) )->setData( "http://readymap.org/readymap/tiles/1.0.0/6/" ); - tmsImageryMenu->addAction( "Readymap: NASA BlueMarble + Landsat + Ocean Masking Layer", this, SLOT( addTMSImagery() ) )->setData( "http://readymap.org/readymap/tiles/1.0.0/7/" ); - tmsImageryMenu->addAction( tr( "Custom…" ), this, SLOT( addCustomTMSImagery() ) ); - addImageryMenu->addAction( tr( "TMS" ) )->setMenu( tmsImageryMenu ); - - QMenu *wmsImageryMenu = new QMenu( this ); - wmsImageryMenu->addAction( tr( "Custom…" ), this, SLOT( addCustomWMSImagery() ) ); - addImageryMenu->addAction( tr( "WMS" ) )->setMenu( wmsImageryMenu ); - - QMenu *fileImageryMenu = new QMenu( this ); - QString worldtif = QDir::cleanPath( QgsApplication::pkgDataPath() + "/globe/world.tif" ); - if ( QgsApplication::isRunningFromBuildDir() ) - { - worldtif = QDir::cleanPath( QgsApplication::buildSourcePath() + "/src/plugins/globe/images/world.tif" ); - } - fileImageryMenu->addAction( tr( "world.tif" ), this, SLOT( addRasterImagery() ) )->setData( worldtif ); - fileImageryMenu->addAction( tr( "Custom…" ), this, SLOT( addCustomRasterImagery() ) ); - addImageryMenu->addAction( tr( "Raster" ) )->setMenu( fileImageryMenu ); - - mAddImageryButton->setMenu( addImageryMenu ); - - - QMenu *addElevationMenu = new QMenu( this ); - - QMenu *tmsElevationMenu = new QMenu( this ); - tmsElevationMenu->addAction( "Readymap: SRTM 90m Elevation Data", this, SLOT( addTMSElevation() ) )->setData( "http://readymap.org/readymap/tiles/1.0.0/9/" ); - tmsElevationMenu->addAction( tr( "Custom…" ), this, SLOT( addCustomTMSElevation() ) ); - addElevationMenu->addAction( tr( "TMS" ) )->setMenu( tmsElevationMenu ); - - QMenu *fileElevationMenu = new QMenu( this ); - fileElevationMenu->addAction( tr( "Custom…" ), this, SLOT( addCustomRasterElevation() ) ); - addElevationMenu->addAction( tr( "Raster" ) )->setMenu( fileElevationMenu ); - - mAddElevationButton->setMenu( addElevationMenu ); - - - comboBoxStereoMode->addItem( "OFF", -1 ); - comboBoxStereoMode->addItem( "ANAGLYPHIC", osg::DisplaySettings::ANAGLYPHIC ); - comboBoxStereoMode->addItem( "QUAD_BUFFER", osg::DisplaySettings::ANAGLYPHIC ); - comboBoxStereoMode->addItem( "HORIZONTAL_SPLIT", osg::DisplaySettings::HORIZONTAL_SPLIT ); - comboBoxStereoMode->addItem( "VERTICAL_SPLIT", osg::DisplaySettings::VERTICAL_SPLIT ); - - lineEditAASamples->setValidator( new QIntValidator( lineEditAASamples ) ); - -#if OSGEARTH_VERSION_LESS_THAN( 2, 5, 0 ) - mSpinBoxVerticalScale->setVisible( false ); -#endif - - connect( checkBoxSkyAutoAmbient, SIGNAL( toggled( bool ) ), horizontalSliderMinAmbient, SLOT( setEnabled( bool ) ) ); - connect( checkBoxDateTime, SIGNAL( toggled( bool ) ), dateTimeEditSky, SLOT( setEnabled( bool ) ) ); - connect( buttonBox->button( QDialogButtonBox::Apply ), SIGNAL( clicked( bool ) ), this, SLOT( apply() ) ); - - restoreSavedSettings(); - readProjectSettings(); -} - -void QgsGlobePluginDialog::restoreSavedSettings() -{ - QgsSettings settings; - - // Video settings - comboBoxStereoMode->setCurrentIndex( comboBoxStereoMode->findText( settings.value( "/Plugin-Globe/stereoMode", "OFF" ).toString() ) ); - spinBoxStereoScreenDistance->setValue( settings.value( "/Plugin-Globe/spinBoxStereoScreenDistance", - osg::DisplaySettings::instance()->getScreenDistance() ).toDouble() ); - spinBoxStereoScreenWidth->setValue( settings.value( "/Plugin-Globe/spinBoxStereoScreenWidth", - osg::DisplaySettings::instance()->getScreenWidth() ).toDouble() ); - spinBoxStereoScreenHeight->setValue( settings.value( "/Plugin-Globe/spinBoxStereoScreenHeight", - osg::DisplaySettings::instance()->getScreenHeight() ).toDouble() ); - spinBoxStereoEyeSeparation->setValue( settings.value( "/Plugin-Globe/spinBoxStereoEyeSeparation", - osg::DisplaySettings::instance()->getEyeSeparation() ).toDouble() ); - spinBoxSplitStereoHorizontalSeparation->setValue( settings.value( "/Plugin-Globe/spinBoxSplitStereoHorizontalSeparation", - osg::DisplaySettings::instance()->getSplitStereoHorizontalSeparation() ).toInt() ); - spinBoxSplitStereoVerticalSeparation->setValue( settings.value( "/Plugin-Globe/spinBoxSplitStereoVerticalSeparation", - osg::DisplaySettings::instance()->getSplitStereoVerticalSeparation() ).toInt() ); - comboBoxSplitStereoHorizontalEyeMapping->setCurrentIndex( settings.value( "/Plugin-Globe/comboBoxSplitStereoHorizontalEyeMapping", - osg::DisplaySettings::instance()->getSplitStereoHorizontalEyeMapping() ).toInt() ); - comboBoxSplitStereoVerticalEyeMapping->setCurrentIndex( settings.value( "/Plugin-Globe/comboBoxSplitStereoVerticalEyeMapping", - osg::DisplaySettings::instance()->getSplitStereoVerticalEyeMapping() ).toInt() ); - groupBoxAntiAliasing->setChecked( settings.value( "/Plugin-Globe/anti-aliasing", false ).toBool() ); - lineEditAASamples->setText( settings.value( "/Plugin-Globe/anti-aliasing-level", "" ).toString() ); - - horizontalSliderMinAmbient->setEnabled( checkBoxSkyAutoAmbient->isChecked() ); - dateTimeEditSky->setEnabled( checkBoxDateTime->isChecked() ); - - // Advanced - sliderScrollSensitivity->setValue( settings.value( "/Plugin-Globe/scrollSensitivity", 20 ).toInt() ); - checkBoxInvertScroll->setChecked( settings.value( "/Plugin-Globe/invertScrollWheel", 0 ).toInt() ); - checkBoxFrustumHighlighting->setChecked( settings.value( "/Plugin-Globe/frustum-highlighting", false ).toBool() ); - checkBoxFeatureIdentification->setChecked( settings.value( "/Plugin-Globe/feature-identification", false ).toBool() ); -} - -void QgsGlobePluginDialog::on_buttonBox_accepted() -{ - apply(); - accept(); -} - -void QgsGlobePluginDialog::on_buttonBox_rejected() -{ - restoreSavedSettings(); - readProjectSettings(); - reject(); -} - -void QgsGlobePluginDialog::apply() -{ - QgsSettings settings; - - // Video settings - settings.setValue( "/Plugin-Globe/stereoMode", comboBoxStereoMode->currentText() ); - settings.setValue( "/Plugin-Globe/stereoScreenDistance", spinBoxStereoScreenDistance->value() ); - settings.setValue( "/Plugin-Globe/stereoScreenWidth", spinBoxStereoScreenWidth->value() ); - settings.setValue( "/Plugin-Globe/stereoScreenHeight", spinBoxStereoScreenHeight->value() ); - settings.setValue( "/Plugin-Globe/stereoEyeSeparation", spinBoxStereoEyeSeparation->value() ); - settings.setValue( "/Plugin-Globe/SplitStereoHorizontalSeparation", spinBoxSplitStereoHorizontalSeparation->value() ); - settings.setValue( "/Plugin-Globe/SplitStereoVerticalSeparation", spinBoxSplitStereoVerticalSeparation->value() ); - settings.setValue( "/Plugin-Globe/SplitStereoHorizontalEyeMapping", comboBoxSplitStereoHorizontalEyeMapping->currentIndex() ); - settings.setValue( "/Plugin-Globe/SplitStereoVerticalEyeMapping", comboBoxSplitStereoVerticalEyeMapping->currentIndex() ); - settings.setValue( "/Plugin-Globe/anti-aliasing", groupBoxAntiAliasing->isChecked() ); - settings.setValue( "/Plugin-Globe/anti-aliasing-level", lineEditAASamples->text() ); - - // Advanced settings - settings.setValue( "/Plugin-Globe/scrollSensitivity", sliderScrollSensitivity->value() ); - settings.setValue( "/Plugin-Globe/invertScrollWheel", checkBoxInvertScroll->checkState() ); - settings.setValue( "/Plugin-Globe/frustum-highlighting", checkBoxFrustumHighlighting->isChecked() ); - settings.setValue( "/Plugin-Globe/feature-identification", checkBoxFeatureIdentification->isChecked() ); - - writeProjectSettings(); - - // Apply stereo settings - int stereoMode = comboBoxStereoMode->currentData().toInt(); - if ( stereoMode == -1 ) - { - osg::DisplaySettings::instance()->setStereo( false ); - } - else - { - osg::DisplaySettings::instance()->setStereo( true ); - osg::DisplaySettings::instance()->setStereoMode( - static_cast( stereoMode ) ); - osg::DisplaySettings::instance()->setEyeSeparation( spinBoxStereoEyeSeparation->value() ); - osg::DisplaySettings::instance()->setScreenDistance( spinBoxStereoScreenDistance->value() ); - osg::DisplaySettings::instance()->setScreenWidth( spinBoxStereoScreenWidth->value() ); - osg::DisplaySettings::instance()->setScreenHeight( spinBoxStereoScreenHeight->value() ); - osg::DisplaySettings::instance()->setSplitStereoVerticalSeparation( - spinBoxSplitStereoVerticalSeparation->value() ); - osg::DisplaySettings::instance()->setSplitStereoVerticalEyeMapping( - static_cast( - comboBoxSplitStereoVerticalEyeMapping->currentIndex() ) ); - osg::DisplaySettings::instance()->setSplitStereoHorizontalSeparation( - spinBoxSplitStereoHorizontalSeparation->value() ); - osg::DisplaySettings::instance()->setSplitStereoHorizontalEyeMapping( - static_cast( - comboBoxSplitStereoHorizontalEyeMapping->currentIndex() ) ); - } - - emit settingsApplied(); -} - -void QgsGlobePluginDialog::readProjectSettings() -{ - // Imagery settings - mImageryTreeView->clear(); - for ( const LayerDataSource &ds : getImageryDataSources() ) - { - QTreeWidgetItem *item = new QTreeWidgetItem( QStringList() << ds.type << ds.uri ); - item->setFlags( item->flags() & ~Qt::ItemIsDropEnabled ); - mImageryTreeView->addTopLevelItem( item ); - } - mImageryTreeView->resizeColumnToContents( 0 ); - - // Elevation settings - mElevationTreeView->clear(); - for ( const LayerDataSource &ds : getElevationDataSources() ) - { - QTreeWidgetItem *item = new QTreeWidgetItem( QStringList() << ds.type << ds.uri ); - item->setFlags( item->flags() & ~Qt::ItemIsDropEnabled ); - mElevationTreeView->addTopLevelItem( item ); - } - mElevationTreeView->resizeColumnToContents( 0 ); - -#if OSGEARTH_VERSION_GREATER_OR_EQUAL( 2, 5, 0 ) - mSpinBoxVerticalScale->setValue( QgsProject::instance()->readDoubleEntry( "Globe-Plugin", "/verticalScale", 1 ) ); -#endif - - // Map settings - groupBoxSky->setChecked( QgsProject::instance()->readBoolEntry( "Globe-Plugin", "/skyEnabled", true ) ); - checkBoxDateTime->setChecked( QgsProject::instance()->readBoolEntry( "Globe-Plugin", "/overrideDateTime", false ) ); - dateTimeEditSky->setDateTime( QDateTime::fromString( QgsProject::instance()->readEntry( "Globe-Plugin", "/skyDateTime", QDateTime::currentDateTime().toString() ) ) ); - checkBoxSkyAutoAmbient->setChecked( QgsProject::instance()->readBoolEntry( "Globe-Plugin", "/skyAutoAmbient", false ) ); - horizontalSliderMinAmbient->setValue( QgsProject::instance()->readDoubleEntry( "Globe-Plugin", "/skyMinAmbient", 30. ) ); -} - -void QgsGlobePluginDialog::writeProjectSettings() -{ - // Imagery settings - QgsProject::instance()->removeEntry( "Globe-Plugin", "/imageryDatasources/" ); - for ( int row = 0, nRows = mImageryTreeView->topLevelItemCount(); row < nRows; ++row ) - { - QTreeWidgetItem *item = mImageryTreeView->topLevelItem( row ); - QString key = QString( "/imageryDatasources/L%1" ).arg( row ); - QgsProject::instance()->writeEntry( "Globe-Plugin", key + "/type", item->text( 0 ) ); - QgsProject::instance()->writeEntry( "Globe-Plugin", key + "/uri", item->text( 1 ) ); - } - - // Elevation settings - QgsProject::instance()->removeEntry( "Globe-Plugin", "/elevationDatasources/" ); - for ( int row = 0, nRows = mElevationTreeView->topLevelItemCount(); row < nRows; ++row ) - { - QTreeWidgetItem *item = mElevationTreeView->topLevelItem( row ); - QString key = QString( "/elevationDatasources/L%1" ).arg( row ); - QgsProject::instance()->writeEntry( "Globe-Plugin", key + "/type", item->text( 0 ) ); - QgsProject::instance()->writeEntry( "Globe-Plugin", key + "/uri", item->text( 1 ) ); - } - -#if OSGEARTH_VERSION_GREATER_OR_EQUAL( 2, 5, 0 ) - QgsProject::instance()->writeEntry( "Globe-Plugin", "/verticalScale", mSpinBoxVerticalScale->value() ); -#endif - - // Map settings - QgsProject::instance()->writeEntry( "Globe-Plugin", "/skyEnabled/", groupBoxSky->isChecked() ); - QgsProject::instance()->writeEntry( "Globe-Plugin", "/overrideDateTime/", checkBoxDateTime->isChecked() ); - QgsProject::instance()->writeEntry( "Globe-Plugin", "/skyDateTime/", dateTimeEditSky->dateTime().toString() ); - QgsProject::instance()->writeEntry( "Globe-Plugin", "/skyAutoAmbient/", checkBoxSkyAutoAmbient->isChecked() ); - QgsProject::instance()->writeEntry( "Globe-Plugin", "/skyMinAmbient/", horizontalSliderMinAmbient->value() ); -} - -bool QgsGlobePluginDialog::validateRemoteUri( const QString &uri, QString &errMsg ) const -{ - QUrl url( uri ); - QgsNetworkAccessManager *nam = QgsNetworkAccessManager::instance(); - QNetworkReply *reply = nullptr; - - while ( true ) - { - QNetworkRequest req( url ); - req.setRawHeader( "User-Agent", "Wget/1.13.4" ); - reply = nam->get( req ); - QTimer timer; - QEventLoop loop; - QObject::connect( &timer, SIGNAL( timeout() ), &loop, SLOT( quit() ) ); - QObject::connect( reply, SIGNAL( finished() ), &loop, SLOT( quit() ) ); - timer.setSingleShot( true ); - timer.start( 500 ); - loop.exec(); - if ( reply->isRunning() ) - { - // Timeout - reply->close(); - delete reply; - errMsg = tr( "Timeout" ); - return false; - } - - QUrl redirectUrl = reply->attribute( QNetworkRequest::RedirectionTargetAttribute ).toUrl(); - if ( redirectUrl.isValid() && url != redirectUrl ) - { - delete reply; - url = redirectUrl; - } - else - { - break; - } - } - - errMsg = reply->error() == QNetworkReply::NoError ? QString() : reply->errorString(); - delete reply; - return errMsg.isEmpty(); -} - -/// MAP /////////////////////////////////////////////////////////////////////// - -void QgsGlobePluginDialog::addImagery( const QString &type, const QString &uri ) -{ - QTreeWidgetItem *item = new QTreeWidgetItem( QStringList() << type << uri ); - item->setFlags( item->flags() & ~Qt::ItemIsDropEnabled ); - mImageryTreeView->addTopLevelItem( item ); - mImageryTreeView->resizeColumnToContents( 0 ); -} - -void QgsGlobePluginDialog::addTMSImagery() -{ - addImagery( "TMS", qobject_cast( QObject::sender() )->data().toString() ); -} - -void QgsGlobePluginDialog::addCustomTMSImagery() -{ - QString url = QInputDialog::getText( this, tr( "Add TMS Imagery" ), tr( "TMS URL:" ) ); - if ( !url.isEmpty() ) - { - QString validationError; - if ( !validateRemoteUri( url, validationError ) ) - { - QMessageBox::warning( this, tr( "Add TMS Imagery" ), validationError ); - } - else - { - addImagery( "TMS", url ); - } - } -} - -void QgsGlobePluginDialog::addCustomWMSImagery() -{ - QString url = QInputDialog::getText( this, tr( "Add WMS Imagery" ), tr( "URL:" ) ); - if ( !url.isEmpty() ) - { - QString validationError; - if ( !validateRemoteUri( url, validationError ) ) - { - QMessageBox::warning( this, tr( "Add WMS Imagery" ), validationError ); - } - else - { - addImagery( "WMS", url ); - } - } -} - -void QgsGlobePluginDialog::addRasterImagery() -{ - addImagery( "Raster", qobject_cast( QObject::sender() )->data().toString() ); -} - -void QgsGlobePluginDialog::addCustomRasterImagery() -{ - QString filename = QFileDialog::getOpenFileName( this, tr( "Add Raster Imagery" ) ); - if ( !filename.isEmpty() ) - { - addImagery( "Raster", filename ); - } -} - -void QgsGlobePluginDialog::addElevation( const QString &type, const QString &uri ) -{ - QTreeWidgetItem *item = new QTreeWidgetItem( QStringList() << type << uri ); - item->setFlags( item->flags() & ~Qt::ItemIsDropEnabled ); - mElevationTreeView->addTopLevelItem( item ); - mElevationTreeView->resizeColumnToContents( 0 ); -} - -void QgsGlobePluginDialog::addTMSElevation() -{ - addElevation( "TMS", qobject_cast( QObject::sender() )->data().toString() ); -} - -void QgsGlobePluginDialog::addCustomTMSElevation() -{ - QString url = QInputDialog::getText( this, tr( "Add TMS Elevation" ), tr( "TMS URL:" ) ); - if ( !url.isEmpty() ) - { - QString validationError; - if ( !validateRemoteUri( url, validationError ) ) - { - QMessageBox::warning( this, tr( "Add TMS Elevation" ), validationError ); - } - else - { - addElevation( "TMS", url ); - } - } -} - -void QgsGlobePluginDialog::addCustomRasterElevation() -{ - QString filename = QFileDialog::getOpenFileName( this, tr( "Add Raster Elevation" ) ); - if ( !filename.isEmpty() ) - { - addElevation( "Raster", filename ); - } -} - -void QgsGlobePluginDialog::on_mRemoveImageryButton_clicked() -{ - delete mImageryTreeView->currentItem(); -} - -void QgsGlobePluginDialog::on_mRemoveElevationButton_clicked() -{ - delete mElevationTreeView->currentItem(); -} - -QList QgsGlobePluginDialog::getImageryDataSources() const -{ - int keysCount = QgsProject::instance()->subkeyList( "Globe-Plugin", "/imageryDatasources/" ).count(); - QList datasources; - for ( int i = 0; i < keysCount; ++i ) - { - QString key = QString( "/imageryDatasources/L%1" ).arg( i ); - LayerDataSource datasource; - datasource.type = QgsProject::instance()->readEntry( "Globe-Plugin", key + "/type" ); - datasource.uri = QgsProject::instance()->readEntry( "Globe-Plugin", key + "/uri" ); - datasources.append( datasource ); - } - return datasources; -} - -QList QgsGlobePluginDialog::getElevationDataSources() const -{ - int keysCount = QgsProject::instance()->subkeyList( "Globe-Plugin", "/elevationDatasources/" ).count(); - QList datasources; - for ( int i = 0; i < keysCount; ++i ) - { - QString key = QString( "/elevationDatasources/L%1" ).arg( i ); - LayerDataSource datasource; - datasource.type = QgsProject::instance()->readEntry( "Globe-Plugin", key + "/type" ); - datasource.uri = QgsProject::instance()->readEntry( "Globe-Plugin", key + "/uri" ); - datasources.append( datasource ); - } - return datasources; -} - -double QgsGlobePluginDialog::getVerticalScale() const -{ - return mSpinBoxVerticalScale->value(); -} - -bool QgsGlobePluginDialog::getSkyEnabled() const -{ - return QgsProject::instance()->readBoolEntry( "Globe-Plugin", "/skyEnabled", true ); -} - -QDateTime QgsGlobePluginDialog::getSkyDateTime() const -{ - bool overrideDateTime = QgsProject::instance()->readBoolEntry( "Globe-Plugin", "/overrideDateTime", false ); - if ( overrideDateTime ) - { - return QDateTime::fromString( QgsProject::instance()->readEntry( "Globe-Plugin", "/skyDateTime", QDateTime::currentDateTime().toString() ) ); - } - else - { - return QDateTime::currentDateTime(); - } -} - -bool QgsGlobePluginDialog::getSkyAutoAmbience() const -{ - return QgsProject::instance()->readBoolEntry( "Globe-Plugin", "/skyAutoAmbient", false ); -} - -double QgsGlobePluginDialog::getSkyMinAmbient() const -{ - return QgsProject::instance()->readDoubleEntry( "Globe-Plugin", "/skyMinAmbient", 30. ) / 100.; -} - -/// ADVANCED ////////////////////////////////////////////////////////////////// - -float QgsGlobePluginDialog::getScrollSensitivity() const -{ - return sliderScrollSensitivity->value() / 10; -} - -bool QgsGlobePluginDialog::getInvertScrollWheel() const -{ - return checkBoxInvertScroll->checkState(); -} - -bool QgsGlobePluginDialog::getFrustumHighlighting() const -{ - return checkBoxFrustumHighlighting->isChecked(); -} - -bool QgsGlobePluginDialog::getFeatureIdenification() const -{ - return checkBoxFeatureIdentification->isChecked(); -} - -/// STEREO //////////////////////////////////////////////////////////////////// -void QgsGlobePluginDialog::on_pushButtonStereoResetDefaults_clicked() -{ - //http://www.openscenegraph.org/projects/osg/wiki/Support/UserGuides/StereoSettings - comboBoxStereoMode->setCurrentIndex( comboBoxStereoMode->findText( "OFF" ) ); - spinBoxStereoScreenDistance->setValue( 0.5 ); - spinBoxStereoScreenHeight->setValue( 0.26 ); - spinBoxStereoScreenWidth->setValue( 0.325 ); - spinBoxStereoEyeSeparation->setValue( 0.06 ); - spinBoxSplitStereoHorizontalSeparation->setValue( 42 ); - spinBoxSplitStereoVerticalSeparation->setValue( 42 ); - comboBoxSplitStereoHorizontalEyeMapping->setCurrentIndex( 0 ); - comboBoxSplitStereoVerticalEyeMapping->setCurrentIndex( 0 ); -} - -void QgsGlobePluginDialog::on_comboBoxStereoMode_currentIndexChanged( int index ) -{ - //http://www.openscenegraph.org/projects/osg/wiki/Support/UserGuides/StereoSettings - //http://www.openscenegraph.org/documentation/OpenSceneGraphReferenceDocs/a00181.html - - int stereoMode = comboBoxStereoMode->itemData( index ).toInt(); - bool stereoEnabled = stereoMode != -1; - bool verticalSplit = stereoMode == osg::DisplaySettings::VERTICAL_SPLIT; - bool horizontalSplit = stereoMode == osg::DisplaySettings::HORIZONTAL_SPLIT; - - spinBoxStereoScreenDistance->setEnabled( stereoEnabled ); - spinBoxStereoScreenHeight->setEnabled( stereoEnabled ); - spinBoxStereoScreenWidth->setEnabled( stereoEnabled ); - spinBoxStereoEyeSeparation->setEnabled( stereoEnabled ); - spinBoxSplitStereoHorizontalSeparation->setEnabled( stereoEnabled && horizontalSplit ); - comboBoxSplitStereoHorizontalEyeMapping->setEnabled( stereoEnabled && horizontalSplit ); - spinBoxSplitStereoVerticalSeparation->setEnabled( stereoEnabled && verticalSplit ); - comboBoxSplitStereoVerticalEyeMapping->setEnabled( stereoEnabled && verticalSplit ); -} diff --git a/src/plugins/globe/qgsglobeplugindialog.h b/src/plugins/globe/qgsglobeplugindialog.h deleted file mode 100644 index 79c275eae98..00000000000 --- a/src/plugins/globe/qgsglobeplugindialog.h +++ /dev/null @@ -1,83 +0,0 @@ -/*************************************************************************** - qgsglobeplugindialog.h - settings dialog for the globe plugin - -------------------------------------- - Date : 11-Nov-2010 - Copyright : (C) 2010 by Marco Bernasocchi - Email : marco at bernawebdesign.ch - *************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ -#ifndef QGSGLOBEPLUGINDIALOG_H -#define QGSGLOBEPLUGINDIALOG_H - -#include "ui_qgsglobeplugindialog.h" -#include - -class GlobePlugin; -class QgsVectorLayer; - -class QgsGlobePluginDialog: public QDialog, private Ui::QgsGlobePluginDialogGuiBase -{ - Q_OBJECT - public: - QgsGlobePluginDialog( QWidget *parent = nullptr, Qt::WFlags fl = 0 ); - - struct LayerDataSource - { - QString uri; - QString type; - bool operator==( const LayerDataSource &other ) { return uri == other.uri && type == other.type; } - bool operator!=( const LayerDataSource &other ) { return uri != other.uri || type != other.type; } - }; - void readProjectSettings(); - - QString getBaseLayerUrl() const; - bool getSkyEnabled() const; - QDateTime getSkyDateTime() const; - bool getSkyAutoAmbience() const; - double getSkyMinAmbient() const; - float getScrollSensitivity() const; - bool getInvertScrollWheel() const; - QList getImageryDataSources() const; - QList getElevationDataSources() const; - double getVerticalScale() const; - bool getFrustumHighlighting() const; - bool getFeatureIdenification() const; - - signals: - void settingsApplied(); - - private: - void restoreSavedSettings(); - void writeProjectSettings(); - bool validateRemoteUri( const QString &uri, QString &errMsg ) const; - - private slots: - void apply(); - void on_buttonBox_accepted(); - void on_buttonBox_rejected(); - - void on_comboBoxStereoMode_currentIndexChanged( int index ); - void on_pushButtonStereoResetDefaults_clicked(); - - void on_mRemoveImageryButton_clicked(); - void on_mRemoveElevationButton_clicked(); - - void addImagery( const QString &type, const QString &uri ); - void addTMSImagery(); - void addCustomTMSImagery(); - void addCustomWMSImagery(); - void addRasterImagery(); - void addCustomRasterImagery(); - void addElevation( const QString &type, const QString &uri ); - void addTMSElevation(); - void addCustomTMSElevation(); - void addCustomRasterElevation(); -}; - -#endif // QGSGLOBEPLUGINDIALOG_H diff --git a/src/plugins/globe/qgsglobeplugindialog.ui b/src/plugins/globe/qgsglobeplugindialog.ui deleted file mode 100644 index 7d20b23e14b..00000000000 --- a/src/plugins/globe/qgsglobeplugindialog.ui +++ /dev/null @@ -1,677 +0,0 @@ - - - QgsGlobePluginDialogGuiBase - - - true - - - - 0 - 0 - 748 - 519 - - - - - 0 - 0 - - - - - 0 - 0 - - - - Globe Settings - - - - ../../.designer/backup../../.designer/backup - - - - - - QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - 0 - - - - Map - - - - - - Sk&y - - - true - - - - - - - 0 - 0 - - - - Override Date / Time (UTC) - - - - - - - - 0 - 0 - - - - dd.MM.yyyy HH:mm - - - true - - - - - - - Ambient lighting - - - - - - - false - - - 100 - - - 50 - - - Qt::Horizontal - - - false - - - QSlider::NoTicks - - - - - - - - - - Imagery - - - - - - true - - - QAbstractItemView::InternalMove - - - 0 - - - true - - - true - - - 2 - - - false - - - 50 - - - - 1 - - - - - 2 - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Add - - - QToolButton::InstantPopup - - - - - - - Remove - - - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - Elevation - - - - - - - 0 - 0 - - - - Vertical scale - - - - - - - - 0 - 0 - - - - 0.100000000000000 - - - 1.000000000000000 - - - - - - - true - - - QAbstractItemView::InternalMove - - - 0 - - - true - - - true - - - true - - - 2 - - - false - - - 50 - - - - 1 - - - - - 2 - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Add - - - QToolButton::InstantPopup - - - - - - - Remove - - - - - - - - - - - - - Video - - - - - - - 0 - 0 - - - - Anti Aliasing - - - true - - - true - - - - QFormLayout::AllNonFixedFieldsGrow - - - - - Samples - - - - - - - [Leave empty for maximum] - - - - - - - <html><head/><body><p><span style=" font-style:italic;">Change requires a restart of the globe plugin</span></p></body></html> - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - Stereo - - - - - - Stereo Mode - - - - - - - - - - Eye separation (m) - - - - - - - false - - - QAbstractSpinBox::UpDownArrows - - - true - - - 3 - - - 10.000000000000000 - - - 0.001000000000000 - - - - - - - Screen distance (m) - - - spinBoxStereoScreenDistance - - - - - - - true - - - 3 - - - 0.100000000000000 - - - - - - - Screen width (m) - - - - - - - true - - - 3 - - - 0.010000000000000 - - - - - - - Screen height (m) - - - - - - - true - - - 3 - - - 0.010000000000000 - - - - - - - Split stereo horizontal separation (px) - - - - - - - true - - - true - - - - - - - Split stereo horizontal eye mapping - - - - - - - - LEFT_EYE_LEFT_VIEWPORT - - - - - LEFT_EYE_RIGHT_VIEWPORT - - - - - - - - Split stereo vertical separation (px) - - - - - - - true - - - - - - - Split stereo vertical eye mapping - - - - - - - true - - - - LEFT_EYE_TOP_VIEWPORT - - - - - LEFT_EYE_BOTTOM_VIEWPORT - - - - - - - - Reset to defaults - - - - - - - - - - - Advanced - - - - - - Scrolling - - - - - - Sensitivity - - - - - - - 10 - - - 50 - - - 1 - - - 20 - - - Qt::Horizontal - - - - - - - Invert scroll wheel - - - - - - - - - - Enable feature identification - - - - - - - Enable frustum highlighting - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - - - buttonBox - - - - diff --git a/src/plugins/globe/qgsglobetilesource.cpp b/src/plugins/globe/qgsglobetilesource.cpp deleted file mode 100644 index cebfb1d7808..00000000000 --- a/src/plugins/globe/qgsglobetilesource.cpp +++ /dev/null @@ -1,294 +0,0 @@ -/*************************************************************************** - qgsglobetilesource.cpp - --------------------- - begin : August 2010 - copyright : (C) 2010 by Pirmin Kalberer - (C) 2015 Sandro Mani - email : pka at sourcepole dot ch - smani at sourcepole dot ch - *************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ - -#include -#include - -#include "qgsglobetilesource.h" -#include "qgscoordinatetransform.h" -#include "qgslogger.h" -#include "qgsmapcanvas.h" -#include "qgsmaprenderercustompainterjob.h" -#include "qgsmaprendererparalleljob.h" - -QgsGlobeTileStatistics *QgsGlobeTileStatistics::s_instance = 0; - -QgsGlobeTileStatistics::QgsGlobeTileStatistics() : mTileCount( 0 ), mQueueTileCount( 0 ) -{ - s_instance = this; -} - -void QgsGlobeTileStatistics::updateTileCount( int change ) -{ - mMutex.lock(); - mTileCount += change; - emit changed( mQueueTileCount, mTileCount ); - mMutex.unlock(); -} - -void QgsGlobeTileStatistics::updateQueueTileCount( int num ) -{ - mMutex.lock(); - mQueueTileCount = num; - emit changed( mQueueTileCount, mTileCount ); - mMutex.unlock(); -} - -/////////////////////////////////////////////////////////////////////////////// - -QgsGlobeTileImage::QgsGlobeTileImage( QgsGlobeTileSource *tileSource, const QgsRectangle &tileExtent, int tileSize, int tileLod ) - : osg::Image() - , mTileSource( tileSource ) - , mTileExtent( tileExtent ) - , mTileSize( tileSize ) - , mLod( tileLod ) -{ - mTileSource->addTile( this ); -#ifdef GLOBE_SHOW_TILE_STATS - QgsGlobeTileStatistics::instance()->updateTileCount( + 1 ); -#endif - mTileData = new unsigned char[mTileSize * mTileSize * 4]; - std::memset( mTileData, 0, mTileSize * mTileSize * 4 ); -#if 0 - setImage( mTileSize, mTileSize, 1, 4, // width, height, depth, internal_format - GL_BGRA, GL_UNSIGNED_BYTE, - mTileData, osg::Image::NO_DELETE ); - - mTileSource->mTileUpdateManager.addTile( const_cast( this ) ); - mDpi = 72; -#else - QImage qImage( mTileData, mTileSize, mTileSize, QImage::Format_ARGB32_Premultiplied ); - QPainter painter( &qImage ); - QgsMapRendererCustomPainterJob job( createSettings( qImage.logicalDpiX(), mTileSource->mLayers ), &painter ); - job.renderSynchronously(); - - setImage( mTileSize, mTileSize, 1, 4, // width, height, depth, internal_format - GL_BGRA, GL_UNSIGNED_BYTE, - mTileData, osg::Image::NO_DELETE ); - flipVertical(); - mDpi = qImage.logicalDpiX(); -#endif -} - -QgsGlobeTileImage::~QgsGlobeTileImage() -{ - mTileSource->removeTile( this ); - mTileSource->mTileUpdateManager.removeTile( this ); - delete[] mTileData; -#ifdef GLOBE_SHOW_TILE_STATS - QgsGlobeTileStatistics::instance()->updateTileCount( -1 ); -#endif -} - -QgsMapSettings QgsGlobeTileImage::createSettings( int dpi, const QList &layers ) const -{ - QgsMapSettings settings; - settings.setBackgroundColor( QColor( Qt::transparent ) ); - settings.setDestinationCrs( QgsCoordinateReferenceSystem::fromOgcWmsCrs( geoEpsgCrsAuthId() ) ); - settings.setExtent( mTileExtent ); - settings.setLayers( layers ); - settings.setFlag( QgsMapSettings::DrawEditingInfo, false ); - settings.setFlag( QgsMapSettings::DrawLabeling, false ); - settings.setFlag( QgsMapSettings::DrawSelection, false ); - settings.setOutputSize( QSize( mTileSize, mTileSize ) ); - settings.setOutputImageFormat( QImage::Format_ARGB32_Premultiplied ); - settings.setOutputDpi( dpi ); - settings.setCustomRenderFlags( "globe" ); - return settings; -} - -void QgsGlobeTileImage::update( osg::NodeVisitor * ) -{ - if ( !mUpdatedImage.isNull() ) - { - QgsDebugMsg( QString( "Updating earth tile image: %1" ).arg( mTileExtent.toString( 5 ) ) ); - std::memcpy( mTileData, mUpdatedImage.bits(), mTileSize * mTileSize * 4 ); - setImage( mTileSize, mTileSize, 1, 4, // width, height, depth, internal_format - GL_BGRA, GL_UNSIGNED_BYTE, - mTileData, osg::Image::NO_DELETE ); - flipVertical(); - mUpdatedImage = QImage(); - } -} - -/////////////////////////////////////////////////////////////////////////////// - -QgsGlobeTileUpdateManager::QgsGlobeTileUpdateManager( QObject *parent ) - : QObject( parent ), mCurrentTile( 0 ), mRenderer( 0 ) -{ - connect( this, SIGNAL( startRendering() ), this, SLOT( start() ) ); - connect( this, SIGNAL( cancelRendering() ), this, SLOT( cancel() ) ); -} - -QgsGlobeTileUpdateManager::~QgsGlobeTileUpdateManager() -{ -#ifdef GLOBE_SHOW_TILE_STATS - QgsGlobeTileStatistics::instance()->updateQueueTileCount( 0 ); -#endif - mTileQueue.clear(); - mCurrentTile = 0; - if ( mRenderer ) - { - mRenderer->cancel(); - } -} - -void QgsGlobeTileUpdateManager::addTile( QgsGlobeTileImage *tile ) -{ - if ( !mTileQueue.contains( tile ) ) - { - mTileQueue.append( tile ); -#ifdef GLOBE_SHOW_TILE_STATS - QgsGlobeTileStatistics::instance()->updateQueueTileCount( mTileQueue.size() ); -#endif - std::sort( mTileQueue.begin(), mTileQueue.end(), QgsGlobeTileImage::lodSort ); - } - emit startRendering(); -} - -void QgsGlobeTileUpdateManager::removeTile( QgsGlobeTileImage *tile ) -{ - if ( mCurrentTile == tile ) - { - mCurrentTile = 0; - if ( mRenderer ) - emit cancelRendering(); - } - else if ( mTileQueue.contains( tile ) ) - { - mTileQueue.removeAll( tile ); -#ifdef GLOBE_SHOW_TILE_STATS - QgsGlobeTileStatistics::instance()->updateQueueTileCount( mTileQueue.size() ); -#endif - } -} - -void QgsGlobeTileUpdateManager::waitForFinished() const -{ - if ( mRenderer ) - { - mRenderer->waitForFinished(); - } -} - -void QgsGlobeTileUpdateManager::start() -{ - if ( mRenderer == 0 && !mTileQueue.isEmpty() ) - { - mCurrentTile = mTileQueue.takeFirst(); -#ifdef GLOBE_SHOW_TILE_STATS - QgsGlobeTileStatistics::instance()->updateQueueTileCount( mTileQueue.size() ); -#endif - mRenderer = new QgsMapRendererParallelJob( mCurrentTile->createSettings( mCurrentTile->dpi(), mLayers ) ); - connect( mRenderer, SIGNAL( finished() ), this, SLOT( renderingFinished() ) ); - mRenderer->start(); - } -} - -void QgsGlobeTileUpdateManager::cancel() -{ - if ( mRenderer ) - mRenderer->cancel(); -} - -void QgsGlobeTileUpdateManager::renderingFinished() -{ - if ( mCurrentTile ) - { - QImage image = mRenderer->renderedImage(); - mCurrentTile->setUpdatedImage( image ); - mCurrentTile = 0; - } - mRenderer->deleteLater(); - mRenderer = 0; - start(); -} - -/////////////////////////////////////////////////////////////////////////////// - -QgsGlobeTileSource::QgsGlobeTileSource( QgsMapCanvas *canvas, const osgEarth::TileSourceOptions &options ) - : TileSource( options ) - , mCanvas( canvas ) -{ - osgEarth::GeoExtent geoextent( osgEarth::SpatialReference::get( "wgs84" ), -180., -90., 180., 90. ); - osgEarth::DataExtentList extents; - extents.push_back( geoextent ); - getDataExtents() = extents; -#if OSGEARTH_VERSION_LESS_THAN(2, 9, 0) - dirtyDataExtents(); -#endif -} - -#if OSGEARTH_VERSION_GREATER_OR_EQUAL(2, 8, 0) -osgEarth::Status QgsGlobeTileSource::initialize( const osgDB::Options * /*dbOptions*/ ) -#else -osgEarth::TileSource::Status QgsGlobeTileSource::initialize( const osgDB::Options * /*dbOptions*/ ) -#endif -{ - setProfile( osgEarth::Registry::instance()->getGlobalGeodeticProfile() ); -#if OSGEARTH_VERSION_GREATER_OR_EQUAL(2, 8, 0) - return osgEarth::Status( osgEarth::Status::NoError ); -#else - return STATUS_OK; -#endif -} - -osg::Image *QgsGlobeTileSource::createImage( const osgEarth::TileKey &key, osgEarth::ProgressCallback *progress ) -{ - Q_UNUSED( progress ) - - int tileSize = getPixelsPerTile(); - if ( tileSize <= 0 ) - { - return osgEarth::ImageUtils::createEmptyImage(); - } - - double xmin, ymin, xmax, ymax; - key.getExtent().getBounds( xmin, ymin, xmax, ymax ); - QgsRectangle tileExtent( xmin, ymin, xmax, ymax ); - - QgsDebugMsg( QString( "Create earth tile image: %1" ).arg( tileExtent.toString( 5 ) ) ); - return new QgsGlobeTileImage( this, tileExtent, getPixelsPerTile(), key.getLOD() ); -} - -void QgsGlobeTileSource::refresh( const QgsRectangle &dirtyExtent ) -{ - mTileUpdateManager.updateLayerSet( mLayers ); - mTileListLock.lock(); - for ( QgsGlobeTileImage *tile : mTiles ) - { - if ( tile->extent().intersects( dirtyExtent ) ) - { - mTileUpdateManager.addTile( tile ); - } - } - mTileListLock.unlock(); -} - -void QgsGlobeTileSource::addTile( QgsGlobeTileImage *tile ) -{ - mTileListLock.lock(); - mTiles.append( tile ); - mTileListLock.unlock(); -} - -void QgsGlobeTileSource::removeTile( QgsGlobeTileImage *tile ) -{ - mTileListLock.lock(); - mTiles.removeOne( tile ); - mTileListLock.unlock(); -} diff --git a/src/plugins/globe/qgsglobetilesource.h b/src/plugins/globe/qgsglobetilesource.h deleted file mode 100644 index 74cd764f021..00000000000 --- a/src/plugins/globe/qgsglobetilesource.h +++ /dev/null @@ -1,149 +0,0 @@ -/*************************************************************************** - qgsglobetilesource.h - --------------------- - begin : August 2010 - copyright : (C) 2010 by Pirmin Kalberer - (C) 2015 Sandro Mani - email : pka at sourcepole dot ch - smani at sourcepole dot ch - *************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ - -#ifndef QGSGLOBETILESOURCE_H -#define QGSGLOBETILESOURCE_H - -#include -#include -#include -#include -#include -#include -#include -#include "qgsrectangle.h" - -//#define GLOBE_SHOW_TILE_STATS - -class QgsCoordinateTransform; -class QgsMapCanvas; -class QgsMapLayer; -class QgsMapRenderer; -class QgsMapSettings; -class QgsGlobeTileSource; -class QgsMapRendererParallelJob; - -class QgsGlobeTileStatistics : public QObject -{ - Q_OBJECT - public: - QgsGlobeTileStatistics(); - ~QgsGlobeTileStatistics() { s_instance = 0; } - static QgsGlobeTileStatistics *instance() { return s_instance; } - void updateTileCount( int change ); - void updateQueueTileCount( int change ); - signals: - void changed( int queued, int tot ); - private: - static QgsGlobeTileStatistics *s_instance; - QMutex mMutex; - int mTileCount; - int mQueueTileCount; -}; - -int getTileCount(); - -class QgsGlobeTileImage : public osg::Image -{ - public: - QgsGlobeTileImage( QgsGlobeTileSource *tileSource, const QgsRectangle &tileExtent, int tileSize, int tileLod ); - ~QgsGlobeTileImage(); - bool requiresUpdateCall() const { return !mUpdatedImage.isNull(); } - QgsMapSettings createSettings( int dpi, const QList &layers ) const; - void setUpdatedImage( const QImage &image ) { mUpdatedImage = image; } - int dpi() const { return mDpi; } - const QgsRectangle &extent() { return mTileExtent; } - - void update( osg::NodeVisitor * ); - - static bool lodSort( const QgsGlobeTileImage *lhs, const QgsGlobeTileImage *rhs ) { return lhs->mLod > rhs->mLod; } - - private: - osg::ref_ptr mTileSource; - QgsRectangle mTileExtent; - int mTileSize; - unsigned char *mTileData; - int mLod; - int mDpi; - QImage mUpdatedImage; -}; - -class QgsGlobeTileUpdateManager : public QObject -{ - Q_OBJECT - public: - QgsGlobeTileUpdateManager( QObject *parent = nullptr ); - ~QgsGlobeTileUpdateManager(); - void updateLayerSet( const QList &layers ) { mLayers = layers; } - void addTile( QgsGlobeTileImage *tile ); - void removeTile( QgsGlobeTileImage *tile ); - void waitForFinished() const; - - signals: - void startRendering(); - void cancelRendering(); - - private: - QList mLayers; - QList mTileQueue; - QgsGlobeTileImage *mCurrentTile = nullptr; - QgsMapRendererParallelJob *mRenderer = nullptr; - - private slots: - void start(); - void cancel(); - void renderingFinished(); -}; - -class QgsGlobeTileSource : public osgEarth::TileSource -{ - public: - QgsGlobeTileSource( QgsMapCanvas *canvas, const osgEarth::TileSourceOptions &options = osgEarth::TileSourceOptions() ); -#if OSGEARTH_VERSION_GREATER_OR_EQUAL(2, 8, 0) - osgEarth::Status initialize( const osgDB::Options *dbOptions ) override; -#else - Status initialize( const osgDB::Options *dbOptions ) override; -#endif - osg::Image *createImage( const osgEarth::TileKey &key, osgEarth::ProgressCallback *progress ) override; - osg::HeightField *createHeightField( const osgEarth::TileKey &/*key*/, osgEarth::ProgressCallback * /*progress*/ ) override { return 0; } - - bool isDynamic() const override { return true; } - osgEarth::CachePolicy getCachePolicyHint( const osgEarth::Profile * /*profile*/ ) const override { return osgEarth::CachePolicy::NO_CACHE; } - - void refresh( const QgsRectangle &dirtyExtent ); - void setLayers( const QList &layers ) { mLayers = layers; } - const QList &layers() const { return mLayers; } - - void waitForFinished() const - { - mTileUpdateManager.waitForFinished(); - } - - private: - friend class QgsGlobeTileImage; - - QMutex mTileListLock; - QList mTiles; - QgsMapCanvas *mCanvas = nullptr; - QList mLayers; - QgsGlobeTileUpdateManager mTileUpdateManager; - - void addTile( QgsGlobeTileImage *tile ); - void removeTile( QgsGlobeTileImage *tile ); -}; - -#endif // QGSGLOBETILESOURCE_H diff --git a/src/plugins/globe/qgsglobevectorlayerproperties.cpp b/src/plugins/globe/qgsglobevectorlayerproperties.cpp deleted file mode 100644 index 4f0313a370f..00000000000 --- a/src/plugins/globe/qgsglobevectorlayerproperties.cpp +++ /dev/null @@ -1,298 +0,0 @@ -/*************************************************************************** - qgsglobevectorlayerpropertiespage.cpp - -------------------------------------- - Date : 9.7.2013 - Copyright : (C) 2013 Matthias Kuhn - Email : matthias dot kuhn at gmx dot ch - *************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ - -#include -#include -#include "qgsglobevectorlayerproperties.h" - -#include - -Q_DECLARE_METATYPE( QgsGlobeVectorLayerConfig * ) - -QgsGlobeVectorLayerConfig *QgsGlobeVectorLayerConfig::getConfig( QgsVectorLayer *layer ) -{ - QgsGlobeVectorLayerConfig *layerConfig = layer->property( "globe-config" ).value(); - if ( !layerConfig ) - { - layerConfig = new QgsGlobeVectorLayerConfig( layer ); - layer->setProperty( "globe-config", QVariant::fromValue( layerConfig ) ); - } - return layerConfig; -} - -/////////////////////////////////////////////////////////////////////////////// - -QgsGlobeVectorLayerPropertiesPage::QgsGlobeVectorLayerPropertiesPage( QgsVectorLayer *layer, QgsMapCanvas *canvas, QWidget *parent ) - : QgsMapLayerConfigWidget( layer, canvas, parent ) - , mLayer( layer ) -{ - setupUi( this ); - - // Populate combo boxes - comboBoxRenderingMode->addItem( tr( "Rasterized" ), QgsGlobeVectorLayerConfig::RenderingModeRasterized ); - comboBoxRenderingMode->addItem( tr( "Model (Simple)" ), QgsGlobeVectorLayerConfig::RenderingModeModelSimple ); - comboBoxRenderingMode->addItem( tr( "Model (Advanced)" ), QgsGlobeVectorLayerConfig::RenderingModeModelAdvanced ); - comboBoxRenderingMode->setItemData( 0, tr( "Rasterize the layer to a texture, and drape it on the terrain" ), Qt::ToolTipRole ); - comboBoxRenderingMode->setItemData( 1, tr( "Render the layer features as models" ), Qt::ToolTipRole ); - comboBoxRenderingMode->setCurrentIndex( -1 ); - - comboBoxAltitudeClamping->addItem( tr( "None" ), static_cast( osgEarth::Symbology::AltitudeSymbol::CLAMP_NONE ) ); - comboBoxAltitudeClamping->addItem( tr( "Terrain" ), static_cast( osgEarth::Symbology::AltitudeSymbol::CLAMP_TO_TERRAIN ) ); - comboBoxAltitudeClamping->addItem( tr( "Relative" ), static_cast( osgEarth::Symbology::AltitudeSymbol::CLAMP_RELATIVE_TO_TERRAIN ) ); - comboBoxAltitudeClamping->addItem( tr( "Absolute" ), static_cast( osgEarth::Symbology::AltitudeSymbol::CLAMP_ABSOLUTE ) ); - comboBoxAltitudeClamping->setItemData( 0, tr( "Do not clamp Z values to the terrain (but still apply the offset, if applicable)" ), Qt::ToolTipRole ); - comboBoxAltitudeClamping->setItemData( 1, tr( "Sample the terrain under the point, and set the feature's Z to the terrain height, ignoring the feature's original Z value" ), Qt::ToolTipRole ); - comboBoxAltitudeClamping->setItemData( 2, tr( "Sample the terrain under the point, and add the terrain height to the feature's original Z value" ), Qt::ToolTipRole ); - comboBoxAltitudeClamping->setItemData( 3, tr( "The feature's Z value describes its height above \"height zero\", which is typically the ellipsoid or MSL" ), Qt::ToolTipRole ); - comboBoxAltitudeClamping->setCurrentIndex( -1 ); - - comboBoxAltitudeTechnique->addItem( tr( "Map" ), static_cast( osgEarth::Symbology::AltitudeSymbol::TECHNIQUE_MAP ) ); - comboBoxAltitudeTechnique->addItem( tr( "Drape" ), static_cast( osgEarth::Symbology::AltitudeSymbol::TECHNIQUE_DRAPE ) ); - comboBoxAltitudeTechnique->addItem( tr( "GPU" ), static_cast( osgEarth::Symbology::AltitudeSymbol::TECHNIQUE_GPU ) ); - comboBoxAltitudeTechnique->addItem( tr( "Scene" ), static_cast( osgEarth::Symbology::AltitudeSymbol::TECHNIQUE_SCENE ) ); - comboBoxAltitudeTechnique->setItemData( 0, tr( "Clamp geometry to the map model's elevation data" ), Qt::ToolTipRole ); - comboBoxAltitudeTechnique->setItemData( 1, tr( "Clamp geometry to the terrain's scene graph" ), Qt::ToolTipRole ); - comboBoxAltitudeTechnique->setItemData( 2, tr( "Clamp geometry to the terrain as they are rendered by the GPU" ), Qt::ToolTipRole ); - comboBoxAltitudeTechnique->setItemData( 3, tr( "Clamp geometry at draw time using projective texturing" ), Qt::ToolTipRole ); - comboBoxAltitudeTechnique->setCurrentIndex( -1 ); - - comboBoxAltitudeBinding->addItem( tr( "Vertex" ), static_cast( osgEarth::Symbology::AltitudeSymbol::BINDING_VERTEX ) ); - comboBoxAltitudeBinding->addItem( tr( "Centroid" ), static_cast( osgEarth::Symbology::AltitudeSymbol::BINDING_CENTROID ) ); - comboBoxAltitudeBinding->setItemData( 0, tr( "Clamp every vertex independently" ), Qt::ToolTipRole ); - comboBoxAltitudeBinding->setItemData( 1, tr( "Clamp to the centroid of the entire geometry" ), Qt::ToolTipRole ); - comboBoxAltitudeBinding->setCurrentIndex( -1 ); - - // Connect signals (setCurrentIndex(-1) above ensures the signal is called when the current values are set below) - connect( comboBoxRenderingMode, SIGNAL( currentIndexChanged( int ) ), this, SLOT( showRenderingModeWidget( int ) ) ); - connect( comboBoxAltitudeClamping, SIGNAL( currentIndexChanged( int ) ), this, SLOT( onAltitudeClampingChanged( int ) ) ); - connect( comboBoxAltitudeTechnique, SIGNAL( currentIndexChanged( int ) ), this, SLOT( onAltituteTechniqueChanged( int ) ) ); - - // Set values - QgsGlobeVectorLayerConfig *layerConfig = QgsGlobeVectorLayerConfig::getConfig( mLayer ); - - comboBoxRenderingMode->setCurrentIndex( comboBoxRenderingMode->findData( static_cast( layerConfig->renderingMode ) ) ); - - comboBoxAltitudeClamping->setCurrentIndex( comboBoxAltitudeClamping->findData( static_cast( layerConfig->altitudeClamping ) ) ); - comboBoxAltitudeTechnique->setCurrentIndex( comboBoxAltitudeTechnique->findData( static_cast( layerConfig->altitudeTechnique ) ) ); - comboBoxAltitudeBinding->setCurrentIndex( comboBoxAltitudeBinding->findData( static_cast( layerConfig->altitudeBinding ) ) ); - - spinBoxAltitudeOffset->setValue( layerConfig->verticalOffset ); - spinBoxAltitudeScale->setValue( layerConfig->verticalScale ); - spinBoxAltitudeResolution->setValue( layerConfig->clampingResolution ); - - groupBoxExtrusion->setChecked( layerConfig->extrusionEnabled ); - labelExtrusionHeight->setText( layerConfig->extrusionHeight ); - checkBoxExtrusionFlatten->setChecked( layerConfig->extrusionFlatten ); - spinBoxExtrusionWallGradient->setValue( layerConfig->extrusionWallGradient ); - -#if OSGEARTH_VERSION_LESS_THAN(2, 7, 0) || OSGEARTH_VERSION_GREATER_THAN(2, 9, 0) - groupBoxLabelingEnabled->setChecked( layerConfig->labelingEnabled ); - checkBoxLabelingDeclutter->setChecked( layerConfig->labelingDeclutter ); -#else - // labeling broken with osgEarth 2.8 - groupBoxLabelingEnabled->setChecked( false ); - checkBoxLabelingDeclutter->setChecked( false ); - groupBoxLabelingEnabled->setVisible( false ); - checkBoxLabelingDeclutter->setVisible( false ); -#endif - - checkBoxLighting->setChecked( layerConfig->lightingEnabled ); -} - -void QgsGlobeVectorLayerPropertiesPage::apply() -{ - QgsGlobeVectorLayerConfig *layerConfig = QgsGlobeVectorLayerConfig::getConfig( mLayer ); - - layerConfig->renderingMode = static_cast( comboBoxRenderingMode->currentData().toInt() ); - layerConfig->altitudeClamping = static_cast( comboBoxAltitudeClamping->currentData().toInt() ); - layerConfig->altitudeTechnique = static_cast( comboBoxAltitudeTechnique->currentData().toInt() ); - layerConfig->altitudeBinding = static_cast( comboBoxAltitudeBinding->currentData().toInt() ); - - layerConfig->verticalOffset = spinBoxAltitudeOffset->value(); - layerConfig->verticalScale = spinBoxAltitudeScale->value(); - layerConfig->clampingResolution = spinBoxAltitudeResolution->value(); - - layerConfig->extrusionEnabled = groupBoxExtrusion->isChecked(); - layerConfig->extrusionHeight = labelExtrusionHeight->text(); - layerConfig->extrusionFlatten = checkBoxExtrusionFlatten->isChecked(); - layerConfig->extrusionWallGradient = spinBoxExtrusionWallGradient->value(); - - layerConfig->labelingEnabled = groupBoxLabelingEnabled->isChecked(); - layerConfig->labelingDeclutter = checkBoxLabelingDeclutter->isChecked(); - - layerConfig->lightingEnabled = checkBoxLighting->isChecked(); - - emit layerSettingsChanged( mLayer ); -} - -void QgsGlobeVectorLayerPropertiesPage::onAltitudeClampingChanged( int index ) -{ - osgEarth::Symbology::AltitudeSymbol::Clamping clamping = static_cast( comboBoxAltitudeClamping->itemData( index ).toInt() ); - - bool terrainClamping = clamping == osgEarth::Symbology::AltitudeSymbol::CLAMP_TO_TERRAIN; - labelAltitudeTechnique->setVisible( terrainClamping ); - comboBoxAltitudeTechnique->setVisible( terrainClamping ); - onAltituteTechniqueChanged( comboBoxAltitudeTechnique->currentIndex() ); -} - -void QgsGlobeVectorLayerPropertiesPage::onAltituteTechniqueChanged( int index ) -{ - osgEarth::Symbology::AltitudeSymbol::Clamping clamping = static_cast( comboBoxAltitudeClamping->currentData().toInt() ); - osgEarth::Symbology::AltitudeSymbol::Technique technique = static_cast( comboBoxAltitudeTechnique->itemData( index ).toInt() ); - - bool mapTechnique = technique == osgEarth::Symbology::AltitudeSymbol::TECHNIQUE_MAP && clamping == osgEarth::Symbology::AltitudeSymbol::CLAMP_TO_TERRAIN; - labelAltitudeBinding->setVisible( mapTechnique ); - comboBoxAltitudeBinding->setVisible( mapTechnique ); - labelAltitudeResolution->setVisible( mapTechnique ); - spinBoxAltitudeResolution->setVisible( mapTechnique ); -} - -void QgsGlobeVectorLayerPropertiesPage::showRenderingModeWidget( int index ) -{ - stackedWidgetRenderingMode->setCurrentIndex( index != 0 ); - bool advanced = index == 2; - groupBoxAltitude->setVisible( advanced ); - checkBoxLighting->setVisible( advanced ); - checkBoxExtrusionFlatten->setVisible( advanced ); - if ( !advanced ) - { - comboBoxAltitudeClamping->setCurrentIndex( comboBoxAltitudeClamping->findData( static_cast( osgEarth::Symbology::AltitudeSymbol::CLAMP_TO_TERRAIN ) ) ); - comboBoxAltitudeTechnique->setCurrentIndex( comboBoxAltitudeTechnique->findData( static_cast( osgEarth::Symbology::AltitudeSymbol::TECHNIQUE_GPU ) ) ); - spinBoxAltitudeResolution->setValue( 0 ); - spinBoxAltitudeOffset->setValue( 0 ); - spinBoxAltitudeScale->setValue( 0 ); - checkBoxExtrusionFlatten->setChecked( false ); - } -} - -/////////////////////////////////////////////////////////////////////////////// - -QgsGlobeLayerPropertiesFactory::QgsGlobeLayerPropertiesFactory( QObject *parent ) - : QObject( parent ) -{ - connect( QgsProject::instance(), SIGNAL( readMapLayer( QgsMapLayer *, QDomElement ) ), this, SLOT( readGlobeVectorLayerConfig( QgsMapLayer *, QDomElement ) ) ); - connect( QgsProject::instance(), SIGNAL( writeMapLayer( QgsMapLayer *, QDomElement &, QDomDocument & ) ), this, SLOT( writeGlobeVectorLayerConfig( QgsMapLayer *, QDomElement &, QDomDocument & ) ) ); -} - -QgsMapLayerConfigWidget *QgsGlobeLayerPropertiesFactory::createWidget( QgsMapLayer *layer, QgsMapCanvas *canvas, bool dockWidget, QWidget *parent ) const -{ - Q_UNUSED( dockWidget ) - QgsGlobeVectorLayerPropertiesPage *propsPage = new QgsGlobeVectorLayerPropertiesPage( qobject_cast( layer ), canvas, parent ); - connect( propsPage, SIGNAL( layerSettingsChanged( QgsMapLayer * ) ), this, SIGNAL( layerSettingsChanged( QgsMapLayer * ) ) ); - return propsPage; -} - -QIcon QgsGlobeLayerPropertiesFactory::icon() const -{ - return QIcon( ":/globe/icon.svg" ); -} - -QString QgsGlobeLayerPropertiesFactory::title() const -{ - return tr( "Globe" ); -} - -bool QgsGlobeLayerPropertiesFactory::supportsLayer( QgsMapLayer *layer ) const -{ - return layer->type() == QgsMapLayerType::VectorLayer; -} - -void QgsGlobeLayerPropertiesFactory::readGlobeVectorLayerConfig( QgsMapLayer *mapLayer, const QDomElement &elem ) -{ - if ( qobject_cast( mapLayer ) ) - { - QgsVectorLayer *vLayer = static_cast( mapLayer ); - QgsGlobeVectorLayerConfig *config = QgsGlobeVectorLayerConfig::getConfig( vLayer ); - - QDomElement globeElem = elem.firstChildElement( "globe" ); - if ( !globeElem.isNull() ) - { - QDomElement renderingModeElem = globeElem.firstChildElement( "renderingMode" ); - config->renderingMode = static_cast( renderingModeElem.attribute( "mode" ).toInt() ); - - QDomElement modelRenderingElem = globeElem.firstChildElement( "modelRendering" ); - if ( !modelRenderingElem.isNull() ) - { - QDomElement altitudeElem = modelRenderingElem.firstChildElement( "altitude" ); - config->altitudeClamping = static_cast( altitudeElem.attribute( "clamping" ).toInt() ); - config->altitudeTechnique = static_cast( altitudeElem.attribute( "technique" ).toInt() ); - config->altitudeBinding = static_cast( altitudeElem.attribute( "binding" ).toInt() ); - config->verticalOffset = altitudeElem.attribute( "verticalOffset" ).toFloat(); - config->verticalScale = altitudeElem.attribute( "verticalScale" ).toFloat(); - config->clampingResolution = altitudeElem.attribute( "clampingResolution" ).toFloat(); - - QDomElement extrusionElem = modelRenderingElem.firstChildElement( "extrusion" ); - config->extrusionEnabled = extrusionElem.attribute( "enabled" ).toInt() == 1; - config->extrusionHeight = extrusionElem.attribute( "height", QString( "10" ) ).trimmed(); - if ( config->extrusionHeight.isEmpty() ) - config->extrusionHeight = "10"; - config->extrusionFlatten = extrusionElem.attribute( "flatten" ).toInt() == 1; - config->extrusionWallGradient = extrusionElem.attribute( "wall-gradient" ).toDouble(); - - QDomElement labelingElem = modelRenderingElem.firstChildElement( "labeling" ); - config->labelingEnabled = labelingElem.attribute( "enabled", "0" ).toInt() == 1; - config->labelingField = labelingElem.attribute( "field" ); - config->labelingDeclutter = labelingElem.attribute( "declutter", "1" ).toInt() == 1; - - config->lightingEnabled = modelRenderingElem.attribute( "lighting", "1" ).toInt() == 1; - } - } - } -} - -void QgsGlobeLayerPropertiesFactory::writeGlobeVectorLayerConfig( QgsMapLayer *mapLayer, QDomElement &elem, QDomDocument &doc ) -{ - if ( qobject_cast( mapLayer ) ) - { - QgsVectorLayer *vLayer = static_cast( mapLayer ); - QgsGlobeVectorLayerConfig *config = QgsGlobeVectorLayerConfig::getConfig( vLayer ); - - QDomElement globeElem = doc.createElement( "globe" ); - - QDomElement renderingModeElem = doc.createElement( "renderingMode" ); - renderingModeElem.setAttribute( "mode", config->renderingMode ); - globeElem.appendChild( renderingModeElem ); - - QDomElement modelRenderingElem = doc.createElement( "modelRendering" ); - - QDomElement altitudeElem = doc.createElement( "altitude" ); - altitudeElem.setAttribute( "clamping", config->altitudeClamping ); - altitudeElem.setAttribute( "technique", config->altitudeTechnique ); - altitudeElem.setAttribute( "binding", config->altitudeBinding ); - altitudeElem.setAttribute( "verticalOffset", config->verticalOffset ); - altitudeElem.setAttribute( "verticalScale", config->verticalScale ); - altitudeElem.setAttribute( "clampingResolution", config->clampingResolution ); - modelRenderingElem.appendChild( altitudeElem ); - - QDomElement extrusionElem = doc.createElement( "extrusion" ); - extrusionElem.setAttribute( "enabled", config->extrusionEnabled ); - extrusionElem.setAttribute( "height", config->extrusionHeight ); - extrusionElem.setAttribute( "flatten", config->extrusionFlatten ); - extrusionElem.setAttribute( "wall-gradient", config->extrusionWallGradient ); - modelRenderingElem.appendChild( extrusionElem ); - - QDomElement labelingElem = doc.createElement( "labeling" ); - labelingElem.setAttribute( "enabled", config->labelingEnabled ); - labelingElem.setAttribute( "field", config->labelingField ); - labelingElem.setAttribute( "declutter", config->labelingDeclutter ); - modelRenderingElem.appendChild( labelingElem ); - - modelRenderingElem.setAttribute( "lighting", config->lightingEnabled ); - - globeElem.appendChild( modelRenderingElem ); - - elem.appendChild( globeElem ); - } -} diff --git a/src/plugins/globe/qgsglobevectorlayerproperties.h b/src/plugins/globe/qgsglobevectorlayerproperties.h deleted file mode 100644 index 00eba7ccf3e..00000000000 --- a/src/plugins/globe/qgsglobevectorlayerproperties.h +++ /dev/null @@ -1,133 +0,0 @@ -/*************************************************************************** - qgsglobevectorlayerproperties.h - -------------------------------------- - Date : 9.7.2013 - Copyright : (C) 2013 Matthias Kuhn - Email : matthias dot kuhn at gmx dot ch - *************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ - -#ifndef QGSGLOBEVECTORLAYERPROPERTIES_H -#define QGSGLOBEVECTORLAYERPROPERTIES_H - -#include - -#include "ui_qgsglobevectorlayerpropertiespage.h" -#include "qgsmaplayerconfigwidget.h" -#include "qgsmaplayerconfigwidgetfactory.h" -#include - -class QgsGlobeVectorLayerConfig; -class QgsMapLayer; -class QgsVectorLayer; -class QDomDocument; -class QDomElement; -class QListWidgetItem; - -class QgsGlobeVectorLayerConfig : public QObject -{ - Q_OBJECT - public: - enum RenderingMode - { - RenderingModeRasterized, - RenderingModeModelSimple, - RenderingModeModelAdvanced - }; - - QgsGlobeVectorLayerConfig( QObject *parent = nullptr ) - : QObject( parent ) - , renderingMode( RenderingModeRasterized ) - , altitudeClamping( osgEarth::Symbology::AltitudeSymbol::CLAMP_TO_TERRAIN ) - , altitudeTechnique( osgEarth::Symbology::AltitudeSymbol::TECHNIQUE_DRAPE ) - , altitudeBinding( osgEarth::Symbology::AltitudeSymbol::BINDING_VERTEX ) - , verticalOffset( 0.0 ) - , verticalScale( 0.0 ) - , clampingResolution( 0.0 ) - , extrusionEnabled( false ) - , extrusionHeight( "10" ) - , extrusionFlatten( false ) - , extrusionWallGradient( 0.5 ) - , labelingEnabled( false ) - , labelingDeclutter( false ) - , lightingEnabled( true ) - { - } - - RenderingMode renderingMode; - osgEarth::Symbology::AltitudeSymbol::Clamping altitudeClamping; - osgEarth::Symbology::AltitudeSymbol::Technique altitudeTechnique; - osgEarth::Symbology::AltitudeSymbol::Binding altitudeBinding; - - float verticalOffset; - float verticalScale; - float clampingResolution; - - bool extrusionEnabled; - QString extrusionHeight; - bool extrusionFlatten; - float extrusionWallGradient; - - bool labelingEnabled; - QString labelingField; - bool labelingDeclutter; - - bool lightingEnabled; - - static QgsGlobeVectorLayerConfig *getConfig( QgsVectorLayer *layer ); -}; - - -class QgsGlobeVectorLayerPropertiesPage : public QgsMapLayerConfigWidget, private Ui::QgsGlobeVectorLayerPropertiesPage -{ - Q_OBJECT - - public: - explicit QgsGlobeVectorLayerPropertiesPage( QgsVectorLayer *layer, QgsMapCanvas *canvas, QWidget *parent = nullptr ); - - public slots: - virtual void apply(); - - private slots: - void onAltitudeClampingChanged( int index ); - void onAltituteTechniqueChanged( int index ); - void showRenderingModeWidget( int index ); - - signals: - void layerSettingsChanged( QgsMapLayer * ); - - private: - QgsVectorLayer *mLayer = nullptr; -}; - - -class QgsGlobeLayerPropertiesFactory : public QObject, public QgsMapLayerConfigWidgetFactory -{ - Q_OBJECT - public: - explicit QgsGlobeLayerPropertiesFactory( QObject *parent = nullptr ); - QgsMapLayerConfigWidget *createWidget( QgsMapLayer *layer, QgsMapCanvas *canvas, bool dockWidget, QWidget *parent ) const override; - - QIcon icon() const override; - - QString title() const override; - - bool supportLayerPropertiesDialog() const override { return true; } - - bool supportsLayer( QgsMapLayer *layer ) const override; - - signals: - void layerSettingsChanged( QgsMapLayer *layer ); - - private slots: - void readGlobeVectorLayerConfig( QgsMapLayer *mapLayer, const QDomElement &elem ); - void writeGlobeVectorLayerConfig( QgsMapLayer *mapLayer, QDomElement &elem, QDomDocument &doc ); -}; - -#endif // QGSGLOBEVECTORLAYERPROPERTIES_H diff --git a/src/plugins/globe/qgsglobevectorlayerpropertiespage.ui b/src/plugins/globe/qgsglobevectorlayerpropertiespage.ui deleted file mode 100644 index fa008ef8c9b..00000000000 --- a/src/plugins/globe/qgsglobevectorlayerpropertiespage.ui +++ /dev/null @@ -1,272 +0,0 @@ - - - QgsGlobeVectorLayerPropertiesPage - - - - 0 - 0 - 446 - 580 - - - - Form - - - - - - 1 - - - - - - - - - - Altitude - - - - - - Terrain following behavior - - - Clamping - - - - - - - Terrain following behavior - - - - - - - Terrain following technique - - - Technique - - - - - - - Granularity at which to sample the terrain - - - Binding - - - - - - - Elevation data resolution at which to sample terrain height - - - Resolution - - - - - - - Vertical offset to apply to geometry Z - - - Offset - - - - - - - Scale factor to apply to geometry Z - - - Scale - - - - - - - Terrain following technique - - - - - - - Granularity at which to sample the terrain - - - - - - - Elevation data resolution at which to sample terrain height - - - - - - - Vertical offset to apply to geometry Z - - - - - - - Scale factor to apply to geometry Z - - - - - - - - - - E&xtrusion - - - true - - - - QFormLayout::AllNonFixedFieldsGrow - - - - - Height [m] - - - - - - - Extrusion height, either a numeric value, or a field expression - - - 0 - - - - - - - Wall gradient - - - - - - - Wall coloring gradient - - - 1.000000000000000 - - - 0.100000000000000 - - - 0.500000000000000 - - - - - - - Whether the top cap of the extruded geometry should be flat - - - Flatten - - - - - - - - - - Enable &labeling - - - true - - - - - - Declutter - - - - - - - - - - Lighting - - - - - - - - - - - Rendering mode: - - - - - - - Rendering method for the layer - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - QgsMapLayerConfigWidget - QWidget -
qgsmaplayerconfigwidget.h
- 1 -
-
- - -
diff --git a/src/plugins/globe/qgsglobewidget.cpp b/src/plugins/globe/qgsglobewidget.cpp deleted file mode 100644 index 37834b42983..00000000000 --- a/src/plugins/globe/qgsglobewidget.cpp +++ /dev/null @@ -1,152 +0,0 @@ -/*************************************************************************** - qgsglobewidget.cpp - --------------------- - begin : August 2016 - copyright : (C) 2016 Sandro Mani - email : smani at sourcepole dot ch - *************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ - -#include "qgsglobewidget.h" -#include "qgsmapcanvas.h" -#include "qgsmaplayer.h" -#include "qgsproject.h" -#include "qgsrasterlayer.h" -#include "qgisinterface.h" -#include "layertree/qgslayertree.h" - -#include -#include -#include -#include -#include - -QgsGlobeWidget::QgsGlobeWidget( QgisInterface *iface, QWidget *parent ) - : QDockWidget( tr( "Globe" ), parent ), mQgisIface( iface ) -{ - setWindowTitle( tr( "Globe" ) ); - - QToolButton *layerSelectionButton = new QToolButton( this ); - layerSelectionButton->setAutoRaise( true ); - layerSelectionButton->setText( tr( "Layers" ) ); - layerSelectionButton->setPopupMode( QToolButton::InstantPopup ); - mLayerSelectionMenu = new QMenu( layerSelectionButton ); - layerSelectionButton->setMenu( mLayerSelectionMenu ); - - QToolButton *syncButton = new QToolButton( this ); - syncButton->setAutoRaise( true ); - syncButton->setToolTip( tr( "Sync extent" ) ); - syncButton->setIcon( QIcon( ":/images/themes/default/sync_views.svg" ) ); - syncButton->setIconSize( QSize( 16, 16 ) ); - connect( syncButton, SIGNAL( clicked() ), this, SIGNAL( syncExtent() ) ); - - QToolButton *refreshButton = new QToolButton( this ); - refreshButton->setAutoRaise( true ); - refreshButton->setToolTip( tr( "Reload scene" ) ); - refreshButton->setIcon( QIcon( ":/images/themes/default/mActionReload.svg" ) ); - refreshButton->setIconSize( QSize( 16, 16 ) ); - connect( refreshButton, SIGNAL( clicked() ), this, SIGNAL( refresh() ) ); - - QToolButton *settingsButton = new QToolButton( this ); - settingsButton->setAutoRaise( true ); - settingsButton->setToolTip( tr( "Globe settings" ) ); - settingsButton->setIcon( QIcon( ":/images/themes/default/mActionOptions.svg" ) ); - settingsButton->setIconSize( QSize( 16, 16 ) ); - connect( settingsButton, SIGNAL( clicked() ), this, SIGNAL( showSettings() ) ); - - QToolButton *closeButton = new QToolButton( this ); - closeButton->setAutoRaise( true ); - closeButton->setIcon( QIcon( ":/images/themes/default/mActionRemove.svg" ) ); - closeButton->setIconSize( QSize( 12, 12 ) ); - closeButton->setToolTip( tr( "Close" ) ); - connect( closeButton, SIGNAL( clicked( bool ) ), this, SLOT( deleteLater() ) ); - - QWidget *titleWidget = new QWidget( this ); - titleWidget->setObjectName( "globeTitleWidget" ); - titleWidget->setLayout( new QHBoxLayout() ); - titleWidget->layout()->addWidget( layerSelectionButton ); - titleWidget->layout()->addWidget( syncButton ); - titleWidget->layout()->addWidget( refreshButton ); - titleWidget->layout()->addWidget( settingsButton ); - static_cast( titleWidget->layout() )->addWidget( new QWidget( this ), 1 ); // spacer - titleWidget->layout()->addWidget( new QLabel( tr( "Globe" ) ) ); - static_cast( titleWidget->layout() )->addWidget( new QWidget( this ), 1 ); // spacer - titleWidget->layout()->addWidget( closeButton ); - titleWidget->layout()->setContentsMargins( 0, 0, 0, 0 ); - - setTitleBarWidget( titleWidget ); - setMinimumSize( 128, 128 ); - setAttribute( Qt::WA_DeleteOnClose ); - - connect( mQgisIface->mapCanvas(), SIGNAL( layersChanged() ), this, SLOT( updateLayerSelectionMenu() ) ); - connect( QgsProject::instance(), SIGNAL( layersAdded( QList ) ), this, SLOT( updateLayerSelectionMenu() ) ); - connect( QgsProject::instance(), SIGNAL( layerRemoved( QString ) ), this, SLOT( updateLayerSelectionMenu() ) ); - - updateLayerSelectionMenu(); -} - -void QgsGlobeWidget::updateLayerSelectionMenu() -{ - QStringList prevLayers; - QStringList prevDisabledLayerIds; - QStringList prevEnabledLayerIds; - for ( QAction *action : mLayerSelectionMenu->actions() ) - { - prevLayers.append( action->data().toString() ); - if ( !action->isChecked() ) - { - prevDisabledLayerIds.append( action->data().toString() ); - } - else - { - prevEnabledLayerIds.append( action->data().toString() ); - } - } - - mLayerSelectionMenu->clear(); - QString heightmap = QgsProject::instance()->readEntry( "Heightmap", "layer" ); - // Use layerTreeRoot to get layers ordered as in the layer tree - for ( QgsLayerTreeLayer *layerTreeLayer : QgsProject::instance()->layerTreeRoot()->findLayers() ) - { - QgsMapLayer *layer = layerTreeLayer->layer(); - if ( !layer ) - continue; - QAction *layerAction = new QAction( layer->name(), mLayerSelectionMenu ); - layerAction->setData( layer->id() ); - // Check if was not previously unchecked, unless it is a new layer with url=http in datasource - layerAction->setCheckable( true ); - bool wasUnchecked = prevDisabledLayerIds.contains( layer->id() ); - bool isNew = !prevLayers.contains( layer->id() ); - bool isRemote = layer->source().contains( "url=http" ); - bool isHeightmap = layer->id() == heightmap; - layerAction->setChecked( !wasUnchecked && !( isNew && ( isRemote || isHeightmap ) ) ); - connect( layerAction, SIGNAL( toggled( bool ) ), this, SIGNAL( layersChanged() ) ); - mLayerSelectionMenu->addAction( layerAction ); - } - if ( prevEnabledLayerIds != getSelectedLayerIds() ) - emit layersChanged(); -} - -QStringList QgsGlobeWidget::getSelectedLayerIds() const -{ - QStringList selectedLayerIds; - for ( QAction *layerAction : mLayerSelectionMenu->actions() ) - { - if ( layerAction->isChecked() ) - { - selectedLayerIds.append( layerAction->data().toString() ); - } - } - return selectedLayerIds; -} - -void QgsGlobeWidget::contextMenuEvent( QContextMenuEvent *e ) -{ - e->accept(); -} diff --git a/src/plugins/globe/qgsglobewidget.h b/src/plugins/globe/qgsglobewidget.h deleted file mode 100644 index 6a29996c064..00000000000 --- a/src/plugins/globe/qgsglobewidget.h +++ /dev/null @@ -1,43 +0,0 @@ -/*************************************************************************** - qgsglobewidget.h - --------------------- - begin : August 2016 - copyright : (C) 2016 Sandro Mani - email : smani at sourcepole dot ch - *************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ - -#include - -class QgisInterface; -class QgsGlobePlugin; -class QMenu; - -class QgsGlobeWidget : public QDockWidget -{ - Q_OBJECT - public: - QgsGlobeWidget( QgisInterface *iface, QWidget *parent = nullptr ); - QStringList getSelectedLayerIds() const; - - signals: - void layersChanged(); - void showSettings(); - void refresh(); - void syncExtent(); - - private: - QgisInterface *mQgisIface = nullptr; - QMenu *mLayerSelectionMenu = nullptr; - - void contextMenuEvent( QContextMenuEvent *e ) override; - - private slots: - void updateLayerSelectionMenu(); -}; diff --git a/src/plugins/globe/qgsosgfeature.cpp b/src/plugins/globe/qgsosgfeature.cpp deleted file mode 100644 index f922d6d6c78..00000000000 --- a/src/plugins/globe/qgsosgfeature.cpp +++ /dev/null @@ -1,20 +0,0 @@ -/*************************************************************************** - qgsosgfeature.cpp - -------------------------------------- - Date : 11.7.2013 - Copyright : (C) 2013 Matthias Kuhn - Email : matthias dot kuhn at gmx dot ch - *************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ - -#include "qgsosgfeature.h" - -QgsOsgFeature::QgsOsgFeature() -{ -} diff --git a/src/plugins/globe/qgsosgfeature.h b/src/plugins/globe/qgsosgfeature.h deleted file mode 100644 index cee86f9469e..00000000000 --- a/src/plugins/globe/qgsosgfeature.h +++ /dev/null @@ -1,25 +0,0 @@ -/*************************************************************************** - qgsosgfeature.h - -------------------------------------- - Date : 11.7.2013 - Copyright : (C) 2013 Matthias Kuhn - Email : matthias dot kuhn at gmx dot ch - *************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ - -#ifndef QGSOSGFEATURE_H -#define QGSOSGFEATURE_H - -class QgsOsgFeature : public Feature -{ - public: - QgsOsgFeature(); -}; - -#endif // QGSOSGFEATURE_H