QGIS API Documentation 3.34.0-Prizren (ffbdd678812)
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 <QWidget>
23#include <QStandardItemModel>
24
25class QgsVectorLayer;
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, QgsVectorLayer *vl = nullptr )
46 : QWidget( parent )
47 , mVectorLayer( vl )
48 {}
49
54 virtual void setCallout( QgsCallout *callout ) = 0;
55
61 virtual QgsCallout *callout() = 0;
62
68 virtual void setContext( const QgsSymbolWidgetContext &context );
69
74 QgsSymbolWidgetContext context() const;
75
79 const QgsVectorLayer *vectorLayer() const { return mVectorLayer; }
80
84 virtual void setGeometryType( Qgis::GeometryType type ) = 0;
85
86 protected:
87
93 void registerDataDefinedButton( QgsPropertyOverrideButton *button, QgsCallout::Property key );
94
96
97 private:
98 QgsVectorLayer *mVectorLayer = nullptr;
99
100 QgsMapCanvas *mMapCanvas = nullptr;
101
102 signals:
103
108 void changed();
109
110 private slots:
111 void updateDataDefinedProperty();
112
113 void createAuxiliaryField();
114
115 private:
116 QgsSymbolWidgetContext mContext;
117};
118
119
121
122#include "ui_widget_simplelinecallout.h"
123
125
126#ifndef SIP_RUN
128
129class GUI_EXPORT QgsSimpleLineCalloutWidget : public QgsCalloutWidget, private Ui::WidgetSimpleLineCallout
130{
131 Q_OBJECT
132
133 public:
134
135 QgsSimpleLineCalloutWidget( QgsVectorLayer *vl, QWidget *parent SIP_TRANSFERTHIS = nullptr );
136
137 static QgsCalloutWidget *create( QgsVectorLayer *vl ) SIP_FACTORY { return new QgsSimpleLineCalloutWidget( vl ); }
138
139 void setCallout( QgsCallout *callout ) override;
140
141 QgsCallout *callout() override;
142
143 void setGeometryType( Qgis::GeometryType type ) override;
144
145 private slots:
146
147 void minimumLengthChanged();
148 void minimumLengthUnitWidgetChanged();
149 void offsetFromAnchorUnitWidgetChanged();
150 void offsetFromAnchorChanged();
151 void offsetFromLabelUnitWidgetChanged();
152 void offsetFromLabelChanged();
153 void lineSymbolChanged();
154 void mAnchorPointComboBox_currentIndexChanged( int index );
155 void mLabelAnchorPointComboBox_currentIndexChanged( int index );
156 void mCalloutBlendComboBox_currentIndexChanged( int index );
157 void drawToAllPartsToggled( bool active );
158
159 private:
160 std::unique_ptr< QgsSimpleLineCallout > mCallout;
161
162};
163
164class GUI_EXPORT QgsManhattanLineCalloutWidget : public QgsSimpleLineCalloutWidget
165{
166 Q_OBJECT
167
168 public:
169
170 QgsManhattanLineCalloutWidget( QgsVectorLayer *vl, QWidget *parent SIP_TRANSFERTHIS = nullptr );
171
172 static QgsCalloutWidget *create( QgsVectorLayer *vl ) SIP_FACTORY { return new QgsManhattanLineCalloutWidget( vl ); }
173
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
189 QgsCurvedLineCalloutWidget( QgsVectorLayer *vl, QWidget *parent SIP_TRANSFERTHIS = nullptr );
190
191 static QgsCalloutWidget *create( QgsVectorLayer *vl ) SIP_FACTORY { return new QgsCurvedLineCalloutWidget( vl ); }
192
193 void setCallout( QgsCallout *callout ) override;
194
195 QgsCallout *callout() override;
196
197 void setGeometryType( Qgis::GeometryType type ) override;
198
199 private slots:
200
201 void minimumLengthChanged();
202 void minimumLengthUnitWidgetChanged();
203 void offsetFromAnchorUnitWidgetChanged();
204 void offsetFromAnchorChanged();
205 void offsetFromLabelUnitWidgetChanged();
206 void offsetFromLabelChanged();
207 void lineSymbolChanged();
208 void mAnchorPointComboBox_currentIndexChanged( int index );
209 void mLabelAnchorPointComboBox_currentIndexChanged( int index );
210 void mCalloutBlendComboBox_currentIndexChanged( int index );
211 void drawToAllPartsToggled( bool active );
212
213 private:
214 std::unique_ptr< QgsCurvedLineCallout > mCallout;
215
216};
217
218
220
221#include "ui_widget_ballooncallout.h"
222
224
225class GUI_EXPORT QgsBalloonCalloutWidget : public QgsCalloutWidget, private Ui::WidgetBalloonCallout
226{
227 Q_OBJECT
228
229 public:
230
231 QgsBalloonCalloutWidget( QgsVectorLayer *vl, QWidget *parent SIP_TRANSFERTHIS = nullptr );
232
233 static QgsCalloutWidget *create( QgsVectorLayer *vl ) SIP_FACTORY { return new QgsBalloonCalloutWidget( vl ); }
234
235 void setCallout( QgsCallout *callout ) override;
236
237 QgsCallout *callout() override;
238
239 void setGeometryType( Qgis::GeometryType type ) override;
240
241 private slots:
242
243 void offsetFromAnchorUnitWidgetChanged();
244 void offsetFromAnchorChanged();
245 void fillSymbolChanged();
246 void mAnchorPointComboBox_currentIndexChanged( int index );
247 void mCalloutBlendComboBox_currentIndexChanged( int index );
248
249 private:
250 std::unique_ptr< QgsBalloonCallout > mCallout;
251
252};
253
254#endif
256
257#endif // QGSCALLOUTWIDGET_H
GeometryType
The geometry types are used to group Qgis::WkbType in a coarse way.
Definition qgis.h:255
A cartoon talking bubble callout style.
Definition qgscallout.h:891
Base class for widgets which allow control over the properties of callouts.
const QgsVectorLayer * vectorLayer() const
Returns the vector layer associated with the widget.
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.
virtual void setCallout(QgsCallout *callout)=0
Sets the callout to show in the widget.
void changed()
Should be emitted whenever configuration changes happened on this symbol layer configuration.
QgsCalloutWidget(QWidget *parent, QgsVectorLayer *vl=nullptr)
Constructor for QgsCalloutWidget.
Abstract base class for callout renderers.
Definition qgscallout.h:53
Property
Data definable properties.
Definition qgscallout.h:84
Draws curved lines as callouts.
Definition qgscallout.h:791
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.
A button for controlling property overrides which may apply to a widget.
A simple direct line callout style.
Definition qgscallout.h:511
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_TRANSFERTHIS
Definition qgis_sip.h:53
#define SIP_FACTORY
Definition qgis_sip.h:76