QGIS API Documentation  2.17.0-Master (8784312)
qgsrendererv2widget.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsrendererv2widget.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 #ifndef QGSRENDERERV2WIDGET_H
16 #define QGSRENDERERV2WIDGET_H
17 
18 #include <QWidget>
19 #include <QMenu>
20 #include <QStackedWidget>
21 #include "qgssymbolv2.h"
22 #include "qgsdatadefined.h"
23 #include "qgspanelwidget.h"
24 
25 class QgsVectorLayer;
26 class QgsStyleV2;
29 class QgsMapCanvas;
30 
41 class GUI_EXPORT QgsRendererV2Widget : public QgsPanelWidget
42 {
43  Q_OBJECT
44  public:
46 
47  virtual ~QgsRendererV2Widget() {}
48 
50  virtual QgsFeatureRendererV2* renderer() = 0;
51 
53  void showSymbolLevelsDialog( QgsFeatureRendererV2* r );
54 
61  virtual void setMapCanvas( QgsMapCanvas* canvas );
62 
67  const QgsMapCanvas* mapCanvas() const;
68 
72  const QgsVectorLayer* vectorLayer() const { return mLayer; }
73 
77  void applyChanges();
78 
79  signals:
85  void layerVariablesChanged();
86 
87  protected:
94 
98  virtual void refreshSymbolView() {}
99 
100  protected slots:
101  void contextMenuViewCategories( QPoint p );
103  void changeSymbolColor();
105  void changeSymbolTransparency();
107  void changeSymbolUnit();
109  void changeSymbolWidth();
111  void changeSymbolSize();
113  void changeSymbolAngle();
114 
115  virtual void copy() {}
116  virtual void paste() {}
117 
118  private:
123  virtual void apply();
124 
125 };
126 
127 
129 
130 #include <QObject>
131 
132 class QMenu;
133 class QgsField;
134 class QgsFields;
135 
136 
143 {
144  Q_OBJECT
145 
146  public:
147 
149  Q_DECL_DEPRECATED QgsRendererV2DataDefinedMenus( QMenu* menu, QgsVectorLayer* layer, const QString& rotationField, const QString& sizeScaleField, QgsSymbolV2::ScaleMethod scaleMethod );
150  ~QgsRendererV2DataDefinedMenus();
151 
152  void populateMenu( QMenu* menu, const QString& fieldName, QActionGroup *actionGroup );
153 #if 0
154  void updateMenu( QActionGroup* actionGroup, QString fieldName );
155 #endif
156  public slots:
157 
158  void rotationFieldSelected( QAction *a );
159  void sizeScaleFieldSelected( QAction *a );
160  void scaleMethodSelected( QAction *a );
161 
162  signals:
163 
164  void rotationFieldChanged( const QString& fldName );
165  void sizeScaleFieldChanged( const QString& fldName );
166  void scaleMethodChanged( QgsSymbolV2::ScaleMethod scaleMethod );
167 
168  protected:
175 };
176 
178 
179 #include "ui_widget_set_dd_value.h"
180 #include "qgssizescalewidget.h"
181 
185 class GUI_EXPORT QgsDataDefinedValueDialog : public QDialog, public Ui::QgsDataDefinedValueDialog
186 {
187  Q_OBJECT
188 
189  public:
195  QgsDataDefinedValueDialog( const QList<QgsSymbolV2*>& symbolList, QgsVectorLayer * layer, const QString & label );
197 
204  virtual void setMapCanvas( QgsMapCanvas* canvas );
205 
210  const QgsMapCanvas* mapCanvas() const;
211 
215  const QgsVectorLayer* vectorLayer() const { return mLayer; }
216 
217  public slots:
218  void dataDefinedChanged();
219 
220  protected:
221  QgsDataDefined symbolDataDefined() const;
222  void init( const QString & description ); // needed in children ctor to call virtual
223 
224  virtual QgsDataDefined symbolDataDefined( const QgsSymbolV2 * ) const = 0;
225  virtual double value( const QgsSymbolV2 * ) const = 0;
226  virtual void setDataDefined( QgsSymbolV2* symbol, const QgsDataDefined& dd ) = 0;
227 
231 };
232 
237 {
238  Q_OBJECT
239  public:
241  : QgsDataDefinedValueDialog( symbolList, layer, tr( "Size" ) )
242  {
243  init( tr( "Symbol size" ) );
244  if ( !symbolList.isEmpty() && symbolList.at( 0 ) && mLayer )
245  mDDBtn->setAssistant( tr( "Size Assistant..." ), new QgsSizeScaleWidget( mLayer, static_cast<const QgsMarkerSymbolV2*>( symbolList.at( 0 ) ) ) );
246  }
247 
248  protected:
249  QgsDataDefined symbolDataDefined( const QgsSymbolV2 * symbol ) const override;
250 
251  double value( const QgsSymbolV2 * symbol ) const override { return static_cast<const QgsMarkerSymbolV2*>( symbol )->size(); }
252 
253  void setDataDefined( QgsSymbolV2* symbol, const QgsDataDefined& dd ) override;
254 };
255 
260 {
261  Q_OBJECT
262  public:
264  : QgsDataDefinedValueDialog( symbolList, layer, tr( "Rotation" ) )
265  {
266  init( tr( "Symbol rotation" ) );
267  }
268 
269  protected:
270  QgsDataDefined symbolDataDefined( const QgsSymbolV2 * symbol ) const override;
271 
272  double value( const QgsSymbolV2 * symbol ) const override { return static_cast<const QgsMarkerSymbolV2*>( symbol )->angle(); }
273 
274  void setDataDefined( QgsSymbolV2* symbol, const QgsDataDefined& dd ) override;
275 };
276 
281 {
282  Q_OBJECT
283  public:
285  : QgsDataDefinedValueDialog( symbolList, layer, tr( "Width" ) )
286  {
287  init( tr( "Symbol width" ) );
288  }
289 
290  protected:
291  QgsDataDefined symbolDataDefined( const QgsSymbolV2 * symbol ) const override;
292 
293  double value( const QgsSymbolV2 * symbol ) const override { return static_cast<const QgsLineSymbolV2*>( symbol )->width(); }
294 
295  void setDataDefined( QgsSymbolV2* symbol, const QgsDataDefined& dd ) override;
296 };
297 
298 
299 
300 #endif // QGSRENDERERV2WIDGET_H
double value(const QgsSymbolV2 *symbol) const override
virtual QList< QgsSymbolV2 * > selectedSymbols()
Subclasses may provide the capability of changing multiple symbols at once by implementing the follow...
QgsDataDefinedRotationDialog(const QList< QgsSymbolV2 * > &symbolList, QgsVectorLayer *layer)
A container class for data source field mapping or expression.
const T & at(int i) const
QgsMapCanvas * mMapCanvas
Container of fields for a vector layer.
Definition: qgsfield.h:193
QgsDataDefinedSizeDialog(const QList< QgsSymbolV2 * > &symbolList, QgsVectorLayer *layer)
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
QgsDataDefinedWidthDialog(const QList< QgsSymbolV2 * > &symbolList, QgsVectorLayer *layer)
double value(const QgsSymbolV2 *symbol) const override
Utility class for providing GUI for data-defined rendering.
Utility classes for "en masse" size definition.
QgsVectorLayer * mLayer
bool isEmpty() const
const QgsVectorLayer * vectorLayer() const
Returns the vector layer associated with the widget.
double value(const QgsSymbolV2 *symbol) const override
Encapsulate a field in an attribute table or data source.
Definition: qgsfield.h:44
double ANALYSIS_EXPORT angle(Point3D *p1, Point3D *p2, Point3D *p3, Point3D *p4)
Calculates the angle between two segments (in 2 dimension, z-values are ignored)
QList< QgsSymbolV2 * > mSymbolList
const QgsVectorLayer * vectorLayer() const
Returns the vector layer associated with the widget.
ScaleMethod
Scale method.
Definition: qgssymbolv2.h:90
Base class for renderer settings widgets.
virtual void refreshSymbolView()
Represents a vector layer which manages a vector based data sets.