QGIS API Documentation  2.15.0-Master (13f053b)
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 
89  void widgetChanged();
90 
91  protected:
98 
102  virtual void refreshSymbolView() {}
103 
104  protected slots:
105  void contextMenuViewCategories( QPoint p );
107  void changeSymbolColor();
109  void changeSymbolTransparency();
111  void changeSymbolUnit();
113  void changeSymbolWidth();
115  void changeSymbolSize();
117  void changeSymbolAngle();
118 
119  virtual void copy() {}
120  virtual void paste() {}
121 
122  private:
127  virtual void apply();
128 
129 };
130 
131 
133 
134 #include <QObject>
135 
136 class QMenu;
137 class QgsField;
138 class QgsFields;
139 
140 
147 {
148  Q_OBJECT
149 
150  public:
151 
153  Q_DECL_DEPRECATED QgsRendererV2DataDefinedMenus( QMenu* menu, QgsVectorLayer* layer, const QString& rotationField, const QString& sizeScaleField, QgsSymbolV2::ScaleMethod scaleMethod );
154  ~QgsRendererV2DataDefinedMenus();
155 
156  void populateMenu( QMenu* menu, const QString& fieldName, QActionGroup *actionGroup );
157 #if 0
158  void updateMenu( QActionGroup* actionGroup, QString fieldName );
159 #endif
160  public slots:
161 
162  void rotationFieldSelected( QAction *a );
163  void sizeScaleFieldSelected( QAction *a );
164  void scaleMethodSelected( QAction *a );
165 
166  signals:
167 
168  void rotationFieldChanged( const QString& fldName );
169  void sizeScaleFieldChanged( const QString& fldName );
170  void scaleMethodChanged( QgsSymbolV2::ScaleMethod scaleMethod );
171 
172  protected:
179 };
180 
182 
183 #include "ui_widget_set_dd_value.h"
184 #include "qgssizescalewidget.h"
185 
189 class GUI_EXPORT QgsDataDefinedValueDialog : public QDialog, public Ui::QgsDataDefinedValueDialog
190 {
191  Q_OBJECT
192 
193  public:
199  QgsDataDefinedValueDialog( const QList<QgsSymbolV2*>& symbolList, QgsVectorLayer * layer, const QString & label );
201 
208  virtual void setMapCanvas( QgsMapCanvas* canvas );
209 
214  const QgsMapCanvas* mapCanvas() const;
215 
219  const QgsVectorLayer* vectorLayer() const { return mLayer; }
220 
221  public slots:
222  void dataDefinedChanged();
223 
224  protected:
225  QgsDataDefined symbolDataDefined() const;
226  void init( const QString & description ); // needed in children ctor to call virtual
227 
228  virtual QgsDataDefined symbolDataDefined( const QgsSymbolV2 * ) const = 0;
229  virtual double value( const QgsSymbolV2 * ) const = 0;
230  virtual void setDataDefined( QgsSymbolV2* symbol, const QgsDataDefined& dd ) = 0;
231 
235 };
236 
238 {
239  Q_OBJECT
240  public:
242  : QgsDataDefinedValueDialog( symbolList, layer, tr( "Size" ) )
243  {
244  init( tr( "Symbol size" ) );
245  if ( !symbolList.isEmpty() && symbolList.at( 0 ) && mLayer )
246  mDDBtn->setAssistant( tr( "Size Assistant..." ), new QgsSizeScaleWidget( mLayer, static_cast<const QgsMarkerSymbolV2*>( symbolList.at( 0 ) ) ) );
247  }
248 
249  protected:
250  QgsDataDefined symbolDataDefined( const QgsSymbolV2 * symbol ) const override;
251 
252  double value( const QgsSymbolV2 * symbol ) const override { return static_cast<const QgsMarkerSymbolV2*>( symbol )->size(); }
253 
254  void setDataDefined( QgsSymbolV2* symbol, const QgsDataDefined& dd ) override;
255 };
256 
258 {
259  Q_OBJECT
260  public:
262  : QgsDataDefinedValueDialog( symbolList, layer, tr( "Rotation" ) )
263  {
264  init( tr( "Symbol rotation" ) );
265  }
266 
267  protected:
268  QgsDataDefined symbolDataDefined( const QgsSymbolV2 * symbol ) const override;
269 
270  double value( const QgsSymbolV2 * symbol ) const override { return static_cast<const QgsMarkerSymbolV2*>( symbol )->angle(); }
271 
272  void setDataDefined( QgsSymbolV2* symbol, const QgsDataDefined& dd ) override;
273 };
274 
275 
277 {
278  Q_OBJECT
279  public:
281  : QgsDataDefinedValueDialog( symbolList, layer, tr( "Width" ) )
282  {
283  init( tr( "Symbol width" ) );
284  }
285 
286  protected:
287  QgsDataDefined symbolDataDefined( const QgsSymbolV2 * symbol ) const override;
288 
289  double value( const QgsSymbolV2 * symbol ) const override { return static_cast<const QgsLineSymbolV2*>( symbol )->width(); }
290 
291  void setDataDefined( QgsSymbolV2* symbol, const QgsDataDefined& dd ) override;
292 };
293 
294 
295 
296 #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)
Map canvas is a class for displaying all GIS data types on a canvas.
Definition: qgsmapcanvas.h:108
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)