QGIS API Documentation 4.3.0-Master (6402a64e93b)
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 "ui_qgssymbolselectordialogbase.h"
20
21#include "qgis_gui.h"
22#include "qgis_sip.h"
23#include "qgshelp.h"
24#include "qgspanelwidget.h"
25#include "qgsproperty.h"
27
28#include <QDialog>
29#include <QDialogButtonBox>
30#include <QPointer>
31#include <QStandardItemModel>
32
33class QgsStyle;
34class QgsSymbol;
35class QgsSymbolLayer;
36class QgsVectorLayer;
37
38class QMenu;
39class QWidget;
40
41class QgsMarkerSymbol;
42class 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 = 0;
66 double mAngle = 0;
67 QPointF mMarkerOffset;
68 QgsProperty mDDSize;
69 QgsProperty mDDAngle;
70
71 QgsLineSymbol *mLine = nullptr;
72 const QgsLineSymbolLayer *mLineSymbolLayer = nullptr;
73 double mWidth = 0;
74 double mLineOffset = 0;
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 5.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 5.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
126
132
137 QgsSymbol *symbol() { return mSymbol; }
138
139 // TODO QGIS 5.0 - transfer ownership of symbol to widget!
140
146 void loadSymbol( QgsSymbol *symbol ) SIP_SKIP;
147
148 public slots:
149
153 void moveLayerDown();
154
158 void moveLayerUp();
159
163 void addLayer();
164
168 void removeLayer();
169
173 void lockLayer();
174
178 void duplicateLayer();
179
184 void layerChanged();
185
189 void updateLayerPreview();
190
194 void updatePreview();
195
197 void symbolChanged();
198
204 void changeLayer( QgsSymbolLayer *layer );
205
206 signals:
207
212
213 private slots:
214
219 void projectDataChanged();
220
224 void layersAboutToBeRemoved( const QList<QgsMapLayer *> &layers );
225
226 void emitSymbolModified();
227
228 void updateListIcons();
229
230 private:
234 void reloadSymbol();
235
239 void updateUi();
240
244 void updateLockButton();
245
246 void updateLockButtonIcon();
247
248 QgsSymbolLayerModelNode *currentLayerNode();
249
254 QgsSymbolLayer *currentLayer();
255
260 QgsSymbolLayerModelNode *currentNode();
261
266 void moveLayerByOffset( int offset );
267
272 void setWidget( QWidget *widget );
273
274 QgsStyle *mStyle = nullptr;
275 QgsSymbol *mSymbol = nullptr;
276 std::unique_ptr<QgsSymbol> mOwnedSymbol;
277 QMenu *mAdvancedMenu = nullptr;
278 QAction *mLockColorAction = nullptr;
279 QAction *mLockSelectionColorAction = nullptr;
280 QPointer<QgsVectorLayer> mVectorLayer;
281
282 QgsSymbolLayerModel *mSymbolLayersModel = nullptr;
283 QWidget *mPresentWidget = nullptr;
284
285 std::unique_ptr<DataDefinedRestorer> mDataDefineRestorer;
286 QgsSymbolWidgetContext mContext;
287 QgsFeature mPreviewFeature;
288 QgsExpressionContext mPreviewExpressionContext;
289 bool mBlockModified = false;
290};
291
297class GUI_EXPORT QgsSymbolSelectorDialog : public QDialog
298{
299 Q_OBJECT
300
301 public:
311 QgsSymbolSelectorDialog( QgsSymbol *symbol, QgsStyle *style, QgsVectorLayer *vl, QWidget *parent SIP_TRANSFERTHIS = nullptr, bool embedded = false );
312
314 QMenu *advancedMenu();
315
322
328
333 QgsSymbol *symbol();
334
340
345 QDialogButtonBox *buttonBox() const;
346
347 public slots:
348
349 void moveLayerDown();
350 void moveLayerUp();
351
352 void addLayer();
353 void removeLayer();
354
355 void lockLayer();
356
360 void duplicateLayer();
361
362 void layerChanged();
363
364 void updateLayerPreview();
365 void updatePreview();
366
368 void symbolChanged();
369
375 void changeLayer( QgsSymbolLayer *layer );
376
377 protected:
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
391
392 private:
393 void reloadSymbol();
394
395 void updateUi();
396
397 void updateLockButton();
398
399 QgsSymbolLayerModelNode *currentLayerNode();
400
401 QgsSymbolLayer *currentLayer();
402
403 void moveLayerByOffset( int offset );
404
405 void setWidget( QWidget *widget );
406
407 QgsSymbolSelectorWidget *mSelectorWidget = nullptr;
408 QDialogButtonBox *mButtonBox = nullptr;
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:60
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.
Abstract base class for marker symbol layers.
A marker symbol type, for rendering Point and MultiPoint geometries.
QgsPanelWidget(QWidget *parent=nullptr)
Base class for any widget that can be shown as an inline panel.
void keyPressEvent(QKeyEvent *event) override
Overridden key press event to handle the esc event on the widget.
A database of saved style entities, including symbols, color ramps, text formats and others.
Definition qgsstyle.h:91
A node contained within a QgsSymbolLayerModel.
A QAbstractItemModel subclass for displaying a QgsSymbol in a tree view in the symbology panel.
Abstract base class for symbol layers.
A dialog that can be used to select and build a symbol.
void setContext(const QgsSymbolWidgetContext &context)
Sets the context in which the symbol widget is shown, e.g., the associated map canvas and expression ...
QgsSymbolSelectorDialog(QgsSymbol *symbol, QgsStyle *style, QgsVectorLayer *vl, QWidget *parent=nullptr, bool embedded=false)
Constructor for QgsSymbolSelectorDialog.
QgsSymbolWidgetContext context() const
Returns the context in which the symbol widget is shown, e.g., the associated map canvas and expressi...
QMenu * advancedMenu()
Returns menu for "advanced" button - create it if doesn't exist and show the advanced button.
void symbolModified()
Emitted when the symbol defined in the dialog is modified.
void symbolChanged()
Slot to update tree when a new symbol from style.
QDialogButtonBox * buttonBox() const
Returns a reference to the dialog's button box.
QgsSymbol * symbol()
Returns the symbol that is currently active in the widget.
void loadSymbol(QgsSymbol *symbol)
Loads the given symbol into the widget.
void duplicateLayer()
Duplicates the current symbol layer and places the duplicated layer above the current symbol layer.
void changeLayer(QgsSymbolLayer *layer)
Alters tree and sets proper widget when Layer Type is changed.
Symbol selector widget that can be used to select and build a symbol.
friend class QgsSymbolSelectorDialog
To allow for non API break access from the dialog.
QMenu * advancedMenu()
Returns menu for "advanced" button - create it if doesn't exist and show the advanced button.
QgsSymbolSelectorWidget(QgsSymbol *symbol, QgsStyle *style, QgsVectorLayer *vl, QWidget *parent=nullptr)
Symbol selector widget that can be used to select and build a symbol.
QgsSymbolWidgetContext context() const
Returns the context in which the symbol widget is shown, e.g., the associated map canvas and expressi...
void symbolModified()
Emitted when a symbol is modified in the widget.
void setContext(const QgsSymbolWidgetContext &context)
Sets the context in which the symbol widget is shown, e.g., the associated map canvas and expression ...
QgsSymbol * symbol()
Returns the symbol that is currently active in the widget.
static QgsSymbolSelectorWidget * createWidgetWithSymbolOwnership(std::unique_ptr< QgsSymbol > symbol, QgsStyle *style, QgsVectorLayer *vl, QWidget *parent=nullptr)
Creates a QgsSymbolSelectorWidget which takes ownership of a symbol and maintains the ownership for t...
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:227
Represents a vector layer which manages a vector based dataset.
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:52
#define SIP_SKIP
Definition qgis_sip.h:133