QGIS API Documentation 3.41.0-Master (af5edcb665c)
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 "qgspallabeling.h"
22#include "qgstextformatwidget.h"
24#include "qgis_gui.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:
43 QgsLabelingGui( QgsVectorLayer *layer, QgsMapCanvas *mapCanvas, const QgsPalLayerSettings &settings, QWidget *parent = nullptr, Qgis::GeometryType geomType = Qgis::GeometryType::Unknown );
44
48 QgsLabelingGui( QgsMeshLayer *layer, QgsMapCanvas *mapCanvas, const QgsPalLayerSettings &settings, QWidget *parent = nullptr, Qgis::GeometryType geomType = Qgis::GeometryType::Unknown );
49
53 QgsLabelingGui( QgsVectorTileLayer *layer, QgsMapCanvas *mapCanvas, const QgsPalLayerSettings &settings, QWidget *parent = nullptr, Qgis::GeometryType geomType = Qgis::GeometryType::Unknown );
54
58 QgsLabelingGui( QgsMapCanvas *mapCanvas, const QgsPalLayerSettings &settings, QWidget *parent = nullptr );
59
60 QgsPalLayerSettings layerSettings();
61
62 enum LabelMode
63 {
64 NoLabels,
65 Labels,
66 ObstaclesOnly,
67 };
68
69 void setLabelMode( LabelMode mode );
70
71 virtual void setLayer( QgsMapLayer *layer );
72
73 void setSettings( const QgsPalLayerSettings &settings );
74
75 void setContext( const QgsSymbolWidgetContext &context ) override;
76
77 public slots:
78
79 void updateUi();
80
81 protected slots:
82 void setFormatFromStyle( const QString &name, QgsStyle::StyleEntity type, const QString &stylePath ) override;
83 void saveFormat() override;
84
85 protected:
98 QgsLabelingGui( QgsMapCanvas *mapCanvas, QWidget *parent, QgsMapLayer *layer ) SIP_SKIP;
99
105 void init();
106
107 void blockInitSignals( bool block );
108 void syncDefinedCheckboxFrame( QgsPropertyOverrideButton *ddBtn, QCheckBox *chkBx, QFrame *f );
109 bool eventFilter( QObject *object, QEvent *event ) override;
110
112 LabelMode mMode;
113
114 private slots:
115
121 void updateGeometryTypeBasedWidgets();
122 void showGeometryGeneratorExpressionBuilder();
123 void validateGeometryGeneratorExpression();
124 void determineGeometryGeneratorType();
125
129 void calloutTypeChanged();
130
131 private:
132 QgsPalLayerSettings mSettings;
133 QgsFeature mPreviewFeature;
134
135 QgsLabelObstacleSettings mObstacleSettings;
136 QgsLabelLineSettings mLineSettings;
137
139
140 private slots:
141
142 void updateCalloutWidget( QgsCallout *callout );
143 void showObstacleSettings();
144 void showLineAnchorSettings();
145};
146
147class GUI_EXPORT QgsLabelSettingsDialog : public QDialog
148{
149 Q_OBJECT
150
151 public:
152 QgsLabelSettingsDialog( const QgsPalLayerSettings &settings, QgsVectorLayer *layer, QgsMapCanvas *mapCanvas, QWidget *parent SIP_TRANSFERTHIS = nullptr, Qgis::GeometryType geomType = Qgis::GeometryType::Unknown );
153
154 QgsPalLayerSettings settings() const { return mWidget->layerSettings(); }
155
159 QDialogButtonBox *buttonBox() const;
160
161 private:
162 QgsLabelingGui *mWidget = nullptr;
163 QDialogButtonBox *mButtonBox = nullptr;
164
165 private slots:
166 void showHelp();
167};
168
170
171#endif // QGSLABELINGGUI_H
GeometryType
The geometry types are used to group Qgis::WkbType in a coarse way.
Definition qgis.h:337
@ Unknown
Unknown types.
Abstract base class for callout renderers.
Definition qgscallout.h:54
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.
Map canvas is a class for displaying all GIS data types on a canvas.
Base class for all map layer types.
Definition qgsmaplayer.h:76
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:203
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 data sets.
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:126