Skip to content

Commit

Permalink
[FEATURE] QGIS 3D (pull request #5203)
Browse files Browse the repository at this point in the history
  • Loading branch information
wonder-sk committed Oct 2, 2017
2 parents 143c4bf + d46c440 commit 68bb68d
Show file tree
Hide file tree
Showing 149 changed files with 15,116 additions and 26 deletions.
18 changes: 17 additions & 1 deletion CMakeLists.txt
Expand Up @@ -59,6 +59,8 @@ IF(WITH_CORE)

SET (WITH_DESKTOP TRUE CACHE BOOL "Determines whether QGIS desktop should be built")

SET (WITH_3D FALSE CACHE BOOL "Determines whether QGIS 3D library should be built")

# server disabled default because it needs FastCGI (which is optional dependency)
SET (WITH_SERVER FALSE CACHE BOOL "Determines whether QGIS server should be built")
IF(WITH_SERVER)
Expand Down Expand Up @@ -258,7 +260,13 @@ IF(WITH_CORE)
ENDIF(WITH_QTWEBKIT)
#############################################################
# search for Qt5
SET(QT_MIN_VERSION 5.2.0)
IF (WITH_3D)
# for 3D support we strictly require Qt >= 5.8
# (Qt 3D was introduced in 5.7 but it is not stable enough in that branch)
SET(QT_MIN_VERSION 5.8.0)
ELSE ()
SET(QT_MIN_VERSION 5.2.0)
ENDIF()
FIND_PACKAGE(Qt5Core QUIET)
FIND_PACKAGE(Qt5Gui REQUIRED)
FIND_PACKAGE(Qt5Widgets REQUIRED)
Expand All @@ -276,6 +284,14 @@ IF(WITH_CORE)
FIND_PACKAGE(Qt5UiTools REQUIRED)
FIND_PACKAGE(Qt5Script REQUIRED)
FIND_PACKAGE(Qt5Sql REQUIRED)
IF (WITH_3D)
FIND_PACKAGE(Qt53DCore REQUIRED)
FIND_PACKAGE(Qt53DRender REQUIRED)
FIND_PACKAGE(Qt53DInput REQUIRED)
FIND_PACKAGE(Qt53DLogic REQUIRED)
FIND_PACKAGE(Qt53DExtras REQUIRED)
SET(HAVE_3D TRUE) # used in qgsconfig.h
ENDIF (WITH_3D)
INCLUDE("cmake/modules/ECMQt4To5Porting.cmake")
MESSAGE(STATUS "Found Qt version: ${Qt5Core_VERSION_STRING}")

Expand Down
4 changes: 3 additions & 1 deletion cmake_templates/qgsconfig.h.in
Expand Up @@ -13,7 +13,7 @@
//used in vim src/core/qgis.cpp
//The way below should work but it resolves to a number like 0110 which the compiler treats as octal I think
//because debuggin it out shows the decimal number 72 which results in incorrect version status.
//As a short term fix I (Tim) am defining the version in top level cmake. It would be good to
//As a short term fix I (Tim) am defining the version in top level cmake. It would be good to
//reinstate this more generic approach below at some point though
//#define VERSION_INT ${CPACK_PACKAGE_VERSION_MAJOR}${CPACK_PACKAGE_VERSION_MINOR}${CPACK_PACKAGE_VERSION_PATCH}
#define VERSION_INT ${QGIS_VERSION_INT}
Expand Down Expand Up @@ -58,5 +58,7 @@

#cmakedefine ENABLE_MODELTEST

#cmakedefine HAVE_3D

#endif

5 changes: 5 additions & 0 deletions doc/CMakeLists.txt
Expand Up @@ -53,6 +53,7 @@ IF(WITH_APIDOC)
SET(DOXYGEN_INPUT
${CMAKE_SOURCE_DIR}/doc
${CMAKE_SOURCE_DIR}/src/core
${CMAKE_SOURCE_DIR}/src/core/3d
${CMAKE_SOURCE_DIR}/src/core/annotations
${CMAKE_SOURCE_DIR}/src/core/auth
${CMAKE_SOURCE_DIR}/src/core/composer
Expand Down Expand Up @@ -91,6 +92,10 @@ IF(WITH_APIDOC)
${CMAKE_SOURCE_DIR}/src/analysis/openstreetmap
${CMAKE_SOURCE_DIR}/src/analysis/raster
${CMAKE_SOURCE_DIR}/src/analysis/vector
${CMAKE_SOURCE_DIR}/src/3d
${CMAKE_SOURCE_DIR}/src/3d/chunks
${CMAKE_SOURCE_DIR}/src/3d/symbols
${CMAKE_SOURCE_DIR}/src/3d/terrain
${CMAKE_SOURCE_DIR}/src/plugins
)

Expand Down
6 changes: 6 additions & 0 deletions doc/modules.dox
Expand Up @@ -25,6 +25,12 @@ components to QGIS.

*/

/** @defgroup 3d 3D library

The 3D library is build on top of the CORE library and Qt 3D framework. It adds support for display of GIS data in 3D scenes.

*/

/** @defgroup plugins plugin classes

Contains classes related to implementation of QGIS plugins.
Expand Down
1 change: 1 addition & 0 deletions images/images.qrc
Expand Up @@ -570,6 +570,7 @@
<file>themes/default/mGeoPackage.svg</file>
<file>themes/default/mActionAddGeoPackageLayer.svg</file>
<file>icons/qgis_icon.svg</file>
<file>themes/default/3d.svg</file>
</qresource>
<qresource prefix="/images/tips">
<file alias="symbol_levels.png">qgis_tips/symbol_levels.png</file>
Expand Down
38 changes: 38 additions & 0 deletions images/themes/default/3d.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions python/CMakeLists.txt
Expand Up @@ -102,6 +102,7 @@ ENDIF ()

INCLUDE_DIRECTORIES(
${CMAKE_SOURCE_DIR}/src/core
${CMAKE_SOURCE_DIR}/src/core/3d
${CMAKE_SOURCE_DIR}/src/core/annotations
${CMAKE_SOURCE_DIR}/src/core/auth
${CMAKE_SOURCE_DIR}/src/core/expression
Expand Down
100 changes: 100 additions & 0 deletions python/core/3d/qgs3drendererregistry.sip
@@ -0,0 +1,100 @@
/************************************************************************
* This file has been generated automatically from *
* *
* src/core/./3d/qgs3drendererregistry.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/






class Qgs3DRendererAbstractMetadata
{
%Docstring
Base metadata class for 3D renderers. Instances of derived classes may be registered in Qgs3DRendererRegistry.
.. versionadded:: 3.0
%End

%TypeHeaderCode
#include "qgs3drendererregistry.h"
%End
public:

virtual ~Qgs3DRendererAbstractMetadata();

QString type() const;
%Docstring
Returns unique identifier of the 3D renderer class
:rtype: str
%End

virtual QgsAbstract3DRenderer *createRenderer( QDomElement &elem, const QgsReadWriteContext &context ) = 0 /Factory/;
%Docstring
Returns new instance of the renderer given the DOM element. Returns NULL on error.
Pure virtual function: must be implemented in derived classes.
:rtype: QgsAbstract3DRenderer
%End

protected:

explicit Qgs3DRendererAbstractMetadata( const QString &type );
%Docstring
Constructor of the base class
%End

protected:
};


class Qgs3DRendererRegistry
{
%Docstring
Keeps track of available 3D renderers. Should be accessed through QgsApplication.renderer3DRegistry() singleton.
.. versionadded:: 3.0
%End

%TypeHeaderCode
#include "qgs3drendererregistry.h"
%End
public:
Qgs3DRendererRegistry();
%Docstring
Creates registry of 3D renderers
%End

~Qgs3DRendererRegistry();

void addRenderer( Qgs3DRendererAbstractMetadata *metadata /Transfer/ );
%Docstring
Registers a new 3D renderer type. The call takes ownership of the passed metadata object.
%End

void removeRenderer( const QString &type );
%Docstring
Unregisters a 3D renderer type
%End

Qgs3DRendererAbstractMetadata *rendererMetadata( const QString &type ) const;
%Docstring
Returns metadata for a 3D renderer type (may be used to create a new instance of the type)
:rtype: Qgs3DRendererAbstractMetadata
%End

QStringList renderersList() const;
%Docstring
Returns a list of all available 3D renderer types.
:rtype: list of str
%End

};

/************************************************************************
* This file has been generated automatically from *
* *
* src/core/./3d/qgs3drendererregistry.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/
66 changes: 66 additions & 0 deletions python/core/3d/qgsabstract3drenderer.sip
@@ -0,0 +1,66 @@
/************************************************************************
* This file has been generated automatically from *
* *
* src/core/./3d/qgsabstract3drenderer.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/






class QgsAbstract3DRenderer /Abstract/
{
%Docstring
Base class for all renderers that may to participate in 3D view.

3D renderers implement the method createEntity() that returns a new 3D entity - that entity
will be added to the 3D scene to represent data in renderer's display style.

Renderers may store some custom properties (e.g. materials, sizes) that are written to and read from
XML. It is therefore not recommended to store large amount of data within a renderer (e.g. arrays of vertices).

.. versionadded:: 3.0
%End

%TypeHeaderCode
#include "qgsabstract3drenderer.h"
%End
public:
virtual ~QgsAbstract3DRenderer();

virtual QString type() const = 0;
%Docstring
Returns unique identifier of the renderer class (used to identify subclass)
:rtype: str
%End
virtual QgsAbstract3DRenderer *clone() const = 0 /Factory/;
%Docstring
Returns a cloned instance
:rtype: QgsAbstract3DRenderer
%End

virtual void writeXml( QDomElement &elem, const QgsReadWriteContext &context ) const = 0;
%Docstring
Writes renderer's properties to given XML element
%End
virtual void readXml( const QDomElement &elem, const QgsReadWriteContext &context ) = 0;
%Docstring
Reads renderer's properties from given XML element
%End
virtual void resolveReferences( const QgsProject &project );
%Docstring
Resolves references to other objects - second phase of loading - after readXml()
%End
};


/************************************************************************
* This file has been generated automatically from *
* *
* src/core/./3d/qgsabstract3drenderer.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/
2 changes: 2 additions & 0 deletions python/core/core_auto.sip
Expand Up @@ -280,6 +280,8 @@
%Include geometry/qgssurface.sip
%Include geometry/qgswkbptr.sip
%Include geometry/qgswkbtypes.sip
%Include ./3d/qgs3drendererregistry.sip
%Include ./3d/qgsabstract3drenderer.sip
%Include fieldformatter/qgsdatetimefieldformatter.sip
%Include fieldformatter/qgsfallbackfieldformatter.sip
%Include fieldformatter/qgskeyvaluefieldformatter.sip
Expand Down
10 changes: 10 additions & 0 deletions python/core/qgsapplication.sip
Expand Up @@ -711,6 +711,16 @@ Returns path to the build output directory. Valid only when running from build d
:rtype: QgsFieldFormatterRegistry
%End

static Qgs3DRendererRegistry *renderer3DRegistry();
%Docstring
Returns registry of available 3D renderers.
.. note::

not available in Python bindings
.. versionadded:: 3.0
:rtype: Qgs3DRendererRegistry
%End

static QString nullRepresentation();
%Docstring
This string is used to represent the value `NULL` throughout QGIS.
Expand Down
26 changes: 25 additions & 1 deletion python/core/qgsmaplayer.sip
Expand Up @@ -453,6 +453,12 @@ Invoked by QgsProject.read().
:rtype: bool
%End

virtual void resolveReferences( QgsProject *project );
%Docstring
Resolve references to other layers (kept as layer IDs after reading XML) into layer objects.
.. versionadded:: 3.0
%End

QStringList customPropertyKeys() const;
%Docstring
Returns list of all keys within custom properties. Properties are stored in a map and saved in project file.
Expand Down Expand Up @@ -754,6 +760,19 @@ Return pointer to layer's undo stack
:rtype: QgsMapLayerStyleManager
%End

void setRenderer3D( QgsAbstract3DRenderer *renderer /Transfer/ );
%Docstring
Sets 3D renderer for the layer. Takes ownership of the renderer.
.. versionadded:: 3.0
%End

QgsAbstract3DRenderer *renderer3D() const;
%Docstring
Returns 3D renderer associated with the layer. May be null.
.. versionadded:: 3.0
:rtype: QgsAbstract3DRenderer
%End

bool isInScaleRange( double scale ) const;
%Docstring
Tests whether the layer should be visible at the specified ``scale``.
Expand Down Expand Up @@ -1047,6 +1066,12 @@ Signal emitted when the blend mode is changed, through QgsMapLayer.setBlendMode(
%Docstring
Signal emitted when legend of the layer has changed
.. versionadded:: 2.6
%End

void renderer3DChanged();
%Docstring
Signal emitted when 3D renderer associated with the layer has changed.
.. versionadded:: 3.0
%End

void configChanged();
Expand Down Expand Up @@ -1116,7 +1141,6 @@ Set whether layer is valid or not - should be used in constructor.
:rtype: bool
%End


void readCustomProperties( const QDomNode &layerNode, const QString &keyStartsWith = QString() );
%Docstring
Read custom properties from project file.
Expand Down
2 changes: 1 addition & 1 deletion python/core/qgsvectorlayer.sip
Expand Up @@ -712,7 +712,7 @@ Return the provider type for this layer
:rtype: bool
%End

void resolveReferences( QgsProject *project );
virtual void resolveReferences( QgsProject *project );
%Docstring
Resolve references to other layers (kept as layer IDs after reading XML) into layer objects.
.. versionadded:: 3.0
Expand Down

0 comments on commit 68bb68d

Please sign in to comment.