QGIS API Documentation  2.5.0-Master
 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 {
35  // try to recognize the previous renderer
36  // (null renderer means "no previous renderer")
37  if ( !renderer || renderer->type() != "singleSymbol" )
38  {
39  // we're not going to use it - so let's delete the renderer
40  delete renderer;
41 
42  // some default options
44 
45  mRenderer = new QgsSingleSymbolRendererV2( symbol );
46  }
47  else
48  {
49  mRenderer = static_cast<QgsSingleSymbolRendererV2*>( renderer );
50  }
51 
52  // load symbol from it
54 
55  // setup ui
57  connect( mSelector, SIGNAL( symbolModified() ), this, SLOT( changeSingleSymbol() ) );
58 
59  QVBoxLayout* layout = new QVBoxLayout;
60  layout->setContentsMargins( 0, 0, 0, 0 );
61  layout->addWidget( mSelector );
62  setLayout( layout );
63 
64  // advanced actions - data defined rendering
65  QMenu* advMenu = mSelector->advancedMenu();
66 
67  advMenu->addAction( tr( "Symbol levels..." ), this, SLOT( showSymbolLevels() ) );
68 
71  connect( mDataDefinedMenus, SIGNAL( rotationFieldChanged( QString ) ), this, SLOT( rotationFieldChanged( QString ) ) );
72  connect( mDataDefinedMenus, SIGNAL( sizeScaleFieldChanged( QString ) ), this, SLOT( sizeScaleFieldChanged( QString ) ) );
74 }
75 
77 {
78  delete mSingleSymbol;
79 
80  delete mRenderer;
81 
82  delete mSelector;
83 
84  delete mDataDefinedMenus;
85 }
86 
87 
89 {
90  return mRenderer;
91 }
92 
94 {
95  // update symbol from the GUI
97 }
98 
100 {
101  mRenderer->setRotationField( fldName );
102 }
103 
105 {
106  mRenderer->setSizeScaleField( fldName );
107 }
108 
110 {
111  mRenderer->setScaleMethod( scaleMethod );
112  // Set also on the symbol clone
113  QgsMarkerSymbolV2 *markerSymbol = dynamic_cast<QgsMarkerSymbolV2 *>( mSingleSymbol );
114  if ( markerSymbol )
115  {
116  markerSymbol->setScaleMethod( scaleMethod );
117  }
118 }
119 
121 {
123 }