QGIS API Documentation 3.37.0-Master (fdefdf9c27f)
qgsgeometrywidget.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsgeometrywidget.h
3 --------------------------------------
4 Date : March 2015
5 Copyright : (C) 2015 Nyall Dawson
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 QGSGEOMETRYWIDGET_H
17#define QGSGEOMETRYWIDGET_H
18
19#include "qgis_gui.h"
20#include "qgis_sip.h"
21
22#include <QList>
23#include <QWidget>
24
26
27class QLineEdit;
28class QToolButton;
29class QMenu;
30
42class GUI_EXPORT QgsGeometryWidget : public QWidget
43{
44 Q_OBJECT
45
46 Q_PROPERTY( QgsReferencedGeometry geometryValue READ geometryValue WRITE setGeometryValue NOTIFY geometryValueChanged )
47
48 public:
49
53 explicit QgsGeometryWidget( QWidget *parent SIP_TRANSFERTHIS = nullptr );
54
64 void setGeometryValue( const QgsReferencedGeometry &geometry );
65
75 QgsReferencedGeometry geometryValue() const;
76
82 void setAcceptedWkbTypes( const QList<Qgis::WkbType> &types );
83
89 QList< Qgis::WkbType > acceptedWkbTypes() const;
90
96 bool isReadOnly() const;
97
98 public slots:
99
105 void setReadOnly( bool readOnly );
106
110 void clearGeometry();
111
117 void copyAsWkt();
118
124 void copyAsGeoJson();
125
126 signals:
127
135
136 private slots:
137
141 void pasteTriggered();
142
143 private:
144 QLineEdit *mLineEdit = nullptr;
145 QToolButton *mButton = nullptr;
146 QMenu *mMenu = nullptr;
147 QAction *mClearAction = nullptr;
148 QAction *mCopyWktAction = nullptr;
149 QAction *mCopyGeoJsonAction = nullptr;
150 QAction *mPasteAction = nullptr;
151 QgsReferencedGeometry mGeometry;
152 QgsReferencedGeometry mPastedGeom;
153 QList<Qgis::WkbType> mAcceptedTypes;
154 bool mReadOnly = false;
155
156 void fetchGeomFromClipboard();
157 bool typeIsAcceptable( Qgis::WkbType type ) const;
158
159 private slots:
160
161 void prepareMenu();
162 void updateLineEdit();
163};
164
165#endif // QGSGEOMETRYWIDGET_H
WkbType
The WKB type describes the number of dimensions a geometry has.
Definition: qgis.h:182
A widget for storing and interacting with a QgsGeometry object.
void geometryValueChanged(const QgsReferencedGeometry &value)
Emitted whenever the geometry value of the widget is changed.
A QgsGeometry with associated coordinate reference system.
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:53