QGIS API Documentation  2.8.2-Wien
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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  , mRenderer( NULL )
35 {
36  // try to recognize the previous renderer
37  // (null renderer means "no previous renderer")
38 
39  if ( renderer )
40  {
42  }
43  if ( !mRenderer )
44  {
46 
47  mRenderer = new QgsSingleSymbolRendererV2( symbol );
48  }
49 
50  // load symbol from it
52 
53  // setup ui
55  connect( mSelector, SIGNAL( symbolModified() ), this, SLOT( changeSingleSymbol() ) );
56 
57  QVBoxLayout* layout = new QVBoxLayout;
58  layout->setContentsMargins( 0, 0, 0, 0 );
59  layout->addWidget( mSelector );
60  setLayout( layout );
61 
62  // advanced actions - data defined rendering
63  QMenu* advMenu = mSelector->advancedMenu();
64 
65  advMenu->addAction( tr( "Symbol levels..." ), this, SLOT( showSymbolLevels() ) );
66 
69  connect( mDataDefinedMenus, SIGNAL( rotationFieldChanged( QString ) ), this, SLOT( rotationFieldChanged( QString ) ) );
70  connect( mDataDefinedMenus, SIGNAL( sizeScaleFieldChanged( QString ) ), this, SLOT( sizeScaleFieldChanged( QString ) ) );
72 }
73 
75 {
76  delete mSingleSymbol;
77 
78  delete mRenderer;
79 
80  delete mSelector;
81 
82  delete mDataDefinedMenus;
83 }
84 
85 
87 {
88  return mRenderer;
89 }
90 
92 {
93  // update symbol from the GUI
95 }
96 
98 {
99  mRenderer->setRotationField( fldName );
100 }
101 
103 {
104  mRenderer->setSizeScaleField( fldName );
105 }
106 
108 {
109  mRenderer->setScaleMethod( scaleMethod );
110  // Set also on the symbol clone
111  QgsMarkerSymbolV2 *markerSymbol = dynamic_cast<QgsMarkerSymbolV2 *>( mSingleSymbol );
112  if ( markerSymbol )
113  {
114  markerSymbol->setScaleMethod( scaleMethod );
115  }
116 }
117 
119 {
121 }