QGIS API Documentation  2.11.0-Master
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 
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 
53  protected:
59 
63  virtual void refreshSymbolView() {}
64 
65  protected slots:
66  void contextMenuViewCategories( const QPoint& p );
68  void changeSymbolColor();
70  void changeSymbolTransparency();
72  void changeSymbolUnit();
74  void changeSymbolWidth();
76  void changeSymbolSize();
78  void changeSymbolAngle();
79 
80  virtual void copy() {}
81  virtual void paste() {}
82 
83 };
84 
85 
87 
88 #include <QObject>
89 
90 class QMenu;
91 class QgsField;
92 class QgsFields;
93 
94 
99 {
100  Q_OBJECT
101 
102  public:
103 
104  QgsRendererV2DataDefinedMenus( QMenu* menu, QgsVectorLayer* layer, QString rotationField, QString sizeScaleField, QgsSymbolV2::ScaleMethod scaleMethod );
106 
107  void populateMenu( QMenu* menu, QString fieldName, QActionGroup *actionGroup );
108 #if 0
109  void updateMenu( QActionGroup* actionGroup, QString fieldName );
110 #endif
111  public slots:
112 
113  void rotationFieldSelected( QAction *a );
114  void sizeScaleFieldSelected( QAction *a );
115  void scaleMethodSelected( QAction *a );
116 
117  signals:
118 
119  void rotationFieldChanged( QString fldName );
120  void sizeScaleFieldChanged( QString fldName );
121  void scaleMethodChanged( QgsSymbolV2::ScaleMethod scaleMethod );
122 
123  protected:
130 };
131 
133 
134 #include "ui_widget_set_dd_value.h"
135 #include "qgssizescalewidget.h"
136 
140 class GUI_EXPORT QgsDataDefinedValueDialog : public QDialog, public Ui::QgsDataDefinedValueDialog
141 {
142  Q_OBJECT
143 
144  public:
150  QgsDataDefinedValueDialog( const QList<QgsSymbolV2*>& symbolList, QgsVectorLayer * layer, const QString & label );
152 
153  public slots:
154  void dataDefinedChanged();
155 
156  protected:
157  QgsDataDefined symbolDataDefined() const;
158  void init( const QString & description ); // needed in children ctor to call virtual
159 
160  virtual QgsDataDefined symbolDataDefined( const QgsSymbolV2 * ) const = 0;
161  virtual double value( const QgsSymbolV2 * ) const = 0;
162  virtual void setDataDefined( QgsSymbolV2* symbol, const QgsDataDefined& dd ) = 0;
163 
166 };
167 
169 {
170  Q_OBJECT
171  public:
173  : QgsDataDefinedValueDialog( symbolList, layer, tr( "Size" ) )
174  {
175  init( tr( "Symbol size" ) );
176  if ( symbolList.length() )
177  mDDBtn->setAssistant( tr( "Size Assistant..." ), new QgsSizeScaleWidget( mLayer, static_cast<const QgsMarkerSymbolV2*>( symbolList[0] ) ) );
178  }
179 
180  protected:
181  QgsDataDefined symbolDataDefined( const QgsSymbolV2 * symbol ) const override;
182 
183  double value( const QgsSymbolV2 * symbol ) const override { return static_cast<const QgsMarkerSymbolV2*>( symbol )->size(); }
184 
185  void setDataDefined( QgsSymbolV2* symbol, const QgsDataDefined& dd ) override;
186 };
187 
189 {
190  Q_OBJECT
191  public:
193  : QgsDataDefinedValueDialog( symbolList, layer, tr( "Rotation" ) )
194  {
195  init( tr( "Symbol rotation" ) );
196  }
197 
198  protected:
199  QgsDataDefined symbolDataDefined( const QgsSymbolV2 * symbol ) const override;
200 
201  double value( const QgsSymbolV2 * symbol ) const override { return static_cast<const QgsMarkerSymbolV2*>( symbol )->angle(); }
202 
203  void setDataDefined( QgsSymbolV2* symbol, const QgsDataDefined& dd ) override;
204 };
205 
206 
208 {
209  Q_OBJECT
210  public:
212  : QgsDataDefinedValueDialog( symbolList, layer, tr( "Width" ) )
213  {
214  init( tr( "Symbol width" ) );
215  }
216 
217  protected:
218  QgsDataDefined symbolDataDefined( const QgsSymbolV2 * symbol ) const override;
219 
220  double value( const QgsSymbolV2 * symbol ) const override { return static_cast<const QgsLineSymbolV2*>( symbol )->width(); }
221 
222  void setDataDefined( QgsSymbolV2* symbol, const QgsDataDefined& dd ) override;
223 };
224 
225 
226 
227 #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.
void init(const QString &description)
int length() const
Container of fields for a vector layer.
Definition: qgsfield.h:173
void populateMenu(QMenu *menu, QString fieldName, QActionGroup *actionGroup)
QgsDataDefinedSizeDialog(const QList< QgsSymbolV2 * > &symbolList, QgsVectorLayer *layer)
QString tr(const char *sourceText, const char *disambiguation, int n)
QgsDataDefinedWidthDialog(const QList< QgsSymbolV2 * > &symbolList, QgsVectorLayer *layer)
double value(const QgsSymbolV2 *symbol) const override
QgsDataDefined symbolDataDefined() const
int width() const
QSize size() const
Utility class for providing GUI for data-defined rendering.
Utility classes for "en masse" size definition.
QgsVectorLayer * mLayer
void rotationFieldChanged(QString fldName)
double value(const QgsSymbolV2 *symbol) const override
Encapsulate a field in an attribute table or data source.
Definition: qgsfield.h:38
void scaleMethodChanged(QgsSymbolV2::ScaleMethod scaleMethod)
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
virtual void setDataDefined(QgsSymbolV2 *symbol, const QgsDataDefined &dd)=0
void sizeScaleFieldChanged(QString fldName)
Base class for renderer settings widgets.
virtual void refreshSymbolView()
QgsRendererV2DataDefinedMenus(QMenu *menu, QgsVectorLayer *layer, QString rotationField, QString sizeScaleField, QgsSymbolV2::ScaleMethod scaleMethod)
Represents a vector layer which manages a vector based data sets.
#define tr(sourceText)