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
core
symbology-ng
qgssymbollayerv2registry.cpp
Go to the documentation of this file.
1
/***************************************************************************
2
qgssymbollayerv2registry.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
16
#include "
qgssymbollayerv2registry.h
"
17
18
#include "
qgsellipsesymbollayerv2.h
"
19
#include "
qgsmarkersymbollayerv2.h
"
20
#include "
qgslinesymbollayerv2.h
"
21
#include "
qgsfillsymbollayerv2.h
"
22
#include "
qgsvectorfieldsymbollayer.h
"
23
24
QgsSymbolLayerV2Registry::QgsSymbolLayerV2Registry
()
25
{
26
// init registry with known symbol layers
27
addSymbolLayerType
(
new
QgsSymbolLayerV2Metadata
(
"SimpleLine"
,
QObject::tr
(
"Simple line"
),
QgsSymbolV2::Line
,
28
QgsSimpleLineSymbolLayerV2::create
,
QgsSimpleLineSymbolLayerV2::createFromSld
) );
29
addSymbolLayerType
(
new
QgsSymbolLayerV2Metadata
(
"MarkerLine"
,
QObject::tr
(
"Marker line"
),
QgsSymbolV2::Line
,
30
QgsMarkerLineSymbolLayerV2::create
,
QgsMarkerLineSymbolLayerV2::createFromSld
) );
31
32
addSymbolLayerType
(
new
QgsSymbolLayerV2Metadata
(
"SimpleMarker"
,
QObject::tr
(
"Simple marker"
),
QgsSymbolV2::Marker
,
33
QgsSimpleMarkerSymbolLayerV2::create
,
QgsSimpleMarkerSymbolLayerV2::createFromSld
) );
34
addSymbolLayerType
(
new
QgsSymbolLayerV2Metadata
(
"SvgMarker"
,
QObject::tr
(
"SVG marker"
),
QgsSymbolV2::Marker
,
35
QgsSvgMarkerSymbolLayerV2::create
,
QgsSvgMarkerSymbolLayerV2::createFromSld
) );
36
addSymbolLayerType
(
new
QgsSymbolLayerV2Metadata
(
"FontMarker"
,
QObject::tr
(
"Font marker"
),
QgsSymbolV2::Marker
,
37
QgsFontMarkerSymbolLayerV2::create
,
QgsFontMarkerSymbolLayerV2::createFromSld
) );
38
addSymbolLayerType
(
new
QgsSymbolLayerV2Metadata
(
"EllipseMarker"
,
QObject::tr
(
"Ellipse marker"
),
QgsSymbolV2::Marker
,
39
QgsEllipseSymbolLayerV2::create
,
QgsEllipseSymbolLayerV2::createFromSld
) );
40
addSymbolLayerType
(
new
QgsSymbolLayerV2Metadata
(
"VectorField"
,
QObject::tr
(
"Vector Field marker"
),
QgsSymbolV2::Marker
,
41
QgsVectorFieldSymbolLayer::create
) );
42
43
addSymbolLayerType
(
new
QgsSymbolLayerV2Metadata
(
"SimpleFill"
,
QObject::tr
(
"Simple fill"
),
QgsSymbolV2::Fill
,
44
QgsSimpleFillSymbolLayerV2::create
,
QgsSimpleFillSymbolLayerV2::createFromSld
) );
45
addSymbolLayerType
(
new
QgsSymbolLayerV2Metadata
(
"GradientFill"
,
QObject::tr
(
"Gradient fill"
),
QgsSymbolV2::Fill
,
46
QgsGradientFillSymbolLayerV2::create
) );
47
addSymbolLayerType
(
new
QgsSymbolLayerV2Metadata
(
"ShapeburstFill"
,
QObject::tr
(
"Shapeburst fill"
),
QgsSymbolV2::Fill
,
48
QgsShapeburstFillSymbolLayerV2::create
) );
49
addSymbolLayerType
(
new
QgsSymbolLayerV2Metadata
(
"RasterFill"
,
QObject::tr
(
"Raster image fill"
),
QgsSymbolV2::Fill
,
50
QgsRasterFillSymbolLayer::create
) );
51
addSymbolLayerType
(
new
QgsSymbolLayerV2Metadata
(
"SVGFill"
,
QObject::tr
(
"SVG fill"
),
QgsSymbolV2::Fill
,
52
QgsSVGFillSymbolLayer::create
,
QgsSVGFillSymbolLayer::createFromSld
) );
53
addSymbolLayerType
(
new
QgsSymbolLayerV2Metadata
(
"CentroidFill"
,
QObject::tr
(
"Centroid fill"
),
QgsSymbolV2::Fill
,
54
QgsCentroidFillSymbolLayerV2::create
,
QgsCentroidFillSymbolLayerV2::createFromSld
) );
55
addSymbolLayerType
(
new
QgsSymbolLayerV2Metadata
(
"LinePatternFill"
,
QObject::tr
(
"Line pattern fill"
),
QgsSymbolV2::Fill
,
56
QgsLinePatternFillSymbolLayer::create
,
QgsLinePatternFillSymbolLayer::createFromSld
) );
57
addSymbolLayerType
(
new
QgsSymbolLayerV2Metadata
(
"PointPatternFill"
,
QObject::tr
(
"Point pattern fill"
),
QgsSymbolV2::Fill
,
58
QgsPointPatternFillSymbolLayer::create
,
QgsPointPatternFillSymbolLayer::createFromSld
) );
59
}
60
61
QgsSymbolLayerV2Registry::~QgsSymbolLayerV2Registry
()
62
{
63
foreach
( QString name,
mMetadata
.keys() )
64
{
65
delete
mMetadata
[name];
66
}
67
mMetadata
.clear();
68
}
69
70
bool
QgsSymbolLayerV2Registry::addSymbolLayerType
(
QgsSymbolLayerV2AbstractMetadata
* metadata )
71
{
72
if
( metadata == NULL ||
mMetadata
.contains( metadata->
name
() ) )
73
return
false
;
74
75
mMetadata
[metadata->
name
()] = metadata;
76
return
true
;
77
}
78
79
80
QgsSymbolLayerV2AbstractMetadata
*
QgsSymbolLayerV2Registry::symbolLayerMetadata
( QString name )
const
81
{
82
if
(
mMetadata
.contains( name ) )
83
return
mMetadata
.value( name );
84
else
85
return
NULL;
86
}
87
88
QgsSymbolLayerV2Registry
*
QgsSymbolLayerV2Registry::instance
()
89
{
90
static
QgsSymbolLayerV2Registry
mInstance;
91
return
&mInstance;
92
}
93
94
QgsSymbolLayerV2
*
QgsSymbolLayerV2Registry::defaultSymbolLayer
(
QgsSymbolV2::SymbolType
type )
95
{
96
switch
( type )
97
{
98
case
QgsSymbolV2::Marker
:
99
return
QgsSimpleMarkerSymbolLayerV2::create
();
100
101
case
QgsSymbolV2::Line
:
102
return
QgsSimpleLineSymbolLayerV2::create
();
103
104
case
QgsSymbolV2::Fill
:
105
return
QgsSimpleFillSymbolLayerV2::create
();
106
}
107
return
NULL;
108
}
109
110
111
QgsSymbolLayerV2
*
QgsSymbolLayerV2Registry::createSymbolLayer
( QString name,
const
QgsStringMap
& properties )
const
112
{
113
if
( !
mMetadata
.contains( name ) )
114
return
NULL;
115
116
return
mMetadata
[name]->createSymbolLayer( properties );
117
}
118
119
QgsSymbolLayerV2
*
QgsSymbolLayerV2Registry::createSymbolLayerFromSld
( QString name, QDomElement& element )
const
120
{
121
if
( !
mMetadata
.contains( name ) )
122
return
NULL;
123
124
return
mMetadata
[name]->createSymbolLayerFromSld( element );
125
}
126
127
QStringList
QgsSymbolLayerV2Registry::symbolLayersForType
(
QgsSymbolV2::SymbolType
type )
128
{
129
QStringList lst;
130
QMap<QString, QgsSymbolLayerV2AbstractMetadata*>::ConstIterator it =
mMetadata
.begin();
131
for
( ; it !=
mMetadata
.end(); ++it )
132
{
133
if
(( *it )->type() == type )
134
lst.append( it.key() );
135
}
136
return
lst;
137
}
Generated on Sun May 10 2015 16:33:25 for QGIS API Documentation by
1.8.1.2