QGIS API Documentation 3.41.0-Master (fda2aa46e9a)
Loading...
Searching...
No Matches
qgsadvanceddigitizingtoolsregistry.h
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
16#ifndef QGSADVANCEDDIGITIZINGTOOLSREGSITRY_H
17#define QGSADVANCEDDIGITIZINGTOOLSREGSITRY_H
18
19#include "qgis_sip.h"
20#include "qgis_gui.h"
21
22#include <QIcon>
23#include <QMap>
24
27class QgsMapCanvas;
28
35{
36 public:
37
45 QgsAdvancedDigitizingToolAbstractMetadata( const QString &name, const QString &visibleName, const QIcon &icon = QIcon() )
46 : mName( name )
47 , mVisibleName( visibleName )
48 , mIcon( icon )
49 {}
50
52
54 QString name() const { return mName; }
55
57 QString visibleName() const { return mVisibleName; }
58
60 QIcon icon() const { return mIcon; }
61
63 virtual QgsAdvancedDigitizingTool *createTool( QgsMapCanvas *canvas, QgsAdvancedDigitizingDockWidget *cadDockWidget ) SIP_FACTORY;
64
65 protected:
66 QString mName;
67 QString mVisibleName;
68 QIcon mIcon;
69};
70
71#ifndef SIP_RUN
72
74
82{
83 public:
84
94 QgsAdvancedDigitizingToolMetadata( const QString &name, const QString &visibleName, const QIcon &icon = QIcon(),
95 const QgsAdvancedDigitizingToolFunc &toolFunction = nullptr )
96 : QgsAdvancedDigitizingToolAbstractMetadata( name, visibleName, icon )
97 , mToolFunc( toolFunction )
98 {}
99
101 QgsAdvancedDigitizingToolFunc toolFunction() const { return mToolFunc; }
102
104 void setToolFunction( const QgsAdvancedDigitizingToolFunc &function ) { mToolFunc = function; }
105
106 QgsAdvancedDigitizingTool *createTool( QgsMapCanvas *canvas, QgsAdvancedDigitizingDockWidget *cadDockWidget ) override;
107
108 protected:
109 QgsAdvancedDigitizingToolFunc mToolFunc = nullptr;
110};
111
112#endif
113
124{
125 public:
126
129
132
134 void addDefaultTools();
135
137 bool addTool( QgsAdvancedDigitizingToolAbstractMetadata *toolMetaData SIP_TRANSFER );
138
140 bool removeTool( const QString &name );
141
143 QgsAdvancedDigitizingToolAbstractMetadata *toolMetadata( const QString &name );
144
146 const QStringList toolMetadataNames() const;
147
148 private:
149#ifdef SIP_RUN
151#endif
152
153 QMap<QString, QgsAdvancedDigitizingToolAbstractMetadata *> mTools;
154};
155
156#endif // QGSADVANCEDDIGITIZINGTOOLSREGSITRY_H
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 visibleName() const
Returns the tool's translatable user-friendly name.
QString name() const
Returns the tool's unique name.
QgsAdvancedDigitizingToolAbstractMetadata(const QString &name, const QString &visibleName, const QIcon &icon=QIcon())
Constructor for QgsAdvancedDigitizingToolAbstractMetadata with the specified tool name.
virtual ~QgsAdvancedDigitizingToolAbstractMetadata()=default
Convenience metadata class that uses static functions to handle advanced digitizing tool creation.
QgsAdvancedDigitizingToolFunc toolFunction() const
Returns the tool creation function.
void setToolFunction(const QgsAdvancedDigitizingToolFunc &function)
Sets the tool creation function.
QgsAdvancedDigitizingToolMetadata(const QString &name, const QString &visibleName, const QIcon &icon=QIcon(), const QgsAdvancedDigitizingToolFunc &toolFunction=nullptr)
Constructor for QgsAdvancedDigitizingToolAbstractMetadata with the specified tool name.
An abstract class for advanced digitizing tools.
Registry of available advanced digitizing tools.
QgsAdvancedDigitizingToolsRegistry(const QgsAdvancedDigitizingToolsRegistry &rh)=delete
QgsAdvancedDigitizingToolsRegistry & operator=(const QgsAdvancedDigitizingToolsRegistry &rh)=delete
Map canvas is a class for displaying all GIS data types on a canvas.
#define SIP_SKIP
Definition qgis_sip.h:126
#define SIP_TRANSFER
Definition qgis_sip.h:36
#define SIP_FACTORY
Definition qgis_sip.h:76
std::function< QgsAdvancedDigitizingTool *(QgsMapCanvas *, QgsAdvancedDigitizingDockWidget *)> QgsAdvancedDigitizingToolFunc