QGIS API Documentation
2.2.0-Valmiera
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
core
symbology-ng
qgsrendererv2registry.cpp
Go to the documentation of this file.
1
/***************************************************************************
2
qgsrendererv2registry.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 "
qgsrendererv2registry.h
"
16
17
// default renderers
18
#include "
qgssinglesymbolrendererv2.h
"
19
#include "
qgscategorizedsymbolrendererv2.h
"
20
#include "
qgsgraduatedsymbolrendererv2.h
"
21
#include "
qgsrulebasedrendererv2.h
"
22
#include "
qgspointdisplacementrenderer.h
"
23
24
QgsRendererV2Registry::QgsRendererV2Registry
()
25
{
26
// add default renderers
27
addRenderer
(
new
QgsRendererV2Metadata
(
"singleSymbol"
,
28
QObject::tr
(
"Single Symbol"
),
29
QgsSingleSymbolRendererV2::create
,
30
QgsSingleSymbolRendererV2::createFromSld
) );
31
32
addRenderer
(
new
QgsRendererV2Metadata
(
"categorizedSymbol"
,
33
QObject::tr
(
"Categorized"
),
34
QgsCategorizedSymbolRendererV2::create
) );
35
addRenderer
(
new
QgsRendererV2Metadata
(
"graduatedSymbol"
,
36
QObject::tr
(
"Graduated"
),
37
QgsGraduatedSymbolRendererV2::create
) );
38
39
addRenderer
(
new
QgsRendererV2Metadata
(
"RuleRenderer"
,
40
QObject::tr
(
"Rule-based"
),
41
QgsRuleBasedRendererV2::create
,
42
QgsRuleBasedRendererV2::createFromSld
) );
43
44
addRenderer
(
new
QgsRendererV2Metadata
(
"pointDisplacement"
,
45
QObject::tr
(
"Point displacement"
),
46
QgsPointDisplacementRenderer::create
) );
47
}
48
49
QgsRendererV2Registry::~QgsRendererV2Registry
()
50
{
51
foreach
( QString name,
mRenderers
.keys() )
52
{
53
delete
mRenderers
[name];
54
}
55
mRenderers
.clear();
56
}
57
58
QgsRendererV2Registry
*
QgsRendererV2Registry::instance
()
59
{
60
static
QgsRendererV2Registry
mInstance;
61
return
&mInstance;
62
}
63
64
65
bool
QgsRendererV2Registry::addRenderer
(
QgsRendererV2AbstractMetadata
* metadata )
66
{
67
if
( metadata == NULL ||
mRenderers
.contains( metadata->
name
() ) )
68
return
false
;
69
70
mRenderers
[metadata->
name
()] = metadata;
71
mRenderersOrder
<< metadata->
name
();
72
return
true
;
73
}
74
75
bool
QgsRendererV2Registry::removeRenderer
( QString rendererName )
76
{
77
if
( !
mRenderers
.contains( rendererName ) )
78
return
false
;
79
80
delete
mRenderers
[rendererName];
81
mRenderers
.remove( rendererName );
82
mRenderersOrder
.removeAll( rendererName );
83
return
true
;
84
}
85
86
QgsRendererV2AbstractMetadata
*
QgsRendererV2Registry::rendererMetadata
( QString rendererName )
87
{
88
return
mRenderers
.value( rendererName );
89
}
90
91
QgsRendererV2Metadata::~QgsRendererV2Metadata
() {}
92
93
QStringList
QgsRendererV2Registry::renderersList
()
94
{
95
return
mRenderersOrder
;
96
}
Generated on Sun Feb 23 2014 14:27:20 for QGIS API Documentation by
1.8.1.2