QGIS API Documentation  3.14.0-Pi (9f7028fd23)
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 
26 class QDialogButtonBox;
27 
28 #define SIP_NO_FILE
29 
31 
32 class GUI_EXPORT QgsLabelingGui : public QgsTextFormatWidget
33 {
34  Q_OBJECT
35 
36  public:
37  QgsLabelingGui( QgsVectorLayer *layer, QgsMapCanvas *mapCanvas, const QgsPalLayerSettings &settings, QWidget *parent = nullptr,
39 
40  QgsPalLayerSettings layerSettings();
41 
42  enum LabelMode
43  {
44  NoLabels,
45  Labels,
46  ObstaclesOnly,
47  };
48 
49  void setLabelMode( LabelMode mode );
50 
51  void setLayer( QgsMapLayer *layer );
52 
53  void setSettings( const QgsPalLayerSettings &settings );
54 
55  void setContext( const QgsSymbolWidgetContext &context ) override;
56 
57  public slots:
58 
59  void updateUi();
60 
61  protected slots:
62  void setFormatFromStyle( const QString &name, QgsStyle::StyleEntity type ) override;
63  void saveFormat() override;
64 
65  protected:
66  void blockInitSignals( bool block );
67  void syncDefinedCheckboxFrame( QgsPropertyOverrideButton *ddBtn, QCheckBox *chkBx, QFrame *f );
68 
69  private slots:
70 
76  void updateGeometryTypeBasedWidgets();
77  void showGeometryGeneratorExpressionBuilder();
78  void validateGeometryGeneratorExpression();
79  void determineGeometryGeneratorType();
80 
84  void calloutTypeChanged();
85 
86  private:
87 
89  QgsPalLayerSettings mSettings;
90  LabelMode mMode;
91  QgsFeature mPreviewFeature;
92  QgsMapCanvas *mCanvas = nullptr;
93 
94  QgsLabelObstacleSettings mObstacleSettings;
95 
97 
98  private slots:
99 
100  void initCalloutWidgets();
101  void updateCalloutWidget( QgsCallout *callout );
102  void showObstacleSettings();
103 
104 };
105 
106 class GUI_EXPORT QgsLabelSettingsDialog : public QDialog
107 {
108  Q_OBJECT
109 
110  public:
111 
112  QgsLabelSettingsDialog( const QgsPalLayerSettings &settings, QgsVectorLayer *layer, QgsMapCanvas *mapCanvas, QWidget *parent SIP_TRANSFERTHIS = nullptr,
114 
115  QgsPalLayerSettings settings() const { return mWidget->layerSettings(); }
116 
120  QDialogButtonBox *buttonBox() const;
121 
122  private:
123 
124  QgsLabelingGui *mWidget = nullptr;
125  QDialogButtonBox *mButtonBox = nullptr;
126 
127  private slots:
128  void showHelp();
129 
130 };
131 
133 
134 #endif // QGSLABELINGGUI_H
135 
136 
QgsExpressionContext
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
Definition: qgsexpressioncontext.h:369
QgsTextFormatWidget::createExpressionContext
QgsExpressionContext createExpressionContext() const override
This method needs to be reimplemented in all classes which implement this interface and return an exp...
Definition: qgstextformatwidget.cpp:1974
qgspallabeling.h
QgsCallout
Abstract base class for callout renderers.
Definition: qgscallout.h:46
QgsPalLayerSettings
Definition: qgspallabeling.h:205
QgsSymbolWidgetContext
Definition: qgssymbolwidgetcontext.h:35
QgsMapCanvas
Definition: qgsmapcanvas.h:83
QgsLabelObstacleSettings
Definition: qgslabelobstaclesettings.h:34
QgsPropertyOverrideButton
Definition: qgspropertyoverridebutton.h:50
qgstextformatwidget.h
QgsTextFormatWidget::setFormatFromStyle
virtual void setFormatFromStyle(const QString &name, QgsStyle::StyleEntity type)
Sets the current text settings from a style entry.
Definition: qgstextformatwidget.cpp:1768
QgsTextFormatWidget
Definition: qgstextformatwidget.h:50
QgsTextFormatWidget::setContext
virtual void setContext(const QgsSymbolWidgetContext &context)
Sets the context in which the widget is shown, e.g., the associated map canvas and expression context...
Definition: qgstextformatwidget.cpp:1157
QgsWkbTypes::GeometryType
GeometryType
The geometry types are used to group QgsWkbTypes::Type in a coarse way.
Definition: qgswkbtypes.h:139
QgsVectorLayer
Definition: qgsvectorlayer.h:385
QgsTextFormatWidget::saveFormat
virtual void saveFormat()
Saves the current text settings to a style entry.
Definition: qgstextformatwidget.cpp:1801
QgsMapLayer
Definition: qgsmaplayer.h:81
QgsWkbTypes::UnknownGeometry
@ UnknownGeometry
Definition: qgswkbtypes.h:144
QgsFeature
Definition: qgsfeature.h:55
SIP_TRANSFERTHIS
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:53
qgspropertyoverridebutton.h
QgsStyle::StyleEntity
StyleEntity
Enum for Entities involved in a style.
Definition: qgsstyle.h:178