QGIS API Documentation 3.99.0-Master (26c88405ac0)
Loading...
Searching...
No Matches
qgsannotationitemwidget_impl.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsannotationitemwidget_impl.h
3 ------------------------
4 Date : September 2021
5 Copyright : (C) 2021 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 QGSANNOTATIONITEMWIDGETIMPL_H
16#define QGSANNOTATIONITEMWIDGETIMPL_H
17
18#include "ui_qgsannotationlinetextwidgetbase.h"
19#include "ui_qgsannotationpicturewidgetbase.h"
20#include "ui_qgsannotationpointtextwidgetbase.h"
21#include "ui_qgsannotationrectangulartextwidgetbase.h"
22#include "ui_qgsannotationsymbolwidgetbase.h"
23
24#include <memory>
25
26#include "qgis_gui.h"
27#include "qgis_sip.h"
30#include "qgstextformat.h"
31
33class QgsFillSymbol;
34class QgsLineSymbol;
35class QgsMarkerSymbol;
44
45#define SIP_NO_FILE
46
48
49class QgsAnnotationPolygonItemWidget : public QgsAnnotationItemBaseWidget, private Ui_QgsAnnotationSymbolWidgetBase
50{
51 Q_OBJECT
52
53 public:
54 QgsAnnotationPolygonItemWidget( QWidget *parent );
55 ~QgsAnnotationPolygonItemWidget() override;
56 QgsAnnotationItem *createItem() override;
57 void updateItem( QgsAnnotationItem *item ) override;
58 void setDockMode( bool dockMode ) override;
59 void setContext( const QgsSymbolWidgetContext &context ) override;
60
61 protected:
62 bool setNewItem( QgsAnnotationItem *item ) override;
63
64 private:
65 QgsSymbolSelectorWidget *mSelector = nullptr;
66 std::unique_ptr<QgsFillSymbol> mSymbol;
67 bool mBlockChangedSignal = false;
68 std::unique_ptr<QgsAnnotationPolygonItem> mItem;
69};
70
71class QgsAnnotationLineItemWidget : public QgsAnnotationItemBaseWidget, private Ui_QgsAnnotationSymbolWidgetBase
72{
73 Q_OBJECT
74
75 public:
76 QgsAnnotationLineItemWidget( QWidget *parent );
77 ~QgsAnnotationLineItemWidget() override;
78 QgsAnnotationItem *createItem() override;
79 void updateItem( QgsAnnotationItem *item ) override;
80 void setDockMode( bool dockMode ) override;
81 void setContext( const QgsSymbolWidgetContext &context ) override;
82
83 protected:
84 bool setNewItem( QgsAnnotationItem *item ) override;
85
86 private:
87 QgsSymbolSelectorWidget *mSelector = nullptr;
88 std::unique_ptr<QgsLineSymbol> mSymbol;
89 bool mBlockChangedSignal = false;
90 std::unique_ptr<QgsAnnotationLineItem> mItem;
91};
92
93class QgsAnnotationMarkerItemWidget : public QgsAnnotationItemBaseWidget, private Ui_QgsAnnotationSymbolWidgetBase
94{
95 Q_OBJECT
96
97 public:
98 QgsAnnotationMarkerItemWidget( QWidget *parent );
99 ~QgsAnnotationMarkerItemWidget() override;
100 QgsAnnotationItem *createItem() override;
101 void updateItem( QgsAnnotationItem *item ) override;
102 void setDockMode( bool dockMode ) override;
103 void setContext( const QgsSymbolWidgetContext &context ) override;
104
105 protected:
106 bool setNewItem( QgsAnnotationItem *item ) override;
107
108 private:
109 QgsSymbolSelectorWidget *mSelector = nullptr;
110 std::unique_ptr<QgsMarkerSymbol> mSymbol;
111 bool mBlockChangedSignal = false;
112 std::unique_ptr<QgsAnnotationMarkerItem> mItem;
113};
114
115
116class QgsAnnotationPointTextItemWidget : public QgsAnnotationItemBaseWidget, private Ui_QgsAnnotationPointTextWidgetBase
117{
118 Q_OBJECT
119
120 public:
121 QgsAnnotationPointTextItemWidget( QWidget *parent );
122 ~QgsAnnotationPointTextItemWidget() override;
123 QgsAnnotationItem *createItem() override;
124 void updateItem( QgsAnnotationItem *item ) override;
125 void setContext( const QgsSymbolWidgetContext &context ) override;
126
127 public slots:
128
129 void focusDefaultWidget() override;
130
131 protected:
132 bool setNewItem( QgsAnnotationItem *item ) override;
133
134 private:
135 void mInsertExpressionButton_clicked();
136
137 bool mBlockChangedSignal = false;
138 std::unique_ptr<QgsAnnotationPointTextItem> mItem;
139};
140
141
142class QgsAnnotationRectangleTextItemWidget : public QgsAnnotationItemBaseWidget, private Ui_QgsAnnotationRectangleTextWidgetBase, private QgsExpressionContextGenerator
143{
144 Q_OBJECT
145
146 public:
147 QgsAnnotationRectangleTextItemWidget( QWidget *parent );
148 ~QgsAnnotationRectangleTextItemWidget() override;
149 QgsAnnotationItem *createItem() override;
150 void updateItem( QgsAnnotationItem *item ) override;
151 void setContext( const QgsSymbolWidgetContext &context ) override;
152 QgsExpressionContext createExpressionContext() const override;
153
154 public slots:
155
156 void focusDefaultWidget() override;
157
158 protected:
159 bool setNewItem( QgsAnnotationItem *item ) override;
160
161 private slots:
162
163 void onWidgetChanged();
164 void sizeModeChanged();
165 void setWidth();
166 void setHeight();
167
168 private:
169 void mInsertExpressionButton_clicked();
170
171 bool mBlockChangedSignal = false;
172 bool mUpdateItemPosition = false;
173
174 std::unique_ptr<QgsAnnotationRectangleTextItem> mItem;
175};
176
177class QgsAnnotationLineTextItemWidget : public QgsAnnotationItemBaseWidget, private Ui_QgsAnnotationLineTextWidgetBase
178{
179 Q_OBJECT
180
181 public:
182 QgsAnnotationLineTextItemWidget( QWidget *parent );
183 ~QgsAnnotationLineTextItemWidget() override;
184 QgsAnnotationItem *createItem() override;
185 void updateItem( QgsAnnotationItem *item ) override;
186 void setContext( const QgsSymbolWidgetContext &context ) override;
187
188 public slots:
189
190 void focusDefaultWidget() override;
191
192 protected:
193 bool setNewItem( QgsAnnotationItem *item ) override;
194
195 private:
196 void mInsertExpressionButton_clicked();
197
198 bool mBlockChangedSignal = false;
199 std::unique_ptr<QgsAnnotationLineTextItem> mItem;
200};
201
202
203class QgsAnnotationPictureItemWidget : public QgsAnnotationItemBaseWidget, private Ui_QgsAnnotationPictureWidgetBase, private QgsExpressionContextGenerator
204{
205 Q_OBJECT
206
207 public:
208 QgsAnnotationPictureItemWidget( QWidget *parent );
209 ~QgsAnnotationPictureItemWidget() override;
210 QgsAnnotationItem *createItem() override;
211 void updateItem( QgsAnnotationItem *item ) override;
212 void setDockMode( bool dockMode ) override;
213 void setContext( const QgsSymbolWidgetContext &context ) override;
214 QgsExpressionContext createExpressionContext() const override;
215 public slots:
216
217 void focusDefaultWidget() override;
218
219 protected:
220 bool setNewItem( QgsAnnotationItem *item ) override;
221
222 private slots:
223
224 void onWidgetChanged();
225
226 void modeChanged( bool checked );
227 void sizeModeChanged();
228 void setWidth();
229 void setHeight();
230 void setLockAspectRatio( bool locked );
231
232 private:
233 double pictureAspectRatio() const;
234
235 bool mBlockChangedSignal = false;
236 bool mUpdateItemPosition = false;
237 std::unique_ptr<QgsAnnotationPictureItem> mItem;
238};
239
241
242#endif // QGSANNOTATIONITEMWIDGETIMPL_H
A base class for property widgets for annotation items.
virtual void focusDefaultWidget()
Focuses the default widget for the page.
virtual void setContext(const QgsSymbolWidgetContext &context)
Sets the context in which the widget is shown, e.g., the associated map canvas and expression context...
virtual QgsAnnotationItem * createItem()=0
Creates a new item matching the settings defined in the widget.
virtual bool setNewItem(QgsAnnotationItem *item)
Attempts to update the widget to show the properties for the specified item.
virtual void updateItem(QgsAnnotationItem *item)=0
Updates an existing item to match the settings defined in the widget.
Abstract base class for annotation items which are drawn with QgsAnnotationLayers.
An annotation item which renders a line symbol along a line geometry.
An annotation item which renders text along a line geometry.
An annotation item which renders a marker symbol at a point location.
An annotation item which renders a picture.
An annotation item which renders a text string at a point location.
An annotation item which renders a fill symbol for a polygon geometry.
An annotation item which renders paragraphs of text within a rectangle.
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...
A fill symbol type, for rendering Polygon and MultiPolygon geometries.
A line symbol type, for rendering LineString and MultiLineString geometries.
A marker symbol type, for rendering Point and MultiPoint geometries.
virtual void setDockMode(bool dockMode)
Set the widget in dock mode which tells the widget to emit panel widgets and not open dialogs.
Symbol selector widget that can be used to select and build a symbol.
Contains settings which reflect the context in which a symbol (or renderer) widget is shown,...
A widget for customizing text formatting settings.