Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add method to reset QgsAnnotationLayer back to default state
  • Loading branch information
nyalldawson committed Aug 27, 2020
1 parent 199cd7e commit 69665cd
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
Expand Up @@ -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.
Expand Down
8 changes: 8 additions & 0 deletions src/core/annotations/qgsannotationlayer.cpp
Expand Up @@ -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();
Expand Down
5 changes: 5 additions & 0 deletions src/core/annotations/qgsannotationlayer.h
Expand Up @@ -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.
*
Expand Down

0 comments on commit 69665cd

Please sign in to comment.