QGIS API Documentation  3.10.0-A Coruña (6c816b4204)
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"
20 #include "qgssymbolwidgetcontext.h"
21 #include "qgscallout.h"
22 #include <QWidget>
23 #include <QStandardItemModel>
24 
25 class QgsVectorLayer;
26 class QgsMapCanvas;
27 
34 class 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( QgsWkbTypes::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
127 
129 class 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( QgsWkbTypes::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 drawToAllPartsToggled( bool active );
156 
157  private:
158  std::unique_ptr< QgsSimpleLineCallout > mCallout;
159 
160 };
161 
162 class GUI_EXPORT QgsManhattanLineCalloutWidget : public QgsSimpleLineCalloutWidget
163 {
164  Q_OBJECT
165 
166  public:
167 
168  QgsManhattanLineCalloutWidget( QgsVectorLayer *vl, QWidget *parent SIP_TRANSFERTHIS = nullptr );
169 
170  static QgsCalloutWidget *create( QgsVectorLayer *vl ) SIP_FACTORY { return new QgsManhattanLineCalloutWidget( vl ); }
171 
172 };
173 
174 #endif
175 
177 #endif // QGSCALLOUTWIDGET_H
virtual QgsCallout * callout()=0
Returns the callout defined by the current settings in the widget.
Abstract base class for callout renderers.
Definition: qgscallout.h:46
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:53
Property
Data definable properties.
Definition: qgscallout.h:69
Base class for widgets which allow control over the properties of callouts.
Map canvas is a class for displaying all GIS data types on a canvas.
Definition: qgsmapcanvas.h:75
QgsCalloutWidget(QWidget *parent, QgsVectorLayer *vl=nullptr)
Constructor for QgsCalloutWidget.
virtual QgsExpressionContext createExpressionContext() const =0
This method needs to be reimplemented in all classes which implement this interface and return an exp...
A button for controlling property overrides which may apply to a widget.
Contains settings which reflect the context in which a symbol (or renderer) widget is shown...
virtual void setCallout(QgsCallout *callout)=0
Sets the callout to show in the widget.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
#define SIP_FACTORY
Definition: qgis_sip.h:76
A simple direct line callout style.
Definition: qgscallout.h:339
Abstract interface for generating an expression context.
GeometryType
The geometry types are used to group QgsWkbTypes::Type in a coarse way.
Definition: qgswkbtypes.h:139
const QgsVectorLayer * vectorLayer() const
Returns the vector layer associated with the widget.
virtual void setGeometryType(QgsWkbTypes::GeometryType type)=0
Sets the geometry type of the features to customize the widget accordingly.
Represents a vector layer which manages a vector based data sets.