Skip to content
Permalink
Browse files

Merge branch 'master' into extendMapTool

  • Loading branch information
lbartoletti committed Nov 15, 2018
2 parents 574a57f + 767e9a5 commit c292e69e498a1ba7c9b04a6da0c17d913cf122ce
Showing with 2,028 additions and 174 deletions.
  1. +25 −3 CMakeLists.txt
  2. +2 −2 cmake/FindSpatiaLite.cmake
  3. +2 −0 cmake_templates/qgsconfig.h.in
  4. +5 −0 images/images.qrc
  5. +1 −0 images/themes/default/grid.svg
  6. +1 −0 images/themes/default/mActionNewFolder.svg
  7. +1 −0 images/themes/default/mActionTerminal.svg
  8. +1 −0 images/themes/default/mIconFolder24.svg
  9. +1 −1 images/themes/default/north_arrow.svg
  10. +1 −0 images/themes/default/title_label.svg
  11. +2 −0 python/core/auto_generated/layout/qgslayoutexporter.sip.in
  12. +2 −1 python/core/auto_generated/qgsmaprenderertask.sip.in
  13. +6 −4 python/core/auto_generated/qgsrunprocess.sip.in
  14. +4 −0 rpm/qgis.spec.template
  15. +2 −0 src/3d/CMakeLists.txt
  16. +32 −13 src/3d/qgs3dmapscene.cpp
  17. +3 −0 src/3d/qgs3dmapscene.h
  18. +43 −0 src/3d/qgs3dmapsettings.cpp
  19. +20 −0 src/3d/qgs3dmapsettings.h
  20. +54 −0 src/3d/qgspointlightsettings.cpp
  21. +88 −0 src/3d/qgspointlightsettings.h
  22. +11 −4 src/CMakeLists.txt
  23. +1 −1 src/analysis/processing/qgsalgorithmextractbinary.cpp
  24. +1 −1 src/app/3d/qgs3danimationwidget.cpp
  25. +4 −0 src/app/3d/qgs3dmapconfigwidget.cpp
  26. +126 −0 src/app/3d/qgslightswidget.cpp
  27. +55 −0 src/app/3d/qgslightswidget.h
  28. +6 −0 src/app/CMakeLists.txt
  29. +13 −2 src/app/browser/qgsinbuiltdataitemproviders.cpp
  30. +18 −6 src/app/decorations/qgsdecorationcopyright.cpp
  31. +10 −14 src/app/decorations/qgsdecorationcopyrightdialog.cpp
  32. +1 −1 src/app/decorations/qgsdecorationcopyrightdialog.h
  33. +4 −10 src/app/decorations/qgsdecorationgriddialog.cpp
  34. +1 −1 src/app/decorations/qgsdecorationgriddialog.h
  35. +2 −0 src/app/decorations/qgsdecorationitem.h
  36. +4 −9 src/app/decorations/qgsdecorationlayoutextentdialog.cpp
  37. +1 −1 src/app/decorations/qgsdecorationlayoutextentdialog.h
  38. +4 −0 src/app/decorations/qgsdecorationnortharrow.cpp
  39. +8 −14 src/app/decorations/qgsdecorationnortharrowdialog.cpp
  40. +1 −1 src/app/decorations/qgsdecorationnortharrowdialog.h
  41. +4 −0 src/app/decorations/qgsdecorationscalebar.cpp
  42. +8 −14 src/app/decorations/qgsdecorationscalebardialog.cpp
  43. +1 −1 src/app/decorations/qgsdecorationscalebardialog.h
  44. +225 −0 src/app/decorations/qgsdecorationtitle.cpp
  45. +81 −0 src/app/decorations/qgsdecorationtitle.h
  46. +139 −0 src/app/decorations/qgsdecorationtitledialog.cpp
  47. +45 −0 src/app/decorations/qgsdecorationtitledialog.h
  48. +13 −2 src/app/qgisapp.cpp
  49. +1 −1 src/app/qgsstatusbarcoordinateswidget.cpp
  50. +12 −4 src/core/CMakeLists.txt
  51. +0 −2 src/core/gps/qgsgpsconnection.cpp
  52. +14 −0 src/core/gps/qgsgpsdetector.cpp
  53. +0 −1 src/core/gps/qgsgpsdetector.h
  54. +3 −0 src/core/layout/qgslayoutexporter.cpp
  55. +5 −1 src/core/layout/qgslayoutexporter.h
  56. +5 −2 src/core/qgsapplication.cpp
  57. +1 −0 src/core/qgsexpressioncontext.cpp
  58. +13 −0 src/core/qgsmaprenderertask.cpp
  59. +3 −2 src/core/qgsmaprenderertask.h
  60. +2 −4 src/core/qgsmultirenderchecker.cpp
  61. +0 −2 src/core/qgsmultirenderchecker.h
  62. +47 −16 src/core/qgsproject.cpp
  63. +12 −0 src/core/qgsrunprocess.cpp
  64. +12 −7 src/core/qgsrunprocess.h
  65. +5 −1 src/core/qgsuserprofilemanager.cpp
  66. +1 −1 src/gui/editorwidgets/core/qgseditorwidgetwrapper.cpp
  67. +10 −0 src/gui/editorwidgets/qgsvaluerelationwidgetwrapper.cpp
  68. +54 −0 src/gui/qgsbrowserdockwidget_p.cpp
  69. +4 −0 src/gui/qgsbrowserdockwidget_p.h
  70. +7 −1 src/native/CMakeLists.txt
  71. +34 −1 src/native/linux/qgslinuxnative.cpp
  72. +1 −0 src/native/linux/qgslinuxnative.h
  73. +15 −4 src/native/mac/qgsmacnative.mm
  74. +10 −0 src/native/qgsnative.cpp
  75. +11 −1 src/native/qgsnative.h
  76. +2 −0 src/providers/CMakeLists.txt
  77. +1 −1 src/quickgui/CMakeLists.txt
  78. +7 −2 src/quickgui/plugin/CMakeLists.txt
  79. +21 −0 src/quickgui/plugin/ios/qmldir
  80. +17 −0 src/quickgui/plugin/qgsquick.qrc
  81. +0 −1 src/quickgui/plugin/qgsquickplugin.h
  82. +0 −4 src/server/CMakeLists.txt
  83. +0 −2 src/server/qgsserver.cpp
  84. +18 −0 src/ui/3d/map3dconfigwidget.ui
  85. +216 −0 src/ui/3d/qgslightswidget.ui
  86. +17 −1 src/ui/qgisapp.ui
  87. +29 −2 src/ui/qgsbrowserlayerpropertiesbase.ui
  88. +14 −1 src/ui/qgsdecorationgriddialog.ui
  89. +16 −3 src/ui/qgsdecorationscalebardialog.ui
  90. +283 −0 src/ui/qgsdecorationtitledialog.ui
  91. +3 −0 tests/src/3d/testqgs3drendering.cpp
  92. +19 −0 tests/src/python/test_qgsproject.py
