Drop Globe plugin

Dropping Globe plugin from the QGIS sources. It depends on osgearth no
newer than version 2.8, released on 2016-09-05, and which is impossible
to build against modern (Qt 5.13+) versions of Qt. With this, the
optional QGIS dependency on OpenSceneGraph and osgearth is also removed.
This commit is contained in:
José de Paula Rodrigues Neto Assis 2020-05-20 21:21:48 -03:00 committed by Nyall Dawson
parent 817f194890
commit c91e0e8450
69 changed files with 0 additions and 6359 deletions

View File

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

View File

@ -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 <osgEarth/Common>
# #include <osgEarth/TileSource>
###### 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 <osgEarthUtil/Controls>
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 )

View File

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

1
debian/rules vendored
View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -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 <osg/PositionAttitudeTransform>
# #include <osgUtil/SceneView>
###### 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 )

View File

@ -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 <OpenThreads/Thread>
# 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)

View File

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

View File

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

View File

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

View File

@ -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 <osgEarthFeatures/FeatureCursor>
#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

View File

@ -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 <http://www.gnu.org/licenses/>
*/
#ifndef QGSGLOBEFEATUREOPTIONS_H
#define QGSGLOBEFEATUREOPTIONS_H
#include <osgEarth/Common>
#include <osgEarthFeatures/FeatureSource>
class QgsVectorLayer;
class QgsGlobeFeatureOptions : public osgEarth::Features::FeatureSourceOptions // NO EXPORT; header only
{
private:
template <class T>
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<std::string> &layerId() { return mLayerId; }
const osgEarth::optional<std::string> &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<std::string> mLayerId;
QgsVectorLayer *mLayer = nullptr;
};
#endif // QGSGLOBEFEATUREOPTIONS_H

View File

