QGIS API Documentation 3.39.0-Master (9ea1ddbe645)
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
290class GUI_EXPORT QgsSymbolSelectorDialog : public QDialog
291{
292 Q_OBJECT
293
294 public:
295
305 QgsSymbolSelectorDialog( QgsSymbol *symbol, QgsStyle *style, QgsVectorLayer *vl, QWidget *parent SIP_TRANSFERTHIS = nullptr, bool embedded = false );
306
308 QMenu *advancedMenu();
309
315 void setContext( const QgsSymbolWidgetContext &context );
316
321 QgsSymbolWidgetContext context() const;
322
327 QgsSymbol *symbol();
328
334 void loadSymbol( QgsSymbol *symbol, SymbolLayerItem *parent = nullptr ) SIP_SKIP;
335
340 QDialogButtonBox *buttonBox() const;
341
342 public slots:
343
344 void moveLayerDown();
345 void moveLayerUp();
346
347 void addLayer();
348 void removeLayer();
349
350 void lockLayer();
351
355 void duplicateLayer();
356
357 void layerChanged();
358
359 void updateLayerPreview();
360 void updatePreview();
361
363 void symbolChanged();
364
370 void changeLayer( QgsSymbolLayer *layer );
371
372 protected:
373
374 // Reimplements dialog keyPress event so we can ignore it
375 void keyPressEvent( QKeyEvent *e ) override;
376
377 private slots:
378
379 void showHelp();
380
381 signals:
382
384
385 private:
386
387 void reloadSymbol();
388
389 void updateUi();
390
391 void updateLockButton();
392
393 SymbolLayerItem *currentLayerItem();
394
395 QgsSymbolLayer *currentLayer();
396
397 void moveLayerByOffset( int offset );
398
399 void setWidget( QWidget *widget );
400
401 QgsSymbolSelectorWidget *mSelectorWidget = nullptr;
402 QDialogButtonBox *mButtonBox = nullptr;
403 QgsSymbolWidgetContext mContext;
404
405};
406
407#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:75
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.
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