QGIS API Documentation  2.15.0-Master (02a0ebe)
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 
257 
258 class GUI_EXPORT QgsSymbolV2SelectorDialog : public QDialog
259 {
260  Q_OBJECT
261 
262  public:
263  QgsSymbolV2SelectorDialog( QgsSymbolV2* symbol, QgsStyleV2* style, const QgsVectorLayer* vl, QWidget* parent = nullptr, bool embedded = false );
265 
267  QMenu* advancedMenu();
268 
276  void setExpressionContext( QgsExpressionContext* context );
277 
284  QgsExpressionContext* expressionContext() const;
285 
291  void setMapCanvas( QgsMapCanvas* canvas );
292 
297  QgsSymbolV2* symbol();
298 
299  protected:
301  void keyPressEvent( QKeyEvent * e ) override;
302 
303  void loadSymbol();
305  void loadSymbol( QgsSymbolV2* symbol, SymbolLayerItem* parent );
306 
307  void updateUi();
308 
309  void updateLockButton();
310 
312  SymbolLayerItem* currentLayerItem();
313  QgsSymbolLayerV2* currentLayer();
314 
315  void moveLayerByOffset( int offset );
316 
317  void setWidget( QWidget* widget );
318 
319  signals:
320  void symbolModified();
321 
322  public slots:
323  void moveLayerDown();
324  void moveLayerUp();
325 
326  void addLayer();
327  void removeLayer();
328 
329  void lockLayer();
330 
331  Q_DECL_DEPRECATED void saveSymbol();
332 
335  void duplicateLayer();
336 
337  void layerChanged();
338 
339  void updateLayerPreview();
340  void updatePreview();
341 
343  void symbolChanged();
346  void changeLayer( QgsSymbolLayerV2* layer );
347 
348  private:
349  QgsSymbolV2SelectorWidget* mSelectorWidget;
350  QDialogButtonBox* mButtonBox;
351 };
352 
353 #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