QGIS API Documentation 3.41.0-Master (45a0abf3bec)
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
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
108 // TODO QGIS 4.0 -- remove when normal constructor takes ownership
109
116 static QgsSymbolSelectorWidget *createWidgetWithSymbolOwnership( std::unique_ptr< QgsSymbol > symbol, QgsStyle *style, QgsVectorLayer *vl, QWidget *parent SIP_TRANSFERTHIS = nullptr ) SIP_SKIP;
117
119 QMenu *advancedMenu();
120
126 void setContext( const QgsSymbolWidgetContext &context );
127
132 QgsSymbolWidgetContext context() const;
133
138 QgsSymbol *symbol() { return mSymbol; }
139
140 // TODO QGIS 4.0 - transfer ownership of symbol to widget!
141
148 void loadSymbol( QgsSymbol *symbol, SymbolLayerItem *parent = nullptr ) SIP_SKIP;
149
150 public slots:
151
155 void moveLayerDown();
156
160 void moveLayerUp();
161
165 void addLayer();
166
170 void removeLayer();
171
175 void lockLayer();
176
180 void duplicateLayer();
181
186 void layerChanged();
187
191 void updateLayerPreview();
192
196 void updatePreview();
197
199 void symbolChanged();
200
206 void changeLayer( QgsSymbolLayer *layer );
207
208 signals:
209
213 void symbolModified();
214
215 private slots:
216
221 void projectDataChanged();
222
226 void layersAboutToBeRemoved( const QList<QgsMapLayer *> &layers );
227
228 private:
229
233 void reloadSymbol();
234
238 void updateUi();
239
243 void updateLockButton();
244
245 void updateLockButtonIcon();
246
247 SymbolLayerItem *currentLayerItem();
248
253 QgsSymbolLayer *currentLayer();
254
259 void moveLayerByOffset( int offset );
260
265 void setWidget( QWidget *widget );
266
267 QgsStyle *mStyle = nullptr;
268 QgsSymbol *mSymbol = nullptr;
269 std::unique_ptr< QgsSymbol > mOwnedSymbol;
270 QMenu *mAdvancedMenu = nullptr;
271 QAction *mLockColorAction = nullptr;
272 QAction *mLockSelectionColorAction = nullptr;
273 QPointer< QgsVectorLayer > mVectorLayer;
274
275 QStandardItemModel *mSymbolLayersModel = nullptr;
276 QWidget *mPresentWidget = nullptr;
277
278 std::unique_ptr<DataDefinedRestorer> mDataDefineRestorer;
279 QgsSymbolWidgetContext mContext;
280 QgsFeature mPreviewFeature;
281 QgsExpressionContext mPreviewExpressionContext;
282 bool mBlockModified = false;
283
284};
285
291class GUI_EXPORT QgsSymbolSelectorDialog : public QDialog
292{
293 Q_OBJECT
294
295 public:
296
306 QgsSymbolSelectorDialog( QgsSymbol *symbol, QgsStyle *style, QgsVectorLayer *vl, QWidget *parent SIP_TRANSFERTHIS = nullptr, bool embedded = false );
307
309 QMenu *advancedMenu();
310
316 void setContext( const QgsSymbolWidgetContext &context );
317
322 QgsSymbolWidgetContext context() const;
323
328 QgsSymbol *symbol();
329
335 void loadSymbol( QgsSymbol *symbol, SymbolLayerItem *parent = nullptr ) SIP_SKIP;
336
341 QDialogButtonBox *buttonBox() const;
342
343 public slots:
344
345 void moveLayerDown();
346 void moveLayerUp();
347
348 void addLayer();
349 void removeLayer();
350
351 void lockLayer();
352
356 void duplicateLayer();
357
358 void layerChanged();
359
360 void updateLayerPreview();
361 void updatePreview();
362
364 void symbolChanged();
365
371 void changeLayer( QgsSymbolLayer *layer );
372
373 protected:
374
375 // Reimplements dialog keyPress event so we can ignore it
376 void keyPressEvent( QKeyEvent *e ) override;
377
378 private slots:
379
380 void showHelp();
381
382 signals:
383
388
389 private:
390
391 void reloadSymbol();
392
393 void updateUi();
394
395 void updateLockButton();
396
397 SymbolLayerItem *currentLayerItem();
398
399 QgsSymbolLayer *currentLayer();
400
401 void moveLayerByOffset( int offset );
402
403 void setWidget( QWidget *widget );
404
405 QgsSymbolSelectorWidget *mSelectorWidget = nullptr;
406 QDialogButtonBox *mButtonBox = nullptr;
407 QgsSymbolWidgetContext mContext;
408
409};
410
411#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