QGIS API Documentation  3.16.0-Hannover (43b64b13f3)
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 #include "qgsabstract3dsymbol.h"
18 
20 {
21 }
22 
24 {
25  qDeleteAll( mMetadata );
26 }
27 
29 {
30  if ( !metadata || mMetadata.contains( metadata->type() ) )
31  return false;
32 
33  mMetadata[metadata->type()] = metadata;
34  return true;
35 }
36 
38 {
39  if ( !mMetadata.contains( type ) )
40  return nullptr;
41 
42  return mMetadata[type]->create();
43 }
44 
46 {
47  switch ( type )
48  {
50  return createSymbol( QStringLiteral( "point" ) );
52  return createSymbol( QStringLiteral( "line" ) );
54  return createSymbol( QStringLiteral( "polygon" ) );
55  default:
56  return nullptr;
57  }
58 }
59 
61 {
62  if ( !symbol )
63  return nullptr;
64 
65  if ( !mMetadata.contains( symbol->type() ) )
66  return nullptr;
67 
68  return mMetadata.value( symbol->type() )->createFeatureHandler( layer, symbol );
69 }
70 
72 {
73  return mMetadata.value( type );
74 }
75 
77 {
78  return mMetadata.keys();
79 }
Qgs3DSymbolRegistry::symbolMetadata
Qgs3DSymbolAbstractMetadata * symbolMetadata(const QString &type) const
Returns metadata for specified symbol type. Returns nullptr if not found.
Definition: qgs3dsymbolregistry.cpp:71
Qgs3DSymbolRegistry::createSymbol
QgsAbstract3DSymbol * createSymbol(const QString &type) const
Creates a new instance of a symbol of the specified type.
Definition: qgs3dsymbolregistry.cpp:37
Qgs3DSymbolAbstractMetadata
Stores metadata about one 3D symbol class.
Definition: qgs3dsymbolregistry.h:42
Qgs3DSymbolRegistry::symbolTypes
QStringList symbolTypes() const
Returns a list of all available symbol types.
Definition: qgs3dsymbolregistry.cpp:76
Qgs3DSymbolRegistry::~Qgs3DSymbolRegistry
~Qgs3DSymbolRegistry()
Definition: qgs3dsymbolregistry.cpp:23
qgsabstract3dsymbol.h
qgs3dsymbolregistry.h
QgsWkbTypes::PolygonGeometry
@ PolygonGeometry
Definition: qgswkbtypes.h:144
Qgs3DSymbolRegistry::defaultSymbolForGeometryType
QgsAbstract3DSymbol * defaultSymbolForGeometryType(QgsWkbTypes::GeometryType type)
Creates a new instance of the default 3D symbol for the specified geometry type.
Definition: qgs3dsymbolregistry.cpp:45
QgsAbstract3DSymbol
3 Abstract base class for 3D symbols that are used by VectorLayer3DRenderer objects.
Definition: qgsabstract3dsymbol.h:46
QgsAbstract3DSymbol::type
virtual QString type() const =0
Returns identifier of symbol type. Each 3D symbol implementation should return a different type.
QgsWkbTypes::LineGeometry
@ LineGeometry
Definition: qgswkbtypes.h:143
QgsWkbTypes::PointGeometry
@ PointGeometry
Definition: qgswkbtypes.h:142
QgsWkbTypes::GeometryType
GeometryType
The geometry types are used to group QgsWkbTypes::Type in a coarse way.
Definition: qgswkbtypes.h:141
QgsVectorLayer
Represents a vector layer which manages a vector based data sets.
Definition: qgsvectorlayer.h:387
Qgs3DSymbolRegistry::addSymbolType
bool addSymbolType(Qgs3DSymbolAbstractMetadata *metadata)
Registers a new symbol type. Takes ownership of the metadata instance.
Definition: qgs3dsymbolregistry.cpp:28
Qgs3DSymbolRegistry::createHandlerForSymbol
QgsFeature3DHandler * createHandlerForSymbol(QgsVectorLayer *layer, const QgsAbstract3DSymbol *symbol)
Creates a feature handler for a symbol, for the specified vector layer.
Definition: qgs3dsymbolregistry.cpp:60
Qgs3DSymbolRegistry::Qgs3DSymbolRegistry
Qgs3DSymbolRegistry()
Definition: qgs3dsymbolregistry.cpp:19
Qgs3DSymbolAbstractMetadata::type
QString type() const
Returns the unique symbol type string.
Definition: qgs3dsymbolregistry.h:58