QGIS API Documentation 3.41.0-Master (cea29feecf2)
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 setDockMode( bool dockMode ) 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 QgsTextFormatWidget *mTextFormatWidget = nullptr;
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 setDockMode( bool dockMode ) override;
153 void setContext( const QgsSymbolWidgetContext &context ) override;
155
156 public slots:
157
158 void focusDefaultWidget() override;
159
160 protected:
161 bool setNewItem( QgsAnnotationItem *item ) override;
162
163 private slots:
164
165 void onWidgetChanged();
166 void sizeModeChanged();
167 void setWidth();
168 void setHeight();
169
170 private:
171 void mInsertExpressionButton_clicked();
172
173 QgsTextFormatWidget *mTextFormatWidget = nullptr;
174 bool mBlockChangedSignal = false;
175 bool mUpdateItemPosition = false;
176
177 std::unique_ptr<QgsAnnotationRectangleTextItem> mItem;
178};
179
180class QgsAnnotationLineTextItemWidget : public QgsAnnotationItemBaseWidget, private Ui_QgsAnnotationLineTextWidgetBase
181{
182 Q_OBJECT
183
184 public:
185 QgsAnnotationLineTextItemWidget( QWidget *parent );
186 ~QgsAnnotationLineTextItemWidget() override;
187 QgsAnnotationItem *createItem() override;
188 void updateItem( QgsAnnotationItem *item ) override;
189 void setDockMode( bool dockMode ) override;
190 void setContext( const QgsSymbolWidgetContext &context ) override;
191
192 public slots:
193
194 void focusDefaultWidget() override;
195
196 protected:
197 bool setNewItem( QgsAnnotationItem *item ) override;
198
199 private:
200 void mInsertExpressionButton_clicked();
201
202 QgsTextFormatWidget *mTextFormatWidget = nullptr;
203 bool mBlockChangedSignal = false;
204 std::unique_ptr<QgsAnnotationLineTextItem> mItem;
205};
206
207
208class QgsAnnotationPictureItemWidget : public QgsAnnotationItemBaseWidget, private Ui_QgsAnnotationPictureWidgetBase, private QgsExpressionContextGenerator
209{
210 Q_OBJECT
211
212 public:
213 QgsAnnotationPictureItemWidget( QWidget *parent );
214 ~QgsAnnotationPictureItemWidget() override;
215 QgsAnnotationItem *createItem() override;
216 void updateItem( QgsAnnotationItem *item ) override;
217 void setDockMode( bool dockMode ) override;
218 void setContext( const QgsSymbolWidgetContext &context ) override;
220 public slots:
221
222 void focusDefaultWidget() override;
223
224 protected:
225 bool setNewItem( QgsAnnotationItem *item ) override;
226
227 private slots:
228
229 void onWidgetChanged();
230
231 void modeChanged( bool checked );
232 void sizeModeChanged();
233 void setWidth();
234 void setHeight();
235 void setLockAspectRatio( bool locked );
236
237 private:
238 double pictureAspectRatio() const;
239
240 bool mBlockChangedSignal = false;
241 bool mUpdateItemPosition = false;
242 std::unique_ptr<QgsAnnotationPictureItem> mItem;
243};
244
246
247#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.