QGIS API Documentation  2.15.0-Master (1f0fce7)
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 
234 {
235  Q_OBJECT
236  public:
238  : QgsDataDefinedValueDialog( symbolList, layer, tr( "Size" ) )
239  {
240  init( tr( "Symbol size" ) );
241  if ( !symbolList.isEmpty() && symbolList.at( 0 ) && mLayer )
242  mDDBtn->setAssistant( tr( "Size Assistant..." ), new QgsSizeScaleWidget( mLayer, static_cast<const QgsMarkerSymbolV2*>( symbolList.at( 0 ) ) ) );
243  }
244 
245  protected:
246  QgsDataDefined symbolDataDefined( const QgsSymbolV2 * symbol ) const override;
247 
248  double value( const QgsSymbolV2 * symbol ) const override { return static_cast<const QgsMarkerSymbolV2*>( symbol )->size(); }
249 
250  void setDataDefined( QgsSymbolV2* symbol, const QgsDataDefined& dd ) override;
251 };
252 
254 {
255  Q_OBJECT
256  public:
258  : QgsDataDefinedValueDialog( symbolList, layer, tr( "Rotation" ) )
259  {
260  init( tr( "Symbol rotation" ) );
261  }
262 
263  protected:
264  QgsDataDefined symbolDataDefined( const QgsSymbolV2 * symbol ) const override;
265 
266  double value( const QgsSymbolV2 * symbol ) const override { return static_cast<const QgsMarkerSymbolV2*>( symbol )->angle(); }
267 
268  void setDataDefined( QgsSymbolV2* symbol, const QgsDataDefined& dd ) override;
269 };
270 
271 
273 {
274  Q_OBJECT
275  public:
277  : QgsDataDefinedValueDialog( symbolList, layer, tr( "Width" ) )
278  {
279  init( tr( "Symbol width" ) );
280  }
281 
282  protected:
283  QgsDataDefined symbolDataDefined( const QgsSymbolV2 * symbol ) const override;
284 
285  double value( const QgsSymbolV2 * symbol ) const override { return static_cast<const QgsLineSymbolV2*>( symbol )->width(); }
286 
287  void setDataDefined( QgsSymbolV2* symbol, const QgsDataDefined& dd ) override;
288 };
289 
290 
291 
292 #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:87
Base class for renderer settings widgets.
virtual void refreshSymbolView()
Represents a vector layer which manages a vector based data sets.