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