Skip to content
Permalink
Browse files

Add scale, offset and counter for points rendered to QgsPointCloudRen…

…derContext
  • Loading branch information
nyalldawson committed Nov 12, 2020
1 parent 2c59fac commit 1a2d6ec5d5b766034b5f0397a4e6f8156448ea09
@@ -26,9 +26,12 @@ Encapsulates the render context for a 2D point cloud rendering operation.
%End
public:

QgsPointCloudRenderContext( QgsRenderContext &context );
QgsPointCloudRenderContext( QgsRenderContext &context, const QgsVector3D &scale, const QgsVector3D &offset );
%Docstring
Constructor for QgsPointCloudRenderContext.

The ``scale`` and ``offset`` arguments specify the scale and offset of the layer's int32 coordinates
compared to CRS coordinates respectively.
%End


@@ -39,6 +42,29 @@ Returns a reference to the context's render context.
%End


QgsVector3D scale() const;
%Docstring
Returns the scale of the layer's int32 coordinates compared to CRS coords.
%End

QgsVector3D offset() const;
%Docstring
Returns the offset of the layer's int32 coordinates compared to CRS coords.
%End

long pointsRendered() const;
%Docstring
Returns the total number of points rendered.
%End

void incrementPointsRendered( long count );
%Docstring
Increments the count of points rendered by the specified amount.

It is a point cloud renderer's responsibility to correctly call this after
rendering a block of points.
%End

private:
QgsPointCloudRenderContext( const QgsPointCloudRenderContext &rh );
};
@@ -65,7 +91,6 @@ Returns a new default point cloud renderer.
Caller takes ownership of the returned renderer.
%End


virtual ~QgsPointCloudRenderer();

virtual QgsPointCloudRenderer *clone() const = 0 /Factory/;
@@ -135,6 +135,8 @@ QgsPointCloudLayerRenderer::QgsPointCloudLayerRenderer( QgsPointCloudLayer *laye
return;

mAttributes.push_back( *renderAttribute );
mScale = mLayer->dataProvider()->index()->scale();
mOffset = mLayer->dataProvider()->index()->offset();
}

bool QgsPointCloudLayerRenderer::render()
@@ -144,7 +146,7 @@ bool QgsPointCloudLayerRenderer::render()
if ( !pc )
return false;

QgsPointCloudRenderContext context( *renderContext() );
QgsPointCloudRenderContext context( *renderContext(), mScale, mOffset );


// Set up the render configuration options
@@ -119,6 +119,8 @@ class CORE_EXPORT QgsPointCloudLayerRenderer: public QgsMapLayerRenderer
std::unique_ptr< QgsPointCloudRenderer > mRenderer;

QgsPointCloudRendererConfig mConfig;
QgsVector3D mScale;
QgsVector3D mOffset;

QgsPointCloudAttributeCollection mAttributes;

@@ -17,12 +17,24 @@

#include "qgspointcloudrenderer.h"

QgsPointCloudRenderContext::QgsPointCloudRenderContext( QgsRenderContext &context )
QgsPointCloudRenderContext::QgsPointCloudRenderContext( QgsRenderContext &context, const QgsVector3D &scale, const QgsVector3D &offset )
: mRenderContext( context )
, mScale( scale )
, mOffset( offset )
{

}

long QgsPointCloudRenderContext::pointsRendered() const
{
return mPointsRendered;
}

void QgsPointCloudRenderContext::incrementPointsRendered( long count )
{
mPointsRendered += count;
}

QgsPointCloudRenderer *QgsPointCloudRenderer::defaultRenderer()
{

@@ -22,6 +22,7 @@

#include "qgis_core.h"
#include "qgis_sip.h"
#include "qgsvector3d.h"

class QgsPointCloudBlock;

@@ -40,8 +41,11 @@ class CORE_EXPORT QgsPointCloudRenderContext

/**
* Constructor for QgsPointCloudRenderContext.
*
* The \a scale and \a offset arguments specify the scale and offset of the layer's int32 coordinates
* compared to CRS coordinates respectively.
*/
QgsPointCloudRenderContext( QgsRenderContext &context );
QgsPointCloudRenderContext( QgsRenderContext &context, const QgsVector3D &scale, const QgsVector3D &offset );

//! QgsPointCloudRenderContext cannot be copied.
QgsPointCloudRenderContext( const QgsPointCloudRenderContext &rh ) = delete;
@@ -60,13 +64,38 @@ class CORE_EXPORT QgsPointCloudRenderContext
*/
const QgsRenderContext &renderContext() const { return mRenderContext; } SIP_SKIP

/**
* Returns the scale of the layer's int32 coordinates compared to CRS coords.
*/
QgsVector3D scale() const { return mScale; }

/**
* Returns the offset of the layer's int32 coordinates compared to CRS coords.
*/
QgsVector3D offset() const { return mOffset; }

/**
* Returns the total number of points rendered.
*/
long pointsRendered() const;

/**
* Increments the count of points rendered by the specified amount.
*
* It is a point cloud renderer's responsibility to correctly call this after
* rendering a block of points.
*/
void incrementPointsRendered( long count );

private:
#ifdef SIP_RUN
QgsPointCloudRenderContext( const QgsPointCloudRenderContext &rh );
#endif

QgsRenderContext &mRenderContext;

QgsVector3D mScale;
QgsVector3D mOffset;
long mPointsRendered = 0;
};


0 comments on commit 1a2d6ec

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