QGIS API Documentation 3.38.0-Grenoble (exported)
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
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:
228
232 void reloadSymbol();
233
237 void updateUi();
238
242 void updateLockButton();
243
244 void updateLockButtonIcon();
245
246 SymbolLayerItem *currentLayerItem();
247
252 QgsSymbolLayer *currentLayer();
253
258 void moveLayerByOffset( int offset );
259
264 void setWidget( QWidget *widget );
265
266 QgsStyle *mStyle = nullptr;
267 QgsSymbol *mSymbol = nullptr;
268 std::unique_ptr< QgsSymbol > mOwnedSymbol;
269 QMenu *mAdvancedMenu = nullptr;
270 QAction *mLockColorAction = nullptr;
271 QAction *mLockSelectionColorAction = nullptr;
272 QPointer< QgsVectorLayer > mVectorLayer;
273
274 QStandardItemModel *mSymbolLayersModel = nullptr;
275 QWidget *mPresentWidget = nullptr;
276
277 std::unique_ptr<DataDefinedRestorer> mDataDefineRestorer;
278 QgsSymbolWidgetContext mContext;
279 QgsFeature mPreviewFeature;
280 QgsExpressionContext mPreviewExpressionContext;
281 bool mBlockModified = false;
282
283};
284
289class GUI_EXPORT QgsSymbolSelectorDialog : public QDialog
290{
291 Q_OBJECT
292
293 public:
294
304 QgsSymbolSelectorDialog( QgsSymbol *symbol, QgsStyle *style, QgsVectorLayer *vl, QWidget *parent SIP_TRANSFERTHIS = nullptr, bool embedded = false );
305
307 QMenu *advancedMenu();
308
314 void setContext( const QgsSymbolWidgetContext &context );
315
320 QgsSymbolWidgetContext context() const;
321
326 QgsSymbol *symbol();
327
333 void loadSymbol( QgsSymbol *symbol, SymbolLayerItem *parent = nullptr ) SIP_SKIP;
334
339 QDialogButtonBox *buttonBox() const;
340
341 public slots:
342
343 void moveLayerDown();
344 void moveLayerUp();
345
346 void addLayer();
347 void removeLayer();
348
349 void lockLayer();
350
354 void duplicateLayer();
355
356 void layerChanged();
357
358 void updateLayerPreview();
359 void updatePreview();
360
362 void symbolChanged();
363
368 void changeLayer( QgsSymbolLayer *layer );
369
370 protected:
371
372 // Reimplements dialog keyPress event so we can ignore it
373 void keyPressEvent( QKeyEvent *e ) override;
374
375 private slots:
376
377 void showHelp();
378
379 signals:
380
382
383 private:
384
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
405#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
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: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