@ -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 <osgDB/ReaderWriter>
#include <osgDB/FileNameUtils>
#include <qgsfeature.h>
#include <qgsfeatureiterator.h>
#include <qgsgeometry.h>
#include <qgslogger.h>
#include <qgsrectangle.h>
#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<osgEarth::Features::Feature>( feature ) ) );
}
else
{
it->second = osg::observer_ptr<osgEarth::Features::Feature>( 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 )

View File

@ -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 <osgEarthFeatures/FeatureSource>
#include <osgEarth/Version>
#include <QObject>
#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<osgEarth::Features::FeatureID, osg::observer_ptr<osgEarth::Features::Feature> > 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

View File

@ -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 <osgEarthFeatures/Feature>
#include <osg/ValueObject>
#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<osgEarth::Features::Ring>( 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<const QgsPoint *>( geom.constGet() ) ) );
return pointSet;
}
case QgsWkbTypes::MultiPoint:
{
osgEarth::Features::PointSet *pointSet = new osgEarth::Features::PointSet();
const QgsMultiPoint *multiPoint = static_cast<const QgsMultiPoint *>( geom.constGet() );
for ( int i = 0, n = multiPoint->numGeometries(); i < n; ++i )
{
pointSet->push_back( pointFromQgsPoint( *static_cast<const QgsPoint *>( multiPoint->geometryN( i ) ) ) );
}
return pointSet;
}
case QgsWkbTypes::LineString:
case QgsWkbTypes::CircularString:
case QgsWkbTypes::CompoundCurve:
{
return lineStringFromQgsLineString( static_cast<const QgsLineString *>( geom.constGet() ) );
}
case QgsWkbTypes::MultiLineString:
{
osgEarth::Features::MultiGeometry *multiGeometry = new osgEarth::Features::MultiGeometry();
const QgsMultiLineString *multiLineString = static_cast<const QgsMultiLineString *>( geom.constGet() );
for ( int i = 0, n = multiLineString->numGeometries(); i < n; ++i )
{
multiGeometry->getComponents().push_back( lineStringFromQgsLineString( static_cast<const QgsLineString *>( multiLineString->geometryN( i ) ) ) );
}
return multiGeometry;
}
case QgsWkbTypes::Polygon:
case QgsWkbTypes::CurvePolygon:
{
return polygonFromQgsPolygon( static_cast<const QgsPolygon *>( geom.constGet() ) );
}
case QgsWkbTypes::MultiPolygon:
{
osgEarth::Features::MultiGeometry *multiGeometry = new osgEarth::Features::MultiGeometry();
const QgsMultiPolygon *multiPolygon = static_cast<const QgsMultiPolygon *>( geom.constGet() );
for ( int i = 0, n = multiPolygon->numGeometries(); i < n; ++i )
{
multiGeometry->getComponents().push_back( polygonFromQgsPolygon( static_cast<const QgsPolygon *>( 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

File diff suppressed because it is too large Load Diff

View File

@ -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 <QObject>
#include <osg/ref_ptr>
#include <osgEarth/Version>
#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<QgsGlobePluginDialog::LayerDataSource> mImagerySources;
QList<QgsGlobePluginDialog::LayerDataSource> mElevationSources;
double mSelectedLat, mSelectedLon, mSelectedElevation;
osg::ref_ptr<osgViewer::Viewer> mOsgViewer;
osg::ref_ptr<osgEarth::MapNode> mMapNode;
osg::ref_ptr<osg::Group> mRootNode;
osg::ref_ptr<osgEarth::Util::SkyNode> mSkyNode;
osg::ref_ptr<osgEarth::ImageLayer> mBaseLayer;
osg::ref_ptr<osgEarth::ImageLayer> mQgisMapLayer;
osg::ref_ptr<QgsGlobeTileSource> mTileSource;
QMap<QString, QgsRectangle> mLayerExtents;
osg::ref_ptr<osgEarth::Util::VerticalScale> mVerticalScale;
//! Creates additional pages in the layer properties for adjusting 3D properties
QgsGlobeLayerPropertiesFactory *mLayerPropertiesFactory = nullptr;
osg::ref_ptr<QgsGlobeFrustumHighlightCallback> mFrustumHighlightCallback;
osg::ref_ptr<QgsGlobeFeatureIdentifyCallback> mFeatureQueryToolIdentifyCb;
// TODO: How to port highlight to 2.7.0?
#if OSGEARTH_VERSION_LESS_THAN(2, 7, 0)
osg::ref_ptr<osgEarth::Util::FeatureHighlightCallback> mFeatureQueryToolHighlightCb;
#endif
osg::ref_ptr<osgEarth::Util::FeatureQueryTool> mFeatureQueryTool;
osg::ref_ptr<osgEarth::Util::Controls::LabelControl> 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

View File

@ -1,6 +0,0 @@
<RCC>
<qresource prefix="/globe">
<file alias="globe.png">images/globe.png</file>
<file alias="icon.svg">images/icon.svg</file>
</qresource>
</RCC>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 314 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 218 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 563 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 429 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 288 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 475 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 201 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 160 B

View File

@ -1,143 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="64px"
height="64px"
id="svg2996"
version="1.1"
inkscape:version="0.48.4 r9939"
sodipodi:docname="icon.svg">
<defs
id="defs2998">
<linearGradient
id="linearGradient3948">
<stop
style="stop-color:#14c412;stop-opacity:1;"
offset="0"
id="stop3950" />
<stop
style="stop-color:#2fa92d;stop-opacity:1;"
offset="1"
id="stop3952" />
</linearGradient>
<linearGradient
id="linearGradient3860">
<stop
style="stop-color:#cfddee;stop-opacity:1;"
offset="0"
id="stop3862" />
<stop
style="stop-color:#6793cd;stop-opacity:1;"
offset="1"
id="stop3864" />
</linearGradient>
<radialGradient
inkscape:collect="always"
xlink:href="#linearGradient3860"
id="radialGradient3870"
cx="42.630283"
cy="18.727272"
fx="42.630283"
fy="18.727272"
r="31.787046"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(-0.79604311,0,0,-1,87.02645,34.545452)" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient3948"
id="linearGradient3954"
x1="1.8088502"
y1="29.950056"
x2="62.28172"
y2="29.950056"
gradientUnits="userSpaceOnUse" />
</defs>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="11"
inkscape:cx="30.353097"
inkscape:cy="32.680944"
inkscape:current-layer="layer1"
showgrid="true"
inkscape:document-units="px"
inkscape:grid-bbox="true"
inkscape:window-width="1920"
inkscape:window-height="1028"
inkscape:window-x="0"
inkscape:window-y="867"
inkscape:window-maximized="1" />
<metadata
id="metadata3001">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
</cc:Work>
</rdf:RDF>
</metadata>
<g
id="layer1"
inkscape:label="Layer 1"
inkscape:groupmode="layer">
<path
style="opacity:1;fill:url(#radialGradient3870);fill-opacity:1;fill-rule:evenodd;stroke:#326fcb;stroke-width:2.66500000000000004;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-linejoin:round"
d="m 62.363635,32.454544 c 0,16.819581 -13.63496,30.454546 -30.454545,30.454546 -16.819581,0 -30.4545465,-13.634965 -30.4545465,-30.454546 0,-16.819581 13.6349655,-30.4545464 30.4545465,-30.4545464 16.819585,0 30.454545,13.6349654 30.454545,30.4545464 z"
id="path3036"
inkscape:connector-curvature="0" />
<g
id="g3941"
style="fill:url(#linearGradient3954);fill-opacity:1">
<path
sodipodi:nodetypes="csszszssssssssssc"
inkscape:connector-curvature="0"
id="path3807"
d="m 12.454545,53.090909 c 1.274253,-0.234239 0.987012,-1.887258 1.167988,-3.342749 0.14498,-1.165998 0.94868,-2.074964 0.426375,-2.997098 C 13.206543,45.26386 10.665333,45.173915 10.090909,44.727273 9.5164846,44.28063 6.2081861,39.649018 4.2602054,38.122499 2.7215555,36.916749 2.4418971,38.844949 2.1818184,38 1.9217398,37.155052 1.3372634,30.593092 3.1337285,24.323806 3.5115035,23.00545 7.1602709,22.238388 7.515887,20.991567 7.8164462,19.93778 6.145546,20.97674 6.5045705,19.949524 6.9292731,18.734395 8.5422106,18.772373 8.9712963,17.539473 9.3487965,16.454795 7.2886825,16.299144 7.3366292,14.911299 c 0.047818,-1.384128 2.5672416,-2.909759 3.0101188,-3.832106 0.501632,-1.044709 3.989113,1.131964 4.453467,0.186338 1.360061,-2.7696803 3.77755,-2.9357004 4.238968,-4.6431458 C 20.135902,2.5640536 9.8124841,10.776552 9.5555349,11.098355 -5.3352534,29.747591 5.3140435,47.482146 8.153283,51.536495 c 0.8794239,1.255791 2.256379,1.571058 4.301262,1.554414 z"
style="fill:url(#linearGradient3954);stroke:#000000;stroke-width:0;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;fill-opacity:1;stroke-miterlimit:4;stroke-dasharray:none;opacity:1" />
<path
sodipodi:nodetypes="zssszzsszsssssssssszssssszszzzsssssszzzzssz"
inkscape:connector-curvature="0"
id="path3809"
d="m 27.636364,21.090909 c 0.780036,-0.268848 3.841437,-0.393949 5.865311,0.466598 1.560421,0.663488 1.932626,2.226274 3.705311,2.820447 1.73958,0.583077 1.719271,-1.07816 3.166476,-0.925882 1.979473,0.208285 5.200248,1.909349 5.626538,-0.04298 0.42629,-1.952329 -3.482539,-1.564576 -3.636364,-1.954546 -0.153825,-0.38997 -0.907464,-2.20096 -1.367687,-2.219935 -0.792951,-0.0327 0.05341,1.647316 -0.882662,1.834095 -0.870354,0.173666 -3.564327,-3.908646 -3.749651,-4.114159 -0.185324,-0.205513 -3.658196,-1.030126 0.01227,1.393627 0.660651,0.436254 1.06746,1.248195 0.99089,1.616479 -0.0805,0.387187 -1.377987,-0.797843 -2.012248,-1.182769 -0.568931,-0.345277 -1.250482,-2.173596 -2.841505,-1.6363 -2.980321,1.006469 -4.410452,3.689536 -6.306909,4.235529 -1.803183,0.519139 -2.182124,-2.658666 -1.606749,-3.390722 0.731477,-0.930665 5.771549,0.199111 2.985466,-2.11817 -1.634495,-1.359465 0.951504,-1.857968 2.952757,-2.427455 0.540886,-0.153917 1.479538,-2.697608 2.652906,-2.949768 0.92167,-0.19807 1.977272,1.678944 2.534156,1.538303 2.61531,-0.660493 3.627299,-0.856397 4.138969,-1.669664 C 40.375306,9.5503696 38.831377,9.3355454 38.64865,8.1414392 38.536654,7.4095538 39.959296,6.3562427 38.992557,6.2706175 37.822051,6.1669445 37.22735,10.955693 35.695763,11.099921 34.674286,11.196113 33.201042,9.9657489 32.225228,9.5607789 29.616386,8.4780901 31.824133,7.6684294 34.175191,6.3965729 c 1.748176,-0.9457141 2.377964,-1.780523 6.370263,-1.6693002 3.992299,0.1112228 8.320174,2.5394347 11.552346,4.9160824 3.077189,2.2626879 4.273435,3.9476669 5.674927,5.9475539 1.401492,1.999888 2.5305,4.587181 3.589725,7.834384 1.059224,3.247202 1.320981,5.502969 0.155378,7.463313 -1.165603,1.960344 -1.125444,7.239011 -1.704848,2.703117 -0.687643,-5.383243 -2.822899,-4.992543 -3.649927,-5.46511 -1.684387,-0.962463 -2.790222,-0.440248 -1.184328,0.59583 2.066408,1.333188 -1.199397,3.659878 -2.461262,4.238816 -4.151366,1.904629 -2.566664,-0.580367 -3.554528,-2.528722 -1.266813,-2.498526 -6.400697,-10.413787 -1.731214,0.204992 2.00796,4.56626 6.0178,4.429608 5.495549,5.726108 -0.522251,1.2965 -2.494318,0.151757 -4.636363,5.454545 -2.142044,5.302788 0.550185,7.981654 -6.636364,12.590909 -7.186548,4.609255 -7.004448,-12.805096 -7.103729,-14.598635 -0.09928,-1.793539 -4.961949,-2.510136 -8.446558,-1.524932 -2.274119,0.642963 -5.891641,-5.638639 -5.73453,-7.377525 0.418624,-4.633269 6.6866,-9.548242 7.466636,-9.81709 z"
style="opacity:1;fill:url(#linearGradient3954);fill-opacity:1;stroke:#000000;stroke-width:0;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
<path
sodipodi:nodetypes="zsszszsz"
inkscape:connector-curvature="0"
id="path3807-9"
d="m 26.626118,12.261844 c 0.506237,-0.183147 -0.826308,1.374667 0.633897,1.236797 1.156344,-0.10918 2.903225,-0.302237 2.38092,-1.224371 -0.842365,-1.487202 -1.264763,-0.94766 -1.480726,-1.978334 -0.215963,-1.0306751 -1.366307,-1.8392743 -1.537059,0.148182 -0.05106,0.594306 -1.615575,0.735346 -1.822054,1.161566 -0.206478,0.42622 -0.210556,1.244186 0.150041,1.3492 0.388335,0.113093 1.168743,-0.509893 1.674981,-0.69304 z"
style="opacity:1;fill:url(#linearGradient3954);fill-opacity:1;stroke:#000000;stroke-width:0;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
<path
sodipodi:nodetypes="zzzz"
inkscape:connector-curvature="0"
id="path3807-9-7"
d="M 23.212662,6.8486211 C 24.138782,6.4601476 22.794749,5.6960066 21.162652,6.771003 19.530555,7.8459993 20.48825,7.5611724 20.862716,7.6702259 21.237182,7.7792794 22.286543,7.2370945 23.212662,6.8486211 z"
style="opacity:1;fill:url(#linearGradient3954);fill-opacity:1;stroke:#000000;stroke-width:0;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
<path
sodipodi:nodetypes="zzzz"
inkscape:connector-curvature="0"
id="path3807-9-1"
d="m 49.173839,50.447542 c 1.593614,0.222363 0.694273,-0.948645 2.250125,-4.038377 1.555851,-3.089731 -1.088018,-0.634888 -1.762048,0.59816 -0.674029,1.233047 -2.081692,3.217854 -0.488077,3.440217 z"
style="opacity:1;fill:url(#linearGradient3954);fill-opacity:1;stroke:#000000;stroke-width:0;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
</g>
<path
inkscape:connector-curvature="0"
id="path3858"
d="m 62.363635,32.454544 c 0,16.819581 -13.63496,30.454546 -30.454545,30.454546 -16.819581,0 -30.4545465,-13.634965 -30.4545465,-30.454546 0,-16.819581 13.6349655,-30.4545464 30.4545465,-30.4545464 16.819585,0 30.454545,13.6349654 30.454545,30.4545464 z"
style="opacity:1;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#326fcb;stroke-width:2.66500000000000004;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-linejoin:round" />
</g>
</svg>

Before

Width:  |  Height:  |  Size: 9.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 826 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 836 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 846 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 824 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 942 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 824 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 826 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 824 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 879 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 560 B

Binary file not shown.

View File

@ -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 <osg/ValueObject>
#include <osgEarth/Registry>
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<QgsGlobeFeatureSource *>( index->getFeatureSource() );
if ( globeSource )
{
QgsVectorLayer *lyr = globeSource->layer();
#else
void QgsGlobeFeatureIdentifyCallback::onHit( osgEarth::ObjectID id )
{
osgEarth::Features::FeatureIndex *index = osgEarth::Registry::objectIndex()->get<osgEarth::Features::FeatureIndex>( 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<QgsVectorLayer *>( 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 );
}

View File

@ -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 <osgEarth/Version>
#include <osgEarthUtil/FeatureQueryTool>
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

View File

@ -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 <qgsrubberband.h>
#include <qgsmapcanvas.h>
#include <osg/View>
#include <osgEarth/SpatialReference>
#include <osgEarth/Terrain>
#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<osg::Node *>( object );
osg::NodeVisitor *nv = dynamic_cast<osg::NodeVisitor *>( 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 );
}
}

View File

@ -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 <osg/Callback>
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

View File

@ -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 <QFileDialog>
#include <QInputDialog>
#include <QMessageBox>
#include <QNetworkAccessManager>
#include <QNetworkRequest>
#include <QNetworkReply>
#include <QMenu>
#include <QTimer>
#include <osg/DisplaySettings>
#include <osgViewer/Viewer>
#include <osgEarth/Version>
#include <osgEarthUtil/EarthManipulator>
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<osg::DisplaySettings::StereoMode>( 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<osg::DisplaySettings::SplitStereoVerticalEyeMapping>(
comboBoxSplitStereoVerticalEyeMapping->currentIndex() ) );
osg::DisplaySettings::instance()->setSplitStereoHorizontalSeparation(
spinBoxSplitStereoHorizontalSeparation->value() );
osg::DisplaySettings::instance()->setSplitStereoHorizontalEyeMapping(
static_cast<osg::DisplaySettings::SplitStereoHorizontalEyeMapping>(
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<QAction *>( 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<QAction *>( 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<QAction *>( 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::LayerDataSource> QgsGlobePluginDialog::getImageryDataSources() const
{
int keysCount = QgsProject::instance()->subkeyList( "Globe-Plugin", "/imageryDatasources/" ).count();
QList<LayerDataSource> 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::LayerDataSource> QgsGlobePluginDialog::getElevationDataSources() const
{
int keysCount = QgsProject::instance()->subkeyList( "Globe-Plugin", "/elevationDatasources/" ).count();
QList<LayerDataSource> 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 );
}

View File

@ -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 <QDialog>
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<LayerDataSource> getImageryDataSources() const;
QList<LayerDataSource> 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

View File

@ -1,677 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>QgsGlobePluginDialogGuiBase</class>
<widget class="QDialog" name="QgsGlobePluginDialogGuiBase">
<property name="enabled">
<bool>true</bool>
</property>
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>748</width>
<height>519</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="windowTitle">
<string>Globe Settings</string>
</property>
<property name="windowIcon">
<iconset>
<normaloff>../../.designer/backup</normaloff>../../.designer/backup</iconset>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="2" column="0">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="tabMap">
<attribute name="title">
<string>Map</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_4">
<item row="2" column="0">
<widget class="QGroupBox" name="groupBoxSky">
<property name="title">
<string>Sk&amp;y</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<layout class="QFormLayout" name="formLayout_3">
<item row="1" column="0">
<widget class="QCheckBox" name="checkBoxDateTime">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Override Date / Time (UTC)</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QDateTimeEdit" name="dateTimeEditSky">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="displayFormat">
<string>dd.MM.yyyy HH:mm</string>
</property>
<property name="calendarPopup">
<bool>true</bool>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QCheckBox" name="checkBoxSkyAutoAmbient">
<property name="text">
<string>Ambient lighting</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QSlider" name="horizontalSliderMinAmbient">
<property name="enabled">
<bool>false</bool>
</property>
<property name="maximum">
<number>100</number>
</property>
<property name="value">
<number>50</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="invertedControls">
<bool>false</bool>
</property>
<property name="tickPosition">
<enum>QSlider::NoTicks</enum>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="0" column="0">
<widget class="QGroupBox" name="mImageryGroupBox">
<property name="title">
<string>Imagery</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QTreeWidget" name="mImageryTreeView">
<property name="dragEnabled">
<bool>true</bool>
</property>
<property name="dragDropMode">
<enum>QAbstractItemView::InternalMove</enum>
</property>
<property name="indentation">
<number>0</number>
</property>
<property name="uniformRowHeights">
<bool>true</bool>
</property>
<property name="allColumnsShowFocus">
<bool>true</bool>
</property>
<property name="columnCount">
<number>2</number>
</property>
<attribute name="headerVisible">
<bool>false</bool>
</attribute>
<attribute name="headerDefaultSectionSize">
<number>50</number>
</attribute>
<column>
<property name="text">
<string notr="true">1</string>
</property>
</column>
<column>
<property name="text">
<string notr="true">2</string>
</property>
</column>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QToolButton" name="mAddImageryButton">
<property name="text">
<string>Add</string>
</property>
<property name="popupMode">
<enum>QToolButton::InstantPopup</enum>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="mRemoveImageryButton">
<property name="text">
<string>Remove</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item row="3" column="0">
<spacer name="verticalSpacerMapTab">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0">
<widget class="QGroupBox" name="mElevationGroupBox">
<property name="title">
<string>Elevation</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="3" column="0">
<widget class="QLabel" name="labelVerticalScale">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Vertical scale</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QDoubleSpinBox" name="mSpinBoxVerticalScale">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property>
<property name="value">
<double>1.000000000000000</double>
</property>
</widget>
</item>
<item row="1" column="0" colspan="2">
<widget class="QTreeWidget" name="mElevationTreeView">
<property name="dragEnabled">
<bool>true</bool>
</property>
<property name="dragDropMode">
<enum>QAbstractItemView::InternalMove</enum>
</property>
<property name="indentation">
<number>0</number>
</property>
<property name="uniformRowHeights">
<bool>true</bool>
</property>
<property name="sortingEnabled">
<bool>true</bool>
</property>
<property name="allColumnsShowFocus">
<bool>true</bool>
</property>
<property name="columnCount">
<number>2</number>
</property>
<attribute name="headerVisible">
<bool>false</bool>
</attribute>
<attribute name="headerDefaultSectionSize">
<number>50</number>
</attribute>
<column>
<property name="text">
<string notr="true">1</string>
</property>
</column>
<column>
<property name="text">
<string notr="true">2</string>
</property>
</column>
</widget>
</item>
<item row="2" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QToolButton" name="mAddElevationButton">
<property name="text">
<string>Add</string>
</property>
<property name="popupMode">
<enum>QToolButton::InstantPopup</enum>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="mRemoveElevationButton">
<property name="text">
<string>Remove</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tabVideo">
<attribute name="title">
<string>Video</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_8">
<item row="1" column="0">
<widget class="QGroupBox" name="groupBoxAntiAliasing">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Anti Aliasing</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>true</bool>
</property>
<layout class="QFormLayout" name="formLayout">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property>
<item row="0" column="0">
<widget class="QLabel" name="labelAASamples">
<property name="text">
<string>Samples</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="lineEditAASamples">
<property name="placeholderText">
<string>[Leave empty for maximum]</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="labelVideoInfo">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-style:italic;&quot;&gt;Change requires a restart of the globe plugin&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="2" column="0">
<spacer name="verticalSpacerVideoTab">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="0">
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Stereo</string>
</property>
<layout class="QGridLayout" name="gridLayout_5">
<item row="0" column="0">
<widget class="QLabel" name="labelStereoMode">
<property name="text">
<string>Stereo Mode</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="comboBoxStereoMode"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="labelEyeSeparation">
<property name="text">
<string>Eye separation (m)</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QDoubleSpinBox" name="spinBoxStereoEyeSeparation">
<property name="readOnly">
<bool>false</bool>
</property>
<property name="buttonSymbols">
<enum>QAbstractSpinBox::UpDownArrows</enum>
</property>
<property name="accelerated">
<bool>true</bool>
</property>
<property name="decimals">
<number>3</number>
</property>
<property name="maximum">
<double>10.000000000000000</double>
</property>
<property name="singleStep">
<double>0.001000000000000</double>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="labelScreenDistance">
<property name="text">
<string>Screen distance (m)</string>
</property>
<property name="buddy">
<cstring>spinBoxStereoScreenDistance</cstring>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QDoubleSpinBox" name="spinBoxStereoScreenDistance">
<property name="accelerated">
<bool>true</bool>
</property>
<property name="decimals">
<number>3</number>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="labelScreenWidth">
<property name="text">
<string>Screen width (m)</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QDoubleSpinBox" name="spinBoxStereoScreenWidth">
<property name="accelerated">
<bool>true</bool>
</property>
<property name="decimals">
<number>3</number>
</property>
<property name="singleStep">
<double>0.010000000000000</double>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="labelScreenHeight">
<property name="text">
<string>Screen height (m)</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QDoubleSpinBox" name="spinBoxStereoScreenHeight">
<property name="accelerated">
<bool>true</bool>
</property>
<property name="decimals">
<number>3</number>
</property>
<property name="singleStep">
<double>0.010000000000000</double>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="labelSplitStereoHorizontalSeparation">
<property name="text">
<string>Split stereo horizontal separation (px)</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QSpinBox" name="spinBoxSplitStereoHorizontalSeparation">
<property name="enabled">
<bool>true</bool>
</property>
<property name="accelerated">
<bool>true</bool>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="labelSplitStereoHorizontalEyeMapping">
<property name="text">
<string>Split stereo horizontal eye mapping</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QComboBox" name="comboBoxSplitStereoHorizontalEyeMapping">
<item>
<property name="text">
<string notr="true">LEFT_EYE_LEFT_VIEWPORT</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">LEFT_EYE_RIGHT_VIEWPORT</string>
</property>
</item>
</widget>
</item>
<item row="7" column="0">
<widget class="QLabel" name="labelSplitStereoVerticalSeparation">
<property name="text">
<string>Split stereo vertical separation (px)</string>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QSpinBox" name="spinBoxSplitStereoVerticalSeparation">
<property name="accelerated">
<bool>true</bool>
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QLabel" name="labelBoxSplitStereoVerticalEyeMapping">
<property name="text">
<string>Split stereo vertical eye mapping</string>
</property>
</widget>
</item>
<item row="8" column="1">
<widget class="QComboBox" name="comboBoxSplitStereoVerticalEyeMapping">
<property name="enabled">
<bool>true</bool>
</property>
<item>
<property name="text">
<string notr="true">LEFT_EYE_TOP_VIEWPORT</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">LEFT_EYE_BOTTOM_VIEWPORT</string>
</property>
</item>
</widget>
</item>
<item row="9" column="1">
<widget class="QPushButton" name="pushButtonStereoResetDefaults">
<property name="text">
<string>Reset to defaults</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tabAdvanced">
<attribute name="title">
<string>Advanced</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QGroupBox" name="groupBoxScrolling">
<property name="title">
<string>Scrolling</string>
</property>
<layout class="QGridLayout" name="gridLayout_9">
<item row="2" column="0">
<widget class="QLabel" name="labelScrollSensitivity">
<property name="text">
<string>Sensitivity</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QSlider" name="sliderScrollSensitivity">
<property name="minimum">
<number>10</number>
</property>
<property name="maximum">
<number>50</number>
</property>
<property name="singleStep">
<number>1</number>
</property>
<property name="value">
<number>20</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="1" column="0" colspan="2">
<widget class="QCheckBox" name="checkBoxInvertScroll">
<property name="text">
<string>Invert scroll wheel</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBoxFeatureIdentification">
<property name="text">
<string>Enable feature identification</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBoxFrustumHighlighting">
<property name="text">
<string>Enable frustum highlighting</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacerAdvancedTab">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11"/>
<tabstops>
<tabstop>buttonBox</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>

View File

@ -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 <osgEarth/Registry>
#include <osgEarth/ImageUtils>
#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<QgsGlobeTileImage *>( 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<QgsMapLayer *> &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();
}

View File

@ -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 <osgEarth/TileSource>
#include <osgEarth/Version>
#include <osg/ImageStream>
#include <QImage>
#include <QStringList>
#include <QLabel>
#include <QMutex>
#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<QgsMapLayer *> &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<QgsGlobeTileSource> 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<QgsMapLayer *> &layers ) { mLayers = layers; }
void addTile( QgsGlobeTileImage *tile );
void removeTile( QgsGlobeTileImage *tile );
void waitForFinished() const;
signals:
void startRendering();
void cancelRendering();
private:
QList<QgsMapLayer *> mLayers;
QList<QgsGlobeTileImage *> 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<QgsMapLayer *> &layers ) { mLayers = layers; }
const QList<QgsMapLayer *> &layers() const { return mLayers; }
void waitForFinished() const
{
mTileUpdateManager.waitForFinished();
}
private:
friend class QgsGlobeTileImage;
QMutex mTileListLock;
QList<QgsGlobeTileImage *> mTiles;
QgsMapCanvas *mCanvas = nullptr;
QList<QgsMapLayer *> mLayers;
QgsGlobeTileUpdateManager mTileUpdateManager;
void addTile( QgsGlobeTileImage *tile );
void removeTile( QgsGlobeTileImage *tile );
};
#endif // QGSGLOBETILESOURCE_H

View File

@ -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 <qgsproject.h>
#include <qgsvectorlayer.h>
#include "qgsglobevectorlayerproperties.h"
#include <osgEarth/Version>
Q_DECLARE_METATYPE( QgsGlobeVectorLayerConfig * )
QgsGlobeVectorLayerConfig *QgsGlobeVectorLayerConfig::getConfig( QgsVectorLayer *layer )
{
QgsGlobeVectorLayerConfig *layerConfig = layer->property( "globe-config" ).value<QgsGlobeVectorLayerConfig *>();
if ( !layerConfig )
{
layerConfig = new QgsGlobeVectorLayerConfig( layer );
layer->setProperty( "globe-config", QVariant::fromValue<QgsGlobeVectorLayerConfig *>( 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<int>( osgEarth::Symbology::AltitudeSymbol::CLAMP_NONE ) );
comboBoxAltitudeClamping->addItem( tr( "Terrain" ), static_cast<int>( osgEarth::Symbology::AltitudeSymbol::CLAMP_TO_TERRAIN ) );
comboBoxAltitudeClamping->addItem( tr( "Relative" ), static_cast<int>( osgEarth::Symbology::AltitudeSymbol::CLAMP_RELATIVE_TO_TERRAIN ) );
comboBoxAltitudeClamping->addItem( tr( "Absolute" ), static_cast<int>( 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<int>( osgEarth::Symbology::AltitudeSymbol::TECHNIQUE_MAP ) );
comboBoxAltitudeTechnique->addItem( tr( "Drape" ), static_cast<int>( osgEarth::Symbology::AltitudeSymbol::TECHNIQUE_DRAPE ) );
comboBoxAltitudeTechnique->addItem( tr( "GPU" ), static_cast<int>( osgEarth::Symbology::AltitudeSymbol::TECHNIQUE_GPU ) );
comboBoxAltitudeTechnique->addItem( tr( "Scene" ), static_cast<int>( 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<int>( osgEarth::Symbology::AltitudeSymbol::BINDING_VERTEX ) );
comboBoxAltitudeBinding->addItem( tr( "Centroid" ), static_cast<int>( 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<int>( layerConfig->renderingMode ) ) );
comboBoxAltitudeClamping->setCurrentIndex( comboBoxAltitudeClamping->findData( static_cast<int>( layerConfig->altitudeClamping ) ) );
comboBoxAltitudeTechnique->setCurrentIndex( comboBoxAltitudeTechnique->findData( static_cast<int>( layerConfig->altitudeTechnique ) ) );
comboBoxAltitudeBinding->setCurrentIndex( comboBoxAltitudeBinding->findData( static_cast<int>( 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<QgsGlobeVectorLayerConfig::RenderingMode>( comboBoxRenderingMode->currentData().toInt() );
layerConfig->altitudeClamping = static_cast<osgEarth::Symbology::AltitudeSymbol::Clamping>( comboBoxAltitudeClamping->currentData().toInt() );
layerConfig->altitudeTechnique = static_cast<osgEarth::Symbology::AltitudeSymbol::Technique>( comboBoxAltitudeTechnique->currentData().toInt() );
layerConfig->altitudeBinding = static_cast<osgEarth::Symbology::AltitudeSymbol::Binding>( 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<osgEarth::Symbology::AltitudeSymbol::Clamping>( 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<osgEarth::Symbology::AltitudeSymbol::Clamping>( comboBoxAltitudeClamping->currentData().toInt() );
osgEarth::Symbology::AltitudeSymbol::Technique technique = static_cast<osgEarth::Symbology::AltitudeSymbol::Technique>( 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<int>( osgEarth::Symbology::AltitudeSymbol::CLAMP_TO_TERRAIN ) ) );
comboBoxAltitudeTechnique->setCurrentIndex( comboBoxAltitudeTechnique->findData( static_cast<int>( 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<QgsVectorLayer *>( 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<QgsVectorLayer *>( mapLayer ) )
{
QgsVectorLayer *vLayer = static_cast<QgsVectorLayer *>( mapLayer );
QgsGlobeVectorLayerConfig *config = QgsGlobeVectorLayerConfig::getConfig( vLayer );
QDomElement globeElem = elem.firstChildElement( "globe" );
if ( !globeElem.isNull() )
{
QDomElement renderingModeElem = globeElem.firstChildElement( "renderingMode" );
config->renderingMode = static_cast<QgsGlobeVectorLayerConfig::RenderingMode>( renderingModeElem.attribute( "mode" ).toInt() );
QDomElement modelRenderingElem = globeElem.firstChildElement( "modelRendering" );
if ( !modelRenderingElem.isNull() )
{
QDomElement altitudeElem = modelRenderingElem.firstChildElement( "altitude" );
config->altitudeClamping = static_cast<osgEarth::Symbology::AltitudeSymbol::Clamping>( altitudeElem.attribute( "clamping" ).toInt() );
config->altitudeTechnique = static_cast<osgEarth::Symbology::AltitudeSymbol::Technique>( altitudeElem.attribute( "technique" ).toInt() );
config->altitudeBinding = static_cast<osgEarth::Symbology::AltitudeSymbol::Binding>( 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<QgsVectorLayer *>( mapLayer ) )
{
QgsVectorLayer *vLayer = static_cast<QgsVectorLayer *>( 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 );
}
}

View File

@ -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 <QIcon>
#include "ui_qgsglobevectorlayerpropertiespage.h"
#include "qgsmaplayerconfigwidget.h"
#include "qgsmaplayerconfigwidgetfactory.h"
#include <osgEarthSymbology/AltitudeSymbol>
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

View File

@ -1,272 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>QgsGlobeVectorLayerPropertiesPage</class>
<widget class="QgsMapLayerConfigWidget" name="QgsGlobeVectorLayerPropertiesPage">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>446</width>
<height>580</height>
</rect>
</property>
<property name="windowTitle">
<string notr="true">Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="0" colspan="2">
<widget class="QStackedWidget" name="stackedWidgetRenderingMode">
<property name="currentIndex">
<number>1</number>
</property>
<widget class="QWidget" name="pageRasterized">
<layout class="QVBoxLayout" name="verticalLayout"/>
</widget>
<widget class="QWidget" name="pageModel">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QGroupBox" name="groupBoxAltitude">
<property name="title">
<string>Altitude</string>
</property>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="labelAltitudeClamping">
<property name="toolTip">
<string>Terrain following behavior</string>
</property>
<property name="text">
<string>Clamping</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="comboBoxAltitudeClamping">
<property name="toolTip">
<string>Terrain following behavior</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="labelAltitudeTechnique">
<property name="toolTip">
<string>Terrain following technique</string>
</property>
<property name="text">
<string>Technique</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="labelAltitudeBinding">
<property name="toolTip">
<string>Granularity at which to sample the terrain</string>
</property>
<property name="text">
<string>Binding</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="labelAltitudeResolution">
<property name="toolTip">
<string>Elevation data resolution at which to sample terrain height</string>
</property>
<property name="text">
<string>Resolution</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="labelAltitudeOffset">
<property name="toolTip">
<string>Vertical offset to apply to geometry Z</string>
</property>
<property name="text">
<string>Offset</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="labelAltitudeScale">
<property name="toolTip">
<string>Scale factor to apply to geometry Z</string>
</property>
<property name="text">
<string>Scale</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="comboBoxAltitudeTechnique">
<property name="toolTip">
<string>Terrain following technique</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QComboBox" name="comboBoxAltitudeBinding">
<property name="toolTip">
<string>Granularity at which to sample the terrain</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QDoubleSpinBox" name="spinBoxAltitudeResolution">
<property name="toolTip">
<string>Elevation data resolution at which to sample terrain height</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QDoubleSpinBox" name="spinBoxAltitudeOffset">
<property name="toolTip">
<string>Vertical offset to apply to geometry Z</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QDoubleSpinBox" name="spinBoxAltitudeScale">
<property name="toolTip">
<string>Scale factor to apply to geometry Z</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBoxExtrusion">
<property name="title">
<string>E&amp;xtrusion</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<layout class="QFormLayout" name="formLayout_2">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property>
<item row="0" column="0">
<widget class="QLabel" name="labelExtrusionHeight_2">
<property name="text">
<string>Height [m]</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="labelExtrusionHeight">
<property name="toolTip">
<string>Extrusion height, either a numeric value, or a field expression</string>
</property>
<property name="text">
<string>0</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="labelExtrusionWallGradient">
<property name="text">
<string>Wall gradient</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QDoubleSpinBox" name="spinBoxExtrusionWallGradient">
<property name="toolTip">
<string>Wall coloring gradient</string>
</property>
<property name="maximum">
<double>1.000000000000000</double>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property>
<property name="value">
<double>0.500000000000000</double>
</property>
</widget>
</item>
<item row="3" column="0" colspan="2">
<widget class="QCheckBox" name="checkBoxExtrusionFlatten">
<property name="toolTip">
<string>Whether the top cap of the extruded geometry should be flat</string>
</property>
<property name="text">
<string>Flatten</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBoxLabelingEnabled">
<property name="title">
<string>Enable &amp;labeling</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<layout class="QFormLayout" name="formLayout_4">
<item row="0" column="0">
<widget class="QCheckBox" name="checkBoxLabelingDeclutter">
<property name="text">
<string>Declutter</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBoxLighting">
<property name="text">
<string>Lighting</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="labelRenderingMode">
<property name="text">
<string>Rendering mode:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="comboBoxRenderingMode">
<property name="toolTip">
<string>Rendering method for the layer</string>
</property>
</widget>
</item>
<item row="2" column="0" colspan="2">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>QgsMapLayerConfigWidget</class>
<extends>QWidget</extends>
<header>qgsmaplayerconfigwidget.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View File

@ -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 <QContextMenuEvent>
#include <QHBoxLayout>
#include <QLabel>
#include <QMenu>
#include <QToolButton>
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<QHBoxLayout *>( titleWidget->layout() )->addWidget( new QWidget( this ), 1 ); // spacer
titleWidget->layout()->addWidget( new QLabel( tr( "Globe" ) ) );
static_cast<QHBoxLayout *>( 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<QgsMapLayer *> ) ), 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();
}

View File

@ -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 <QDockWidget>
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();
};

View File

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

View File

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