@@ -16,6 +16,7 @@ SET(CPACK_PACKAGE_VERSION_PATCH "0")
SET(COMPLETE_VERSION ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH})
SET(RELEASE_NAME "Master")
PROJECT(qgis VERSION ${COMPLETE_VERSION})

IF (APPLE)
SET(QGIS_APP_NAME "QGIS")
ELSE (APPLE)
@@ -68,6 +69,20 @@ IF(NOT MSVC)
endif(USE_CCACHE)
endif(NOT MSVC)

IF (IOS)
SET (DEFAULT_FORCE_STATIC_LIBS TRUE)
ELSE (IOS)
SET (DEFAULT_FORCE_STATIC_LIBS FALSE)
ENDIF (IOS)
SET (FORCE_STATIC_LIBS ${DEFAULT_FORCE_STATIC_LIBS} CACHE BOOL "Determines whether libraries should be static only")
MARK_AS_ADVANCED(FORCE_STATIC_LIBS)

IF(FORCE_STATIC_LIBS)
SET(LIBRARY_TYPE STATIC)
ELSE (FORCE_STATIC_LIBS)
SET(LIBRARY_TYPE SHARED)
ENDIF (FORCE_STATIC_LIBS)

# in generated makefiles use relative paths so the project dir is moveable
# Note commented out since it cause problems but it would be nice to resolve these and enable
#
@@ -316,6 +331,15 @@ IF(WITH_CORE)
#############################################################
# search for Qt5
SET(QT_MIN_VERSION 5.9.0)

