Skip to content

Commit

Permalink
Renaming and moving of 3D entities for 3D symbols
Browse files Browse the repository at this point in the history
  • Loading branch information
wonder-sk committed Sep 15, 2017
1 parent fc28a97 commit ff5ebe9
Show file tree
Hide file tree
Showing 9 changed files with 156 additions and 117 deletions.
12 changes: 6 additions & 6 deletions src/3d/CMakeLists.txt
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
55 changes: 0 additions & 55 deletions src/3d/pointentity.h

This file was deleted.

18 changes: 9 additions & 9 deletions src/3d/lineentity.cpp → src/3d/symbols/qgsline3dsymbol_p.cpp
@@ -1,4 +1,4 @@
#include "lineentity.h"
#include "qgsline3dsymbol_p.h"

#include "qgsline3dsymbol.h"
#include "polygongeometry.h"
Expand All @@ -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;

Expand All @@ -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 );
Expand All @@ -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 );
Expand All @@ -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 );

Expand Down
27 changes: 20 additions & 7 deletions src/3d/lineentity.h → 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 <Qt3DCore/QEntity>
#include <Qt3DExtras/QPhongMaterial>
Expand All @@ -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 );
Expand All @@ -26,15 +37,17 @@ 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 );

PolygonGeometry *mGeometry;
};

#endif // LINEENTITY_H
/// @endcond

#endif // QGSLINE3DSYMBOL_P_H
36 changes: 18 additions & 18 deletions src/3d/pointentity.cpp → src/3d/symbols/qgspoint3dsymbol_p.cpp
@@ -1,4 +1,4 @@
#include "pointentity.h"
#include "qgspoint3dsymbol_p.h"

#include <Qt3DRender/QAttribute>
#include <Qt3DRender/QBuffer>
Expand Down Expand Up @@ -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" );
Expand Down Expand Up @@ -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 );
Expand All @@ -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 );
Expand All @@ -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<QVector3D> pos = Utils::positions( map, layer, req );
addComponent( renderer( symbol, pos ) );
}

Qt3DRender::QGeometryRenderer *InstancedPointEntityNode::renderer( const QgsPoint3DSymbol &symbol, const QList<QVector3D> &positions ) const
Qt3DRender::QGeometryRenderer *QgsPoint3DSymbolInstancedEntityNode::renderer( const QgsPoint3DSymbol &symbol, const QList<QVector3D> &positions ) const
{
int count = positions.count();

Expand Down Expand Up @@ -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 );
Expand All @@ -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;
Expand All @@ -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<QVector3D> positions = Utils::positions( map, layer, req );
Q_FOREACH ( const QVector3D &position, positions )
Expand All @@ -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 );
Expand Down Expand Up @@ -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() );
Expand Down

0 comments on commit ff5ebe9

Please sign in to comment.