QGIS API Documentation 3.99.0-Master (26c88405ac0)
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
26class QDialogButtonBox;
27
28class QgsMeshLayer;
30
31#define SIP_NO_FILE
32
34
35class GUI_EXPORT QgsLabelingGui : public QgsTextFormatWidget
36{
37 Q_OBJECT
38
39 public:
40
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:
87
100 QgsLabelingGui( QgsMapCanvas *mapCanvas, QWidget *parent, QgsMapLayer *layer ) SIP_SKIP;
101
107 void init();
108
109 void blockInitSignals( bool block );
110 void syncDefinedCheckboxFrame( QgsPropertyOverrideButton *ddBtn, QCheckBox *chkBx, QFrame *f );
111 bool eventFilter( QObject *object, QEvent *event ) override;
112
114 LabelMode mMode;
115
116 private slots:
117
123 void updateGeometryTypeBasedWidgets();
124 void showGeometryGeneratorExpressionBuilder();
125 void validateGeometryGeneratorExpression();
126 void determineGeometryGeneratorType();
127
131 void calloutTypeChanged();
132
133 private:
134 QgsPalLayerSettings mSettings;
135 QgsFeature mPreviewFeature;
136
137 QgsLabelObstacleSettings mObstacleSettings;
138 QgsLabelLineSettings mLineSettings;
139 QgsLabelThinningSettings mThinningSettings;
140
142
143 private slots:
144
145 void updateCalloutWidget( QgsCallout *callout );
146 void showObstacleSettings();
147 void showLineAnchorSettings();
148 void showDuplicateSettings();
149};
150
151class GUI_EXPORT QgsLabelSettingsDialog : public QDialog
152{
153 Q_OBJECT
154
155 public:
156 QgsLabelSettingsDialog( const QgsPalLayerSettings &settings, QgsVectorLayer *layer, QgsMapCanvas *mapCanvas, QWidget *parent SIP_TRANSFERTHIS = nullptr, Qgis::GeometryType geomType = Qgis::GeometryType::Unknown );
157
158 QgsPalLayerSettings settings() const { return mWidget->layerSettings(); }
159
163 QDialogButtonBox *buttonBox() const;
164
165 private:
166 QgsLabelingGui *mWidget = nullptr;
167 QDialogButtonBox *mButtonBox = nullptr;
168
169 private slots:
170 void showHelp();
171};
172
174
175#endif // QGSLABELINGGUI_H
GeometryType
The geometry types are used to group Qgis::WkbType in a coarse way.
Definition qgis.h:358
@ Unknown
Unknown types.
Definition qgis.h:362
Abstract base class for callout renderers.
Definition qgscallout.h:55
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Definition qgsfeature.h:58
Contains settings related to how the label engine places and formats labels for line features (or pol...
Contains settings related to how the label engine treats features as obstacles.
Contains settings related to how the label engine removes candidate label positions and reduces the n...
Map canvas is a class for displaying all GIS data types on a canvas.
Base class for all map layer types.
Definition qgsmaplayer.h:80
Represents a mesh layer supporting display of data on structured or unstructured meshes.
Contains settings for how a map layer will be labeled.
A button for controlling property overrides which may apply to a widget.
StyleEntity
Enum for Entities involved in a style.
Definition qgsstyle.h:204
Contains settings which reflect the context in which a symbol (or renderer) widget is shown,...
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:53
#define SIP_SKIP
Definition qgis_sip.h:134