# Use Qt5SerialPort optionally for GPS
SET (WITH_QT5SERIALPORT TRUE CACHE BOOL "Determines whether Qt5SerialPort should be tried for GPS positioning")
IF (WITH_QT5SERIALPORT)
FIND_PACKAGE(Qt5SerialPort REQUIRED)
# following variable is used in qgsconfig.h
SET (HAVE_QT5SERIALPORT TRUE)
ENDIF(WITH_QT5SERIALPORT)

FIND_PACKAGE(Qt5Core QUIET)
FIND_PACKAGE(Qt5Gui REQUIRED)
FIND_PACKAGE(Qt5Widgets REQUIRED)
@@ -324,7 +348,6 @@ IF(WITH_CORE)
FIND_PACKAGE(Qt5Svg REQUIRED)
FIND_PACKAGE(Qt5Concurrent REQUIRED)
FIND_PACKAGE(Qt5PrintSupport REQUIRED)
FIND_PACKAGE(Qt5SerialPort REQUIRED)
FIND_PACKAGE(Qt5Positioning)
IF (WITH_QTWEBKIT)
FIND_PACKAGE(Qt5WebKit REQUIRED)
@@ -352,7 +375,7 @@ IF(WITH_CORE)
IF(${CMAKE_SYSTEM_NAME} MATCHES "Android")
FIND_PACKAGE(Qt5AndroidExtras)
ELSE(${CMAKE_SYSTEM_NAME} MATCHES "Android")
FIND_PACKAGE(QtQmlTools REQUIRED)
FIND_PACKAGE(QtQmlTools)
ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "Android")

