QGIS API Documentation
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 "qgssymbolv2.h"
21 #include "qgsdatadefined.h"
22 
23 class QgsVectorLayer;
24 class QgsStyleV2;
27 class QgsMapCanvas;
28 
39 class GUI_EXPORT QgsRendererV2Widget : public QWidget
40 {
41  Q_OBJECT
42  public:
44 
45  virtual ~QgsRendererV2Widget() {}
46 
48  virtual QgsFeatureRendererV2* renderer() = 0;
49 
51  void showSymbolLevelsDialog( QgsFeatureRendererV2* r );
52 
59  virtual void setMapCanvas( QgsMapCanvas* canvas );
60 
65  const QgsMapCanvas* mapCanvas() const;
66 
70  const QgsVectorLayer* vectorLayer() const { return mLayer; }
71 
75  void applyChanges();
76 
77  signals:
83  void layerVariablesChanged();
84 
85  protected:
92 
96  virtual void refreshSymbolView() {}
97 
98  protected slots:
99  void contextMenuViewCategories( QPoint p );
101  void changeSymbolColor();
103  void changeSymbolTransparency();
105  void changeSymbolUnit();
107  void changeSymbolWidth();
109  void changeSymbolSize();
111  void changeSymbolAngle();
112 
113  virtual void copy() {}
114  virtual void paste() {}
115 
116  private:
121  virtual void apply();
122 
123 };
124 
125 
127 
128 #include <QObject>
129 
130 class QMenu;
131 class QgsField;
132 class QgsFields;
133 
134 
141 {
142  Q_OBJECT
143 
144  public:
145 
147  Q_DECL_DEPRECATED QgsRendererV2DataDefinedMenus( QMenu* menu, QgsVectorLayer* layer, const QString& rotationField, const QString& sizeScaleField, QgsSymbolV2::ScaleMethod scaleMethod );
148  ~QgsRendererV2DataDefinedMenus();
149 
150  void populateMenu( QMenu* menu, const QString& fieldName, QActionGroup *actionGroup );
151 #if 0
152  void updateMenu( QActionGroup* actionGroup, QString fieldName );
153 #endif
154  public slots:
155 
156  void rotationFieldSelected( QAction *a );
157  void sizeScaleFieldSelected( QAction *a );
158  void scaleMethodSelected( QAction *a );
159 
160  signals:
161 
162  void rotationFieldChanged( const QString& fldName );
163  void sizeScaleFieldChanged( const QString& fldName );
164  void scaleMethodChanged( QgsSymbolV2::ScaleMethod scaleMethod );
165 
166  protected:
173 };
174 
176 
177 #include "ui_widget_set_dd_value.h"
178 #include "qgssizescalewidget.h"
179 
183 class GUI_EXPORT QgsDataDefinedValueDialog : public QDialog, public Ui::QgsDataDefinedValueDialog
184 {
185  Q_OBJECT
186 
187  public:
193  QgsDataDefinedValueDialog( const QList<QgsSymbolV2*>& symbolList, QgsVectorLayer * layer, const QString & label );
195 
202  virtual void setMapCanvas( QgsMapCanvas* canvas );
203 
208  const QgsMapCanvas* mapCanvas() const;
209 
213  const QgsVectorLayer* vectorLayer() const { return mLayer; }
214 
215  public slots:
216  void dataDefinedChanged();
217 
218  protected:
219  QgsDataDefined symbolDataDefined() const;
220  void init( const QString & description ); // needed in children ctor to call virtual
221 
222  virtual QgsDataDefined symbolDataDefined( const QgsSymbolV2 * ) const = 0;
223  virtual double value( const QgsSymbolV2 * ) const = 0;
224  virtual void setDataDefined( QgsSymbolV2* symbol, const QgsDataDefined& dd ) = 0;
225 
229 };
230 
232 {
233  Q_OBJECT
234  public:
236  : QgsDataDefinedValueDialog( symbolList, layer, tr( "Size" ) )
237  {
238  init( tr( "Symbol size" ) );
239  if ( !symbolList.isEmpty() && symbolList.at( 0 ) && mLayer )
240  mDDBtn->setAssistant( tr( "Size Assistant..." ), new QgsSizeScaleWidget( mLayer, static_cast<const QgsMarkerSymbolV2*>( symbolList.at( 0 ) ) ) );
241  }
242 
243  protected:
244  QgsDataDefined symbolDataDefined( const QgsSymbolV2 * symbol ) const override;
245 
246  double value( const QgsSymbolV2 * symbol ) const override { return static_cast<const QgsMarkerSymbolV2*>( symbol )->size(); }
247 
248  void setDataDefined( QgsSymbolV2* symbol, const QgsDataDefined& dd ) override;
249 };
250 
252 {
253  Q_OBJECT
254  public:
256  : QgsDataDefinedValueDialog( symbolList, layer, tr( "Rotation" ) )
257  {
258  init( tr( "Symbol rotation" ) );
259  }
260 
261  protected:
262  QgsDataDefined symbolDataDefined( const QgsSymbolV2 * symbol ) const override;
263 
264  double value( const QgsSymbolV2 * symbol ) const override { return static_cast<const QgsMarkerSymbolV2*>( symbol )->angle(); }
265 
266  void setDataDefined( QgsSymbolV2* symbol, const QgsDataDefined& dd ) override;
267 };
268 
269 
271 {
272  Q_OBJECT
273  public:
275  : QgsDataDefinedValueDialog( symbolList, layer, tr( "Width" ) )
276  {
277  init( tr( "Symbol width" ) );
278  }
279 
280  protected:
281  QgsDataDefined symbolDataDefined( const QgsSymbolV2 * symbol ) const override;
282 
283  double value( const QgsSymbolV2 * symbol ) const override { return static_cast<const QgsLineSymbolV2*>( symbol )->width(); }
284 
285  void setDataDefined( QgsSymbolV2* symbol, const QgsDataDefined& dd ) override;
286 };
287 
288 
289 
290 #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:187
QgsDataDefinedSizeDialog(const QList< QgsSymbolV2 * > &symbolList, QgsVectorLayer *layer)
Map canvas is a class for displaying all GIS data types on a canvas.
Definition: qgsmapcanvas.h:105
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.
#define tr(sourceText)