QGIS API Documentation  2.11.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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 
100 {
101  Q_OBJECT
102 
103  public:
104 
105  Q_DECL_DEPRECATED QgsRendererV2DataDefinedMenus( QMenu* menu, QgsVectorLayer* layer, QString rotationField, QString sizeScaleField, QgsSymbolV2::ScaleMethod scaleMethod );
107 
108  void populateMenu( QMenu* menu, QString fieldName, QActionGroup *actionGroup );
109 #if 0
110  void updateMenu( QActionGroup* actionGroup, QString fieldName );
111 #endif
112  public slots:
113 
114  void rotationFieldSelected( QAction *a );
115  void sizeScaleFieldSelected( QAction *a );
116  void scaleMethodSelected( QAction *a );
117 
118  signals:
119 
120  void rotationFieldChanged( QString fldName );
121  void sizeScaleFieldChanged( QString fldName );
122  void scaleMethodChanged( QgsSymbolV2::ScaleMethod scaleMethod );
123 
124  protected:
131 };
132 
134 
135 #include "ui_widget_set_dd_value.h"
136 #include "qgssizescalewidget.h"
137 
141 class GUI_EXPORT QgsDataDefinedValueDialog : public QDialog, public Ui::QgsDataDefinedValueDialog
142 {
143  Q_OBJECT
144 
145  public:
151  QgsDataDefinedValueDialog( const QList<QgsSymbolV2*>& symbolList, QgsVectorLayer * layer, const QString & label );
153 
154  public slots:
155  void dataDefinedChanged();
156 
157  protected:
158  QgsDataDefined symbolDataDefined() const;
159  void init( const QString & description ); // needed in children ctor to call virtual
160 
161  virtual QgsDataDefined symbolDataDefined( const QgsSymbolV2 * ) const = 0;
162  virtual double value( const QgsSymbolV2 * ) const = 0;
163  virtual void setDataDefined( QgsSymbolV2* symbol, const QgsDataDefined& dd ) = 0;
164 
167 };
168 
170 {
171  Q_OBJECT
172  public:
174  : QgsDataDefinedValueDialog( symbolList, layer, tr( "Size" ) )
175  {
176  init( tr( "Symbol size" ) );
177  if ( symbolList.length() && mLayer )
178  mDDBtn->setAssistant( tr( "Size Assistant..." ), new QgsSizeScaleWidget( mLayer, static_cast<const QgsMarkerSymbolV2*>( symbolList[0] ) ) );
179  }
180 
181  protected:
182  QgsDataDefined symbolDataDefined( const QgsSymbolV2 * symbol ) const override;
183 
184  double value( const QgsSymbolV2 * symbol ) const override { return static_cast<const QgsMarkerSymbolV2*>( symbol )->size(); }
185 
186  void setDataDefined( QgsSymbolV2* symbol, const QgsDataDefined& dd ) override;
187 };
188 
190 {
191  Q_OBJECT
192  public:
194  : QgsDataDefinedValueDialog( symbolList, layer, tr( "Rotation" ) )
195  {
196  init( tr( "Symbol rotation" ) );
197  }
198 
199  protected:
200  QgsDataDefined symbolDataDefined( const QgsSymbolV2 * symbol ) const override;
201 
202  double value( const QgsSymbolV2 * symbol ) const override { return static_cast<const QgsMarkerSymbolV2*>( symbol )->angle(); }
203 
204  void setDataDefined( QgsSymbolV2* symbol, const QgsDataDefined& dd ) override;
205 };
206 
207 
209 {
210  Q_OBJECT
211  public:
213  : QgsDataDefinedValueDialog( symbolList, layer, tr( "Width" ) )
214  {
215  init( tr( "Symbol width" ) );
216  }
217 
218  protected:
219  QgsDataDefined symbolDataDefined( const QgsSymbolV2 * symbol ) const override;
220 
221  double value( const QgsSymbolV2 * symbol ) const override { return static_cast<const QgsLineSymbolV2*>( symbol )->width(); }
222 
223  void setDataDefined( QgsSymbolV2* symbol, const QgsDataDefined& dd ) override;
224 };
225 
226 
227 
228 #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:177
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:40
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()
Q_DECL_DEPRECATED 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)