1 /*************************************************************************** 2 qgsabstract3dsymbol.h 3 -------------------------------------- 4 Date : July 2017 5 Copyright : (C) 2017 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 #ifndef QGSABSTRACT3DSYMBOL_H 17 #define QGSABSTRACT3DSYMBOL_H 18 19 #include "qgis_core.h" 20 #include "qgis_sip.h" 21 22 #include "qgspropertycollection.h" 23 24 class QDomElement; 25 class QString; 26 27 class QgsReadWriteContext; 28 class Qgs3DSceneExporter; 29 namespace Qt3DCore { class QEntity; } SIP_SKIP 30 31 32 /** 33 * \ingroup 3d 34 * \brief Abstract base class for 3D symbols that are used by VectorLayer3DRenderer objects. 35 * 36 * 3D symbol objects define appearance of GIS data. 37 * 38 * \warning This is not considered stable API, and may change in future QGIS releases. It is 39 * exposed to the Python bindings as a tech preview only. 40 * 41 * \note Prior to QGIS 3.16 this was available through the QGIS 3D library. 42 * 43 * \since QGIS 3.0 44 */ 45 class CORE_EXPORT QgsAbstract3DSymbol 46 { 47 public: 48 virtual ~QgsAbstract3DSymbol() = default; 49 50 //! Returns identifier of symbol type. Each 3D symbol implementation should return a different type. 51 virtual QString type() const = 0; 52 //! Returns a new instance of the symbol with the same settings 53 virtual QgsAbstract3DSymbol *clone() const = 0 SIP_FACTORY; 54 55 //! Writes symbol configuration to the given DOM element 56 virtual void writeXml( QDomElement &elem, const QgsReadWriteContext &context ) const = 0; 57 //! Reads symbol configuration from the given DOM element 58 virtual void readXml( const QDomElement &elem, const QgsReadWriteContext &context ) = 0; 59 60 /** 61 * Returns the list of the vector layer geometry types which are compatible with this symbol. 62 * 63 * \since QGIS 3.16 64 */ 65 virtual QList< QgsWkbTypes::GeometryType > compatibleGeometryTypes() const; 66 67 //! Data definable properties. 68 enum Property 69 { 70 PropertyHeight = 0, //!< Height (altitude) 71 PropertyExtrusionHeight, //!< Extrusion height (zero means no extrusion) 72 }; 73 74 //! Returns the symbol layer property definitions. 75 static const QgsPropertiesDefinition &propertyDefinitions(); 76 77 //! Returns a reference to the symbol layer's property collection, used for data defined overrides. dataDefinedProperties()78 QgsPropertyCollection &dataDefinedProperties() { return mDataDefinedProperties; } 79 80 //! Returns a reference to the symbol layer's property collection, used for data defined overrides. dataDefinedProperties()81 const QgsPropertyCollection &dataDefinedProperties() const { return mDataDefinedProperties; } SIP_SKIP 82 83 //! Sets the symbol layer's property collection, used for data defined overrides. setDataDefinedProperties(const QgsPropertyCollection & collection)84 void setDataDefinedProperties( const QgsPropertyCollection &collection ) { mDataDefinedProperties = collection; } 85 86 /** 87 * Exports the geometries contained within the hierarchy of entity. 88 * Returns whether any objects were exported 89 * If this function is not overloaded we don't try to export anything 90 */ 91 virtual bool exportGeometries( Qgs3DSceneExporter *exporter, Qt3DCore::QEntity *entity, const QString &objectNamePrefix ) const SIP_SKIP; 92 93 protected: 94 95 /** 96 * Copies base class settings from this object to a \a destination object. 97 */ 98 void copyBaseSettings( QgsAbstract3DSymbol *destination ) const; 99 QgsPropertyCollection mDataDefinedProperties; 100 101 private: 102 static void initPropertyDefinitions(); 103 104 //! Property definitions 105 static QgsPropertiesDefinition sPropertyDefinitions; 106 }; 107 108 109 #endif // QGSABSTRACT3DSYMBOL_H 110