QGIS API Documentation 3.41.0-Master (af5edcb665c)
Loading...
Searching...
No Matches
qgsadvanceddigitizingtoolsregistry.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgsadvanceddigitizingtoolsregistry.cpp
3 -------------------
4 begin : July 27 2024
5 copyright : (C) 2024 by Mathieu Pellerin
6 email : mathieu at opengis dot ch
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
18#include "qgsapplication.h"
19
24
29
34
36{
37 addTool( new QgsAdvancedDigitizingToolMetadata( QStringLiteral( "circlesintersection" ), QObject::tr( "2-Circle Point Intersection" ), QgsApplication::getThemeIcon( QStringLiteral( "/cadtools/circlesintersection.svg" ) ), [=]( QgsMapCanvas *canvas, QgsAdvancedDigitizingDockWidget *cadDockWidget ) -> QgsAdvancedDigitizingTool * {
38 return new QgsAdvancedDigitizingCirclesIntersectionTool( canvas, cadDockWidget );
39 } ) );
40}
41
43{
44 if ( mTools.contains( toolMetaData->name() ) )
45 return false;
46
47 mTools[toolMetaData->name()] = toolMetaData;
48
49 return true;
50}
51
52
54{
55 if ( !mTools.contains( name ) )
56 return false;
57
58 delete mTools.take( name );
59
60 return true;
61}
62
64{
65 if ( !mTools.contains( name ) )
66 return nullptr;
67
68 return mTools[name];
69}
70
72{
73 return mTools.keys();
74}
A advanced digitizing tools to handle the selection of a point at the intersection of two circles.
The QgsAdvancedDigitizingDockWidget class is a dockable widget used to handle the CAD tools on top of...
Stores metadata about one advanced digitizing tool class.
QString name() const
Returns the tool's unique name.
virtual QgsAdvancedDigitizingTool * createTool(QgsMapCanvas *canvas, QgsAdvancedDigitizingDockWidget *cadDockWidget)
Returns new tool of this type. Return nullptr on error.
Convenience metadata class that uses static functions to handle advanced digitizing tool creation.
QgsAdvancedDigitizingTool * createTool(QgsMapCanvas *canvas, QgsAdvancedDigitizingDockWidget *cadDockWidget) override
Returns new tool of this type. Return nullptr on error.
An abstract class for advanced digitizing tools.
bool removeTool(const QString &name)
Removes the advanced digitizing tool matching the provided name and return true on success.
bool addTool(QgsAdvancedDigitizingToolAbstractMetadata *toolMetaData)
Adds an advanced digitizing tool (take ownership) and return true on success.
QgsAdvancedDigitizingToolAbstractMetadata * toolMetadata(const QString &name)
Returns the advanced digitizing tool matching the provided name or nullptr when no match available.
void addDefaultTools()
Adds the default tools shipped in QGIS.
const QStringList toolMetadataNames() const
Returns the list of registered tool names.
static QIcon getThemeIcon(const QString &name, const QColor &fillColor=QColor(), const QColor &strokeColor=QColor())
Helper to get a theme icon.
Map canvas is a class for displaying all GIS data types on a canvas.