Skip to content
Permalink
Browse files

some stubs for 3d classes

  • Loading branch information
PeterPetrik authored and nyalldawson committed Oct 26, 2020
1 parent 63ecfb9 commit b7e8071831aca6639914986671c17dc40092de6f
@@ -10,6 +10,7 @@
%Include auto_generated/qgsdirectionallightsettings.sip
%Include auto_generated/qgsrulebased3drenderer.sip
%Include auto_generated/qgsvectorlayer3drenderer.sip
%Include auto_generated/qgspointcloudlayer3drenderer.sip
%Include auto_generated/materials/qgsabstractmaterialsettings.sip
%Include auto_generated/materials/qgsgoochmaterialsettings.sip
%Include auto_generated/materials/qgsmaterialregistry.sip
@@ -0,0 +1,91 @@
/************************************************************************
* This file has been generated automatically from *
* *
* src/3d/qgspointcloudlayer3drenderer.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/







class QgsPointCloudLayer3DRendererMetadata : Qgs3DRendererAbstractMetadata
{
%Docstring
Metadata for point cloud layer 3D renderer to allow creation of its instances from XML

.. warning::

This is not considered stable API, and may change in future QGIS releases. It is
exposed to the Python bindings as a tech preview only.

.. versionadded:: 3.18
%End

%TypeHeaderCode
#include "qgspointcloudlayer3drenderer.h"
%End
public:
QgsPointCloudLayer3DRendererMetadata();

virtual QgsAbstract3DRenderer *createRenderer( QDomElement &elem, const QgsReadWriteContext &context ) /Factory/;

%Docstring
Creates an instance of a 3D renderer based on a DOM element with renderer configuration
%End
};


class QgsPointCloudLayer3DRenderer : QgsAbstract3DRenderer
{
%Docstring
3D renderer that renders all points from a point cloud layer

.. versionadded:: 3.18
%End

%TypeHeaderCode
#include "qgspointcloudlayer3drenderer.h"
%End
public:
explicit QgsPointCloudLayer3DRenderer();
%Docstring
Takes ownership of the symbol object
%End

void setLayer( QgsPointCloudLayer *layer );
%Docstring
Sets point cloud layer associated with the renderer
%End
QgsPointCloudLayer *layer() const;
%Docstring
Returns point cloud layer associated with the renderer
%End

virtual QString type() const;
virtual QgsPointCloudLayer3DRenderer *clone() const /Factory/;


virtual void writeXml( QDomElement &elem, const QgsReadWriteContext &context ) const;

virtual void readXml( const QDomElement &elem, const QgsReadWriteContext &context );

virtual void resolveReferences( const QgsProject &project );


private:
QgsPointCloudLayer3DRenderer( const QgsPointCloudLayer3DRenderer & );
QgsPointCloudLayer3DRenderer &operator=( const QgsPointCloudLayer3DRenderer & );
};


/************************************************************************
* This file has been generated automatically from *
* *
* src/3d/qgspointcloudlayer3drenderer.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/
@@ -35,8 +35,12 @@ Represents a 2D renderer of point cloud data
explicit QgsPointCloudRenderer( QgsPointCloudLayer *layer, QgsRenderContext &context );
~QgsPointCloudRenderer();


virtual bool render();

%Docstring
QgsPointCloudRenderer cannot be copied.
%End

void writeXml( QDomElement &elem, const QgsReadWriteContext &context ) const;
void readXml( const QDomElement &elem, const QgsReadWriteContext &context );
@@ -37,6 +37,9 @@ SET(QGIS_3D_SRCS
qgspreviewquad.cpp
qgsshadowsettings.cpp

qgspointcloudlayer3drenderer.cpp
qgspointcloudlayerchunkloader_p.cpp

chunks/qgschunkboundsentity_p.cpp
chunks/qgschunkedentity_p.cpp
chunks/qgschunklist_p.cpp
@@ -115,6 +118,7 @@ SET(QGIS_3D_HDRS
qgspostprocessingentity.h
qgspreviewquad.h
qgsshadowsettings.h
qgspointcloudlayer3drenderer.h

materials/qgsabstractmaterialsettings.h
materials/qgsgoochmaterialsettings.h
@@ -146,6 +150,7 @@ SET(QGIS_3D_HDRS
SET(QGIS_3D_PRIVATE_HDRS
qgsrulebasedchunkloader_p.h
qgsvectorlayerchunkloader_p.h
qgspointcloudlayerchunkloader_p.h
chunks/qgschunkboundsentity_p.h
chunks/qgschunkedentity_p.h
chunks/qgschunklist_p.h
@@ -189,6 +194,7 @@ INCLUDE_DIRECTORIES(
${CMAKE_SOURCE_DIR}/src/core/expression
${CMAKE_SOURCE_DIR}/src/core/layout
${CMAKE_SOURCE_DIR}/src/core/3d
${CMAKE_SOURCE_DIR}/src/core/pointcloud
${CMAKE_SOURCE_DIR}/src/core/textrenderer
${CMAKE_SOURCE_DIR}/external
${CMAKE_SOURCE_DIR}/external/nlohmann
@@ -25,6 +25,7 @@
#include "qgsrulebased3drenderer.h"
#include "qgsvectorlayer3drenderer.h"
#include "qgsmeshlayer3drenderer.h"
#include "qgspointcloudlayer3drenderer.h"
#include "qgs3dsymbolregistry.h"
#include "qgspoint3dsymbol.h"
#include "qgsline3dsymbol.h"
@@ -60,6 +61,7 @@ void Qgs3D::initialize()
QgsApplication::renderer3DRegistry()->addRenderer( new QgsVectorLayer3DRendererMetadata );
QgsApplication::renderer3DRegistry()->addRenderer( new QgsRuleBased3DRendererMetadata );
QgsApplication::renderer3DRegistry()->addRenderer( new QgsMeshLayer3DRendererMetadata );
QgsApplication::renderer3DRegistry()->addRenderer( new QgsPointCloudLayer3DRendererMetadata );

QgsApplication::symbol3DRegistry()->addSymbolType( new Qgs3DSymbolMetadata( QStringLiteral( "point" ), QObject::tr( "Point" ),
&QgsPoint3DSymbol::create, nullptr, Qgs3DSymbolImpl::handlerForPoint3DSymbol ) );
@@ -56,6 +56,8 @@
#include "qgsmeshlayer3drenderer.h"
#include "qgspoint3dsymbol.h"
#include "qgsrulebased3drenderer.h"
#include "qgspointcloudlayer.h"
#include "qgspointcloudlayer3drenderer.h"
#include "qgssourcecache.h"
#include "qgsterrainentity_p.h"
#include "qgsterraingenerator.h"
@@ -734,6 +736,11 @@ void Qgs3DMapScene::addLayerEntity( QgsMapLayer *layer )
sym->setMaximumTextureSize( maximumTextureSize() );
meshRenderer->setSymbol( sym );
}
else if ( layer->type() == QgsMapLayerType::PointCloudLayer && renderer->type() == QLatin1String( "pointcloud" ) )
{
QgsPointCloudLayer3DRenderer *pointCloudRenderer = static_cast<QgsPointCloudLayer3DRenderer *>( renderer );
pointCloudRenderer->setLayer( static_cast<QgsPointCloudLayer *>( layer ) );
}

Qt3DCore::QEntity *newEntity = renderer->createEntity( mMap );
if ( newEntity )
@@ -22,6 +22,7 @@
#include "qgsonlineterraingenerator.h"
#include "qgsvectorlayer3drenderer.h"
#include "qgsmeshlayer3drenderer.h"
#include "qgspointcloudlayer3drenderer.h"

#include <QDomDocument>
#include <QDomElement>
@@ -216,6 +217,10 @@ void Qgs3DMapSettings::readXml( const QDomElement &elem, const QgsReadWriteConte
{
renderer = new QgsMeshLayer3DRenderer;
}
else if ( type == QLatin1String( "pointcloud" ) )
{
renderer = new QgsPointCloudLayer3DRenderer;
}

if ( renderer )
{
@@ -0,0 +1,107 @@
/***************************************************************************
qgspointcloudlayer3drenderer.cpp
--------------------------------------
Date : October 2020
Copyright : (C) 2020 by Peter Petrik
Email : zilolv dot sk at gmail dot com
***************************************************************************
* *
* 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 "qgspointcloudlayer3drenderer.h"

#include "qgs3dutils.h"
#include "qgschunkedentity_p.h"
#include "qgspointcloudlayerchunkloader_p.h"

#include "qgspointcloudlayer.h"
#include "qgsxmlutils.h"
#include "qgsapplication.h"
#include "qgs3dsymbolregistry.h"


QgsPointCloudLayer3DRendererMetadata::QgsPointCloudLayer3DRendererMetadata()
: Qgs3DRendererAbstractMetadata( QStringLiteral( "pointcloud" ) )
{
}

QgsAbstract3DRenderer *QgsPointCloudLayer3DRendererMetadata::createRenderer( QDomElement &elem, const QgsReadWriteContext &context )
{
QgsPointCloudLayer3DRenderer *r = new QgsPointCloudLayer3DRenderer;
r->readXml( elem, context );
return r;
}


// ---------


QgsPointCloudLayer3DRenderer::QgsPointCloudLayer3DRenderer( )
{
}

void QgsPointCloudLayer3DRenderer::setLayer( QgsPointCloudLayer *layer )
{
mLayerRef = QgsMapLayerRef( layer );
}

QgsPointCloudLayer *QgsPointCloudLayer3DRenderer::layer() const
{
return qobject_cast<QgsPointCloudLayer *>( mLayerRef.layer );
}

QgsPointCloudLayer3DRenderer *QgsPointCloudLayer3DRenderer::clone() const
{
QgsPointCloudLayer3DRenderer *r = new QgsPointCloudLayer3DRenderer;
return r;
}

Qt3DCore::QEntity *QgsPointCloudLayer3DRenderer::createEntity( const Qgs3DMapSettings &map ) const
{
QgsPointCloudLayer *vl = layer();
if ( !vl )
return nullptr;

double zMin, zMax;
//Qgs3DUtils::estimateVectorLayerZRange( vl, zMin, zMax );

return new QgsPointCloudLayerChunkedEntity( vl, zMin, zMax, map );
}

void QgsPointCloudLayer3DRenderer::writeXml( QDomElement &elem, const QgsReadWriteContext &context ) const
{
QDomDocument doc = elem.ownerDocument();

elem.setAttribute( QStringLiteral( "layer" ), mLayerRef.layerId );
/*
QDomElement elemSymbol = doc.createElement( QStringLiteral( "symbol" ) );
if ( mSymbol )
{
elemSymbol.setAttribute( QStringLiteral( "type" ), mSymbol->type() );
mSymbol->writeXml( elemSymbol, context );
}
elem.appendChild( elemSymbol );
*/
}

