QGIS API Documentation  2.7.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
qgssinglesymbolrendererv2widget.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgssinglesymbolrendererv2widget.cpp
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  ***************************************************************************/
16 
18 #include "qgssymbolv2.h"
19 
20 #include "qgslogger.h"
21 #include "qgsvectorlayer.h"
22 
24 
25 #include <QMenu>
26 
28 {
29  return new QgsSingleSymbolRendererV2Widget( layer, style, renderer );
30 }
31 
33  : QgsRendererV2Widget( layer, style )
34 {
35  // try to recognize the previous renderer
36  // (null renderer means "no previous renderer")
37 
38  if ( renderer )
39  {
41  }
42  if ( !mRenderer )
43  {
45 
46  mRenderer = new QgsSingleSymbolRendererV2( symbol );
47  }
48 
49  // load symbol from it
51 
52  // setup ui
54  connect( mSelector, SIGNAL( symbolModified() ), this, SLOT( changeSingleSymbol() ) );
55 
56  QVBoxLayout* layout = new QVBoxLayout;
57  layout->setContentsMargins( 0, 0, 0, 0 );
58  layout->addWidget( mSelector );
59  setLayout( layout );
60 
61  // advanced actions - data defined rendering
62  QMenu* advMenu = mSelector->advancedMenu();
63 
64  advMenu->addAction( tr( "Symbol levels..." ), this, SLOT( showSymbolLevels() ) );
65 
68  connect( mDataDefinedMenus, SIGNAL( rotationFieldChanged( QString ) ), this, SLOT( rotationFieldChanged( QString ) ) );
69  connect( mDataDefinedMenus, SIGNAL( sizeScaleFieldChanged( QString ) ), this, SLOT( sizeScaleFieldChanged( QString ) ) );
71 }
72 
74 {
75  delete mSingleSymbol;
76 
77  delete mRenderer;
78 
79  delete mSelector;
80 
81  delete mDataDefinedMenus;
82 }
83 
84 
86 {
87  return mRenderer;
88 }
89 
91 {
92  // update symbol from the GUI
94 }
95 
97 {
98  mRenderer->setRotationField( fldName );
99 }
100 
102 {
103  mRenderer->setSizeScaleField( fldName );
104 }
105 
107 {
108  mRenderer->setScaleMethod( scaleMethod );
109  // Set also on the symbol clone
110  QgsMarkerSymbolV2 *markerSymbol = dynamic_cast<QgsMarkerSymbolV2 *>( mSingleSymbol );
111  if ( markerSymbol )
112  {
113  markerSymbol->setScaleMethod( scaleMethod );
114  }
115 }
116 
118 {
120 }
void showSymbolLevelsDialog(QgsFeatureRendererV2 *r)
show a dialog with renderer's symbol level settings
void scaleMethodChanged(QgsSymbolV2::ScaleMethod scaleMethod)
virtual QgsFeatureRendererV2 * renderer()
return pointer to the renderer (no transfer of ownership)
virtual QgsSymbolV2 * clone() const =0
void setSizeScaleField(QString fieldOrExpression)
QString rotationField() const
return rotation field name (or empty string if not set or not supported by renderer) ...
QgsSymbolV2::ScaleMethod scaleMethod() const
static QgsSingleSymbolRendererV2 * convertFromRenderer(const QgsFeatureRendererV2 *renderer)
creates a QgsSingleSymbolRendererV2 from an existing renderer.
Utility class for providing GUI for data-defined rendering.
QgsVectorLayer * mLayer
QMenu * advancedMenu()
return menu for "advanced" button - create it if doesn't exist and show the advanced button ...
QgsSingleSymbolRendererV2Widget(QgsVectorLayer *layer, QgsStyleV2 *style, QgsFeatureRendererV2 *renderer)
static QgsRendererV2Widget * create(QgsVectorLayer *layer, QgsStyleV2 *style, QgsFeatureRendererV2 *renderer)
void setRotationField(QString fieldOrExpression)
sets rotation field of renderer (if supported by the renderer)
QGis::GeometryType geometryType() const
Returns point, line or polygon.
void setScaleMethod(QgsSymbolV2::ScaleMethod scaleMethod)
static QgsSymbolV2 * defaultSymbol(QGis::GeometryType geomType)
return new default symbol for specified geometry type
QgsRendererV2DataDefinedMenus * mDataDefinedMenus
Base class for renderer settings widgets.
Represents a vector layer which manages a vector based data sets.
void setScaleMethod(QgsSymbolV2::ScaleMethod scaleMethod)
#define tr(sourceText)