QGIS API Documentation 3.99.0-Master (d270888f95f)
Loading...
Searching...
No Matches
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
22using namespace Qt::StringLiterals;
23
27
29{
30 qDeleteAll( mMetadata );
31}
32
34{
35 if ( !metadata || mMetadata.contains( metadata->type() ) )
36 return false;
37
38 mMetadata[metadata->type()] = metadata;
39 return true;
40}
41
43{
44 if ( !mMetadata.contains( type ) )
45 return nullptr;
46
47 return mMetadata[type]->create();
48}
49
51{
52 switch ( type )
53 {
55 return createSymbol( u"point"_s );
57 return createSymbol( u"line"_s );
59 return createSymbol( u"polygon"_s );
60 default:
61 return nullptr;
62 }
63}
64
66{
67 if ( !symbol )
68 return nullptr;
69
70 auto it = mMetadata.constFind( symbol->type() );
71 if ( it == mMetadata.constEnd() )
72 return nullptr;
73
74 return it.value()->createFeatureHandler( layer, symbol );
75}
76
78{
79 return mMetadata.value( type );
80}
81
83{
84 return mMetadata.keys();
85}
GeometryType
The geometry types are used to group Qgis::WkbType in a coarse way.
Definition qgis.h:365
@ Point
Points.
Definition qgis.h:366
@ Line
Lines.
Definition qgis.h:367
@ Polygon
Polygons.
Definition qgis.h:368
Stores metadata about one 3D symbol class.
QString type() const
Returns the unique symbol type string.
QStringList symbolTypes() const
Returns a list of all available symbol types.
QgsAbstract3DSymbol * defaultSymbolForGeometryType(Qgis::GeometryType type)
Creates a new instance of the default 3D symbol for the specified geometry type.
QgsAbstract3DSymbol * createSymbol(const QString &type) const
Creates a new instance of a symbol of the specified type.
Qgs3DSymbolAbstractMetadata * symbolMetadata(const QString &type) const
Returns metadata for specified symbol type. Returns nullptr if not found.
QgsFeature3DHandler * createHandlerForSymbol(QgsVectorLayer *layer, const QgsAbstract3DSymbol *symbol)
Creates a feature handler for a symbol, for the specified vector layer.
bool addSymbolType(Qgs3DSymbolAbstractMetadata *metadata)
Registers a new symbol type. Takes ownership of the metadata instance.
Abstract base class for 3D symbols that are used by VectorLayer3DRenderer objects.
virtual QString type() const =0
Returns identifier of symbol type. Each 3D symbol implementation should return a different type.
Represents a vector layer which manages a vector based dataset.