QGIS API Documentation
3.40.0-Bratislava (b56115d8743)
Loading...
Searching...
No Matches
src
gui
maptools
qgsmaptoolshaperegistry.cpp
Go to the documentation of this file.
1
/***************************************************************************
2
qgsmaptoolshaperegistry.cpp
3
----------------------
4
begin : January 2022
5
copyright : (C) 2022 by Denis Rouzaud
6
email :
[email protected]
7
***************************************************************************/
8
9
/***************************************************************************
10
* *
11
* This program is free software; you can redistribute it and/or modify *
12
* it under the terms of the GNU General Public License as published by *
13
* the Free Software Foundation; either version 2 of the License, or *
14
* (at your option) any later version. *
15
* *
16
***************************************************************************/
17
18
#include "
qgsmaptoolshaperegistry.h
"
19
20
21
QgsMapToolShapeRegistry::QgsMapToolShapeRegistry
()
22
{
23
}
24
25
QgsMapToolShapeRegistry::~QgsMapToolShapeRegistry
()
26
{
27
qDeleteAll( mMapTools );
28
mMapTools.clear();
29
}
30
31
void
QgsMapToolShapeRegistry::addMapTool
(
QgsMapToolShapeMetadata
*mapTool )
32
{
33
if
( !
mapTool
)
34
return
;
35
36
if
(
mapToolMetadata
(
mapTool
->
id
() ) )
37
return
;
38
39
mMapTools.append(
mapTool
);
40
}
41
42
void
QgsMapToolShapeRegistry::removeMapTool
(
const
QString &
id
)
43
{
44
QList<QgsMapToolShapeMetadata *>::iterator it = mMapTools.begin();
45
while
( it != mMapTools.end() )
46
{
47
if
( ( *it )->id() ==
id
)
48
{
49
delete
*it;
50
it = mMapTools.erase( it );
51
}
52
else
53
{
54
++it;
55
}
56
}
57
}
58
59
QgsMapToolShapeMetadata
*
QgsMapToolShapeRegistry::mapToolMetadata
(
const
QString &
id
)
const
60
{
61
for
(
QgsMapToolShapeMetadata
*md : std::as_const( mMapTools ) )
62
{
63
if
( md->id() == id )
64
return
md;
65
}
66
67
return
nullptr
;
68
}
69
70
QgsMapToolShapeAbstract
*
QgsMapToolShapeRegistry::mapTool
(
const
QString &
id
,
QgsMapToolCapture
*parentTool )
const
71
{
72
QgsMapToolShapeMetadata
*md =
mapToolMetadata
(
id
);
73
if
( !md )
74
return
nullptr
;
75
76
return
md->
factory
( parentTool );
77
}
QgsMapToolCapture
QgsMapToolCapture is a base class capable of capturing point, lines and polygons.
Definition
qgsmaptoolcapture.h:49
QgsMapToolShapeAbstract
QgsMapToolShapeAbstract is a base class for shape map tools to be used by QgsMapToolCapture.
Definition
qgsmaptoolshapeabstract.h:42
QgsMapToolShapeAbstract::id
QString id() const
Returns the id of the shape tool (equivalent to the one from the metadata)
Definition
qgsmaptoolshapeabstract.h:67
QgsMapToolShapeMetadata
QgsMapToolShapeMetadata is a base class for shape map tools metadata to be used in QgsMapToolShapeReg...
Definition
qgsmaptoolshaperegistry.h:82
QgsMapToolShapeMetadata::factory
virtual QgsMapToolShapeAbstract * factory(QgsMapToolCapture *parentlTool) const =0
Creates the shape map tool for the given parentTool Caller takes ownership of the returned object.
QgsMapToolShapeRegistry::mapTool
QgsMapToolShapeAbstract * mapTool(const QString &id, QgsMapToolCapture *parentTool) const
Constructs the map tool at the given id for the given parentTool Caller takes ownership of the return...
Definition
qgsmaptoolshaperegistry.cpp:70
QgsMapToolShapeRegistry::~QgsMapToolShapeRegistry
~QgsMapToolShapeRegistry()
Definition
qgsmaptoolshaperegistry.cpp:25
QgsMapToolShapeRegistry::removeMapTool
void removeMapTool(const QString &id)
Removes a registered map tool at the given id The tool will be deleted.
Definition
qgsmaptoolshaperegistry.cpp:42
QgsMapToolShapeRegistry::addMapTool
void addMapTool(QgsMapToolShapeMetadata *mapTool)
Adds a new shape map tool.
Definition
qgsmaptoolshaperegistry.cpp:31
QgsMapToolShapeRegistry::QgsMapToolShapeRegistry
QgsMapToolShapeRegistry()
Constructor.
Definition
qgsmaptoolshaperegistry.cpp:21
QgsMapToolShapeRegistry::mapToolMetadata
QgsMapToolShapeMetadata * mapToolMetadata(const QString &id) const
Returns the map tool metadata for the given id.
Definition
qgsmaptoolshaperegistry.cpp:59
qgsmaptoolshaperegistry.h
Generated on Mon Oct 28 2024 22:06:03 for QGIS API Documentation by
1.9.8