QGIS API Documentation  2.17.0-Master (f49f7ce)
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 
131  protected:
132 
136  void loadSymbol();
138 
144  void loadSymbol( QgsSymbolV2* symbol, SymbolLayerItem* parent );
145 
149  void updateUi();
150 
154  void updateLockButton();
155 
157  SymbolLayerItem* currentLayerItem();
158 
164 
169  void moveLayerByOffset( int offset );
170 
175  void setWidget( QWidget* widget );
176 
177  signals:
181  void symbolModified();
182 
183  public slots:
187  void moveLayerDown();
188 
192  void moveLayerUp();
193 
197  void addLayer();
198 
202  void removeLayer();
203 
207  void lockLayer();
208 
212  Q_DECL_DEPRECATED void saveSymbol();
213 
216  void duplicateLayer();
217 
222  void layerChanged();
223 
227  void updateLayerPreview();
228 
232  void updatePreview();
233 
235  void symbolChanged();
238  void changeLayer( QgsSymbolLayerV2* layer );
239 
240 
241  protected: // data
246 
249 
250  private:
251  QScopedPointer<DataDefinedRestorer> mDataDefineRestorer;
252  QScopedPointer< QgsExpressionContext > mPresetExpressionContext;
253 
254  QgsMapCanvas* mMapCanvas;
255 };
256 
260 class GUI_EXPORT QgsSymbolV2SelectorDialog : public QDialog
261 {
262  Q_OBJECT
263 
264  public:
265  QgsSymbolV2SelectorDialog( QgsSymbolV2* symbol, QgsStyleV2* style, const QgsVectorLayer* vl, QWidget* parent = nullptr, bool embedded = false );
267 
269  QMenu* advancedMenu();
270 
278  void setExpressionContext( QgsExpressionContext* context );
279 
286  QgsExpressionContext* expressionContext() const;
287 
293  void setMapCanvas( QgsMapCanvas* canvas );
294 
299  QgsSymbolV2* symbol();
300 
301  protected:
303  void keyPressEvent( QKeyEvent * e ) override;
304 
305  void loadSymbol();
307  void loadSymbol( QgsSymbolV2* symbol, SymbolLayerItem* parent );
308 
309  void updateUi();
310 
311  void updateLockButton();
312 
314  SymbolLayerItem* currentLayerItem();
315  QgsSymbolLayerV2* currentLayer();
316 
317  void moveLayerByOffset( int offset );
318 
319  void setWidget( QWidget* widget );
320 
321  signals:
322  void symbolModified();
323 
324  public slots:
325  void moveLayerDown();
326  void moveLayerUp();
327 
328  void addLayer();
329  void removeLayer();
330 
331  void lockLayer();
332 
333  Q_DECL_DEPRECATED void saveSymbol();
334 
337  void duplicateLayer();
338 
339  void layerChanged();
340 
341  void updateLayerPreview();
342  void updatePreview();
343 
345  void symbolChanged();
348  void changeLayer( QgsSymbolLayerV2* layer );
349 
350  private:
351  QgsSymbolV2SelectorWidget* mSelectorWidget;
352  QDialogButtonBox* mButtonBox;
353 };
354 
355 #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
QgsExpressionContext * expressionContext() const
Returns the expression context used for the dialog, if set.
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...
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