QGIS API Documentation 3.41.0-Master (45a0abf3bec)
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
32class GUI_EXPORT QgsCalloutWidget : public QWidget, protected QgsExpressionContextGenerator
33{
34 Q_OBJECT
35
36 public:
37
43 QgsCalloutWidget( QWidget *parent SIP_TRANSFERTHIS, QgsMapLayer *vl = nullptr )
44 : QWidget( parent )
45 , mLayer( vl )
46 {}
47
52 virtual void setCallout( const QgsCallout *callout ) = 0;
53
59 virtual QgsCallout *callout() = 0;
60
66 virtual void setContext( const QgsSymbolWidgetContext &context );
67
72 QgsSymbolWidgetContext context() const;
73
79 Q_DECL_DEPRECATED const QgsVectorLayer *vectorLayer() const SIP_DEPRECATED { return qobject_cast< QgsVectorLayer * >( mLayer ); }
80
86 const QgsMapLayer *layer() const { return mLayer; }
87
91 virtual void setGeometryType( Qgis::GeometryType type ) = 0;
92
93 protected:
94
100 void registerDataDefinedButton( QgsPropertyOverrideButton *button, QgsCallout::Property key );
101
103
104 private:
105 QgsMapLayer *mLayer = nullptr;
106
107 signals:
108
113 void changed();
114
115 private slots:
116 void updateDataDefinedProperty();
117
118 void createAuxiliaryField();
119
120 private:
121 QgsSymbolWidgetContext mContext;
122};
123
124
126
127#include "ui_widget_simplelinecallout.h"
128
130
131#ifndef SIP_RUN
133
134class GUI_EXPORT QgsSimpleLineCalloutWidget : public QgsCalloutWidget, private Ui::WidgetSimpleLineCallout
135{
136 Q_OBJECT
137
138 public:
139
140 QgsSimpleLineCalloutWidget( QgsMapLayer *vl, QWidget *parent SIP_TRANSFERTHIS = nullptr );
141
142 static QgsCalloutWidget *create( QgsMapLayer *vl ) SIP_FACTORY { return new QgsSimpleLineCalloutWidget( vl ); }
143
144 void setCallout( const QgsCallout *callout ) override;
145
146 QgsCallout *callout() override;
147
148 void setGeometryType( Qgis::GeometryType type ) override;
149
150 private slots:
151
152 void minimumLengthChanged();
153 void minimumLengthUnitWidgetChanged();
154 void offsetFromAnchorUnitWidgetChanged();
155 void offsetFromAnchorChanged();
156 void offsetFromLabelUnitWidgetChanged();
157 void offsetFromLabelChanged();
158 void lineSymbolChanged();
159 void mAnchorPointComboBox_currentIndexChanged( int index );
160 void mLabelAnchorPointComboBox_currentIndexChanged( int index );
161 void mCalloutBlendComboBox_currentIndexChanged( int index );
162 void drawToAllPartsToggled( bool active );
163
164 private:
165 std::unique_ptr< QgsSimpleLineCallout > mCallout;
166
167};
168
169class GUI_EXPORT QgsManhattanLineCalloutWidget : public QgsSimpleLineCalloutWidget
170{
171 Q_OBJECT
172
173 public:
174
175 QgsManhattanLineCalloutWidget( QgsMapLayer *vl, QWidget *parent SIP_TRANSFERTHIS = nullptr );
176
177 static QgsCalloutWidget *create( QgsMapLayer *vl ) SIP_FACTORY { return new QgsManhattanLineCalloutWidget( vl ); } // cppcheck-suppress duplInheritedMember
178
179};
180
181
183
184#include "ui_widget_curvedlinecallout.h"
185
187
188class GUI_EXPORT QgsCurvedLineCalloutWidget : public QgsCalloutWidget, private Ui::WidgetCurvedLineCallout
189{
190 Q_OBJECT
191
192 public:
193
194 QgsCurvedLineCalloutWidget( QgsMapLayer *vl, QWidget *parent SIP_TRANSFERTHIS = nullptr );
195
196 static QgsCalloutWidget *create( QgsMapLayer *vl ) SIP_FACTORY { return new QgsCurvedLineCalloutWidget( vl ); }
197
198 void setCallout( const QgsCallout *callout ) override;
199
200 QgsCallout *callout() override;
201
202 void setGeometryType( Qgis::GeometryType type ) override;
203
204 private slots:
205
206 void minimumLengthChanged();
207 void minimumLengthUnitWidgetChanged();
208 void offsetFromAnchorUnitWidgetChanged();
209 void offsetFromAnchorChanged();
210 void offsetFromLabelUnitWidgetChanged();
211 void offsetFromLabelChanged();
212 void lineSymbolChanged();
213 void mAnchorPointComboBox_currentIndexChanged( int index );
214 void mLabelAnchorPointComboBox_currentIndexChanged( int index );
215 void mCalloutBlendComboBox_currentIndexChanged( int index );
216 void drawToAllPartsToggled( bool active );
217
218 private:
219 std::unique_ptr< QgsCurvedLineCallout > mCallout;
220
221};
222
223
225
226#include "ui_widget_ballooncallout.h"
227
229
230class GUI_EXPORT QgsBalloonCalloutWidget : public QgsCalloutWidget, private Ui::WidgetBalloonCallout
231{
232 Q_OBJECT
233
234 public:
235
236 QgsBalloonCalloutWidget( QgsMapLayer *vl, QWidget *parent SIP_TRANSFERTHIS = nullptr );
237
238 static QgsCalloutWidget *create( QgsMapLayer *vl ) SIP_FACTORY { return new QgsBalloonCalloutWidget( vl ); }
239
240 void setCallout( const QgsCallout *callout ) override;
241
242 QgsCallout *callout() override;
243
244 void setGeometryType( Qgis::GeometryType type ) override;
245
246 private slots:
247
248 void offsetFromAnchorUnitWidgetChanged();
249 void offsetFromAnchorChanged();
250 void fillSymbolChanged();
251 void markerSymbolChanged();
252 void mAnchorPointComboBox_currentIndexChanged( int index );
253 void mCalloutBlendComboBox_currentIndexChanged( int index );
254
255 private:
256 std::unique_ptr< QgsBalloonCallout > mCallout;
257
258};
259
260#endif
262
263#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...
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