QGIS API Documentation 3.40.0-Bratislava (b56115d8743)
Loading...
Searching...
No Matches
qgscalloutwidget.h
Go to the documentation of this file.
1/***************************************************************************
2 qgscalloutwidget.h
3 ---------------------
4 begin : July 2019
5 copyright : (C) 2019 by Nyall Dawson
6 email : nyall dot dawson at gmail dot com
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#ifndef QGSCALLOUTWIDGET_H
16#define QGSCALLOUTWIDGET_H
17
19#include "qgis_sip.h"
21#include "qgscallout.h"
22#include "qgsvectorlayer.h"
23#include <QWidget>
24#include <QStandardItemModel>
25
26class QgsMapCanvas;
27
34class GUI_EXPORT QgsCalloutWidget : public QWidget, protected QgsExpressionContextGenerator
35{
36 Q_OBJECT
37
38 public:
39
45 QgsCalloutWidget( QWidget *parent SIP_TRANSFERTHIS, QgsMapLayer *vl = nullptr )
46 : QWidget( parent )
47 , mLayer( vl )
48 {}
49
54 virtual void setCallout( const QgsCallout *callout ) = 0;
55
61 virtual QgsCallout *callout() = 0;
62
68 virtual void setContext( const QgsSymbolWidgetContext &context );
69
74 QgsSymbolWidgetContext context() const;
75
81 Q_DECL_DEPRECATED const QgsVectorLayer *vectorLayer() const SIP_DEPRECATED { return qobject_cast< QgsVectorLayer * >( mLayer ); }
82
88 const QgsMapLayer *layer() const { return mLayer; }
89
93 virtual void setGeometryType( Qgis::GeometryType type ) = 0;
94
95 protected:
96
102 void registerDataDefinedButton( QgsPropertyOverrideButton *button, QgsCallout::Property key );
103
105
106 private:
107 QgsMapLayer *mLayer = nullptr;
108
109 QgsMapCanvas *mMapCanvas = nullptr;
110
111 signals:
112
117 void changed();
118
119 private slots:
120 void updateDataDefinedProperty();
121
122 void createAuxiliaryField();
123
124 private:
125 QgsSymbolWidgetContext mContext;
126};
127
128
130
131#include "ui_widget_simplelinecallout.h"
132
134
135#ifndef SIP_RUN
137
138class GUI_EXPORT QgsSimpleLineCalloutWidget : public QgsCalloutWidget, private Ui::WidgetSimpleLineCallout
139{
140 Q_OBJECT
141
142 public:
143
144 QgsSimpleLineCalloutWidget( QgsMapLayer *vl, QWidget *parent SIP_TRANSFERTHIS = nullptr );
145
146 static QgsCalloutWidget *create( QgsMapLayer *vl ) SIP_FACTORY { return new QgsSimpleLineCalloutWidget( vl ); }
147
148 void setCallout( const QgsCallout *callout ) override;
149
150 QgsCallout *callout() override;
151
152 void setGeometryType( Qgis::GeometryType type ) override;
153
154 private slots:
155
156 void minimumLengthChanged();
157 void minimumLengthUnitWidgetChanged();
158 void offsetFromAnchorUnitWidgetChanged();
159 void offsetFromAnchorChanged();
160 void offsetFromLabelUnitWidgetChanged();
161 void offsetFromLabelChanged();
162 void lineSymbolChanged();
163 void mAnchorPointComboBox_currentIndexChanged( int index );
164 void mLabelAnchorPointComboBox_currentIndexChanged( int index );
165 void mCalloutBlendComboBox_currentIndexChanged( int index );
166 void drawToAllPartsToggled( bool active );
167
168 private:
169 std::unique_ptr< QgsSimpleLineCallout > mCallout;
170
171};
172
173class GUI_EXPORT QgsManhattanLineCalloutWidget : public QgsSimpleLineCalloutWidget
174{
175 Q_OBJECT
176
177 public:
178
179 QgsManhattanLineCalloutWidget( QgsMapLayer *vl, QWidget *parent SIP_TRANSFERTHIS = nullptr );
180
181 static QgsCalloutWidget *create( QgsMapLayer *vl ) SIP_FACTORY { return new QgsManhattanLineCalloutWidget( vl ); } // cppcheck-suppress duplInheritedMember
182
183};
184
185
187
188#include "ui_widget_curvedlinecallout.h"
189
191
192class GUI_EXPORT QgsCurvedLineCalloutWidget : public QgsCalloutWidget, private Ui::WidgetCurvedLineCallout
193{
194 Q_OBJECT
195
196 public:
197
198 QgsCurvedLineCalloutWidget( QgsMapLayer *vl, QWidget *parent SIP_TRANSFERTHIS = nullptr );
199
200 static QgsCalloutWidget *create( QgsMapLayer *vl ) SIP_FACTORY { return new QgsCurvedLineCalloutWidget( vl ); }
201
202 void setCallout( const QgsCallout *callout ) override;
203
204 QgsCallout *callout() override;
205
206 void setGeometryType( Qgis::GeometryType type ) override;
207
208 private slots:
209
210 void minimumLengthChanged();
211 void minimumLengthUnitWidgetChanged();
212 void offsetFromAnchorUnitWidgetChanged();
213 void offsetFromAnchorChanged();
214 void offsetFromLabelUnitWidgetChanged();
215 void offsetFromLabelChanged();
216 void lineSymbolChanged();
217 void mAnchorPointComboBox_currentIndexChanged( int index );
218 void mLabelAnchorPointComboBox_currentIndexChanged( int index );
219 void mCalloutBlendComboBox_currentIndexChanged( int index );
220 void drawToAllPartsToggled( bool active );
221
222 private:
223 std::unique_ptr< QgsCurvedLineCallout > mCallout;
224
225};
226
227
229
230#include "ui_widget_ballooncallout.h"
231
233
234class GUI_EXPORT QgsBalloonCalloutWidget : public QgsCalloutWidget, private Ui::WidgetBalloonCallout
235{
236 Q_OBJECT
237
238 public:
239
240 QgsBalloonCalloutWidget( QgsMapLayer *vl, QWidget *parent SIP_TRANSFERTHIS = nullptr );
241
242 static QgsCalloutWidget *create( QgsMapLayer *vl ) SIP_FACTORY { return new QgsBalloonCalloutWidget( vl ); }
243
244 void setCallout( const QgsCallout *callout ) override;
245
246 QgsCallout *callout() override;
247
248 void setGeometryType( Qgis::GeometryType type ) override;
249
250 private slots:
251
252 void offsetFromAnchorUnitWidgetChanged();
253 void offsetFromAnchorChanged();
254 void fillSymbolChanged();
255 void markerSymbolChanged();
256 void mAnchorPointComboBox_currentIndexChanged( int index );
257 void mCalloutBlendComboBox_currentIndexChanged( int index );
258
259 private:
260 std::unique_ptr< QgsBalloonCallout > mCallout;
261
262};
263
264#endif
266
267#endif // QGSCALLOUTWIDGET_H
GeometryType
The geometry types are used to group Qgis::WkbType in a coarse way.
Definition qgis.h:337
A cartoon talking bubble callout style.
Definition qgscallout.h:880
Base class for widgets which allow control over the properties of callouts.
virtual void setGeometryType(Qgis::GeometryType type)=0
Sets the geometry type of the features to customize the widget accordingly.
virtual QgsCallout * callout()=0
Returns the callout defined by the current settings in the widget.
const QgsMapLayer * layer() const
Returns the vector layer associated with the widget.
void changed()
Should be emitted whenever configuration changes happened on this symbol layer configuration.
Q_DECL_DEPRECATED const QgsVectorLayer * vectorLayer() const
Returns the vector layer associated with the widget.
virtual void setCallout(const QgsCallout *callout)=0
Sets the callout to show in the widget.
QgsCalloutWidget(QWidget *parent, QgsMapLayer *vl=nullptr)
Constructor for QgsCalloutWidget.
Abstract base class for callout renderers.
Definition qgscallout.h:54
Property
Data definable properties.
Definition qgscallout.h:86
Draws curved lines as callouts.
Definition qgscallout.h:785
Abstract interface for generating an expression context.
virtual QgsExpressionContext createExpressionContext() const =0
This method needs to be reimplemented in all classes which implement this interface and return an exp...
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
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
A button for controlling property overrides which may apply to a widget.
A simple direct line callout style.
Definition qgscallout.h:514
Contains settings which reflect the context in which a symbol (or renderer) widget is shown,...
Represents a vector layer which manages a vector based data sets.
#define SIP_DEPRECATED
Definition qgis_sip.h:106
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:53
#define SIP_FACTORY
Definition qgis_sip.h:76