Skip to content
Permalink
Browse files

Default to a RGB renderer for point clouds with Red/Green/Blue attrib…

…utes present
  • Loading branch information
nyalldawson committed Nov 12, 2020
1 parent 9b8da23 commit 515892242816672d425e575879201dfdc0caf36f
@@ -126,13 +126,6 @@ Abstract base class for 2d point cloud renderers.
%End
public:

static QgsPointCloudRenderer *defaultRenderer() /Factory/;
%Docstring
Returns a new default point cloud renderer.

Caller takes ownership of the returned renderer.
%End

virtual ~QgsPointCloudRenderer();

virtual QString type() const = 0;
@@ -8,6 +8,7 @@




class QgsPointCloudRendererAbstractMetadata
{
%Docstring
@@ -150,6 +151,13 @@ renderer was not found in the registry.
QStringList renderersList() const;
%Docstring
Returns a list of available renderers.
%End

static QgsPointCloudRenderer *defaultRenderer( const QgsPointCloudAttributeCollection &attributes ) /Factory/;
%Docstring
Returns a new default point cloud renderer for a layer with the specified ``attributes``.

Caller takes ownership of the returned renderer.
%End

private:
@@ -27,6 +27,8 @@
#include "qgsruntimeprofiler.h"
#include "qgsapplication.h"
#include "qgspainting.h"
#include "qgspointcloudrendererregistry.h"


QgsPointCloudLayer::QgsPointCloudLayer( const QString &path,
const QString &baseName,
@@ -162,7 +164,7 @@ bool QgsPointCloudLayer::readStyle( const QDomNode &node, QString &, QgsReadWrit
// make sure layer has a renderer - if none exists, fallback to a default renderer
if ( !mRenderer )
{
setRenderer( QgsPointCloudRenderer::defaultRenderer() );
setRenderer( QgsApplication::pointCloudRendererRegistry()->defaultRenderer( attributes() ) );
}
}

@@ -334,7 +336,7 @@ void QgsPointCloudLayer::setDataSource( const QString &dataSource, const QString
if ( !defaultLoadedFlag )
{
// all else failed, create default renderer
setRenderer( QgsPointCloudRenderer::defaultRenderer() );
setRenderer( QgsApplication::pointCloudRendererRegistry()->defaultRenderer( attributes() ) );
}
}

@@ -47,11 +47,6 @@ void QgsPointCloudRenderContext::setAttributes( const QgsPointCloudAttributeColl
attributes.find( QStringLiteral( "Y" ), mYOffset );
}

QgsPointCloudRenderer *QgsPointCloudRenderer::defaultRenderer()
{
return new QgsDummyPointCloudRenderer();
}

QgsPointCloudRenderer *QgsPointCloudRenderer::load( QDomElement &element, const QgsReadWriteContext &context )
{
if ( element.isNull() )
@@ -162,13 +162,6 @@ class CORE_EXPORT QgsPointCloudRenderer

public:

/**
* Returns a new default point cloud renderer.
*
* Caller takes ownership of the returned renderer.
*/
static QgsPointCloudRenderer *defaultRenderer() SIP_FACTORY;

virtual ~QgsPointCloudRenderer() = default;

/**
@@ -74,3 +74,12 @@ QStringList QgsPointCloudRendererRegistry::renderersList() const
return renderers;
}

QgsPointCloudRenderer *QgsPointCloudRendererRegistry::defaultRenderer( const QgsPointCloudAttributeCollection &attributes )
{
//if red/green/blue attributes are present, then default to a RGB renderer
if ( attributes.indexOf( QStringLiteral( "Red" ) ) >= 0 && attributes.indexOf( QStringLiteral( "Green" ) ) >= 0 && attributes.indexOf( QStringLiteral( "Blue" ) ) >= 0 )
return new QgsPointCloudRgbRenderer();

return new QgsDummyPointCloudRenderer();
}

@@ -30,6 +30,8 @@ class QgsStyle;
class QgsPointCloudRendererWidget SIP_EXTERNAL;
#endif

class QgsPointCloudAttributeCollection;

/**
* \ingroup core
* Stores metadata about one point cloud renderer class.
@@ -216,6 +218,13 @@ class CORE_EXPORT QgsPointCloudRendererRegistry
*/
QStringList renderersList() const;

/**
* Returns a new default point cloud renderer for a layer with the specified \a attributes.
*
* Caller takes ownership of the returned renderer.
*/
static QgsPointCloudRenderer *defaultRenderer( const QgsPointCloudAttributeCollection &attributes ) SIP_FACTORY;

private:
#ifdef SIP_RUN
QgsPointCloudRendererRegistry( const QgsPointCloudRendererRegistry &rh );

0 comments on commit 5158922

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