Skip to content
Permalink
Browse files

Add method to reset QgsAnnotationLayer back to default state

  • Loading branch information
nyalldawson committed Aug 27, 2020
1 parent 199cd7e commit 69665cd5347f47039c46aceb01464c4f5f5f74a8
@@ -50,6 +50,11 @@ The ``options`` argument specifies load-time layer options.
%End
~QgsAnnotationLayer();

void reset();
%Docstring
Resets the annotation layer to a default state, and clears all items from it.
%End

QString addItem( QgsAnnotationItem *item /Transfer/ );
%Docstring
Adds an ``item`` to the layer.
@@ -35,6 +35,14 @@ QgsAnnotationLayer::~QgsAnnotationLayer()
qDeleteAll( mItems );
}

void QgsAnnotationLayer::reset()
{
mOpacity = 100.0;
setCrs( QgsCoordinateReferenceSystem() );
setTransformContext( QgsCoordinateTransformContext() );
clear();
}

QString QgsAnnotationLayer::addItem( QgsAnnotationItem *item )
{
const QString uuid = QUuid::createUuid().toString();
@@ -72,6 +72,11 @@ class CORE_EXPORT QgsAnnotationLayer : public QgsMapLayer
QgsAnnotationLayer( const QString &name, const QgsAnnotationLayer::LayerOptions &options );
~QgsAnnotationLayer() override;

/**
* Resets the annotation layer to a default state, and clears all items from it.
*/
void reset();

/**
* Adds an \a item to the layer.
*

0 comments on commit 69665cd

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