QGIS API Documentation 3.28.0-Firenze (ed3ad0430f)
qgssymbolselectordialog.h
Go to the documentation of this file.
1/***************************************************************************
2 qgssymbolselectordialog.h
3 ---------------------
4 begin : November 2009
5 copyright : (C) 2009 by Martin Dobias
6 email : wonder dot sk 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
16#ifndef QGSSYMBOLSELECTORDIALOG_H
17#define QGSSYMBOLSELECTORDIALOG_H
18
19#include <QDialog>
20#include "qgis_sip.h"
21
22#include "ui_qgssymbolselectordialogbase.h"
23
24#include "qgspanelwidget.h"
26#include "qgsproperty.h"
27#include "qgshelp.h"
28
29#include <QStandardItemModel>
30#include <QDialogButtonBox>
31#include <QPointer>
32#include "qgis_gui.h"
33
34class QgsStyle;
35class QgsSymbol;
36class QgsSymbolLayer;
37class QgsVectorLayer;
38
39class QMenu;
40class QWidget;
41
42class SymbolLayerItem;
43class QgsMarkerSymbol;
44class QgsLineSymbol;
47
48class QgsMapCanvas;
49
50#ifndef SIP_RUN
52
53class DataDefinedRestorer: public QObject
54{
55 Q_OBJECT
56 public:
57 DataDefinedRestorer( QgsSymbol *symbol, const QgsSymbolLayer *symbolLayer );
58
59 public slots:
60 void restore();
61
62 private:
63 QgsMarkerSymbol *mMarker = nullptr;
64 const QgsMarkerSymbolLayer *mMarkerSymbolLayer = nullptr;
65 double mSize;
66 double mAngle;
67 QPointF mMarkerOffset;
68 QgsProperty mDDSize;
69 QgsProperty mDDAngle;
70
71 QgsLineSymbol *mLine = nullptr;
72 const QgsLineSymbolLayer *mLineSymbolLayer = nullptr;
73 double mWidth;
74 double mLineOffset;
75 QgsProperty mDDWidth;
76
77 void save();
78};
80#endif
81
83
88class GUI_EXPORT QgsSymbolSelectorWidget: public QgsPanelWidget, private Ui::QgsSymbolSelectorDialogBase
89{
90 Q_OBJECT
93
94 public:
95
96 // TODO QGIS 4.0 - transfer ownership of symbol to widget!
97
106 QgsSymbolSelectorWidget( QgsSymbol *symbol, QgsStyle *style, QgsVectorLayer *vl, QWidget *parent SIP_TRANSFERTHIS = nullptr );
107
109 QMenu *advancedMenu();
110
118
125
130 QgsSymbol *symbol() { return mSymbol; }
131
132 // TODO QGIS 4.0 - transfer ownership of symbol to widget!
133
140 void loadSymbol( QgsSymbol *symbol, SymbolLayerItem *parent = nullptr ) SIP_SKIP;
141
142 public slots:
143
147 void moveLayerDown();
148
152 void moveLayerUp();
153
157 void addLayer();
158
162 void removeLayer();
163
167 void lockLayer();
168
173 void duplicateLayer();
174
179 void layerChanged();
180
184 void updateLayerPreview();
185
189 void updatePreview();
190
192 void symbolChanged();
193
198 void changeLayer( QgsSymbolLayer *layer );
199
200 signals:
201
206
207 private slots:
208
213 void projectDataChanged();
214
218 void layersAboutToBeRemoved( const QList<QgsMapLayer *> &layers );
219
220 private:
221
225 void reloadSymbol();
226
230 void updateUi();
231
235 void updateLockButton();
236
237 SymbolLayerItem *currentLayerItem();
238
243 QgsSymbolLayer *currentLayer();
244
249 void moveLayerByOffset( int offset );
250
255 void setWidget( QWidget *widget );
256
257 QgsStyle *mStyle = nullptr;
258 QgsSymbol *mSymbol = nullptr;
259 QMenu *mAdvancedMenu = nullptr;
260 QPointer< QgsVectorLayer > mVectorLayer;
261
262 QStandardItemModel *mSymbolLayersModel = nullptr;
263 QWidget *mPresentWidget = nullptr;
264
265 std::unique_ptr<DataDefinedRestorer> mDataDefineRestorer;
266 QgsSymbolWidgetContext mContext;
267 QgsFeature mPreviewFeature;
268 QgsExpressionContext mPreviewExpressionContext;
269 bool mBlockModified = false;
270
271};
272
277class GUI_EXPORT QgsSymbolSelectorDialog : public QDialog
278{
279 Q_OBJECT
280
281 public:
282
292 QgsSymbolSelectorDialog( QgsSymbol *symbol, QgsStyle *style, QgsVectorLayer *vl, QWidget *parent SIP_TRANSFERTHIS = nullptr, bool embedded = false );
293
295 QMenu *advancedMenu();
296
304
311
316 QgsSymbol *symbol();
317
323 void loadSymbol( QgsSymbol *symbol, SymbolLayerItem *parent = nullptr ) SIP_SKIP;
324
329 QDialogButtonBox *buttonBox() const;
330
331 public slots:
332
333 void moveLayerDown();
334 void moveLayerUp();
335
336 void addLayer();
337 void removeLayer();
338
339 void lockLayer();
340
345 void duplicateLayer();
346
347 void layerChanged();
348
349 void updateLayerPreview();
350 void updatePreview();
351
353 void symbolChanged();
354
359 void changeLayer( QgsSymbolLayer *layer );
360
361 protected:
362
363 // Reimplements dialog keyPress event so we can ignore it
364 void keyPressEvent( QKeyEvent *e ) override;
365
366 private slots:
367
368 void showHelp();
369
370 signals:
371
373
374 private:
375
376 void reloadSymbol();
377
378 void updateUi();
379
380 void updateLockButton();
381
382 SymbolLayerItem *currentLayerItem();
383
384 QgsSymbolLayer *currentLayer();
385
386 void moveLayerByOffset( int offset );
387
388 void setWidget( QWidget *widget );
389
390 QgsSymbolSelectorWidget *mSelectorWidget = nullptr;
391 QDialogButtonBox *mButtonBox = nullptr;
392 QgsSymbolWidgetContext mContext;
393
394};
395
396#endif
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Definition: qgsfeature.h:56
A line symbol type, for rendering LineString and MultiLineString geometries.
Definition: qgslinesymbol.h:30
Map canvas is a class for displaying all GIS data types on a canvas.
Definition: qgsmapcanvas.h:90
Base class for all map layer types.
Definition: qgsmaplayer.h:73
Abstract base class for marker symbol layers.
A marker symbol type, for rendering Point and MultiPoint geometries.
Base class for any widget that can be shown as a inline panel.
void keyPressEvent(QKeyEvent *event) override
Overridden key press event to handle the esc event on the widget.
A store for object properties.
Definition: qgsproperty.h:230
void setContext(const QgsSymbolWidgetContext &context)
Sets the context in which the symbol widget is shown, e.g., the associated map canvas and expression ...
QgsSymbolSelectorDialog(QgsSymbol *symbol, QgsStyle *style, QgsVectorLayer *vl, QWidget *parent=nullptr, bool embedded=false)
Constructor for QgsSymbolSelectorDialog.
QgsSymbolWidgetContext context() const
Returns the context in which the symbol widget is shown, e.g., the associated map canvas and expressi...
QMenu * advancedMenu()
Returns menu for "advanced" button - create it if doesn't exist and show the advanced button.
void symbolChanged()
Slot to update tree when a new symbol from style.
QDialogButtonBox * buttonBox() const
Returns a reference to the dialog's button box.
QgsSymbol * symbol()
Returns the symbol that is currently active in the widget.
void duplicateLayer()
Duplicates the current symbol layer and places the duplicated layer above the current symbol layer.
void changeLayer(QgsSymbolLayer *layer)
alters tree and sets proper widget when Layer Type is changed
void loadSymbol(QgsSymbol *symbol, SymbolLayerItem *parent=nullptr)
Loads the given symbol into the widget.
Symbol selector widget that can be used to select and build a symbol.
QgsSymbol * symbol()
Returns the symbol that is currently active in the widget.
Contains settings which reflect the context in which a symbol (or renderer) widget is shown,...
Abstract base class for all rendered symbols.
Definition: qgssymbol.h:93
Represents a vector layer which manages a vector based data sets.
std::unique_ptr< GEOSGeometry, GeosDeleter > unique_ptr
Scoped GEOS pointer.
Definition: qgsgeos.h:74
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:53
#define SIP_SKIP
Definition: qgis_sip.h:126