QGIS API Documentation  3.14.0-Pi (9f7028fd23)
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 mLabelAnchorPointComboBox_currentIndexChanged( int index );
156  void drawToAllPartsToggled( bool active );
157 
158  private:
159  std::unique_ptr< QgsSimpleLineCallout > mCallout;
160 
161 };
162 
163 class GUI_EXPORT QgsManhattanLineCalloutWidget : public QgsSimpleLineCalloutWidget
164 {
165  Q_OBJECT
166 
167  public:
168 
169  QgsManhattanLineCalloutWidget( QgsVectorLayer *vl, QWidget *parent SIP_TRANSFERTHIS = nullptr );
170 
171  static QgsCalloutWidget *create( QgsVectorLayer *vl ) SIP_FACTORY { return new QgsManhattanLineCalloutWidget( vl ); }
172 
173 };
174 
175 #endif
176 
178 #endif // QGSCALLOUTWIDGET_H
QgsCalloutWidget::setCallout
virtual void setCallout(QgsCallout *callout)=0
Sets the callout to show in the widget.
QgsExpressionContext
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
Definition: qgsexpressioncontext.h:369
QgsCalloutWidget
Definition: qgscalloutwidget.h:34
QgsCallout
Abstract base class for callout renderers.
Definition: qgscallout.h:46
QgsSymbolWidgetContext
Definition: qgssymbolwidgetcontext.h:35
QgsMapCanvas
Definition: qgsmapcanvas.h:83
qgssymbolwidgetcontext.h
QgsPropertyOverrideButton
Definition: qgspropertyoverridebutton.h:50
SIP_FACTORY
#define SIP_FACTORY
Definition: qgis_sip.h:76
QgsCalloutWidget::vectorLayer
const QgsVectorLayer * vectorLayer() const
Returns the vector layer associated with the widget.
Definition: qgscalloutwidget.h:79
QgsCalloutWidget::setGeometryType
virtual void setGeometryType(QgsWkbTypes::GeometryType type)=0
Sets the geometry type of the features to customize the widget accordingly.
QgsCalloutWidget::callout
virtual QgsCallout * callout()=0
Returns the callout defined by the current settings in the widget.
qgis_sip.h
QgsExpressionContextGenerator::createExpressionContext
virtual QgsExpressionContext createExpressionContext() const =0
This method needs to be reimplemented in all classes which implement this interface and return an exp...
QgsSimpleLineCallout
A simple direct line callout style.
Definition: qgscallout.h:401
qgscallout.h
QgsWkbTypes::GeometryType
GeometryType
The geometry types are used to group QgsWkbTypes::Type in a coarse way.
Definition: qgswkbtypes.h:139
QgsVectorLayer
Definition: qgsvectorlayer.h:385
QgsCalloutWidget::QgsCalloutWidget
QgsCalloutWidget(QWidget *parent, QgsVectorLayer *vl=nullptr)
Constructor for QgsCalloutWidget.
Definition: qgscalloutwidget.h:45
QgsCallout::Property
Property
Data definable properties.
Definition: qgscallout.h:69
QgsExpressionContextGenerator
Definition: qgsexpressioncontextgenerator.h:36
SIP_TRANSFERTHIS
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:53
qgspropertyoverridebutton.h