QGIS API Documentation 3.99.0-Master (2fe06baccd8)
Loading...
Searching...
No Matches
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 "ui_qgssymbolselectordialogbase.h"
20
21#include "qgis_gui.h"
22#include "qgis_sip.h"
23#include "qgshelp.h"
24#include "qgspanelwidget.h"
25#include "qgsproperty.h"
27
28#include <QDialog>
29#include <QDialogButtonBox>
30#include <QPointer>
31#include <QStandardItemModel>
32
33class QgsStyle;
34class QgsSymbol;
35class QgsSymbolLayer;
36class QgsVectorLayer;
37
38class QMenu;
39class QWidget;
40
41class SymbolLayerItem;
42class QgsMarkerSymbol;
43class QgsLineSymbol;
46
47class QgsMapCanvas;
48
49#ifndef SIP_RUN
51
52class DataDefinedRestorer : public QObject
53{
54 Q_OBJECT
55 public:
56 DataDefinedRestorer( QgsSymbol *symbol, const QgsSymbolLayer *symbolLayer );
57
58 public slots:
59 void restore();
60
61 private:
62 QgsMarkerSymbol *mMarker = nullptr;
63 const QgsMarkerSymbolLayer *mMarkerSymbolLayer = nullptr;
64 double mSize = 0;
65 double mAngle = 0;
66 QPointF mMarkerOffset;
67 QgsProperty mDDSize;
68 QgsProperty mDDAngle;
69
70 QgsLineSymbol *mLine = nullptr;
71 const QgsLineSymbolLayer *mLineSymbolLayer = nullptr;
72 double mWidth = 0;
73 double mLineOffset = 0;
74 QgsProperty mDDWidth;
75
76 void save();
77};
79#endif
80
82
87class GUI_EXPORT QgsSymbolSelectorWidget : public QgsPanelWidget, private Ui::QgsSymbolSelectorDialogBase
88{
89 Q_OBJECT
92
93 public:
94 // TODO QGIS 4.0 - transfer ownership of symbol to widget!
95
104 QgsSymbolSelectorWidget( QgsSymbol *symbol, QgsStyle *style, QgsVectorLayer *vl, QWidget *parent SIP_TRANSFERTHIS = nullptr );
105
106 // TODO QGIS 4.0 -- remove when normal constructor takes ownership
107
114 static QgsSymbolSelectorWidget *createWidgetWithSymbolOwnership( std::unique_ptr<QgsSymbol> symbol, QgsStyle *style, QgsVectorLayer *vl, QWidget *parent SIP_TRANSFERTHIS = nullptr ) SIP_SKIP;
115
117 QMenu *advancedMenu();
118
125
131
136 QgsSymbol *symbol() { return mSymbol; }
137
138 // TODO QGIS 4.0 - transfer ownership of symbol to widget!
139
146 void loadSymbol( QgsSymbol *symbol, SymbolLayerItem *parent = nullptr ) SIP_SKIP;
147
148 public slots:
149
153 void moveLayerDown();
154
158 void moveLayerUp();
159
163 void addLayer();
164
168 void removeLayer();
169
173 void lockLayer();
174
178 void duplicateLayer();
179
184 void layerChanged();
185
189 void updateLayerPreview();
190
194 void updatePreview();
195
197 void symbolChanged();
198
204 void changeLayer( QgsSymbolLayer *layer );
205
206 signals:
207
212
213 private slots:
214
219 void projectDataChanged();
220
224 void layersAboutToBeRemoved( const QList<QgsMapLayer *> &layers );
225
226 private:
230 void reloadSymbol();
231
235 void updateUi();
236
240 void updateLockButton();
241
242 void updateLockButtonIcon();
243
244 SymbolLayerItem *currentLayerItem();
245
250 QgsSymbolLayer *currentLayer();
251
256 void moveLayerByOffset( int offset );
257
262 void setWidget( QWidget *widget );
263
264 QgsStyle *mStyle = nullptr;
265 QgsSymbol *mSymbol = nullptr;
266 std::unique_ptr<QgsSymbol> mOwnedSymbol;
267 QMenu *mAdvancedMenu = nullptr;
268 QAction *mLockColorAction = nullptr;
269 QAction *mLockSelectionColorAction = nullptr;
270 QPointer<QgsVectorLayer> mVectorLayer;
271
272 QStandardItemModel *mSymbolLayersModel = nullptr;
273 QWidget *mPresentWidget = nullptr;
274
275 std::unique_ptr<DataDefinedRestorer> mDataDefineRestorer;
276 QgsSymbolWidgetContext mContext;
277 QgsFeature mPreviewFeature;
278 QgsExpressionContext mPreviewExpressionContext;
279 bool mBlockModified = false;
280};
281
287class GUI_EXPORT QgsSymbolSelectorDialog : public QDialog
288{
289 Q_OBJECT
290
291 public:
301 QgsSymbolSelectorDialog( QgsSymbol *symbol, QgsStyle *style, QgsVectorLayer *vl, QWidget *parent SIP_TRANSFERTHIS = nullptr, bool embedded = false );
302
304 QMenu *advancedMenu();
305
312
318
323 QgsSymbol *symbol();
324
330 void loadSymbol( QgsSymbol *symbol, SymbolLayerItem *parent = nullptr ) SIP_SKIP;
331
336 QDialogButtonBox *buttonBox() const;
337
338 public slots:
339
340 void moveLayerDown();
341 void moveLayerUp();
342
343 void addLayer();
344 void removeLayer();
345
346 void lockLayer();
347
351 void duplicateLayer();
352
353 void layerChanged();
354
355 void updateLayerPreview();
356 void updatePreview();
357
359 void symbolChanged();
360
366 void changeLayer( QgsSymbolLayer *layer );
367
368 protected:
369 // Reimplements dialog keyPress event so we can ignore it
370 void keyPressEvent( QKeyEvent *e ) override;
371
372 private slots:
373
374 void showHelp();
375
376 signals:
377
382
383 private:
384 void reloadSymbol();
385
386 void updateUi();
387
388 void updateLockButton();
389
390 SymbolLayerItem *currentLayerItem();
391
392 QgsSymbolLayer *currentLayer();
393
394 void moveLayerByOffset( int offset );
395
396 void setWidget( QWidget *widget );
397
398 QgsSymbolSelectorWidget *mSelectorWidget = nullptr;
399 QDialogButtonBox *mButtonBox = nullptr;
400};
401
402#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:58
Abstract base class for line symbol layers.
A line symbol type, for rendering LineString and MultiLineString geometries.
Map canvas is a class for displaying all GIS data types on a canvas.
Base class for all map layer types.
Definition qgsmaplayer.h:80
Abstract base class for marker symbol layers.
A marker symbol type, for rendering Point and MultiPoint geometries.
QgsPanelWidget(QWidget *parent=nullptr)
Base class for any widget that can be shown as an inline panel.
void keyPressEvent(QKeyEvent *event) override
Overridden key press event to handle the esc event on the widget.
A database of saved style entities, including symbols, color ramps, text formats and others.
Definition qgsstyle.h:88
Abstract base class for symbol layers.
A dialog that can be used to select and build a symbol.
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 symbolModified()
Emitted when the symbol defined in the dialog is modified.
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.
friend class QgsSymbolSelectorDialog
To allow for non API break access from the dialog.
QMenu * advancedMenu()
Returns menu for "advanced" button - create it if doesn't exist and show the advanced button.
QgsSymbolSelectorWidget(QgsSymbol *symbol, QgsStyle *style, QgsVectorLayer *vl, QWidget *parent=nullptr)
Symbol selector widget that can be used to select and build a symbol.
QgsSymbolWidgetContext context() const
Returns the context in which the symbol widget is shown, e.g., the associated map canvas and expressi...
void symbolModified()
Emitted when a symbol is modified in the widget.
void setContext(const QgsSymbolWidgetContext &context)
Sets the context in which the symbol widget is shown, e.g., the associated map canvas and expression ...
QgsSymbol * symbol()
Returns the symbol that is currently active in the widget.
static QgsSymbolSelectorWidget * createWidgetWithSymbolOwnership(std::unique_ptr< QgsSymbol > symbol, QgsStyle *style, QgsVectorLayer *vl, QWidget *parent=nullptr)
Creates a QgsSymbolSelectorWidget which takes ownership of a symbol and maintains the ownership for t...
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:231
Represents a vector layer which manages a vector based dataset.
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:53
#define SIP_SKIP
Definition qgis_sip.h:134