QGIS API Documentation  3.16.0-Hannover (43b64b13f3)
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"
25 #include "qgssymbolwidgetcontext.h"
26 #include "qgsproperty.h"
27 #include "qgshelp.h"
28 
29 #include <QStandardItemModel>
30 #include <QDialogButtonBox>
31 #include "qgis_gui.h"
32 
33 class QgsStyle;
34 class QgsSymbol;
35 class QgsSymbolLayer;
36 class QgsVectorLayer;
37 
38 class QMenu;
39 class QWidget;
40 
41 class SymbolLayerItem;
42 class QgsMarkerSymbol;
43 class QgsLineSymbol;
45 class QgsLineSymbolLayer;
46 
47 class QgsMapCanvas;
48 
49 #ifndef SIP_RUN
50 
52 class DataDefinedRestorer: public QObject
53 {
54  Q_OBJECT
55  public:
56  DataDefinedRestorer( QgsSymbol *symbol, const QgsSymbolLayer *symbolLayer );
57 
58  public slots:
59  void restore();
60 
61  private:
62  QgsMarkerSymbol *mMarker = nullptr;
63  const QgsMarkerSymbolLayer *mMarkerSymbolLayer = nullptr;
64  double mSize;
65  double mAngle;
66  QPointF mMarkerOffset;
67  QgsProperty mDDSize;
68  QgsProperty mDDAngle;
69 
70  QgsLineSymbol *mLine = nullptr;
71  const QgsLineSymbolLayer *mLineSymbolLayer = nullptr;
72  double mWidth;
73  double mLineOffset;
74  QgsProperty mDDWidth;
75 
76  void save();
77 };
79 #endif
80 
82 
87 class GUI_EXPORT QgsSymbolSelectorWidget: public QgsPanelWidget, private Ui::QgsSymbolSelectorDialogBase
88 {
89  Q_OBJECT
92 
93  public:
94 
95  // TODO QGIS 4.0 - transfer ownership of symbol to widget!
96 
105  QgsSymbolSelectorWidget( QgsSymbol *symbol, QgsStyle *style, QgsVectorLayer *vl, QWidget *parent SIP_TRANSFERTHIS = nullptr );
106 
108  QMenu *advancedMenu();
109 
117 
124 
129  QgsSymbol *symbol() { return mSymbol; }
130 
131  // TODO QGIS 4.0 - transfer ownership of symbol to widget!
132 
139  void loadSymbol( QgsSymbol *symbol, SymbolLayerItem *parent = nullptr ) SIP_SKIP;
140 
141  public slots:
142 
146  void moveLayerDown();
147 
151  void moveLayerUp();
152 
156  void addLayer();
157 
161  void removeLayer();
162 
166  void lockLayer();
167 
172  void duplicateLayer();
173 
178  void layerChanged();
179 
183  void updateLayerPreview();
184 
188  void updatePreview();
189 
191  void symbolChanged();
192 
197  void changeLayer( QgsSymbolLayer *layer );
198 
199  signals:
200 
205 
206  private:
207 
211  void reloadSymbol();
212 
216  void updateUi();
217 
221  void updateLockButton();
222 
223  SymbolLayerItem *currentLayerItem();
224 
229  QgsSymbolLayer *currentLayer();
230 
235  void moveLayerByOffset( int offset );
236 
241  void setWidget( QWidget *widget );
242 
243  QgsStyle *mStyle = nullptr;
244  QgsSymbol *mSymbol = nullptr;
245  QMenu *mAdvancedMenu = nullptr;
246  QgsVectorLayer *mVectorLayer = nullptr;
247 
248  QStandardItemModel *model = nullptr;
249  QWidget *mPresentWidget = nullptr;
250 
251  std::unique_ptr<DataDefinedRestorer> mDataDefineRestorer;
252  QgsSymbolWidgetContext mContext;
253  QgsFeature mPreviewFeature;
254  QgsExpressionContext mPreviewExpressionContext;
255  bool mBlockModified = false;
256 
257 };
258 
263 class GUI_EXPORT QgsSymbolSelectorDialog : public QDialog
264 {
265  Q_OBJECT
266 
267  public:
268 
278  QgsSymbolSelectorDialog( QgsSymbol *symbol, QgsStyle *style, QgsVectorLayer *vl, QWidget *parent SIP_TRANSFERTHIS = nullptr, bool embedded = false );
279 
281  QMenu *advancedMenu();
282 
290 
297 
302  QgsSymbol *symbol();
303 
309  void loadSymbol( QgsSymbol *symbol, SymbolLayerItem *parent = nullptr ) SIP_SKIP;
310 
315  QDialogButtonBox *buttonBox() const;
316 
317  public slots:
318 
319  void moveLayerDown();
320  void moveLayerUp();
321 
322  void addLayer();
323  void removeLayer();
324 
325  void lockLayer();
326 
331  void duplicateLayer();
332 
333  void layerChanged();
334 
335  void updateLayerPreview();
336  void updatePreview();
337 
339  void symbolChanged();
340 
345  void changeLayer( QgsSymbolLayer *layer );
346 
347  protected:
348 
349  // Reimplements dialog keyPress event so we can ignore it
350  void keyPressEvent( QKeyEvent *e ) override;
351 
352  private slots:
353 
354  void showHelp();
355 
356  signals:
357 
359 
360  private:
361 
362  void reloadSymbol();
363 
364  void updateUi();
365 
366  void updateLockButton();
367 
368  SymbolLayerItem *currentLayerItem();
369 
370  QgsSymbolLayer *currentLayer();
371 
372  void moveLayerByOffset( int offset );
373 
374  void setWidget( QWidget *widget );
375 
376  QgsSymbolSelectorWidget *mSelectorWidget = nullptr;
377  QDialogButtonBox *mButtonBox = nullptr;
378  QgsSymbolWidgetContext mContext;
379 
380 };
381 
382 #endif
QgsSymbolSelectorDialog::moveLayerDown
void moveLayerDown()
Definition: qgssymbolselectordialog.cpp:878
QgsSymbolSelectorDialog
Definition: qgssymbolselectordialog.h:264
QgsLineSymbolLayer
Definition: qgssymbollayer.h:901
QgsExpressionContext
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
Definition: qgsexpressioncontext.h:370
QgsSymbolSelectorDialog::updatePreview
void updatePreview()
Definition: qgssymbolselectordialog.cpp:918
QgsSymbolSelectorDialog::buttonBox
QDialogButtonBox * buttonBox() const
Returns a reference to the dialog's button box.
Definition: qgssymbolselectordialog.cpp:933
QgsProperty
A store for object properties.
Definition: qgsproperty.h:232
QgsSymbolSelectorDialog::layerChanged
void layerChanged()
Definition: qgssymbolselectordialog.cpp:908
QgsSymbolSelectorDialog::symbolModified
void symbolModified()
QgsSymbolSelectorDialog::moveLayerUp
void moveLayerUp()
Definition: qgssymbolselectordialog.cpp:883
QgsSymbolSelectorDialog::duplicateLayer
void duplicateLayer()
Duplicates the current symbol layer and places the duplicated layer above the current symbol layer.
Definition: qgssymbolselectordialog.cpp:903
QgsSymbolSelectorWidget::symbol
QgsSymbol * symbol()
Returns the symbol that is currently active in the widget.
Definition: qgssymbolselectordialog.h:129
QgsSymbolWidgetContext
Contains settings which reflect the context in which a symbol (or renderer) widget is shown,...
Definition: qgssymbolwidgetcontext.h:36
QgsSymbolSelectorDialog::QgsSymbolSelectorDialog
QgsSymbolSelectorDialog(QgsSymbol *symbol, QgsStyle *style, QgsVectorLayer *vl, QWidget *parent=nullptr, bool embedded=false)
Constructor for QgsSymbolSelectorDialog.
Definition: qgssymbolselectordialog.cpp:771
QgsMapCanvas
Map canvas is a class for displaying all GIS data types on a canvas.
Definition: qgsmapcanvas.h:85
QgsSymbolSelectorDialog::context
QgsSymbolWidgetContext context() const
Returns the context in which the symbol widget is shown, e.g., the associated map canvas and expressi...
Definition: qgssymbolselectordialog.cpp:815
QgsMarkerSymbolLayer
Abstract base class for marker symbol layers.
Definition: qgssymbollayer.h:582
QgsSymbolSelectorWidget
Symbol selector widget that can be used to select and build a symbol.
Definition: qgssymbolselectordialog.h:88
QgsSymbol
Abstract base class for all rendered symbols.
Definition: qgssymbol.h:64
qgssymbolwidgetcontext.h
QgsSymbolSelectorDialog::removeLayer
void removeLayer()
Definition: qgssymbolselectordialog.cpp:893
QgsSymbolSelectorDialog::updateLayerPreview
void updateLayerPreview()
Definition: qgssymbolselectordialog.cpp:913
geos::unique_ptr
std::unique_ptr< GEOSGeometry, GeosDeleter > unique_ptr
Scoped GEOS pointer.
Definition: qgsgeos.h:79
QgsSymbolLayer
Definition: qgssymbollayer.h:53
SIP_SKIP
#define SIP_SKIP
Definition: qgis_sip.h:126
QgsPanelWidget
Base class for any widget that can be shown as a inline panel.
Definition: qgspanelwidget.h:30
QgsMarkerSymbol
A marker symbol type, for rendering Point and MultiPoint geometries.
Definition: qgssymbol.h:931
QgsSymbolSelectorDialog::lockLayer
void lockLayer()
Definition: qgssymbolselectordialog.cpp:898
qgis_sip.h
QgsLineSymbol
A line symbol type, for rendering LineString and MultiLineString geometries.
Definition: qgssymbol.h:1131
QgsSymbolSelectorDialog::setContext
void setContext(const QgsSymbolWidgetContext &context)
Sets the context in which the symbol widget is shown, e.g., the associated map canvas and expression ...
Definition: qgssymbolselectordialog.cpp:810
QgsSymbolSelectorDialog::addLayer
void addLayer()
Definition: qgssymbolselectordialog.cpp:888
QgsSymbolSelectorDialog::symbolChanged
void symbolChanged()
Slot to update tree when a new symbol from style.
Definition: qgssymbolselectordialog.cpp:923
QgsPanelWidget::keyPressEvent
void keyPressEvent(QKeyEvent *event) override
Overridden key press event to handle the esc event on the widget.
Definition: qgspanelwidget.cpp:112
QgsSymbolSelectorDialog::changeLayer
void changeLayer(QgsSymbolLayer *layer)
alters tree and sets proper widget when Layer Type is changed
Definition: qgssymbolselectordialog.cpp:928
QgsSymbolSelectorDialog::symbol
QgsSymbol * symbol()
Returns the symbol that is currently active in the widget.
Definition: qgssymbolselectordialog.cpp:820
QgsStyle
Definition: qgsstyle.h:160
QgsVectorLayer
Represents a vector layer which manages a vector based data sets.
Definition: qgsvectorlayer.h:387
QgsSymbolSelectorDialog::advancedMenu
QMenu * advancedMenu()
Returns menu for "advanced" button - create it if doesn't exist and show the advanced button.
Definition: qgssymbolselectordialog.cpp:805
qgsproperty.h
QgsFeature
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition: qgsfeature.h:56
qgspanelwidget.h
QgsSymbolSelectorDialog::loadSymbol
void loadSymbol(QgsSymbol *symbol, SymbolLayerItem *parent=nullptr)
Loads the given symbol into the widget.
Definition: qgssymbolselectordialog.cpp:843
SIP_TRANSFERTHIS
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:53
qgshelp.h