void QgsPointCloudLayer3DRenderer::readXml( const QDomElement &elem, const QgsReadWriteContext &context )
{
mLayerRef = QgsMapLayerRef( elem.attribute( QStringLiteral( "layer" ) ) );

/*
QDomElement elemSymbol = elem.firstChildElement( QStringLiteral( "symbol" ) );
QgsMesh3DSymbol *symbol = new QgsMesh3DSymbol;
symbol->readXml( elemSymbol, context );
mSymbol.reset( symbol );
*/
}

void QgsPointCloudLayer3DRenderer::resolveReferences( const QgsProject &project )
{
mLayerRef.setLayer( project.mapLayer( mLayerRef.layerId ) );
}
@@ -0,0 +1,86 @@
/***************************************************************************
qgspointcloudlayer3drenderer.h
--------------------------------------
Date : October 2020
Copyright : (C) 2020 by Peter Petrik
Email : zilolv dot sk at gmail dot com
***************************************************************************
* *
* 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 QGSPOINTCLOUDLAYER3DRENDERER_H
#define QGSPOINTCLOUDLAYER3DRENDERER_H

#include "qgis_3d.h"
#include "qgis_sip.h"

#include "qgs3drendererregistry.h"
#include "qgsabstract3drenderer.h"
#include "qgsmaplayerref.h"

#include <QObject>

class QgsPointCloudLayer;


/**
* \ingroup core
* Metadata for point cloud layer 3D renderer to allow creation of its instances from XML
*
* \warning This is not considered stable API, and may change in future QGIS releases. It is
* exposed to the Python bindings as a tech preview only.
*
* \since QGIS 3.18
*/
class _3D_EXPORT QgsPointCloudLayer3DRendererMetadata : public Qgs3DRendererAbstractMetadata
{
public:
QgsPointCloudLayer3DRendererMetadata();

//! Creates an instance of a 3D renderer based on a DOM element with renderer configuration
QgsAbstract3DRenderer *createRenderer( QDomElement &elem, const QgsReadWriteContext &context ) override SIP_FACTORY;
};


