QGIS API Documentation 3.41.0-Master (af5edcb665c)
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 <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 // TODO QGIS 4.0 - transfer ownership of symbol to widget!
96
105 QgsSymbolSelectorWidget( QgsSymbol *symbol, QgsStyle *style, QgsVectorLayer *vl, QWidget *parent SIP_TRANSFERTHIS = nullptr );
106
107 // TODO QGIS 4.0 -- remove when normal constructor takes ownership
108
115 static QgsSymbolSelectorWidget *createWidgetWithSymbolOwnership( std::unique_ptr<QgsSymbol> symbol, QgsStyle *style, QgsVectorLayer *vl, QWidget *parent SIP_TRANSFERTHIS = nullptr ) SIP_SKIP;
116
118 QMenu *advancedMenu();
119
125 void setContext( const QgsSymbolWidgetContext &context );
126
131 QgsSymbolWidgetContext context() const;
132
137 QgsSymbol *symbol() { return mSymbol; }
138
139 // TODO QGIS 4.0 - transfer ownership of symbol to widget!
140
147 void loadSymbol( QgsSymbol *symbol, SymbolLayerItem *parent = nullptr ) SIP_SKIP;
148
149 public slots:
150
154 void moveLayerDown();
155
159 void moveLayerUp();
160
164 void addLayer();
165
169 void removeLayer();
170
174 void lockLayer();
175
179 void duplicateLayer();
180
185 void layerChanged();
186
190 void updateLayerPreview();
191
195 void updatePreview();
196
198 void symbolChanged();
199
205 void changeLayer( QgsSymbolLayer *layer );
206
207 signals:
208
212 void symbolModified();
213
214 private slots:
215
220 void projectDataChanged();
221
225 void layersAboutToBeRemoved( const QList<QgsMapLayer *> &layers );
226
227 private:
231 void reloadSymbol();
232
236 void updateUi();
237
241 void updateLockButton();
242
243 void updateLockButtonIcon();
244
245 SymbolLayerItem *currentLayerItem();
246
251 QgsSymbolLayer *currentLayer();
252
257 void moveLayerByOffset( int offset );
258
263 void setWidget( QWidget *widget );
264
265 QgsStyle *mStyle = nullptr;
266 QgsSymbol *mSymbol = nullptr;
267 std::unique_ptr<QgsSymbol> mOwnedSymbol;
268 QMenu *mAdvancedMenu = nullptr;
269 QAction *mLockColorAction = nullptr;
270 QAction *mLockSelectionColorAction = nullptr;
271 QPointer<QgsVectorLayer> mVectorLayer;
272
273 QStandardItemModel *mSymbolLayersModel = nullptr;
274 QWidget *mPresentWidget = nullptr;
275
276 std::unique_ptr<DataDefinedRestorer> mDataDefineRestorer;
277 QgsSymbolWidgetContext mContext;
278 QgsFeature mPreviewFeature;
279 QgsExpressionContext mPreviewExpressionContext;
280 bool mBlockModified = false;
281};
282
288class GUI_EXPORT QgsSymbolSelectorDialog : public QDialog
289{
290 Q_OBJECT
291
292 public:
302 QgsSymbolSelectorDialog( QgsSymbol *symbol, QgsStyle *style, QgsVectorLayer *vl, QWidget *parent SIP_TRANSFERTHIS = nullptr, bool embedded = false );
303
305 QMenu *advancedMenu();
306
312 void setContext( const QgsSymbolWidgetContext &context );
313
318 QgsSymbolWidgetContext context() const;
319
324 QgsSymbol *symbol();
325
331 void loadSymbol( QgsSymbol *symbol, SymbolLayerItem *parent = nullptr ) SIP_SKIP;
332
337 QDialogButtonBox *buttonBox() const;
338
339 public slots:
340
341 void moveLayerDown();
342 void moveLayerUp();
343
344 void addLayer();
345 void removeLayer();
346
347 void lockLayer();
348
352 void duplicateLayer();
353
354 void layerChanged();
355
356 void updateLayerPreview();
357 void updatePreview();
358
360 void symbolChanged();
361
367 void changeLayer( QgsSymbolLayer *layer );
368
369 protected:
370 // Reimplements dialog keyPress event so we can ignore it
371 void keyPressEvent( QKeyEvent *e ) override;
372
373 private slots:
374
375 void showHelp();
376
377 signals:
378
383
384 private:
385 void reloadSymbol();
386
387 void updateUi();
388
389 void updateLockButton();
390
391 SymbolLayerItem *currentLayerItem();
392
393 QgsSymbolLayer *currentLayer();
394
395 void moveLayerByOffset( int offset );
396
397 void setWidget( QWidget *widget );
398
399 QgsSymbolSelectorWidget *mSelectorWidget = nullptr;
400 QDialogButtonBox *mButtonBox = nullptr;
401 QgsSymbolWidgetContext mContext;
402};
403
404#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:76
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.
A dialog that can be used to select and build a symbol.
void symbolModified()
Emitted when the symbol defined in the dialog is modified.
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,...
Abstract base class for all rendered symbols.
Definition qgssymbol.h:231
Represents a vector layer which manages a vector based data sets.
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:53
#define SIP_SKIP
Definition qgis_sip.h:126