QGIS API Documentation
4.3.0-Master (0ad0cdb9438)
Toggle main menu visibility
Loading...
Searching...
No Matches
src
core
3d
qgs3dsymbolregistry.cpp
Go to the documentation of this file.
1
/***************************************************************************
2
qgs3dsymbolregistry.cpp
3
--------------------------------------
4
Date : July 2020
5
Copyright : (C) 2020 by Nyall Dawson
6
Email : nyall dot dawson 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 "
qgs3dsymbolregistry.h
"
17
18
#include "
qgsabstract3dsymbol.h
"
19
20
#include <QString>
21
22
using namespace
Qt::StringLiterals;
23
24
Qgs3DSymbolRegistry::Qgs3DSymbolRegistry
()
25
{}
26
27
Qgs3DSymbolRegistry::~Qgs3DSymbolRegistry
()
28
{
29
qDeleteAll( mMetadata );
30
}
31
32
bool
Qgs3DSymbolRegistry::addSymbolType
(
Qgs3DSymbolAbstractMetadata
*metadata )
33
{
34
if
( !metadata || mMetadata.contains( metadata->
type
() ) )
35
return
false
;
36
37
mMetadata[metadata->
type
()] = metadata;
38
return
true
;
39
}
40
41
std::unique_ptr<QgsAbstract3DSymbol>
Qgs3DSymbolRegistry::createSymbol
(
const
QString &type )
const
42
{
43
if
( !mMetadata.contains( type ) )
44
return
nullptr
;
45
46
return
std::unique_ptr<QgsAbstract3DSymbol>( mMetadata[type]->create() );
47
}
48
49
std::unique_ptr<QgsAbstract3DSymbol>
Qgs3DSymbolRegistry::defaultSymbolForGeometryType
(
Qgis::GeometryType
type )
50
{
51
switch
( type )
52
{
53
case
Qgis::GeometryType::Point
:
54
return
createSymbol
( u
"point"
_s );
55
case
Qgis::GeometryType::Line
:
56
return
createSymbol
( u
"line"
_s );
57
case
Qgis::GeometryType::Polygon
:
58
return
createSymbol
( u
"polygon"
_s );
59
default
:
60
return
nullptr
;
61
}
62
}
63
64
QgsFeature3DHandler *
Qgs3DSymbolRegistry::createHandlerForSymbol
(
const
QgsVectorLayer
*layer,
const
QgsAbstract3DSymbol
*symbol )
65
{
66
if
( !symbol )
67
return
nullptr
;
68
69
auto
it = mMetadata.constFind( symbol->
type
() );
70
if
( it == mMetadata.constEnd() )
71
return
nullptr
;
72
73
return
it.value()->createFeatureHandler( layer, symbol );
74
}
75
76
Qgs3DSymbolAbstractMetadata
*
Qgs3DSymbolRegistry::symbolMetadata
(
const
QString &type )
const
77
{
78
return
mMetadata.value( type );
79
}
80
81
QStringList
Qgs3DSymbolRegistry::symbolTypes
()
const
82
{
83
return
mMetadata.keys();
84
}
Qgis::GeometryType
GeometryType
The geometry types are used to group Qgis::WkbType in a coarse way.
Definition
qgis.h:399
Qgis::GeometryType::Point
@ Point
Points.
Definition
qgis.h:400
Qgis::GeometryType::Line
@ Line
Lines.
Definition
qgis.h:401
Qgis::GeometryType::Polygon
@ Polygon
Polygons.
Definition
qgis.h:402
Qgs3DSymbolAbstractMetadata
Stores metadata about one 3D symbol class.
Definition
qgs3dsymbolregistry.h:42
Qgs3DSymbolAbstractMetadata::type
QString type() const
Returns the unique symbol type string.
Definition
qgs3dsymbolregistry.h:57
Qgs3DSymbolRegistry::symbolTypes
QStringList symbolTypes() const
Returns a list of all available symbol types.
Definition
qgs3dsymbolregistry.cpp:81
Qgs3DSymbolRegistry::~Qgs3DSymbolRegistry
~Qgs3DSymbolRegistry()
Definition
qgs3dsymbolregistry.cpp:27
Qgs3DSymbolRegistry::defaultSymbolForGeometryType
std::unique_ptr< QgsAbstract3DSymbol > defaultSymbolForGeometryType(Qgis::GeometryType type)
Creates a new instance of the default 3D symbol for the specified geometry type.
Definition
qgs3dsymbolregistry.cpp:49
Qgs3DSymbolRegistry::symbolMetadata
Qgs3DSymbolAbstractMetadata * symbolMetadata(const QString &type) const
Returns metadata for specified symbol type. Returns nullptr if not found.
Definition
qgs3dsymbolregistry.cpp:76
Qgs3DSymbolRegistry::addSymbolType
bool addSymbolType(Qgs3DSymbolAbstractMetadata *metadata)
Registers a new symbol type. Takes ownership of the metadata instance.
Definition
qgs3dsymbolregistry.cpp:32
Qgs3DSymbolRegistry::createSymbol
std::unique_ptr< QgsAbstract3DSymbol > createSymbol(const QString &type) const
Creates a new instance of a symbol of the specified type.
Definition
qgs3dsymbolregistry.cpp:41
Qgs3DSymbolRegistry::Qgs3DSymbolRegistry
Qgs3DSymbolRegistry()
Definition
qgs3dsymbolregistry.cpp:24
Qgs3DSymbolRegistry::createHandlerForSymbol
QgsFeature3DHandler * createHandlerForSymbol(const QgsVectorLayer *layer, const QgsAbstract3DSymbol *symbol)
Creates a feature handler for a symbol, for the specified vector layer.
Definition
qgs3dsymbolregistry.cpp:64
QgsAbstract3DSymbol
Abstract base class for 3D symbols that are used by VectorLayer3DRenderer objects.
Definition
qgsabstract3dsymbol.h:48
QgsAbstract3DSymbol::type
virtual QString type() const =0
Returns identifier of symbol type. Each 3D symbol implementation should return a different type.
QgsVectorLayer
Represents a vector layer which manages a vector based dataset.
Definition
qgsvectorlayer.h:414
qgs3dsymbolregistry.h
qgsabstract3dsymbol.h
Generated on
for QGIS API Documentation by
1.17.0