QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
qgscreateannotationitemmaptool.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgscreateannotationitemmaptool.cpp
3  ------------------------
4  Date : September 2021
5  Copyright : (C) 2021 Nyall Dawson
6  Email : nyall dot dawson at gmail dot com
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 
17 #include "qgsmapcanvas.h"
18 #include "qgsannotationlayer.h"
19 #include "qgsannotationitem.h"
20 
22  : QObject( parent )
23  , mMapCanvas( canvas )
24  , mCadDockWidget( cadDockWidget )
25 {
26 
27 }
28 
30 {
31  return mCreatedItem.release();
32 }
33 
35 
37 {
38  if ( QgsAnnotationLayer *res = qobject_cast< QgsAnnotationLayer * >( mMapCanvas->currentLayer() ) )
39  return res;
40  else
42 }
43 
45 {
46  mCreatedItem.reset( item );
47  emit itemCreated();
48 }
qgsmapcanvas.h
QgsCreateAnnotationItemMapToolHandler::pushCreatedItem
void pushCreatedItem(QgsAnnotationItem *item)
Pushes a created item to the handler.
Definition: qgscreateannotationitemmaptool.cpp:44
qgscreateannotationitemmaptool.h
QgsMapCanvas
Map canvas is a class for displaying all GIS data types on a canvas.
Definition: qgsmapcanvas.h:89
QgsProject::instance
static QgsProject * instance()
Returns the QgsProject singleton instance.
Definition: qgsproject.cpp:480
QgsCreateAnnotationItemMapToolHandler::targetLayer
QgsAnnotationLayer * targetLayer()
Returns the target layer for newly created items.
Definition: qgscreateannotationitemmaptool.cpp:36
QgsCreateAnnotationItemMapToolHandler::takeCreatedItem
QgsAnnotationItem * takeCreatedItem()
Takes the newly created item from the tool, transferring ownership to the caller.
Definition: qgscreateannotationitemmaptool.cpp:29
QgsCreateAnnotationItemMapToolHandler::~QgsCreateAnnotationItemMapToolHandler
~QgsCreateAnnotationItemMapToolHandler() override
qgsannotationlayer.h
QgsAdvancedDigitizingDockWidget
The QgsAdvancedDigitizingDockWidget class is a dockable widget used to handle the CAD tools on top of...
Definition: qgsadvanceddigitizingdockwidget.h:50
QgsCreateAnnotationItemMapToolHandler::itemCreated
void itemCreated()
Emitted by the tool when a new annotation item has been created.
QgsAnnotationLayer
Represents a map layer containing a set of georeferenced annotations, e.g. markers,...
Definition: qgsannotationlayer.h:46
QgsMapCanvas::currentLayer
QgsMapLayer * currentLayer()
returns current layer (set by legend widget)
Definition: qgsmapcanvas.cpp:614
qgsannotationitem.h
QgsCreateAnnotationItemMapToolHandler::QgsCreateAnnotationItemMapToolHandler
QgsCreateAnnotationItemMapToolHandler(QgsMapCanvas *canvas, QgsAdvancedDigitizingDockWidget *cadDockWidget, QObject *parent=nullptr)
Constructor for QgsCreateAnnotationItemMapToolHandler, with the specified parent object.
Definition: qgscreateannotationitemmaptool.cpp:21
QgsProject::mainAnnotationLayer
QgsAnnotationLayer * mainAnnotationLayer()
Returns the main annotation layer associated with the project.
Definition: qgsproject.cpp:3925
QgsAnnotationItem
Abstract base class for annotation items which are drawn with QgsAnnotationLayers.
Definition: qgsannotationitem.h:42