QGIS API Documentation 3.41.0-Master (1deb1daf037)
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
19#include "qgis_sip.h"
20#include "qgis_gui.h"
21#include "qgstextformat.h"
23#include <memory>
24
25#include "ui_qgsannotationpointtextwidgetbase.h"
26#include "ui_qgsannotationsymbolwidgetbase.h"
27#include "ui_qgsannotationlinetextwidgetbase.h"
28#include "ui_qgsannotationrectangulartextwidgetbase.h"
29#include "ui_qgsannotationpicturewidgetbase.h"
30
32class QgsFillSymbol;
33class QgsLineSymbol;
34class QgsMarkerSymbol;
43
44#define SIP_NO_FILE
45
47
48class QgsAnnotationPolygonItemWidget : public QgsAnnotationItemBaseWidget, private Ui_QgsAnnotationSymbolWidgetBase
49{
50 Q_OBJECT
51
52 public:
53 QgsAnnotationPolygonItemWidget( QWidget *parent );
54 ~QgsAnnotationPolygonItemWidget() override;
55 QgsAnnotationItem *createItem() override;
56 void updateItem( QgsAnnotationItem *item ) override;
57 void setDockMode( bool dockMode ) override;
58 void setContext( const QgsSymbolWidgetContext &context ) override;
59
60 protected:
61 bool setNewItem( QgsAnnotationItem *item ) override;
62
63 private:
64 QgsSymbolSelectorWidget *mSelector = nullptr;
65 std::unique_ptr<QgsFillSymbol> mSymbol;
66 bool mBlockChangedSignal = false;
67 std::unique_ptr<QgsAnnotationPolygonItem> mItem;
68};
69
70class QgsAnnotationLineItemWidget : public QgsAnnotationItemBaseWidget, private Ui_QgsAnnotationSymbolWidgetBase
71{
72 Q_OBJECT
73
74 public:
75 QgsAnnotationLineItemWidget( QWidget *parent );
76 ~QgsAnnotationLineItemWidget() override;
77 QgsAnnotationItem *createItem() override;
78 void updateItem( QgsAnnotationItem *item ) override;
79 void setDockMode( bool dockMode ) override;
80 void setContext( const QgsSymbolWidgetContext &context ) override;
81
82 protected:
83 bool setNewItem( QgsAnnotationItem *item ) override;
84
85 private:
86 QgsSymbolSelectorWidget *mSelector = nullptr;
87 std::unique_ptr<QgsLineSymbol> mSymbol;
88 bool mBlockChangedSignal = false;
89 std::unique_ptr<QgsAnnotationLineItem> mItem;
90};
91
92class QgsAnnotationMarkerItemWidget : public QgsAnnotationItemBaseWidget, private Ui_QgsAnnotationSymbolWidgetBase
93{
94 Q_OBJECT
95
96 public:
97 QgsAnnotationMarkerItemWidget( QWidget *parent );
98 ~QgsAnnotationMarkerItemWidget() override;
99 QgsAnnotationItem *createItem() override;
100 void updateItem( QgsAnnotationItem *item ) override;
101 void setDockMode( bool dockMode ) override;
102 void setContext( const QgsSymbolWidgetContext &context ) override;
103
104 protected:
105 bool setNewItem( QgsAnnotationItem *item ) override;
106
107 private:
108 QgsSymbolSelectorWidget *mSelector = nullptr;
109 std::unique_ptr<QgsMarkerSymbol> mSymbol;
110 bool mBlockChangedSignal = false;
111 std::unique_ptr<QgsAnnotationMarkerItem> mItem;
112};
113
114
115class QgsAnnotationPointTextItemWidget : public QgsAnnotationItemBaseWidget, private Ui_QgsAnnotationPointTextWidgetBase
116{
117 Q_OBJECT
118
119 public:
120 QgsAnnotationPointTextItemWidget( QWidget *parent );
121 ~QgsAnnotationPointTextItemWidget() override;
122 QgsAnnotationItem *createItem() override;
123 void updateItem( QgsAnnotationItem *item ) override;
124 void setContext( const QgsSymbolWidgetContext &context ) override;
125
126 public slots:
127
128 void focusDefaultWidget() override;
129
130 protected:
131 bool setNewItem( QgsAnnotationItem *item ) override;
132
133 private:
134 void mInsertExpressionButton_clicked();
135
136 bool mBlockChangedSignal = false;
137 std::unique_ptr<QgsAnnotationPointTextItem> mItem;
138};
139
140
141class QgsAnnotationRectangleTextItemWidget : public QgsAnnotationItemBaseWidget, private Ui_QgsAnnotationRectangleTextWidgetBase, private QgsExpressionContextGenerator
142{
143 Q_OBJECT
144
145 public:
146 QgsAnnotationRectangleTextItemWidget( QWidget *parent );
147 ~QgsAnnotationRectangleTextItemWidget() override;
148 QgsAnnotationItem *createItem() override;
149 void updateItem( QgsAnnotationItem *item ) override;
150 void setContext( const QgsSymbolWidgetContext &context ) override;
152
153 public slots:
154
155 void focusDefaultWidget() override;
156
157 protected:
158 bool setNewItem( QgsAnnotationItem *item ) override;
159
160 private slots:
161
162 void onWidgetChanged();
163 void sizeModeChanged();
164 void setWidth();
165 void setHeight();
166
167 private:
168 void mInsertExpressionButton_clicked();
169
170 bool mBlockChangedSignal = false;
171 bool mUpdateItemPosition = false;
172
173 std::unique_ptr<QgsAnnotationRectangleTextItem> mItem;
174};
175
176class QgsAnnotationLineTextItemWidget : public QgsAnnotationItemBaseWidget, private Ui_QgsAnnotationLineTextWidgetBase
177{
178 Q_OBJECT
179
180 public:
181 QgsAnnotationLineTextItemWidget( QWidget *parent );
182 ~QgsAnnotationLineTextItemWidget() override;
183 QgsAnnotationItem *createItem() override;
184 void updateItem( QgsAnnotationItem *item ) override;
185 void setContext( const QgsSymbolWidgetContext &context ) override;
186
187 public slots:
188
189 void focusDefaultWidget() override;
190
191 protected:
192 bool setNewItem( QgsAnnotationItem *item ) override;
193
194 private:
195 void mInsertExpressionButton_clicked();
196
197 bool mBlockChangedSignal = false;
198 std::unique_ptr<QgsAnnotationLineTextItem> mItem;
199};
200
201
202class QgsAnnotationPictureItemWidget : public QgsAnnotationItemBaseWidget, private Ui_QgsAnnotationPictureWidgetBase, private QgsExpressionContextGenerator
203{
204 Q_OBJECT
205
206 public:
207 QgsAnnotationPictureItemWidget( QWidget *parent );
208 ~QgsAnnotationPictureItemWidget() override;
209 QgsAnnotationItem *createItem() override;
210 void updateItem( QgsAnnotationItem *item ) override;
211 void setDockMode( bool dockMode ) override;
212 void setContext( const QgsSymbolWidgetContext &context ) override;
214 public slots:
215
216 void focusDefaultWidget() override;
217
218 protected:
219 bool setNewItem( QgsAnnotationItem *item ) override;
220
221 private slots:
222
223 void onWidgetChanged();
224
225 void modeChanged( bool checked );
226 void sizeModeChanged();
227 void setWidth();
228 void setHeight();
229 void setLockAspectRatio( bool locked );
230
231 private:
232 double pictureAspectRatio() const;
233
234 bool mBlockChangedSignal = false;
235 bool mUpdateItemPosition = false;
236 std::unique_ptr<QgsAnnotationPictureItem> mItem;
237};
238
240
241#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...
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
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.