QGIS API Documentation
2.0.1-Dufour
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::mInstance
= NULL;
25
26
QgsRendererV2Registry::QgsRendererV2Registry
()
27
{
28
// add default renderers
29
addRenderer
(
new
QgsRendererV2Metadata
(
"singleSymbol"
,
30
QObject::tr
(
"Single Symbol"
),
31
QgsSingleSymbolRendererV2::create
,
32
QgsSingleSymbolRendererV2::createFromSld
) );
33
34
addRenderer
(
new
QgsRendererV2Metadata
(
"categorizedSymbol"
,
35
QObject::tr
(
"Categorized"
),
36
QgsCategorizedSymbolRendererV2::create
) );
37
addRenderer
(
new
QgsRendererV2Metadata
(
"graduatedSymbol"
,
38
QObject::tr
(
"Graduated"
),
39
QgsGraduatedSymbolRendererV2::create
) );
40
41
addRenderer
(
new
QgsRendererV2Metadata
(
"RuleRenderer"
,
42
QObject::tr
(
"Rule-based"
),
43
QgsRuleBasedRendererV2::create
,
44
QgsRuleBasedRendererV2::createFromSld
) );
45
46
addRenderer
(
new
QgsRendererV2Metadata
(
"pointDisplacement"
,
47
QObject::tr
(
"Point displacement"
),
48
QgsPointDisplacementRenderer::create
) );
49
}
50
51
QgsRendererV2Registry::~QgsRendererV2Registry
()
52
{
53
foreach
( QString name,
mRenderers
.keys() )
54
{
55
delete
mRenderers
[name];
56
}
57
mRenderers
.clear();
58
}
59
60
QgsRendererV2Registry
*
QgsRendererV2Registry::instance
()
61
{
62
if
( !
mInstance
)
63
mInstance
=
new
QgsRendererV2Registry
();
64
65
return
mInstance
;
66
}
67
68
69
bool
QgsRendererV2Registry::addRenderer
(
QgsRendererV2AbstractMetadata
* metadata )
70
{
71
if
( metadata == NULL ||
mRenderers
.contains( metadata->
name
() ) )
72
return
false
;
73
74
mRenderers
[metadata->
name
()] = metadata;
75
mRenderersOrder
<< metadata->
name
();
76
return
true
;
77
}
78
79
bool
QgsRendererV2Registry::removeRenderer
( QString rendererName )
80
{
81
if
( !
mRenderers
.contains( rendererName ) )
82
return
false
;
83
84
delete
mRenderers
[rendererName];
85
mRenderers
.remove( rendererName );
86
mRenderersOrder
.removeAll( rendererName );
87
return
true
;
88
}
89
90
QgsRendererV2AbstractMetadata
*
QgsRendererV2Registry::rendererMetadata
( QString rendererName )
91
{
92
return
mRenderers
.value( rendererName );
93
}
94
95
QStringList
QgsRendererV2Registry::renderersList
()
96
{
97
return
mRenderersOrder
;
98
}
Generated on Tue Sep 24 2013 14:41:48 for QGIS API Documentation by
1.8.1.2