diff --git a/src/3d/CMakeLists.txt b/src/3d/CMakeLists.txt index 88294dcfe421..4b8730721aa9 100644 --- a/src/3d/CMakeLists.txt +++ b/src/3d/CMakeLists.txt @@ -3,11 +3,8 @@ SET(QGIS_3D_SRCS cameracontroller.cpp - lineentity.cpp map3d.cpp phongmaterialsettings.cpp - pointentity.cpp - polygonentity.cpp polygongeometry.cpp scene.cpp tessellator.cpp @@ -23,8 +20,11 @@ SET(QGIS_3D_SRCS symbols/qgsabstract3dsymbol.cpp symbols/qgsline3dsymbol.cpp + symbols/qgsline3dsymbol_p.cpp symbols/qgspoint3dsymbol.cpp + symbols/qgspoint3dsymbol_p.cpp symbols/qgspolygon3dsymbol.cpp + symbols/qgspolygon3dsymbol_p.cpp terrain/demterraingenerator.cpp terrain/demterraintilegeometry.cpp @@ -69,11 +69,8 @@ QT5_ADD_RESOURCES(QGIS_3D_RCC_SRCS shaders.qrc) SET(QGIS_3D_HDRS aabb.h cameracontroller.h - lineentity.h map3d.h phongmaterialsettings.h - pointentity.h - polygonentity.h polygongeometry.h scene.h tessellator.h @@ -89,8 +86,11 @@ SET(QGIS_3D_HDRS symbols/qgsabstract3dsymbol.h symbols/qgsline3dsymbol.h + symbols/qgsline3dsymbol_p.h symbols/qgspoint3dsymbol.h + symbols/qgspoint3dsymbol_p.h symbols/qgspolygon3dsymbol.h + symbols/qgspolygon3dsymbol_p.h terrain/demterraingenerator.h terrain/demterraintilegeometry.h diff --git a/src/3d/pointentity.h b/src/3d/pointentity.h deleted file mode 100644 index b9559afd9edf..000000000000 --- a/src/3d/pointentity.h +++ /dev/null @@ -1,55 +0,0 @@ -#ifndef POINTENTITY_H -#define POINTENTITY_H - -#include -#include -#include -#include - -class Map3D; -class QgsPoint3DSymbol; - -class QgsVectorLayer; -class QgsFeatureRequest; - - -//! Entity that handles rendering of points as 3D objects -class PointEntity : public Qt3DCore::QEntity -{ - public: - PointEntity( const Map3D &map, QgsVectorLayer *layer, const QgsPoint3DSymbol &symbol, Qt3DCore::QNode *parent = nullptr ); -}; - -class InstancedPointEntityFactory -{ - public: - static void addEntityForSelectedPoints( const Map3D &map, QgsVectorLayer *layer, const QgsPoint3DSymbol &symbol, PointEntity *parent ); - static void addEntityForNotSelectedPoints( const Map3D &map, QgsVectorLayer *layer, const QgsPoint3DSymbol &symbol, PointEntity *parent ); - - private: - static Qt3DRender::QMaterial *material( const QgsPoint3DSymbol &symbol ); -}; - -class InstancedPointEntityNode : public Qt3DCore::QEntity -{ - public: - InstancedPointEntityNode( const Map3D &map, QgsVectorLayer *layer, const QgsPoint3DSymbol &symbol, const QgsFeatureRequest &req, Qt3DCore::QNode *parent = nullptr ); - - private: - Qt3DRender::QGeometryRenderer *renderer( const QgsPoint3DSymbol &symbol, const QList &positions ) const; -}; - -class Model3DPointEntityFactory -{ - public: - static void addEntitiesForSelectedPoints( const Map3D &map, QgsVectorLayer *layer, const QgsPoint3DSymbol &symbol, PointEntity *parent ); - static void addEntitiesForNotSelectedPoints( const Map3D &map, QgsVectorLayer *layer, const QgsPoint3DSymbol &symbol, PointEntity *parent ); - - private: - static void addSceneEntities( const Map3D &map, QgsVectorLayer *layer, const QgsFeatureRequest &req, const QgsPoint3DSymbol &symbol, PointEntity *parent ); - static void addMeshEntities( const Map3D &map, QgsVectorLayer *layer, const QgsFeatureRequest &req, const QgsPoint3DSymbol &symbol, PointEntity *parent, bool are_selected ); - - static Qt3DCore::QTransform *transform( const QVector3D &position, const QgsPoint3DSymbol &symbol ); -}; - -#endif // POINTENTITY_H diff --git a/src/3d/lineentity.cpp b/src/3d/symbols/qgsline3dsymbol_p.cpp similarity index 78% rename from src/3d/lineentity.cpp rename to src/3d/symbols/qgsline3dsymbol_p.cpp index 58a879d34c84..568b61e8bfc5 100644 --- a/src/3d/lineentity.cpp +++ b/src/3d/symbols/qgsline3dsymbol_p.cpp @@ -1,4 +1,4 @@ -#include "lineentity.h" +#include "qgsline3dsymbol_p.h" #include "qgsline3dsymbol.h" #include "polygongeometry.h" @@ -11,14 +11,14 @@ #include "qgsgeos.h" -LineEntity::LineEntity( const Map3D &map, QgsVectorLayer *layer, const QgsLine3DSymbol &symbol, Qt3DCore::QNode *parent ) +QgsLine3DSymbolEntity::QgsLine3DSymbolEntity( const Map3D &map, QgsVectorLayer *layer, const QgsLine3DSymbol &symbol, Qt3DCore::QNode *parent ) : Qt3DCore::QEntity( parent ) { addEntityForSelectedLines( map, layer, symbol ); addEntityForNotSelectedLines( map, layer, symbol ); } -Qt3DExtras::QPhongMaterial *LineEntity::material( const QgsLine3DSymbol &symbol ) const +Qt3DExtras::QPhongMaterial *QgsLine3DSymbolEntity::material( const QgsLine3DSymbol &symbol ) const { Qt3DExtras::QPhongMaterial *material = new Qt3DExtras::QPhongMaterial; @@ -30,7 +30,7 @@ Qt3DExtras::QPhongMaterial *LineEntity::material( const QgsLine3DSymbol &symbol return material; } -void LineEntity::addEntityForSelectedLines( const Map3D &map, QgsVectorLayer *layer, const QgsLine3DSymbol &symbol ) +void QgsLine3DSymbolEntity::addEntityForSelectedLines( const Map3D &map, QgsVectorLayer *layer, const QgsLine3DSymbol &symbol ) { // build the default material Qt3DExtras::QPhongMaterial *mat = material( symbol ); @@ -45,12 +45,12 @@ void LineEntity::addEntityForSelectedLines( const Map3D &map, QgsVectorLayer *la req.setFilterFids( layer->selectedFeatureIds() ); // build the entity - LineEntityNode *entity = new LineEntityNode( map, layer, symbol, req ); + QgsLine3DSymbolEntityNode *entity = new QgsLine3DSymbolEntityNode( map, layer, symbol, req ); entity->addComponent( mat ); entity->setParent( this ); } -void LineEntity::addEntityForNotSelectedLines( const Map3D &map, QgsVectorLayer *layer, const QgsLine3DSymbol &symbol ) +void QgsLine3DSymbolEntity::addEntityForNotSelectedLines( const Map3D &map, QgsVectorLayer *layer, const QgsLine3DSymbol &symbol ) { // build the default material Qt3DExtras::QPhongMaterial *mat = material( symbol ); @@ -64,18 +64,18 @@ void LineEntity::addEntityForNotSelectedLines( const Map3D &map, QgsVectorLayer req.setFilterFids( notSelected ); // build the entity - LineEntityNode *entity = new LineEntityNode( map, layer, symbol, req ); + QgsLine3DSymbolEntityNode *entity = new QgsLine3DSymbolEntityNode( map, layer, symbol, req ); entity->addComponent( mat ); entity->setParent( this ); } -LineEntityNode::LineEntityNode( const Map3D &map, QgsVectorLayer *layer, const QgsLine3DSymbol &symbol, const QgsFeatureRequest &req, Qt3DCore::QNode *parent ) +QgsLine3DSymbolEntityNode::QgsLine3DSymbolEntityNode( const Map3D &map, QgsVectorLayer *layer, const QgsLine3DSymbol &symbol, const QgsFeatureRequest &req, Qt3DCore::QNode *parent ) : Qt3DCore::QEntity( parent ) { addComponent( renderer( map, symbol, layer, req ) ); } -Qt3DRender::QGeometryRenderer *LineEntityNode::renderer( const Map3D &map, const QgsLine3DSymbol &symbol, const QgsVectorLayer *layer, const QgsFeatureRequest &request ) +Qt3DRender::QGeometryRenderer *QgsLine3DSymbolEntityNode::renderer( const Map3D &map, const QgsLine3DSymbol &symbol, const QgsVectorLayer *layer, const QgsFeatureRequest &request ) { QgsPointXY origin( map.originX, map.originY ); diff --git a/src/3d/lineentity.h b/src/3d/symbols/qgsline3dsymbol_p.h similarity index 51% rename from src/3d/lineentity.h rename to src/3d/symbols/qgsline3dsymbol_p.h index 455953323846..7c7922490baa 100644 --- a/src/3d/lineentity.h +++ b/src/3d/symbols/qgsline3dsymbol_p.h @@ -1,5 +1,16 @@ -#ifndef LINEENTITY_H -#define LINEENTITY_H +#ifndef QGSLINE3DSYMBOL_P_H +#define QGSLINE3DSYMBOL_P_H + +/// @cond PRIVATE + +// +// W A R N I N G +// ------------- +// +// This file is not part of the QGIS API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// #include #include @@ -14,10 +25,10 @@ class QgsFeatureRequest; //! Entity that handles rendering of linestrings -class LineEntity : public Qt3DCore::QEntity +class QgsLine3DSymbolEntity : public Qt3DCore::QEntity { public: - LineEntity( const Map3D &map, QgsVectorLayer *layer, const QgsLine3DSymbol &symbol, Qt3DCore::QNode *parent = nullptr ); + QgsLine3DSymbolEntity( const Map3D &map, QgsVectorLayer *layer, const QgsLine3DSymbol &symbol, Qt3DCore::QNode *parent = nullptr ); private: void addEntityForSelectedLines( const Map3D &map, QgsVectorLayer *layer, const QgsLine3DSymbol &symbol ); @@ -26,10 +37,10 @@ class LineEntity : public Qt3DCore::QEntity Qt3DExtras::QPhongMaterial *material( const QgsLine3DSymbol &symbol ) const; }; -class LineEntityNode : public Qt3DCore::QEntity +class QgsLine3DSymbolEntityNode : public Qt3DCore::QEntity { public: - LineEntityNode( const Map3D &map, QgsVectorLayer *layer, const QgsLine3DSymbol &symbol, const QgsFeatureRequest &req, Qt3DCore::QNode *parent = nullptr ); + QgsLine3DSymbolEntityNode( const Map3D &map, QgsVectorLayer *layer, const QgsLine3DSymbol &symbol, const QgsFeatureRequest &req, Qt3DCore::QNode *parent = nullptr ); private: Qt3DRender::QGeometryRenderer *renderer( const Map3D &map, const QgsLine3DSymbol &symbol, const QgsVectorLayer *layer, const QgsFeatureRequest &req ); @@ -37,4 +48,6 @@ class LineEntityNode : public Qt3DCore::QEntity PolygonGeometry *mGeometry; }; -#endif // LINEENTITY_H +/// @endcond + +#endif // QGSLINE3DSYMBOL_P_H diff --git a/src/3d/pointentity.cpp b/src/3d/symbols/qgspoint3dsymbol_p.cpp similarity index 82% rename from src/3d/pointentity.cpp rename to src/3d/symbols/qgspoint3dsymbol_p.cpp index bfc039ccb987..1e487d2c995b 100644 --- a/src/3d/pointentity.cpp +++ b/src/3d/symbols/qgspoint3dsymbol_p.cpp @@ -1,4 +1,4 @@ -#include "pointentity.h" +#include "qgspoint3dsymbol_p.h" #include #include @@ -34,24 +34,24 @@ #include "utils.h" -PointEntity::PointEntity( const Map3D &map, QgsVectorLayer *layer, const QgsPoint3DSymbol &symbol, Qt3DCore::QNode *parent ) +QgsPoint3DSymbolEntity::QgsPoint3DSymbolEntity( const Map3D &map, QgsVectorLayer *layer, const QgsPoint3DSymbol &symbol, Qt3DCore::QNode *parent ) : Qt3DCore::QEntity( parent ) { if ( symbol.shapeProperties()["shape"].toString() == "model" ) { - Model3DPointEntityFactory::addEntitiesForSelectedPoints( map, layer, symbol, this ); - Model3DPointEntityFactory::addEntitiesForNotSelectedPoints( map, layer, symbol, this ); + QgsPoint3DSymbolModelEntityFactory::addEntitiesForSelectedPoints( map, layer, symbol, this ); + QgsPoint3DSymbolModelEntityFactory::addEntitiesForNotSelectedPoints( map, layer, symbol, this ); } else { - InstancedPointEntityFactory::addEntityForNotSelectedPoints( map, layer, symbol, this ); - InstancedPointEntityFactory::addEntityForSelectedPoints( map, layer, symbol, this ); + QgsPoint3DSymbolInstancedEntityFactory::addEntityForNotSelectedPoints( map, layer, symbol, this ); + QgsPoint3DSymbolInstancedEntityFactory::addEntityForSelectedPoints( map, layer, symbol, this ); } } //* INSTANCED RENDERING *// -Qt3DRender::QMaterial *InstancedPointEntityFactory::material( const QgsPoint3DSymbol &symbol ) +Qt3DRender::QMaterial *QgsPoint3DSymbolInstancedEntityFactory::material( const QgsPoint3DSymbol &symbol ) { Qt3DRender::QFilterKey *filterKey = new Qt3DRender::QFilterKey; filterKey->setName( "renderingStyle" ); @@ -120,7 +120,7 @@ Qt3DRender::QMaterial *InstancedPointEntityFactory::material( const QgsPoint3DSy return material; } -void InstancedPointEntityFactory::addEntityForSelectedPoints( const Map3D &map, QgsVectorLayer *layer, const QgsPoint3DSymbol &symbol, PointEntity *parent ) +void QgsPoint3DSymbolInstancedEntityFactory::addEntityForSelectedPoints( const Map3D &map, QgsVectorLayer *layer, const QgsPoint3DSymbol &symbol, QgsPoint3DSymbolEntity *parent ) { // build the default material Qt3DRender::QMaterial *mat = material( symbol ); @@ -140,12 +140,12 @@ void InstancedPointEntityFactory::addEntityForSelectedPoints( const Map3D &map, req.setFilterFids( layer->selectedFeatureIds() ); // build the entity - InstancedPointEntityNode *entity = new InstancedPointEntityNode( map, layer, symbol, req ); + QgsPoint3DSymbolInstancedEntityNode *entity = new QgsPoint3DSymbolInstancedEntityNode( map, layer, symbol, req ); entity->addComponent( mat ); entity->setParent( parent ); } -void InstancedPointEntityFactory::addEntityForNotSelectedPoints( const Map3D &map, QgsVectorLayer *layer, const QgsPoint3DSymbol &symbol, PointEntity *parent ) +void QgsPoint3DSymbolInstancedEntityFactory::addEntityForNotSelectedPoints( const Map3D &map, QgsVectorLayer *layer, const QgsPoint3DSymbol &symbol, QgsPoint3DSymbolEntity *parent ) { // build the default material Qt3DRender::QMaterial *mat = material( symbol ); @@ -159,19 +159,19 @@ void InstancedPointEntityFactory::addEntityForNotSelectedPoints( const Map3D &ma req.setFilterFids( notSelected ); // build the entity - InstancedPointEntityNode *entity = new InstancedPointEntityNode( map, layer, symbol, req ); + QgsPoint3DSymbolInstancedEntityNode *entity = new QgsPoint3DSymbolInstancedEntityNode( map, layer, symbol, req ); entity->addComponent( mat ); entity->setParent( parent ); } -InstancedPointEntityNode::InstancedPointEntityNode( const Map3D &map, QgsVectorLayer *layer, const QgsPoint3DSymbol &symbol, const QgsFeatureRequest &req, Qt3DCore::QNode *parent ) +QgsPoint3DSymbolInstancedEntityNode::QgsPoint3DSymbolInstancedEntityNode( const Map3D &map, QgsVectorLayer *layer, const QgsPoint3DSymbol &symbol, const QgsFeatureRequest &req, Qt3DCore::QNode *parent ) : Qt3DCore::QEntity( parent ) { QList pos = Utils::positions( map, layer, req ); addComponent( renderer( symbol, pos ) ); } -Qt3DRender::QGeometryRenderer *InstancedPointEntityNode::renderer( const QgsPoint3DSymbol &symbol, const QList &positions ) const +Qt3DRender::QGeometryRenderer *QgsPoint3DSymbolInstancedEntityNode::renderer( const QgsPoint3DSymbol &symbol, const QList &positions ) const { int count = positions.count(); @@ -293,7 +293,7 @@ static Qt3DExtras::QPhongMaterial *phongMaterial( const QgsPoint3DSymbol &symbol return phong; } -void Model3DPointEntityFactory::addEntitiesForSelectedPoints( const Map3D &map, QgsVectorLayer *layer, const QgsPoint3DSymbol &symbol, PointEntity *parent ) +void QgsPoint3DSymbolModelEntityFactory::addEntitiesForSelectedPoints( const Map3D &map, QgsVectorLayer *layer, const QgsPoint3DSymbol &symbol, QgsPoint3DSymbolEntity *parent ) { QgsFeatureRequest req; req.setDestinationCrs( map.crs ); @@ -304,7 +304,7 @@ void Model3DPointEntityFactory::addEntitiesForSelectedPoints( const Map3D &map, -void Model3DPointEntityFactory::addEntitiesForNotSelectedPoints( const Map3D &map, QgsVectorLayer *layer, const QgsPoint3DSymbol &symbol, PointEntity *parent ) +void QgsPoint3DSymbolModelEntityFactory::addEntitiesForNotSelectedPoints( const Map3D &map, QgsVectorLayer *layer, const QgsPoint3DSymbol &symbol, QgsPoint3DSymbolEntity *parent ) { // build the feature request to select features QgsFeatureRequest req; @@ -323,7 +323,7 @@ void Model3DPointEntityFactory::addEntitiesForNotSelectedPoints( const Map3D &ma } } -void Model3DPointEntityFactory::addSceneEntities( const Map3D &map, QgsVectorLayer *layer, const QgsFeatureRequest &req, const QgsPoint3DSymbol &symbol, PointEntity *parent ) +void QgsPoint3DSymbolModelEntityFactory::addSceneEntities( const Map3D &map, QgsVectorLayer *layer, const QgsFeatureRequest &req, const QgsPoint3DSymbol &symbol, QgsPoint3DSymbolEntity *parent ) { QList positions = Utils::positions( map, layer, req ); Q_FOREACH ( const QVector3D &position, positions ) @@ -341,7 +341,7 @@ void Model3DPointEntityFactory::addSceneEntities( const Map3D &map, QgsVectorLay } } -void Model3DPointEntityFactory::addMeshEntities( const Map3D &map, QgsVectorLayer *layer, const QgsFeatureRequest &req, const QgsPoint3DSymbol &symbol, PointEntity *parent, bool are_selected ) +void QgsPoint3DSymbolModelEntityFactory::addMeshEntities( const Map3D &map, QgsVectorLayer *layer, const QgsFeatureRequest &req, const QgsPoint3DSymbol &symbol, QgsPoint3DSymbolEntity *parent, bool are_selected ) { // build the default material Qt3DExtras::QPhongMaterial *mat = phongMaterial( symbol ); @@ -370,7 +370,7 @@ void Model3DPointEntityFactory::addMeshEntities( const Map3D &map, QgsVectorLaye } } -Qt3DCore::QTransform *Model3DPointEntityFactory::transform( const QVector3D &position, const QgsPoint3DSymbol &symbol ) +Qt3DCore::QTransform *QgsPoint3DSymbolModelEntityFactory::transform( const QVector3D &position, const QgsPoint3DSymbol &symbol ) { Qt3DCore::QTransform *tr = new Qt3DCore::QTransform; tr->setMatrix( symbol.transform() ); diff --git a/src/3d/symbols/qgspoint3dsymbol_p.h b/src/3d/symbols/qgspoint3dsymbol_p.h new file mode 100644 index 000000000000..f7a3d628b5c0 --- /dev/null +++ b/src/3d/symbols/qgspoint3dsymbol_p.h @@ -0,0 +1,68 @@ +#ifndef QGSPOINT3DSYMBOL_P_H +#define QGSPOINT3DSYMBOL_P_H + +/// @cond PRIVATE + +// +// W A R N I N G +// ------------- +// +// This file is not part of the QGIS API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// + +#include +#include +#include +#include + +class Map3D; +class QgsPoint3DSymbol; + +class QgsVectorLayer; +class QgsFeatureRequest; + + +//! Entity that handles rendering of points as 3D objects +class QgsPoint3DSymbolEntity : public Qt3DCore::QEntity +{ + public: + QgsPoint3DSymbolEntity( const Map3D &map, QgsVectorLayer *layer, const QgsPoint3DSymbol &symbol, Qt3DCore::QNode *parent = nullptr ); +}; + +class QgsPoint3DSymbolInstancedEntityFactory +{ + public: + static void addEntityForSelectedPoints( const Map3D &map, QgsVectorLayer *layer, const QgsPoint3DSymbol &symbol, QgsPoint3DSymbolEntity *parent ); + static void addEntityForNotSelectedPoints( const Map3D &map, QgsVectorLayer *layer, const QgsPoint3DSymbol &symbol, QgsPoint3DSymbolEntity *parent ); + + private: + static Qt3DRender::QMaterial *material( const QgsPoint3DSymbol &symbol ); +}; + +class QgsPoint3DSymbolInstancedEntityNode : public Qt3DCore::QEntity +{ + public: + QgsPoint3DSymbolInstancedEntityNode( const Map3D &map, QgsVectorLayer *layer, const QgsPoint3DSymbol &symbol, const QgsFeatureRequest &req, Qt3DCore::QNode *parent = nullptr ); + + private: + Qt3DRender::QGeometryRenderer *renderer( const QgsPoint3DSymbol &symbol, const QList &positions ) const; +}; + +class QgsPoint3DSymbolModelEntityFactory +{ + public: + static void addEntitiesForSelectedPoints( const Map3D &map, QgsVectorLayer *layer, const QgsPoint3DSymbol &symbol, QgsPoint3DSymbolEntity *parent ); + static void addEntitiesForNotSelectedPoints( const Map3D &map, QgsVectorLayer *layer, const QgsPoint3DSymbol &symbol, QgsPoint3DSymbolEntity *parent ); + + private: + static void addSceneEntities( const Map3D &map, QgsVectorLayer *layer, const QgsFeatureRequest &req, const QgsPoint3DSymbol &symbol, QgsPoint3DSymbolEntity *parent ); + static void addMeshEntities( const Map3D &map, QgsVectorLayer *layer, const QgsFeatureRequest &req, const QgsPoint3DSymbol &symbol, QgsPoint3DSymbolEntity *parent, bool are_selected ); + + static Qt3DCore::QTransform *transform( const QVector3D &position, const QgsPoint3DSymbol &symbol ); +}; + +/// @endcond + +#endif // QGSPOINT3DSYMBOL_P_H diff --git a/src/3d/polygonentity.cpp b/src/3d/symbols/qgspolygon3dsymbol_p.cpp similarity index 77% rename from src/3d/polygonentity.cpp rename to src/3d/symbols/qgspolygon3dsymbol_p.cpp index 5220c8b5a221..dc4a914d7aab 100644 --- a/src/3d/polygonentity.cpp +++ b/src/3d/symbols/qgspolygon3dsymbol_p.cpp @@ -1,4 +1,4 @@ -#include "polygonentity.h" +#include "qgspolygon3dsymbol_p.h" #include "qgspolygon3dsymbol.h" #include "polygongeometry.h" @@ -13,14 +13,14 @@ -PolygonEntity::PolygonEntity( const Map3D &map, QgsVectorLayer *layer, const QgsPolygon3DSymbol &symbol, Qt3DCore::QNode *parent ) +QgsPolygon3DSymbolEntity::QgsPolygon3DSymbolEntity( const Map3D &map, QgsVectorLayer *layer, const QgsPolygon3DSymbol &symbol, Qt3DCore::QNode *parent ) : Qt3DCore::QEntity( parent ) { addEntityForSelectedPolygons( map, layer, symbol ); addEntityForNotSelectedPolygons( map, layer, symbol ); } -void PolygonEntity::addEntityForSelectedPolygons( const Map3D &map, QgsVectorLayer *layer, const QgsPolygon3DSymbol &symbol ) +void QgsPolygon3DSymbolEntity::addEntityForSelectedPolygons( const Map3D &map, QgsVectorLayer *layer, const QgsPolygon3DSymbol &symbol ) { // build the default material Qt3DExtras::QPhongMaterial *mat = material( symbol ); @@ -39,13 +39,13 @@ void PolygonEntity::addEntityForSelectedPolygons( const Map3D &map, QgsVectorLay req.setFilterFids( layer->selectedFeatureIds() ); // build the entity - PolygonEntityNode *entity = new PolygonEntityNode( map, layer, symbol, req ); + QgsPolygon3DSymbolEntityNode *entity = new QgsPolygon3DSymbolEntityNode( map, layer, symbol, req ); entity->addComponent( mat ); entity->addComponent( tform ); entity->setParent( this ); } -void PolygonEntity::addEntityForNotSelectedPolygons( const Map3D &map, QgsVectorLayer *layer, const QgsPolygon3DSymbol &symbol ) +void QgsPolygon3DSymbolEntity::addEntityForNotSelectedPolygons( const Map3D &map, QgsVectorLayer *layer, const QgsPolygon3DSymbol &symbol ) { // build the default material Qt3DExtras::QPhongMaterial *mat = material( symbol ); @@ -63,13 +63,13 @@ void PolygonEntity::addEntityForNotSelectedPolygons( const Map3D &map, QgsVector req.setFilterFids( notSelected ); // build the entity - PolygonEntityNode *entity = new PolygonEntityNode( map, layer, symbol, req ); + QgsPolygon3DSymbolEntityNode *entity = new QgsPolygon3DSymbolEntityNode( map, layer, symbol, req ); entity->addComponent( mat ); entity->addComponent( tform ); entity->setParent( this ); } -Qt3DExtras::QPhongMaterial *PolygonEntity::material( const QgsPolygon3DSymbol &symbol ) const +Qt3DExtras::QPhongMaterial *QgsPolygon3DSymbolEntity::material( const QgsPolygon3DSymbol &symbol ) const { Qt3DExtras::QPhongMaterial *material = new Qt3DExtras::QPhongMaterial; material->setAmbient( symbol.material().ambient() ); @@ -79,13 +79,13 @@ Qt3DExtras::QPhongMaterial *PolygonEntity::material( const QgsPolygon3DSymbol &s return material; } -PolygonEntityNode::PolygonEntityNode( const Map3D &map, QgsVectorLayer *layer, const QgsPolygon3DSymbol &symbol, const QgsFeatureRequest &req, Qt3DCore::QNode *parent ) +QgsPolygon3DSymbolEntityNode::QgsPolygon3DSymbolEntityNode( const Map3D &map, QgsVectorLayer *layer, const QgsPolygon3DSymbol &symbol, const QgsFeatureRequest &req, Qt3DCore::QNode *parent ) : Qt3DCore::QEntity( parent ) { addComponent( renderer( map, symbol, layer, req ) ); } -Qt3DRender::QGeometryRenderer *PolygonEntityNode::renderer( const Map3D &map, const QgsPolygon3DSymbol &symbol, const QgsVectorLayer *layer, const QgsFeatureRequest &request ) +Qt3DRender::QGeometryRenderer *QgsPolygon3DSymbolEntityNode::renderer( const Map3D &map, const QgsPolygon3DSymbol &symbol, const QgsVectorLayer *layer, const QgsFeatureRequest &request ) { QgsPointXY origin( map.originX, map.originY ); QList polygons; diff --git a/src/3d/polygonentity.h b/src/3d/symbols/qgspolygon3dsymbol_p.h similarity index 51% rename from src/3d/polygonentity.h rename to src/3d/symbols/qgspolygon3dsymbol_p.h index c5b813429bcc..1339e8148b03 100644 --- a/src/3d/polygonentity.h +++ b/src/3d/symbols/qgspolygon3dsymbol_p.h @@ -1,5 +1,16 @@ -#ifndef POLYGONENTITY_H -#define POLYGONENTITY_H +#ifndef QGSPOLYGON3DSYMBOL_P_H +#define QGSPOLYGON3DSYMBOL_P_H + +/// @cond PRIVATE + +// +// W A R N I N G +// ------------- +// +// This file is not part of the QGIS API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// #include #include @@ -15,10 +26,10 @@ class QgsFeatureRequest; //! Entity that handles rendering of polygons -class PolygonEntity : public Qt3DCore::QEntity +class QgsPolygon3DSymbolEntity : public Qt3DCore::QEntity { public: - PolygonEntity( const Map3D &map, QgsVectorLayer *layer, const QgsPolygon3DSymbol &symbol, Qt3DCore::QNode *parent = nullptr ); + QgsPolygon3DSymbolEntity( const Map3D &map, QgsVectorLayer *layer, const QgsPolygon3DSymbol &symbol, Qt3DCore::QNode *parent = nullptr ); private: void addEntityForSelectedPolygons( const Map3D &map, QgsVectorLayer *layer, const QgsPolygon3DSymbol &symbol ); @@ -27,10 +38,10 @@ class PolygonEntity : public Qt3DCore::QEntity Qt3DExtras::QPhongMaterial *material( const QgsPolygon3DSymbol &symbol ) const; }; -class PolygonEntityNode : public Qt3DCore::QEntity +class QgsPolygon3DSymbolEntityNode : public Qt3DCore::QEntity { public: - PolygonEntityNode( const Map3D &map, QgsVectorLayer *layer, const QgsPolygon3DSymbol &symbol, const QgsFeatureRequest &req, Qt3DCore::QNode *parent = nullptr ); + QgsPolygon3DSymbolEntityNode( const Map3D &map, QgsVectorLayer *layer, const QgsPolygon3DSymbol &symbol, const QgsFeatureRequest &req, Qt3DCore::QNode *parent = nullptr ); private: Qt3DRender::QGeometryRenderer *renderer( const Map3D &map, const QgsPolygon3DSymbol &symbol, const QgsVectorLayer *layer, const QgsFeatureRequest &request ); @@ -38,4 +49,6 @@ class PolygonEntityNode : public Qt3DCore::QEntity PolygonGeometry *mGeometry; }; -#endif // POLYGONENTITY_H +/// @endcond + +#endif // QGSPOLYGON3DSYMBOL_P_H diff --git a/src/3d/vectorlayer3drenderer.cpp b/src/3d/vectorlayer3drenderer.cpp index c95d489de719..b21e596519cf 100644 --- a/src/3d/vectorlayer3drenderer.cpp +++ b/src/3d/vectorlayer3drenderer.cpp @@ -3,9 +3,9 @@ #include "qgsline3dsymbol.h" #include "qgspoint3dsymbol.h" #include "qgspolygon3dsymbol.h" -#include "lineentity.h" -#include "pointentity.h" -#include "polygonentity.h" +#include "qgsline3dsymbol_p.h" +#include "qgspoint3dsymbol_p.h" +#include "qgspolygon3dsymbol_p.h" #include "qgsvectorlayer.h" #include "qgsxmlutils.h" @@ -71,11 +71,11 @@ Qt3DCore::QEntity *VectorLayer3DRenderer::createEntity( const Map3D &map ) const return nullptr; if ( mSymbol->type() == "polygon" ) - return new PolygonEntity( map, vl, *static_cast( mSymbol.get() ) ); + return new QgsPolygon3DSymbolEntity( map, vl, *static_cast( mSymbol.get() ) ); else if ( mSymbol->type() == "point" ) - return new PointEntity( map, vl, *static_cast( mSymbol.get() ) ); + return new QgsPoint3DSymbolEntity( map, vl, *static_cast( mSymbol.get() ) ); else if ( mSymbol->type() == "line" ) - return new LineEntity( map, vl, *static_cast( mSymbol.get() ) ); + return new QgsLine3DSymbolEntity( map, vl, *static_cast( mSymbol.get() ) ); else return nullptr; }