Skip to content
Permalink
Browse files

erase inheritance from QObject

  • Loading branch information
NEDJIMAbelgacem committed Jul 27, 2020
1 parent 64f004b commit fd8c68c7d57d7f42377ab99243a533a6cf5fc61b
@@ -32,9 +32,8 @@ class QgsAbstractMaterialSettings;
* \ingroup 3d
* \since QGIS 3.16
*/
class Qgs3DExportObject : public QObject
class Qgs3DExportObject
{
Q_OBJECT
public:
//! The type of exported geometry
enum ObjectType
@@ -52,7 +51,7 @@ class Qgs3DExportObject : public QObject
* \param parent
* The parent QObject (we use this to delete the Qgs3DExportObject instance once the exporter instance is deallocated)
*/
Qgs3DExportObject( const QString &name, QObject *parent = nullptr ) : QObject( parent ), mName( name ) { }
Qgs3DExportObject( const QString &name ) : mName( name ) { }

//! Returns the object name
QString name() const { return mName; }
@@ -16,7 +16,7 @@
#include "qgs3dmapexportsettings.h"
#include "qgssettings.h"

Qgs3DMapExportSettings::Qgs3DMapExportSettings( QObject *parent ): QObject( parent )
Qgs3DMapExportSettings::Qgs3DMapExportSettings()
{
QgsSettings settings;
mSceneName = settings.value( QStringLiteral( "UI/last3DSceneExportName" ), QStringLiteral( "Scene" ) ).toString();
@@ -28,12 +28,11 @@
* \ingroup 3d
* \since QGIS 3.16
*/
class _3D_EXPORT Qgs3DMapExportSettings : public QObject
class _3D_EXPORT Qgs3DMapExportSettings
{
Q_OBJECT
public:
//! Constructor
Qgs3DMapExportSettings( QObject *parent = nullptr );
Qgs3DMapExportSettings();

//! destructor (save the export settings before deallocation)
~Qgs3DMapExportSettings();
@@ -899,14 +899,14 @@ void Qgs3DMapScene::exportScene( const Qgs3DMapExportSettings &exportSettings )
}
}

if ( mTerrain != nullptr )
if ( mTerrain )
exporter.parseTerrain( mTerrain, "Terrain" );

exporter.save( exportSettings.sceneName(), exportSettings.sceneFolderPath() );

if ( !notParsedLayers.empty() )
{
QString message = "The following layers were not exported: \n";
QString message = tr( "The following layers were not exported:" ) + "\n";
for ( const QString &layerName : notParsedLayers )
message += layerName + "\n";
QgsMessageOutput::showMessage( tr( "3D exporter warning" ), message, QgsMessageOutput::MessageText );
@@ -428,7 +428,7 @@ void Qgs3DSceneExporter::parseFlatTile( QgsTerrainTileEntity *tileEntity, const
QString objectNamePrefix = layerName;
if ( objectNamePrefix != QString() ) objectNamePrefix += QString();

Qgs3DExportObject *object = new Qgs3DExportObject( getObjectName( objectNamePrefix + QStringLiteral( "Flat_tile" ) ), this );
Qgs3DExportObject *object = new Qgs3DExportObject( getObjectName( objectNamePrefix + QStringLiteral( "Flat_tile" ) ) );
mObjects.push_back( object );

object->setSmoothEdges( mSmoothEdges );
@@ -483,7 +483,7 @@ void Qgs3DSceneExporter::parseDemTile( QgsTerrainTileEntity *tileEntity, const Q
QString objectNamePrefix = layerName;
if ( objectNamePrefix != QString() ) objectNamePrefix += QStringLiteral( "_" );

Qgs3DExportObject *object = new Qgs3DExportObject( getObjectName( layerName + QStringLiteral( "DEM_tile" ) ), this );
Qgs3DExportObject *object = new Qgs3DExportObject( getObjectName( layerName + QStringLiteral( "DEM_tile" ) ) );
mObjects.push_back( object );

object->setSmoothEdges( mSmoothEdges );
@@ -550,7 +550,7 @@ QVector<Qgs3DExportObject *> Qgs3DSceneExporter::processInstancedPointGeometry(
QVector<float> instancePosition = getAttributeData<float>( instanceDataAttribute, instancePositionBytes );
for ( int i = 0; i < instancePosition.size(); i += 3 )
{
Qgs3DExportObject *object = new Qgs3DExportObject( getObjectName( objectNamePrefix + QStringLiteral( "shape_geometry" ) ), this );
Qgs3DExportObject *object = new Qgs3DExportObject( getObjectName( objectNamePrefix + QStringLiteral( "shape_geometry" ) ) );
objects.push_back( object );
object->setupPositionCoordinates( positionData, 1.0f, QVector3D( instancePosition[i], instancePosition[i + 1], instancePosition[i + 2] ) );
object->setupFaces( indexData );
@@ -649,7 +649,7 @@ Qgs3DExportObject *Qgs3DSceneExporter::processGeometryRenderer( Qt3DRender::QGeo
return nullptr;
}

Qgs3DExportObject *object = new Qgs3DExportObject( getObjectName( objectNamePrefix + QStringLiteral( "mesh_geometry" ) ), this );
Qgs3DExportObject *object = new Qgs3DExportObject( getObjectName( objectNamePrefix + QStringLiteral( "mesh_geometry" ) ) );
object->setupPositionCoordinates( positionData, scale * sceneScale, translation + sceneTranslation );
object->setupFaces( indexData );

@@ -701,7 +701,7 @@ QVector<Qgs3DExportObject *> Qgs3DSceneExporter::processLines( Qt3DCore::QEntity
QVector<float> positionData = getAttributeData<float>( positionAttribute, vertexBytes );
QVector<uint> indexData = getIndexData( indexAttribute, indexBytes );

Qgs3DExportObject *exportObject = new Qgs3DExportObject( getObjectName( objectNamePrefix + QStringLiteral( "line" ) ), this );
Qgs3DExportObject *exportObject = new Qgs3DExportObject( getObjectName( objectNamePrefix + QStringLiteral( "line" ) ) );
exportObject->setType( Qgs3DExportObject::LineStrip );
exportObject->setupPositionCoordinates( positionData );
exportObject->setupLine( indexData );
@@ -727,7 +727,7 @@ Qgs3DExportObject *Qgs3DSceneExporter::processPoints( Qt3DCore::QEntity *entity,
QVector<float> positions = getAttributeData<float>( positionAttribute, positionBytes );
points << positions;
}
Qgs3DExportObject *obj = new Qgs3DExportObject( getObjectName( objectNamePrefix + QStringLiteral( "points" ) ), this );
Qgs3DExportObject *obj = new Qgs3DExportObject( getObjectName( objectNamePrefix + QStringLiteral( "points" ) ) );
obj->setType( Qgs3DExportObject::Points );
obj->setupPositionCoordinates( points );
return obj;
@@ -25,6 +25,8 @@
#include <QFile>
#include <QVector3D>

#include "qgs3dexportobject.h"

class QgsTessellatedPolygonGeometry;
class QgsTerrainTileEntity;
class QgsTerrainEntity;
@@ -48,10 +50,15 @@ class QgsMeshEntity;
*/
class Qgs3DSceneExporter : public Qt3DCore::QEntity
{
Q_OBJECT
public:
//! Constructor
Qgs3DSceneExporter( Qt3DCore::QNode *parent = nullptr ) : Qt3DCore::QEntity( parent ) { }
Qgs3DSceneExporter() { }
//! Destructor
~Qgs3DSceneExporter()
{
for ( Qgs3DExportObject *obj : mObjects )
delete obj;
}

/**
* Creates necessary export objects from entity if it represents valid vector layer entity

0 comments on commit fd8c68c

Please sign in to comment.
You can’t perform that action at this time.