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