# following variable is used in qgsconfig.h
@@ -412,7 +435,6 @@ SET(QML_IMPORT_PATH "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" CACHE PATH "QML director
SET (ENABLE_TESTS TRUE CACHE BOOL "Build unit tests?")
IF (ENABLE_TESTS)
SET( QT_USE_QTTEST TRUE )
ADD_DEFINITIONS(-DENABLE_TESTS)
ENABLE_TESTING()
# Adds some testing specific build targets e.g. make Experimental
INCLUDE(Dart)
@@ -24,7 +24,7 @@ include(CheckLibraryExists)

# try to use sqlite framework on mac
# want clean framework path, not unix compatibility path
IF (APPLE)
IF (APPLE AND NOT IOS)
IF (CMAKE_FIND_FRAMEWORK MATCHES "FIRST"
OR CMAKE_FRAMEWORK_PATH MATCHES "ONLY"
OR NOT CMAKE_FIND_FRAMEWORK)
@@ -39,7 +39,7 @@ IF (APPLE)
ENDIF (SPATIALITE_INCLUDE_DIR)
SET (CMAKE_FIND_FRAMEWORK ${CMAKE_FIND_FRAMEWORK_save} CACHE STRING "" FORCE)
ENDIF ()
ENDIF (APPLE)
ENDIF (APPLE AND NOT IOS)

FIND_PATH(SPATIALITE_INCLUDE_DIR spatialite.h
/usr/include
@@ -69,5 +69,7 @@

#cmakedefine HAVE_QUICK

#cmakedefine HAVE_QT5SERIALPORT

#endif

@@ -155,6 +155,7 @@
<file>themes/default/grass_mapset.svg</file>
<file>themes/default/grass_mapset_open.svg</file>
<file>themes/default/grass_mapset_search.svg</file>
<file>themes/default/grid.svg</file>
<file>themes/default/histogram.svg</file>
<file>themes/default/heatmap.svg</file>
<file>themes/default/join_bevel.svg</file>
@@ -584,6 +585,7 @@
<file>themes/default/symbologyRemove.svg</file>
<file>themes/default/sync_views.svg</file>
<file>themes/default/text.svg</file>
<file>themes/default/title_label.svg</file>
<file>themes/default/tracking.svg</file>
<file>themes/default/transformed.svg</file>
<file>themes/default/transp-background_8x8.png</file>
@@ -730,6 +732,9 @@
<file>themes/default/mIconInteriorRings.svg</file>
<file>themes/default/mIconFieldBinary.svg</file>
<file>themes/default/mActionTrimExtendFeature.svg</file>
<file>themes/default/mActionTerminal.svg</file>
<file>themes/default/mIconFolder24.svg</file>
<file>themes/default/mActionNewFolder.svg</file>
</qresource>
<qresource prefix="/images/tips">
<file alias="symbol_levels.png">qgis_tips/symbol_levels.png</file>
@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24"><g transform="matrix(.99986 0 0 1 1.993 1.99)" stroke="#d0d0d0" stroke-opacity=".996" fill="none"><rect x="1.51" y="1.51" width="20" height="20" rx=".728" ry=".728" stroke-linejoin="round"/><path d="M1.47 5.85h20.5M1.53 12.2l20.3.027M1.61 17.8l20.3-.027M5.5 1.5v20M11.5 1.5v20M17.5 1.5v20"/></g><g transform="matrix(.99986 0 0 1 1.993 1.99)" stroke="#000" fill="none"><rect x=".507" y=".507" width="20" height="20" rx=".728" ry=".728" stroke-linejoin="round"/><path d="M.473 4.85h20.5M.527 11.2l20.3.027M.609 16.8l20.3-.027M4.5.5v20M10.5.5v20M16.5.5v20"/></g><g transform="translate(-.615 -.615) scale(.76923)" stroke-width="1.067"><rect height="13" rx="2.789" ry="2.789" width="13" x="19" y="19" fill="#5a8c5a"/><path d="M21.6 25.5h7.8m-3.9 3.9v-7.8" overflow="visible" fill="#fff" fill-rule="evenodd" stroke="#fff" stroke-width="2.773" stroke-linecap="round" stroke-linejoin="round"/><path d="M20.3 25.5h10.4v-2.6c0-2.6-.65-2.6-5.2-2.6s-5.2 0-5.2 2.6z" opacity=".3" fill="#fcffff" fill-rule="evenodd"/></g></svg>
@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24"><path d="M1.5 2.502V21.25s.03 1.25 1.212 1.25h18.576s1.21 0 1.21-1.25L22.5 5.833h-8.562L10.708 2.5H1.5z" fill="#eee" stroke="#888a85"/><g transform="translate(33)"><rect y="13" x="-20" width="11" rx="2.011" height="11" fill="#c4a000"/><path d="M-15 14v2.063a2.501 2.501 0 0 0-1.375.78l-1.781-1.03-.5.874 1.781 1.032A2.46 2.46 0 0 0-17 18.5c0 .275.043.534.125.781l-1.781 1.032.5.875 1.781-1.032c.353.4.833.67 1.375.782V23h1v-2.063a2.501 2.501 0 0 0 1.375-.78l1.781 1.03.5-.875-1.781-1.03A2.46 2.46 0 0 0-12 18.5a2.46 2.46 0 0 0-.125-.781l1.781-1.032-.5-.875-1.781 1.032c-.353-.4-.833-.67-1.375-.782V14zm.5 3.5a1 1 0 1 1 0 2 1 1 0 0 1 0-2z" fill="#fcffff"/><path d="M-19 19l9-.01v-2C-10 14-11 14-14.5 14s-4.5 0-4.5 3v2z" opacity=".3" fill="#fcffff" fill-rule="evenodd"/></g></svg>
@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" version="1"><path d="M.994 20.406v.392c0 .65.523 1.173 1.173 1.173h19.554a1.17 1.17 0 0 0 1.173-1.173v-.392c0 .65-.054-2.013-.054-2.013l-21.775.424s-.071 2.24-.071 1.59z" opacity=".2"/><rect width="21.9" height="18.772" x=".994" y="2.012" rx="1.173" ry="1.173" fill="#4f4f4f"/><path d="M2.167 2.012A1.17 1.17 0 0 0 .994 3.185v.39c0-.65.523-1.172 1.173-1.172h19.554c.65 0 1.173.523 1.173 1.173v-.391a1.17 1.17 0 0 0-1.173-1.173z" opacity=".1" fill="#fff"/><path d="M3.1 5.399v-1.13L8 7.156v1.03l-4.9 2.888v-1.13l3.937-2.266z" aria-label="&gt;" style="fill:#e6e6e6" font-weight="400" font-size="40" font-family="sans-serif" letter-spacing="0" word-spacing="0" fill="#e6e6e6"/><path fill="#e6e6e6" d="M9 10h4v1H9z"/></svg>
@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24"><path d="M1.5 2.502V21.25s.03 1.25 1.212 1.25h18.576s1.21 0 1.21-1.25L22.5 5.833h-8.562L10.708 2.5H1.5z" fill="#eee" stroke="#888a85"/></svg>
@@ -1 +1 @@
<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg"><path d="m12 2.06-7.26 19.9 7.26-6.41l7.26 6.41z" fill="#6d97c4" stroke="#415a75" stroke-linejoin="round"/><path d="m14 15h-.834l-2.17-4.51v4.51h-1v-6h1.06l1.95 3.48v-3.48h1z" fill="#fff"/></svg>
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24"><path d="M12 2.06l-7.26 19.9L12 15.55l7.26 6.41z" fill="#6d97c4" stroke="#415a75" stroke-linejoin="round"/><path d="M14 15h-.834l-2.17-4.51V15h-1V9h1.06l1.95 3.48V9h1z" fill="#fff"/><g transform="matrix(.76923 0 0 .76923 -.615 -.615)" stroke-width="1.067"><rect height="13" rx="2.789" ry="2.789" width="13" x="19" y="19" fill="#5a8c5a"/><path d="M21.6 25.5h7.8m-3.9 3.9v-7.8" overflow="visible" fill="#fff" fill-rule="evenodd" stroke="#fff" stroke-width="2.773" stroke-linecap="round" stroke-linejoin="round"/><path d="M20.3 25.5h10.4v-2.6c0-2.6-.65-2.6-5.2-2.6s-5.2 0-5.2 2.6z" opacity=".3" fill="#fcffff" fill-rule="evenodd"/></g></svg>
@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 22.5 22.5" width="24"><path d="M11.25 19.66V4.715M4.714 3.75h13.072" fill="none" stroke="#d0d0d0" stroke-width="3.75" stroke-linecap="round" stroke-opacity=".996"/><g transform="matrix(.72115 0 0 .72115 -.577 -.577)" stroke-width="1.067"><rect height="13" rx="2.789" ry="2.789" width="13" x="19" y="19" fill="#5a8c5a"/><path d="M21.6 25.5h7.8M25.5 29.4v-7.8" overflow="visible" fill="#fff" fill-rule="evenodd" stroke="#fff" stroke-width="2.773" stroke-linecap="round" stroke-linejoin="round"/><path d="M20.3 25.5h10.4v-2.6c0-2.6-.65-2.6-5.2-2.6s-5.2 0-5.2 2.6v2.6z" opacity=".3" fill="#fcffff" fill-rule="evenodd"/></g><path d="M12.4 5.541c-1.067 0-2.019.213-2.847.639a4.627 4.627 0 0 0-1.916 1.777c-.419.706-.631 1.51-.662 2.4a9.016 9.016 0 0 0 .625.028 9.016 9.016 0 0 0 1.435-.13c.057-.856.338-1.56.867-2.109.597-.613 1.412-.921 2.467-.921.656 0 1.203.123 1.649.365l.002.002c.02.011.038.025.058.037a9.016 9.016 0 0 0 1.09-1.379c-.765-.467-1.685-.709-2.768-.709z" overflow="visible" fill="none"/><path d="M11.25 19.66V4.688M4.7 3.737h13.1" fill="none" stroke="#000" stroke-width="1.875" stroke-linecap="round"/></svg>
@@ -8,6 +8,7 @@




class QgsLayoutExporter
{
%Docstring
@@ -363,6 +364,7 @@ Subclasses can override this method to customize page file naming.




/************************************************************************
* This file has been generated automatically from *
* *
@@ -27,7 +27,8 @@ task. This can be used to draw maps without blocking the QGIS interface.
enum ErrorType
{
ImageAllocationFail,
ImageSaveFail
ImageSaveFail,
ImageUnsupportedFormat
};

QgsMapRendererTask( const QgsMapSettings &ms,
@@ -17,6 +17,9 @@ class QgsRunProcess: QObject /NoDefaultCtors/
A class that executes an external program/script.
It can optionally capture the standard output and error from the
process and displays them in a dialog box.

On some platforms (e.g. iOS) , the process execution is skipped
https://lists.qt-project.org/pipermail/development/2015-July/022205.html
%End

%TypeHeaderCode
@@ -26,16 +29,15 @@ process and displays them in a dialog box.

static QgsRunProcess *create( const QString &action, bool capture ) /Factory/;

private:
QgsRunProcess( const QString &action, bool capture );
~QgsRunProcess();
public slots:
void stdoutAvailable();
void stderrAvailable();
void processError( QProcess::ProcessError );
void processExit( int, QProcess::ExitStatus );
void dialogGone();

private:
QgsRunProcess( const QString &action, bool capture );
~QgsRunProcess();
};

/************************************************************************
@@ -107,6 +107,10 @@ BuildRequires: qwt-devel
BuildRequires: qwt-qt5-devel
BuildRequires: qwt-qt5-devel

# GDAL must be explicit. It is required by some raster tools
# like Warp (Reproject) which relies on gdalwarp
Requires: gdal

# Installation of QCA plugins must be explicit
Requires: qca-qt5-ossl
Requires: gpsbabel
@@ -12,6 +12,7 @@ SET(QGIS_3D_SRCS
qgslayoutitem3dmap.cpp
qgsoffscreen3dengine.cpp
qgsphongmaterialsettings.cpp
qgspointlightsettings.cpp
qgsraycastingutils_p.cpp
qgstessellatedpolygongeometry.cpp
qgstilingscheme.cpp
@@ -93,6 +94,7 @@ SET(QGIS_3D_HDRS
qgslayoutitem3dmap.h
qgsoffscreen3dengine.h
qgsphongmaterialsettings.h
qgspointlightsettings.h
qgsraycastingutils_p.h
qgstessellatedpolygongeometry.h
qgstilingscheme.h
@@ -93,6 +93,7 @@ Qgs3DMapScene::Qgs3DMapScene( const Qgs3DMapSettings &map, QgsAbstract3DEngine *
connect( &map, &Qgs3DMapSettings::maxTerrainScreenErrorChanged, this, &Qgs3DMapScene::createTerrain );
connect( &map, &Qgs3DMapSettings::maxTerrainGroundErrorChanged, this, &Qgs3DMapScene::createTerrain );
connect( &map, &Qgs3DMapSettings::terrainShadingChanged, this, &Qgs3DMapScene::createTerrain );
connect( &map, &Qgs3DMapSettings::pointLightsChanged, this, &Qgs3DMapScene::updateLights );

// create entities of renderers

@@ -105,19 +106,7 @@ Qgs3DMapScene::Qgs3DMapScene( const Qgs3DMapSettings &map, QgsAbstract3DEngine *
// listen to changes of layers in order to add/remove 3D renderer entities
connect( &map, &Qgs3DMapSettings::layersChanged, this, &Qgs3DMapScene::onLayersChanged );

Qt3DCore::QEntity *lightEntity = new Qt3DCore::QEntity;
Qt3DCore::QTransform *lightTransform = new Qt3DCore::QTransform;
lightTransform->setTranslation( QVector3D( 0, 1000, 0 ) );
// defaults: white, intensity 0.5
// attenuation: constant 1.0, linear 0.0, quadratic 0.0
Qt3DRender::QPointLight *light = new Qt3DRender::QPointLight;
light->setConstantAttenuation( 0 );
//light->setColor(Qt::white);
//light->setIntensity(0.5);
lightEntity->addComponent( light );
lightEntity->addComponent( lightTransform );
lightEntity->setParent( this );

updateLights();

#if 0
ChunkedEntity *testChunkEntity = new ChunkedEntity( AABB( -500, 0, -500, 500, 100, 500 ), 2.f, 3.f, 7, new TestChunkLoaderFactory );
@@ -465,6 +454,36 @@ void Qgs3DMapScene::onLayerEntityPickEvent( Qt3DRender::QPickEvent *event )

}

void Qgs3DMapScene::updateLights()
{
for ( Qt3DCore::QEntity *entity : qgis::as_const( mLightEntities ) )
entity->deleteLater();
mLightEntities.clear();

const auto newPointLights = mMap.pointLights();
for ( const QgsPointLightSettings &pointLightSettings : newPointLights )
{
Qt3DCore::QEntity *lightEntity = new Qt3DCore::QEntity;
Qt3DCore::QTransform *lightTransform = new Qt3DCore::QTransform;
lightTransform->setTranslation( QVector3D( pointLightSettings.position().x(),
pointLightSettings.position().y(),
pointLightSettings.position().z() ) );

Qt3DRender::QPointLight *light = new Qt3DRender::QPointLight;
light->setColor( pointLightSettings.color() );
light->setIntensity( pointLightSettings.intensity() );

light->setConstantAttenuation( pointLightSettings.constantAttenuation() );
light->setLinearAttenuation( pointLightSettings.linearAttenuation() );
light->setQuadraticAttenuation( pointLightSettings.quadraticAttenuation() );

lightEntity->addComponent( light );
lightEntity->addComponent( lightTransform );
lightEntity->setParent( this );
mLightEntities << lightEntity;
}
}

void Qgs3DMapScene::onLayerRenderer3DChanged()
{
QgsMapLayer *layer = qobject_cast<QgsMapLayer *>( sender() );
@@ -106,6 +106,7 @@ class _3D_EXPORT Qgs3DMapScene : public Qt3DCore::QEntity
void createTerrainDeferred();
void onBackgroundColorChanged();
void onLayerEntityPickEvent( Qt3DRender::QPickEvent *event );
void updateLights();

private:
void addLayerEntity( QgsMapLayer *layer );
@@ -132,6 +133,8 @@ class _3D_EXPORT Qgs3DMapScene : public Qt3DCore::QEntity
SceneState mSceneState = Ready;
//! List of currently registered pick handlers (used by identify tool)
QList<Qgs3DMapScenePickHandler *> mPickHandlers;
//! List of lights in the scene
QList<Qt3DCore::QEntity *> mLightEntities;
};

#endif // QGS3DMAPSCENE_H
@@ -42,6 +42,8 @@ Qgs3DMapSettings::Qgs3DMapSettings( const Qgs3DMapSettings &other )
, mShowTerrainBoundingBoxes( other.mShowTerrainBoundingBoxes )
, mShowTerrainTileInfo( other.mShowTerrainTileInfo )
, mShowCameraViewCenter( other.mShowCameraViewCenter )
, mShowLabels( other.mShowLabels )
, mPointLights( other.mPointLights )
, mLayers( other.mLayers )
, mSkyboxEnabled( other.mSkyboxEnabled )
, mSkyboxFileBase( other.mSkyboxFileBase )
@@ -86,6 +88,28 @@ void Qgs3DMapSettings::readXml( const QDomElement &elem, const QgsReadWriteConte
if ( !elemTerrainShadingMaterial.isNull() )
mTerrainShadingMaterial.readXml( elemTerrainShadingMaterial );
mShowLabels = elemTerrain.attribute( QStringLiteral( "show-labels" ), QStringLiteral( "0" ) ).toInt();

mPointLights.clear();
QDomElement elemPointLights = elem.firstChildElement( QStringLiteral( "point-lights" ) );
if ( !elemPointLights.isNull() )
{
QDomElement elemPointLight = elemPointLights.firstChildElement( QStringLiteral( "point-light" ) );
while ( !elemPointLight.isNull() )
{
QgsPointLightSettings pointLight;
pointLight.readXml( elemPointLight );
mPointLights << pointLight;
elemPointLight = elemPointLight.nextSiblingElement( QStringLiteral( "point-light" ) );
}
}
else
{
// QGIS <= 3.4 did not have light configuration
QgsPointLightSettings defaultLight;
defaultLight.setPosition( QgsVector3D( 0, 1000, 0 ) );
mPointLights << defaultLight;
}

QDomElement elemMapLayers = elemTerrain.firstChildElement( QStringLiteral( "layers" ) );
QDomElement elemMapLayer = elemMapLayers.firstChildElement( QStringLiteral( "layer" ) );
QList<QgsMapLayerRef> mapLayers;
@@ -95,6 +119,7 @@ void Qgs3DMapSettings::readXml( const QDomElement &elem, const QgsReadWriteConte
elemMapLayer = elemMapLayer.nextSiblingElement( QStringLiteral( "layer" ) );
}
mLayers = mapLayers; // needs to resolve refs afterwards

QDomElement elemTerrainGenerator = elemTerrain.firstChildElement( QStringLiteral( "generator" ) );
QString terrainGenType = elemTerrainGenerator.attribute( QStringLiteral( "type" ) );
if ( terrainGenType == QLatin1String( "dem" ) )
@@ -180,6 +205,15 @@ QDomElement Qgs3DMapSettings::writeXml( QDomDocument &doc, const QgsReadWriteCon
mTerrainShadingMaterial.writeXml( elemTerrainShadingMaterial );
elemTerrain.appendChild( elemTerrainShadingMaterial );
elemTerrain.setAttribute( QStringLiteral( "show-labels" ), mShowLabels ? 1 : 0 );

QDomElement elemPointLights = doc.createElement( QStringLiteral( "point-lights" ) );
for ( const QgsPointLightSettings &pointLight : qgis::as_const( mPointLights ) )
{
QDomElement elemPointLight = pointLight.writeXml( doc );
elemPointLights.appendChild( elemPointLight );
}
elem.appendChild( elemPointLights );

QDomElement elemMapLayers = doc.createElement( QStringLiteral( "layers" ) );
Q_FOREACH ( const QgsMapLayerRef &layerRef, mLayers )
{
@@ -438,3 +472,12 @@ void Qgs3DMapSettings::setShowLabels( bool enabled )
mShowLabels = enabled;
emit showLabelsChanged();
}

void Qgs3DMapSettings::setPointLights( const QList<QgsPointLightSettings> &pointLights )
{
if ( mPointLights == pointLights )
return;

mPointLights = pointLights;
emit pointLightsChanged();
}

0 comments on commit c292e69

Please sign in to comment.
You can’t perform that action at this time.