QGIS API Documentation 3.99.0-Master (a8f284845db)
Loading...
Searching...
No Matches
qgslabelinggui.h
Go to the documentation of this file.
1/***************************************************************************
2 qgslabelinggui.h
3 Smart labeling for vector layers
4 -------------------
5 begin : June 2009
6 copyright : (C) Martin Dobias
7 email : wonder dot sk at gmail dot com
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#ifndef QGSLABELINGGUI_H
19#define QGSLABELINGGUI_H
20
21#include "qgis_gui.h"
22#include "qgspallabeling.h"
24#include "qgstextformatwidget.h"
25
26#define SIP_NO_FILE
27
28class QDialogButtonBox;
29
30class QgsMeshLayer;
32
33
35
36class GUI_EXPORT QgsLabelingGui : public QgsTextFormatWidget
37{
38 Q_OBJECT
39
40 public:
44 QgsLabelingGui( QgsVectorLayer *layer, QgsMapCanvas *mapCanvas, const QgsPalLayerSettings &settings, QWidget *parent = nullptr, Qgis::GeometryType geomType = Qgis::GeometryType::Unknown );
45
49 QgsLabelingGui( QgsMeshLayer *layer, QgsMapCanvas *mapCanvas, const QgsPalLayerSettings &settings, QWidget *parent = nullptr, Qgis::GeometryType geomType = Qgis::GeometryType::Unknown );
50
54 QgsLabelingGui( QgsVectorTileLayer *layer, QgsMapCanvas *mapCanvas, const QgsPalLayerSettings &settings, QWidget *parent = nullptr, Qgis::GeometryType geomType = Qgis::GeometryType::Unknown );
55
59 QgsLabelingGui( QgsMapCanvas *mapCanvas, const QgsPalLayerSettings &settings, QWidget *parent = nullptr );
60
61 QgsPalLayerSettings layerSettings();
62
63 enum LabelMode
64 {
65 NoLabels,
66 Labels,
67 ObstaclesOnly,
68 };
69
70 void setLabelMode( LabelMode mode );
71
72 virtual void setLayer( QgsMapLayer *layer );
73
74 void setSettings( const QgsPalLayerSettings &settings );
75
76 void setContext( const QgsSymbolWidgetContext &context ) override;
77
78 public slots:
79
80 void updateUi();
81
82 protected slots:
83 void setFormatFromStyle( const QString &name, QgsStyle::StyleEntity type, const QString &stylePath ) override;
84 void saveFormat() override;
85
86 protected:
99 QgsLabelingGui( QgsMapCanvas *mapCanvas, QWidget *parent, QgsMapLayer *layer ) SIP_SKIP;
100
106 void init();
107
108 void blockInitSignals( bool block );
109 void syncDefinedCheckboxFrame( QgsPropertyOverrideButton *ddBtn, QCheckBox *chkBx, QFrame *f );
110 bool eventFilter( QObject *object, QEvent *event ) override;
111
113 LabelMode mMode;
114
115 private slots:
116
122 void updateGeometryTypeBasedWidgets();
123 void showGeometryGeneratorExpressionBuilder();
124 void validateGeometryGeneratorExpression();
125 void determineGeometryGeneratorType();
126
130 void calloutTypeChanged();
131
132 private:
133 QgsPalLayerSettings mSettings;
134 QgsFeature mPreviewFeature;
135
136 QgsLabelObstacleSettings mObstacleSettings;
137 QgsLabelLineSettings mLineSettings;
138 QgsLabelThinningSettings mThinningSettings;
139
140 QgsExpressionContext createExpressionContext() const override;
141
142 private slots:
143
144 void updateCalloutWidget( QgsCallout *callout );
145 void showObstacleSettings();
146 void showLineAnchorSettings();
147 void showDuplicateSettings();
148};
149
150class GUI_EXPORT QgsLabelSettingsDialog : public QDialog
151{
152 Q_OBJECT
153
154 public:
155 QgsLabelSettingsDialog( const QgsPalLayerSettings &settings, QgsVectorLayer *layer, QgsMapCanvas *mapCanvas, QWidget *parent SIP_TRANSFERTHIS = nullptr, Qgis::GeometryType geomType = Qgis::GeometryType::Unknown );
156
157 QgsPalLayerSettings settings() const { return mWidget->layerSettings(); }
158
162 QDialogButtonBox *buttonBox() const;
163
164 private:
165 QgsLabelingGui *mWidget = nullptr;
166 QDialogButtonBox *mButtonBox = nullptr;
167
168 private slots:
169 void showHelp();
170};
171
173
174#endif // QGSLABELINGGUI_H
GeometryType
The geometry types are used to group Qgis::WkbType in a coarse way.
Definition qgis.h:376
@ Unknown
Unknown types.
Definition qgis.h:380
Map canvas is a class for displaying all GIS data types on a canvas.
Represents a mesh layer supporting display of data on structured or unstructured meshes.
Contains settings for how a map layer will be labeled.
StyleEntity
Enum for Entities involved in a style.
Definition qgsstyle.h:205
A widget for customizing text formatting settings.
QgsExpressionContext createExpressionContext() const override
This method needs to be reimplemented in all classes which implement this interface and return an exp...
virtual void setContext(const QgsSymbolWidgetContext &context)
Sets the context in which the widget is shown, e.g., the associated map canvas and expression context...
virtual void setFormatFromStyle(const QString &name, QgsStyle::StyleEntity type, const QString &stylePath)
Sets the current text settings from a style entry.
virtual void saveFormat()
Saves the current text settings to a style entry.
Represents a vector layer which manages a vector based dataset.
Implements a map layer that is dedicated to rendering of vector tiles.
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:52
#define SIP_SKIP
Definition qgis_sip.h:133