QGIS API Documentation 3.41.0-Master (af5edcb665c)
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:
44 QgsAdvancedDigitizingToolAbstractMetadata( const QString &name, const QString &visibleName, const QIcon &icon = QIcon() )
45 : mName( name )
46 , mVisibleName( visibleName )
47 , mIcon( icon )
48 {}
49
51
53 QString name() const { return mName; }
54
56 QString visibleName() const { return mVisibleName; }
57
59 QIcon icon() const { return mIcon; }
60
62 virtual QgsAdvancedDigitizingTool *createTool( QgsMapCanvas *canvas, QgsAdvancedDigitizingDockWidget *cadDockWidget ) SIP_FACTORY;
63
64 protected:
65 QString mName;
66 QString mVisibleName;
67 QIcon mIcon;
68};
69
70#ifndef SIP_RUN
71
73
81{
82 public:
92 QgsAdvancedDigitizingToolMetadata( const QString &name, const QString &visibleName, const QIcon &icon = QIcon(), const QgsAdvancedDigitizingToolFunc &toolFunction = nullptr )
93 : QgsAdvancedDigitizingToolAbstractMetadata( name, visibleName, icon )
94 , mToolFunc( toolFunction )
95 {}
96
98 QgsAdvancedDigitizingToolFunc toolFunction() const { return mToolFunc; }
99
101 void setToolFunction( const QgsAdvancedDigitizingToolFunc &function ) { mToolFunc = function; }
102
103 QgsAdvancedDigitizingTool *createTool( QgsMapCanvas *canvas, QgsAdvancedDigitizingDockWidget *cadDockWidget ) override;
104
105 protected:
106 QgsAdvancedDigitizingToolFunc mToolFunc = nullptr;
107};
108
109#endif
110
121{
122 public:
125
128
130 void addDefaultTools();
131
133 bool addTool( QgsAdvancedDigitizingToolAbstractMetadata *toolMetaData SIP_TRANSFER );
134
136 bool removeTool( const QString &name );
137
139 QgsAdvancedDigitizingToolAbstractMetadata *toolMetadata( const QString &name );
140
142 const QStringList toolMetadataNames() const;
143
144 private:
145#ifdef SIP_RUN
147#endif
148
149 QMap<QString, QgsAdvancedDigitizingToolAbstractMetadata *> mTools;
150};
151
152#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