QGIS API Documentation  2.18.21-Las Palmas (9fba24a)
qgssymbolv2selectordialog.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgssymbolv2selectordialog.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 QGSSYMBOLV2SELECTORDIALOG_H
17 #define QGSSYMBOLV2SELECTORDIALOG_H
18 
19 #include <QDialog>
20 
21 #include "ui_qgssymbolv2selectordialogbase.h"
22 
23 #include "qgsdatadefined.h"
24 #include "qgspanelwidget.h"
25 
26 #include <QStandardItemModel>
27 #include <QScopedPointer>
28 #include <QDialogButtonBox>
29 
30 class QgsStyleV2;
31 class QgsSymbolV2;
32 class QgsSymbolLayerV2;
33 class QgsVectorLayer;
34 
35 class QMenu;
36 class QWidget;
37 
38 class SymbolLayerItem;
39 class QgsMarkerSymbolV2;
40 class QgsLineSymbolV2;
43 
44 class QgsMapCanvas;
45 
47 
48 class DataDefinedRestorer: public QObject
49 {
50  Q_OBJECT
51  public:
52  DataDefinedRestorer( QgsSymbolV2* symbol, const QgsSymbolLayerV2* symbolLayer );
53 
54  public slots:
55  void restore();
56 
57  private:
58  QgsMarkerSymbolV2* mMarker;
59  const QgsMarkerSymbolLayerV2* mMarkerSymbolLayer;
60  double mSize;
61  double mAngle;
62  QPointF mMarkerOffset;
63  QgsDataDefined mDDSize;
64  QgsDataDefined mDDAngle;
65 
66  QgsLineSymbolV2* mLine;
67  const QgsLineSymbolLayerV2* mLineSymbolLayer;
68  double mWidth;
69  double mLineOffset;
70  QgsDataDefined mDDWidth;
71 
72  void save();
73 };
75 
77 
81 class GUI_EXPORT QgsSymbolV2SelectorWidget: public QgsPanelWidget, private Ui::QgsSymbolV2SelectorDialogBase
82 {
83  Q_OBJECT
86 
87  public:
97 
100 
109 
116  QgsExpressionContext* expressionContext() const { return mPresetExpressionContext.data(); }
117 
123  void setMapCanvas( QgsMapCanvas* canvas );
124 
129  QgsSymbolV2* symbol() { return mSymbol; }
130 
137  void releaseSymbol();
138 
139  protected:
140 
144  void loadSymbol();
146 
152  void loadSymbol( QgsSymbolV2* symbol, SymbolLayerItem* parent );
153 
157  void updateUi();
158 
162  void updateLockButton();
163 
165  SymbolLayerItem* currentLayerItem();
166 
172 
177  void moveLayerByOffset( int offset );
178 
183  void setWidget( QWidget* widget );
184 
185  signals:
189  void symbolModified();
190 
191  public slots:
195  void moveLayerDown();
196 
200  void moveLayerUp();
201 
205  void addLayer();
206 
210  void removeLayer();
211 
215  void lockLayer();
216 
220  Q_DECL_DEPRECATED void saveSymbol();
221 
224  void duplicateLayer();
225 
230  void layerChanged();
231 
235  void updateLayerPreview();
236 
240  void updatePreview();
241 
243  void symbolChanged();
246  void changeLayer( QgsSymbolLayerV2* layer );
247 
248 
249  protected: // data
254 
257 
258  private:
259  QScopedPointer<DataDefinedRestorer> mDataDefineRestorer;
260  QScopedPointer< QgsExpressionContext > mPresetExpressionContext;
261 
262  QgsMapCanvas* mMapCanvas;
263 };
264 
268 class GUI_EXPORT QgsSymbolV2SelectorDialog : public QDialog
269 {
270  Q_OBJECT
271 
272  public:
273  QgsSymbolV2SelectorDialog( QgsSymbolV2* symbol, QgsStyleV2* style, const QgsVectorLayer* vl, QWidget* parent = nullptr, bool embedded = false );
275 
277  QMenu* advancedMenu();
278 
286  void setExpressionContext( QgsExpressionContext* context );
287 
294  QgsExpressionContext* expressionContext() const;
295 
301  void setMapCanvas( QgsMapCanvas* canvas );
302 
307  QgsSymbolV2* symbol();
308 
309  protected:
311  void keyPressEvent( QKeyEvent * e ) override;
312 
313  void loadSymbol();
315  void loadSymbol( QgsSymbolV2* symbol, SymbolLayerItem* parent );
316 
317  void updateUi();
318 
319  void updateLockButton();
320 
322  SymbolLayerItem* currentLayerItem();
323  QgsSymbolLayerV2* currentLayer();
324 
325  void moveLayerByOffset( int offset );
326 
327  void setWidget( QWidget* widget );
328 
329  signals:
330  void symbolModified();
331 
332  public slots:
333  void moveLayerDown();
334  void moveLayerUp();
335 
336  void addLayer();
337  void removeLayer();
338 
339  void lockLayer();
340 
341  Q_DECL_DEPRECATED void saveSymbol();
342 
345  void duplicateLayer();
346 
347  void layerChanged();
348 
349  void updateLayerPreview();
350  void updatePreview();
351 
353  void symbolChanged();
356  void changeLayer( QgsSymbolLayerV2* layer );
357 
358  private:
359  QgsSymbolV2SelectorWidget* mSelectorWidget;
360  QDialogButtonBox* mButtonBox;
361 };
362 
363 #endif
Symbol selector widget that cna be used to select and build a symbol.
void setExpressionContext(QgsExpressionContext *context)
Sets the optional expression context used for the widget.
A container class for data source field mapping or expression.
QStyle * style() const
QgsSymbolV2 * symbol()
Return the symbol that is currently active in the widget.
void symbolChanged()
Slot to update tree when a new symbol from style.
Base class for any widget that can be shown as a inline panel.
Map canvas is a class for displaying all GIS data types on a canvas.
Definition: qgsmapcanvas.h:109
QMenu * advancedMenu()
return menu for "advanced" button - create it if doesn&#39;t exist and show the advanced button ...
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
QgsExpressionContext * expressionContext() const
Returns the expression context used for the dialog, if set.
void duplicateLayer()
Duplicates the current symbol layer and places the duplicated layer above the current symbol layer...
void setMapCanvas(QgsMapCanvas *canvas)
Sets the map canvas associated with the dialog.
void changeLayer(QgsSymbolLayerV2 *layer)
alters tree and sets proper widget when Layer Type is changed
Abstract base class for marker symbol layers.
QObject * parent() const
Represents a vector layer which manages a vector based data sets.
QgsSymbolV2 * symbol()
Return the symbol that is currently active in the widget.
Q_DECL_DEPRECATED void saveSymbol()
const QgsVectorLayer * mVectorLayer