QGIS API Documentation 3.41.0-Master (3440c17df1d)
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
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
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
111 QgsSymbolSelectorWidget *mSelector = nullptr;
112 std::unique_ptr< QgsMarkerSymbol > mSymbol;
113 bool mBlockChangedSignal = false;
114 std::unique_ptr< QgsAnnotationMarkerItem> mItem;
115};
116
117
118class QgsAnnotationPointTextItemWidget : public QgsAnnotationItemBaseWidget, private Ui_QgsAnnotationPointTextWidgetBase
119{
120 Q_OBJECT
121
122 public:
123 QgsAnnotationPointTextItemWidget( QWidget *parent );
124 ~QgsAnnotationPointTextItemWidget() override;
125 QgsAnnotationItem *createItem() override;
126 void updateItem( QgsAnnotationItem *item ) override;
127 void setDockMode( bool dockMode ) override;
128 void setContext( const QgsSymbolWidgetContext &context ) override;
129
130 public slots:
131
132 void focusDefaultWidget() override;
133
134 protected:
135 bool setNewItem( QgsAnnotationItem *item ) override;
136
137 private:
138 void mInsertExpressionButton_clicked();
139
140 QgsTextFormatWidget *mTextFormatWidget = nullptr;
141 bool mBlockChangedSignal = false;
142 std::unique_ptr< QgsAnnotationPointTextItem> mItem;
143};
144
145
146class QgsAnnotationRectangleTextItemWidget : public QgsAnnotationItemBaseWidget, private Ui_QgsAnnotationRectangleTextWidgetBase, private QgsExpressionContextGenerator
147{
148 Q_OBJECT
149
150 public:
151 QgsAnnotationRectangleTextItemWidget( QWidget *parent );
152 ~QgsAnnotationRectangleTextItemWidget() override;
153 QgsAnnotationItem *createItem() override;
154 void updateItem( QgsAnnotationItem *item ) override;
155 void setDockMode( bool dockMode ) override;
156 void setContext( const QgsSymbolWidgetContext &context ) override;
158
159 public slots:
160
161 void focusDefaultWidget() override;
162
163 protected:
164 bool setNewItem( QgsAnnotationItem *item ) override;
165
166 private slots:
167
168 void onWidgetChanged();
169 void sizeModeChanged();
170 void setWidth();
171 void setHeight();
172
173 private:
174 void mInsertExpressionButton_clicked();
175
176 QgsTextFormatWidget *mTextFormatWidget = nullptr;
177 bool mBlockChangedSignal = false;
178 bool mUpdateItemPosition = false;
179
180 std::unique_ptr< QgsAnnotationRectangleTextItem> mItem;
181};
182
183class QgsAnnotationLineTextItemWidget : public QgsAnnotationItemBaseWidget, private Ui_QgsAnnotationLineTextWidgetBase
184{
185 Q_OBJECT
186
187 public:
188 QgsAnnotationLineTextItemWidget( QWidget *parent );
189 ~QgsAnnotationLineTextItemWidget() override;
190 QgsAnnotationItem *createItem() override;
191 void updateItem( QgsAnnotationItem *item ) override;
192 void setDockMode( bool dockMode ) override;
193 void setContext( const QgsSymbolWidgetContext &context ) override;
194
195 public slots:
196
197 void focusDefaultWidget() override;
198
199 protected:
200 bool setNewItem( QgsAnnotationItem *item ) override;
201
202 private:
203 void mInsertExpressionButton_clicked();
204
205 QgsTextFormatWidget *mTextFormatWidget = nullptr;
206 bool mBlockChangedSignal = false;
207 std::unique_ptr< QgsAnnotationLineTextItem> mItem;
208};
209
210
211class QgsAnnotationPictureItemWidget : public QgsAnnotationItemBaseWidget, private Ui_QgsAnnotationPictureWidgetBase, private QgsExpressionContextGenerator
212{
213 Q_OBJECT
214
215 public:
216 QgsAnnotationPictureItemWidget( QWidget *parent );
217 ~QgsAnnotationPictureItemWidget() override;
218 QgsAnnotationItem *createItem() override;
219 void updateItem( QgsAnnotationItem *item ) override;
220 void setDockMode( bool dockMode ) override;
221 void setContext( const QgsSymbolWidgetContext &context ) override;
223 public slots:
224
225 void focusDefaultWidget() override;
226
227 protected:
228 bool setNewItem( QgsAnnotationItem *item ) override;
229
230 private slots:
231
232 void onWidgetChanged();
233
234 void modeChanged( bool checked );
235 void sizeModeChanged();
236 void setWidth();
237 void setHeight();
238 void setLockAspectRatio( bool locked );
239 private:
240 double pictureAspectRatio() const;
241
242 bool mBlockChangedSignal = false;
243 bool mUpdateItemPosition = false;
244 std::unique_ptr< QgsAnnotationPictureItem> mItem;
245};
246
248
249#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.