QGIS API Documentation 3.34.0-Prizren (ffbdd678812)
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
127 void setContext( const QgsSymbolWidgetContext &context );
128
134 QgsSymbolWidgetContext context() const;
135
140 QgsSymbol *symbol() { return mSymbol; }
141
142 // TODO QGIS 4.0 - transfer ownership of symbol to widget!
143
150 void loadSymbol( QgsSymbol *symbol, SymbolLayerItem *parent = nullptr ) SIP_SKIP;
151
152 public slots:
153
157 void moveLayerDown();
158
162 void moveLayerUp();
163
167 void addLayer();
168
172 void removeLayer();
173
177 void lockLayer();
178
183 void duplicateLayer();
184
189 void layerChanged();
190
194 void updateLayerPreview();
195
199 void updatePreview();
200
202 void symbolChanged();
203
208 void changeLayer( QgsSymbolLayer *layer );
209
210 signals:
211
215 void symbolModified();
216
217 private slots:
218
223 void projectDataChanged();
224
228 void layersAboutToBeRemoved( const QList<QgsMapLayer *> &layers );
229
230 private:
231
235 void reloadSymbol();
236
240 void updateUi();
241
245 void updateLockButton();
246
247 void updateLockButtonIcon();
248
249 SymbolLayerItem *currentLayerItem();
250
255 QgsSymbolLayer *currentLayer();
256
261 void moveLayerByOffset( int offset );
262
267 void setWidget( QWidget *widget );
268
269 QgsStyle *mStyle = nullptr;
270 QgsSymbol *mSymbol = nullptr;
271 std::unique_ptr< QgsSymbol > mOwnedSymbol;
272 QMenu *mAdvancedMenu = nullptr;
273 QAction *mLockColorAction = nullptr;
274 QAction *mLockSelectionColorAction = nullptr;
275 QPointer< QgsVectorLayer > mVectorLayer;
276
277 QStandardItemModel *mSymbolLayersModel = nullptr;
278 QWidget *mPresentWidget = nullptr;
279
280 std::unique_ptr<DataDefinedRestorer> mDataDefineRestorer;
281 QgsSymbolWidgetContext mContext;
282 QgsFeature mPreviewFeature;
283 QgsExpressionContext mPreviewExpressionContext;
284 bool mBlockModified = false;
285
286};
287
292class GUI_EXPORT QgsSymbolSelectorDialog : public QDialog
293{
294 Q_OBJECT
295
296 public:
297
307 QgsSymbolSelectorDialog( QgsSymbol *symbol, QgsStyle *style, QgsVectorLayer *vl, QWidget *parent SIP_TRANSFERTHIS = nullptr, bool embedded = false );
308
310 QMenu *advancedMenu();
311
318 void setContext( const QgsSymbolWidgetContext &context );
319
325 QgsSymbolWidgetContext context() const;
326
331 QgsSymbol *symbol();
332
338 void loadSymbol( QgsSymbol *symbol, SymbolLayerItem *parent = nullptr ) SIP_SKIP;
339
344 QDialogButtonBox *buttonBox() const;
345
346 public slots:
347
348 void moveLayerDown();
349 void moveLayerUp();
350
351 void addLayer();
352 void removeLayer();
353
354 void lockLayer();
355
360 void duplicateLayer();
361
362 void layerChanged();
363
364 void updateLayerPreview();
365 void updatePreview();
366
368 void symbolChanged();
369
374 void changeLayer( QgsSymbolLayer *layer );
375
376 protected:
377
378 // Reimplements dialog keyPress event so we can ignore it
379 void keyPressEvent( QKeyEvent *e ) override;
380
381 private slots:
382
383 void showHelp();
384
385 signals:
386
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:56
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:74
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:94
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