QGIS API Documentation
2.8.2-Wien
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
src
gui
symbology-ng
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
***************************************************************************/
15
#include "
qgssinglesymbolrendererv2widget.h
"
16
17
#include "
qgssinglesymbolrendererv2.h
"
18
#include "
qgssymbolv2.h
"
19
20
#include "
qgslogger.h
"
21
#include "
qgsvectorlayer.h
"
22
23
#include "
qgssymbolv2selectordialog.h
"
24
25
#include <QMenu>
26
27
QgsRendererV2Widget
*
QgsSingleSymbolRendererV2Widget::create
(
QgsVectorLayer
* layer,
QgsStyleV2
* style,
QgsFeatureRendererV2
* renderer )
28
{
29
return
new
QgsSingleSymbolRendererV2Widget
( layer, style, renderer );
30
}
31
32
QgsSingleSymbolRendererV2Widget::QgsSingleSymbolRendererV2Widget
(
QgsVectorLayer
* layer,
QgsStyleV2
* style,
QgsFeatureRendererV2
* renderer )
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
{
41
mRenderer
=
QgsSingleSymbolRendererV2::convertFromRenderer
( renderer );
42
}
43
if
( !
mRenderer
)
44
{
45
QgsSymbolV2
* symbol =
QgsSymbolV2::defaultSymbol
(
mLayer
->
geometryType
() );
46
47
mRenderer
=
new
QgsSingleSymbolRendererV2
( symbol );
48
}
49
50
// load symbol from it
51
mSingleSymbol
=
mRenderer
->
symbol
()->
clone
();
52
53
// setup ui
54
mSelector
=
new
QgsSymbolV2SelectorDialog
(
mSingleSymbol
,
mStyle
,
mLayer
, NULL,
true
);
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
67
mDataDefinedMenus
=
new
QgsRendererV2DataDefinedMenus
( advMenu,
mLayer
,
68
mRenderer
->
rotationField
(),
mRenderer
->
sizeScaleField
(),
mRenderer
->
scaleMethod
() );
69
connect(
mDataDefinedMenus
, SIGNAL(
rotationFieldChanged
( QString ) ),
this
, SLOT(
rotationFieldChanged
( QString ) ) );
70
connect(
mDataDefinedMenus
, SIGNAL(
sizeScaleFieldChanged
( QString ) ),
this
, SLOT(
sizeScaleFieldChanged
( QString ) ) );
71
connect(
mDataDefinedMenus
, SIGNAL(
scaleMethodChanged
(
QgsSymbolV2::ScaleMethod
) ),
this
, SLOT(
scaleMethodChanged
(
QgsSymbolV2::ScaleMethod
) ) );
72
}
73
74
QgsSingleSymbolRendererV2Widget::~QgsSingleSymbolRendererV2Widget
()
75
{
76
delete
mSingleSymbol
;
77
78
delete
mRenderer
;
79
80
delete
mSelector
;
81
82
delete
mDataDefinedMenus
;
83
}
84
85
86
QgsFeatureRendererV2
*
QgsSingleSymbolRendererV2Widget::renderer
()
87
{
88
return
mRenderer
;
89
}
90
91
void
QgsSingleSymbolRendererV2Widget::changeSingleSymbol
()
92
{
93
// update symbol from the GUI
94
mRenderer
->
setSymbol
(
mSingleSymbol
->
clone
() );
95
}
96
97
void
QgsSingleSymbolRendererV2Widget::rotationFieldChanged
( QString fldName )
98
{
99
mRenderer
->
setRotationField
( fldName );
100
}
101
102
void
QgsSingleSymbolRendererV2Widget::sizeScaleFieldChanged
( QString fldName )
103
{
104
mRenderer
->
setSizeScaleField
( fldName );
105
}
106
107
void
QgsSingleSymbolRendererV2Widget::scaleMethodChanged
(
QgsSymbolV2::ScaleMethod
scaleMethod )
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
118
void
QgsSingleSymbolRendererV2Widget::showSymbolLevels
()
119
{
120
showSymbolLevelsDialog
(
mRenderer
);
121
}
Generated on Sun May 10 2015 16:33:26 for QGIS API Documentation by
1.8.1.2