QGIS API Documentation 3.99.0-Master (2fe06baccd8)
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
18#include "qgis_sip.h"
19#include "qgscallout.h"
22#include "qgsvectorlayer.h"
23
24#include <QStandardItemModel>
25#include <QWidget>
26
33class GUI_EXPORT QgsCalloutWidget : public QWidget, protected QgsExpressionContextGenerator
34{
35 Q_OBJECT
36
37 public:
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
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:
100
102
103 private:
104 QgsMapLayer *mLayer = nullptr;
105
106 signals:
107
112 void changed();
113
114 private slots:
115 void updateDataDefinedProperty();
116
117 void createAuxiliaryField();
118
119 private:
120 QgsSymbolWidgetContext mContext;
121};
122
123
125
126#include "ui_widget_simplelinecallout.h"
127
129
130#ifndef SIP_RUN
132
133class GUI_EXPORT QgsSimpleLineCalloutWidget : public QgsCalloutWidget, private Ui::WidgetSimpleLineCallout
134{
135 Q_OBJECT
136
137 public:
138 QgsSimpleLineCalloutWidget( QgsMapLayer *vl, QWidget *parent SIP_TRANSFERTHIS = nullptr );
139
140 static QgsCalloutWidget *create( QgsMapLayer *vl ) SIP_FACTORY { return new QgsSimpleLineCalloutWidget( vl ); }
141
142 void setCallout( const QgsCallout *callout ) override;
143
144 QgsCallout *callout() override;
145
146 void setGeometryType( Qgis::GeometryType type ) override;
147
148 private slots:
149
150 void minimumLengthChanged();
151 void minimumLengthUnitWidgetChanged();
152 void offsetFromAnchorUnitWidgetChanged();
153 void offsetFromAnchorChanged();
154 void offsetFromLabelUnitWidgetChanged();
155 void offsetFromLabelChanged();
156 void lineSymbolChanged();
157 void mAnchorPointComboBox_currentIndexChanged( int index );
158 void mLabelAnchorPointComboBox_currentIndexChanged( int index );
159 void mCalloutBlendComboBox_currentIndexChanged( int index );
160 void drawToAllPartsToggled( bool active );
161
162 private:
163 std::unique_ptr<QgsSimpleLineCallout> mCallout;
164};
165
166class GUI_EXPORT QgsManhattanLineCalloutWidget : public QgsSimpleLineCalloutWidget
167{
168 Q_OBJECT
169
170 public:
171 QgsManhattanLineCalloutWidget( QgsMapLayer *vl, QWidget *parent SIP_TRANSFERTHIS = nullptr );
172
173 static QgsCalloutWidget *create( QgsMapLayer *vl ) SIP_FACTORY { return new QgsManhattanLineCalloutWidget( vl ); } // cppcheck-suppress duplInheritedMember
174};
175
176
178
179#include "ui_widget_curvedlinecallout.h"
180
182
183class GUI_EXPORT QgsCurvedLineCalloutWidget : public QgsCalloutWidget, private Ui::WidgetCurvedLineCallout
184{
185 Q_OBJECT
186
187 public:
188 QgsCurvedLineCalloutWidget( QgsMapLayer *vl, QWidget *parent SIP_TRANSFERTHIS = nullptr );
189
190 static QgsCalloutWidget *create( QgsMapLayer *vl ) SIP_FACTORY { return new QgsCurvedLineCalloutWidget( vl ); }
191
192 void setCallout( const QgsCallout *callout ) override;
193
194 QgsCallout *callout() override;
195
196 void setGeometryType( Qgis::GeometryType type ) override;
197
198 private slots:
199
200 void minimumLengthChanged();
201 void minimumLengthUnitWidgetChanged();
202 void offsetFromAnchorUnitWidgetChanged();
203 void offsetFromAnchorChanged();
204 void offsetFromLabelUnitWidgetChanged();
205 void offsetFromLabelChanged();
206 void lineSymbolChanged();
207 void mAnchorPointComboBox_currentIndexChanged( int index );
208 void mLabelAnchorPointComboBox_currentIndexChanged( int index );
209 void mCalloutBlendComboBox_currentIndexChanged( int index );
210 void drawToAllPartsToggled( bool active );
211
212 private:
213 std::unique_ptr<QgsCurvedLineCallout> mCallout;
214};
215
216
218
219#include "ui_widget_ballooncallout.h"
220
222
223class GUI_EXPORT QgsBalloonCalloutWidget : public QgsCalloutWidget, private Ui::WidgetBalloonCallout
224{
225 Q_OBJECT
226
227 public:
228 QgsBalloonCalloutWidget( QgsMapLayer *vl, QWidget *parent SIP_TRANSFERTHIS = nullptr );
229
230 static QgsCalloutWidget *create( QgsMapLayer *vl ) SIP_FACTORY { return new QgsBalloonCalloutWidget( vl ); }
231
232 void setCallout( const QgsCallout *callout ) override;
233
234 QgsCallout *callout() override;
235
236 void setGeometryType( Qgis::GeometryType type ) override;
237
238 private slots:
239
240 void offsetFromAnchorUnitWidgetChanged();
241 void offsetFromAnchorChanged();
242 void fillSymbolChanged();
243 void markerSymbolChanged();
244 void mAnchorPointComboBox_currentIndexChanged( int index );
245 void mCalloutBlendComboBox_currentIndexChanged( int index );
246
247 private:
248 std::unique_ptr<QgsBalloonCallout> mCallout;
249};
250
251#endif
253
254#endif // QGSCALLOUTWIDGET_H
GeometryType
The geometry types are used to group Qgis::WkbType in a coarse way.
Definition qgis.h:358
A cartoon talking bubble callout style.
Definition qgscallout.h:881
Base class for widgets which allow control over the properties of callouts.
QgsSymbolWidgetContext context() const
Returns the context in which the symbol widget is shown, e.g., the associated map canvas and expressi...
virtual void setContext(const QgsSymbolWidgetContext &context)
Sets the context in which the symbol widget is shown, e.g., the associated map canvas and expression ...
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.
void registerDataDefinedButton(QgsPropertyOverrideButton *button, QgsCallout::Property key)
Registers a data defined override button.
QgsCalloutWidget(QWidget *parent, QgsMapLayer *vl=nullptr)
Constructor for QgsCalloutWidget.
Abstract base class for callout renderers.
Definition qgscallout.h:55
Property
Data definable properties.
Definition qgscallout.h:87
Draws curved lines as callouts.
Definition qgscallout.h:786
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:80
A button for controlling property overrides which may apply to a widget.
A simple direct line callout style.
Definition qgscallout.h:515
Contains settings which reflect the context in which a symbol (or renderer) widget is shown,...
Represents a vector layer which manages a vector based dataset.
#define SIP_DEPRECATED
Definition qgis_sip.h:114
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:53
#define SIP_FACTORY
Definition qgis_sip.h:84