/**
* \ingroup core
* 3D renderer that renders all points from a point cloud layer
*
* \since QGIS 3.18
*/
class _3D_EXPORT QgsPointCloudLayer3DRenderer : public QgsAbstract3DRenderer
{
public:
//! Takes ownership of the symbol object
explicit QgsPointCloudLayer3DRenderer();

//! Sets point cloud layer associated with the renderer
void setLayer( QgsPointCloudLayer *layer );
//! Returns point cloud layer associated with the renderer
QgsPointCloudLayer *layer() const;

QString type() const override { return "pointcloud"; }
QgsPointCloudLayer3DRenderer *clone() const override SIP_FACTORY;
Qt3DCore::QEntity *createEntity( const Qgs3DMapSettings &map ) const override SIP_SKIP;

void writeXml( QDomElement &elem, const QgsReadWriteContext &context ) const override;
void readXml( const QDomElement &elem, const QgsReadWriteContext &context ) override;
void resolveReferences( const QgsProject &project ) override;

private:
QgsMapLayerRef mLayerRef; //!< Layer used to extract mesh data from

private:
#ifdef SIP_RUN
QgsPointCloudLayer3DRenderer( const QgsPointCloudLayer3DRenderer & );
QgsPointCloudLayer3DRenderer &operator=( const QgsPointCloudLayer3DRenderer & );
#endif
};


#endif // QGSPOINTCLOUDLAYER3DRENDERER_H

0 comments on commit b7e8071

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