Skip to content
Permalink
Browse files

Add more methods to QgsPointCloudRenderer class

  • Loading branch information
nyalldawson committed Nov 12, 2020
1 parent 1a2d6ec commit 1feccd1ea158879f4ea47e14da932439789389a4
@@ -104,8 +104,61 @@ and generate a proper subclass.
Renders a ``block`` of point cloud data using the specified render ``context``.
%End

};
static QgsPointCloudRenderer *load( QDomElement &element, const QgsReadWriteContext &context ) /Factory/;
%Docstring
Creates a renderer from an XML ``element``.

Caller takes ownership of the returned renderer.

.. seealso:: :py:func:`save`
%End

virtual QDomElement save( QDomDocument &doc, const QgsReadWriteContext &context ) const = 0;
%Docstring
Saves the renderer configuration to an XML element.

.. seealso:: :py:func:`load`
%End

virtual QSet< QString > usedAttributes( const QgsPointCloudRenderContext &context ) const;
%Docstring
Returns a list of attributes required by this renderer. Attributes not listed in here may
not be requested from the provider at rendering time.

.. note::

the "X" and "Y" attributes will always be fetched and do not need to be explicitly
returned here.
%End

virtual void startRender( QgsPointCloudRenderContext &context );
%Docstring
Must be called when a new render cycle is started. A call to :py:func:`~QgsPointCloudRenderer.startRender` must always
be followed by a corresponding call to :py:func:`~QgsPointCloudRenderer.stopRender` after all features have been rendered.

.. seealso:: :py:func:`stopRender`

.. warning::

This method is not thread safe. Before calling :py:func:`~QgsPointCloudRenderer.startRender` in a non-main thread,
the renderer should instead be cloned and :py:func:`~QgsPointCloudRenderer.startRender`/:py:func:`~QgsPointCloudRenderer.stopRender` called on the clone.
%End

virtual void stopRender( QgsPointCloudRenderContext &context );
%Docstring
Must be called when a render cycle has finished, to allow the renderer to clean up.

Calls to :py:func:`~QgsPointCloudRenderer.stopRender` must always be preceded by a call to :py:func:`~QgsPointCloudRenderer.startRender`.

.. warning::

This method is not thread safe. Before calling :py:func:`~QgsPointCloudRenderer.startRender` in a non-main thread,
the renderer should instead be cloned and :py:func:`~QgsPointCloudRenderer.startRender`/:py:func:`~QgsPointCloudRenderer.stopRender` called on the clone.

.. seealso:: :py:func:`startRender`
%End

};

/************************************************************************
* This file has been generated automatically from *
@@ -39,3 +39,48 @@ QgsPointCloudRenderer *QgsPointCloudRenderer::defaultRenderer()
{

}

QgsPointCloudRenderer *QgsPointCloudRenderer::load( QDomElement &element, const QgsReadWriteContext &context )
{
if ( element.isNull() )
return nullptr;

// load renderer
QString rendererType = element.attribute( QStringLiteral( "type" ) );

#if 0
QgsRendererAbstractMetadata *m = QgsApplication::rendererRegistry()->rendererMetadata( rendererType );
if ( !m )
return nullptr;

std::unique_ptr< QgsPointCloudRenderer > r( m->createRenderer( element, context ) );
return r.release();
#endif
return new QgsDummyPointCloudRenderer();
}

QSet<QString> QgsPointCloudRenderer::usedAttributes( const QgsPointCloudRenderContext & ) const
{
return QSet< QString >();
}

void QgsPointCloudRenderer::startRender( QgsPointCloudRenderContext & )
{
#ifdef QGISDEBUG
if ( !mThread )
{
mThread = QThread::currentThread();
}
else
{
Q_ASSERT_X( mThread == QThread::currentThread(), "QgsPointCloudRenderer::startRender", "startRender called in a different thread - use a cloned renderer instead" );
}
#endif
}

void QgsPointCloudRenderer::stopRender( QgsPointCloudRenderContext & )
{
#ifdef QGISDEBUG
Q_ASSERT_X( mThread == QThread::currentThread(), "QgsPointCloudRenderer::stopRender", "stopRender called in a different thread - use a cloned renderer instead" );
#endif
}
@@ -118,7 +118,6 @@ class CORE_EXPORT QgsPointCloudRenderer
*/
static QgsPointCloudRenderer *defaultRenderer() SIP_FACTORY;


virtual ~QgsPointCloudRenderer() = default;

/**
@@ -132,7 +131,58 @@ class CORE_EXPORT QgsPointCloudRenderer
*/
virtual void renderBlock( const QgsPointCloudBlock *block, QgsPointCloudRenderContext &context ) = 0;

};
/**
* Creates a renderer from an XML \a element.
*
* Caller takes ownership of the returned renderer.
*
* \see save()
*/
static QgsPointCloudRenderer *load( QDomElement &element, const QgsReadWriteContext &context ) SIP_FACTORY;

/**
* Saves the renderer configuration to an XML element.
* \see load()
*/
virtual QDomElement save( QDomDocument &doc, const QgsReadWriteContext &context ) const = 0;

/**
* Returns a list of attributes required by this renderer. Attributes not listed in here may
* not be requested from the provider at rendering time.
*
* \note the "X" and "Y" attributes will always be fetched and do not need to be explicitly
* returned here.
*/
virtual QSet< QString > usedAttributes( const QgsPointCloudRenderContext &context ) const;

/**
* Must be called when a new render cycle is started. A call to startRender() must always
* be followed by a corresponding call to stopRender() after all features have been rendered.
*
* \see stopRender()
*
* \warning This method is not thread safe. Before calling startRender() in a non-main thread,
* the renderer should instead be cloned and startRender()/stopRender() called on the clone.
*/
virtual void startRender( QgsPointCloudRenderContext &context );

/**
* Must be called when a render cycle has finished, to allow the renderer to clean up.
*
* Calls to stopRender() must always be preceded by a call to startRender().
*
* \warning This method is not thread safe. Before calling startRender() in a non-main thread,
* the renderer should instead be cloned and startRender()/stopRender() called on the clone.
*
* \see startRender()
*/
virtual void stopRender( QgsPointCloudRenderContext &context );

private:
#ifdef QGISDEBUG
//! Pointer to thread in which startRender was first called
QThread *mThread = nullptr;
#endif
};

#endif // QGSPOINTCLOUDRENDERER_H

0 comments on commit 1feccd1

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