Skip to content
Permalink
Browse files

Warning message for not parsed layers

  • Loading branch information
NEDJIMAbelgacem committed Jul 11, 2020
1 parent 8cb4315 commit 38b72ef545a808e48a4bf7063d3a22d02c6ae835
Showing with 27 additions and 10 deletions.
  1. +16 −5 src/3d/qgs3dmapscene.cpp
  2. +9 −3 src/3d/qgs3dsceneexporter.cpp
  3. +2 −2 src/3d/qgs3dsceneexporter.h
@@ -60,6 +60,7 @@
#include "qgs3dsceneexporter.h"
#include "qgsabstract3drenderer.h"
#include "qgs3dmapexportsettings.h"
#include "qgsmessageoutput.h"

Qgs3DMapScene::Qgs3DMapScene( const Qgs3DMapSettings &map, QgsAbstract3DEngine *engine )
: mMap( map )
@@ -769,6 +770,7 @@ void Qgs3DMapScene::updateSceneState()

void Qgs3DMapScene::exportScene( const Qgs3DMapExportSettings &exportSettings )
{
QVector<QString> notParsedLayers;
Qgs3DSceneExporter exporter;

exporter.setTerrainResolution( exportSettings.terrrainResolution() );
@@ -785,24 +787,33 @@ void Qgs3DMapScene::exportScene( const Qgs3DMapExportSettings &exportSettings )
switch ( layerType )
{
case QgsMapLayerType::VectorLayer:
exporter.parseVectorLayerEntity( rootEntity );
if ( !exporter.parseVectorLayerEntity( rootEntity ) )
notParsedLayers.push_back( layer->name() );
break;
case QgsMapLayerType::RasterLayer:
qDebug() << "Raster layer skipped";
notParsedLayers.push_back( layer->name() );
break;
case QgsMapLayerType::PluginLayer:
qDebug() << "Plugin layer skipped";
notParsedLayers.push_back( layer->name() );
break;
case QgsMapLayerType::MeshLayer: //!< Added in 3.2
qDebug() << "Mesh layer skipped";
notParsedLayers.push_back( layer->name() );
break;
case QgsMapLayerType::VectorTileLayer: //!< Added in 3.14
qDebug() << "Vector tile layer skipped";
notParsedLayers.push_back( layer->name() );
break;
}
}
if ( mTerrain != nullptr )
exporter.parseTerrain( mTerrain );

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

if ( notParsedLayers.size() != 0 )
{
QString message = "The following layers were not exported: \n";
for ( QString layerName : notParsedLayers )
message += layerName + "\n";
QgsMessageOutput::showMessage( "3D exporter warning", message, QgsMessageOutput::MessageText );
}
}
@@ -115,10 +115,11 @@ Qgs3DSceneExporter::Qgs3DSceneExporter( Qt3DCore::QNode *parent )

}

void Qgs3DSceneExporter::parseVectorLayerEntity( Qt3DCore::QEntity *entity )
bool Qgs3DSceneExporter::parseVectorLayerEntity( Qt3DCore::QEntity *entity )
{
if ( entity == nullptr )
return;
return false;
bool isValid = false;
// We iterate over every component and find components that represent a tessellated geometry
for ( Qt3DCore::QComponent *c : entity->components() )
{
@@ -131,6 +132,7 @@ void Qgs3DSceneExporter::parseVectorLayerEntity( Qt3DCore::QEntity *entity )
if ( tessellated != nullptr )
{
processPolygonGeometry( tessellated );
isValid = true;
continue;
}

@@ -141,8 +143,12 @@ void Qgs3DSceneExporter::parseVectorLayerEntity( Qt3DCore::QEntity *entity )
{
Qt3DCore::QEntity *childEntity = qobject_cast<Qt3DCore::QEntity *>( child );
if ( childEntity != nullptr )
parseVectorLayerEntity( childEntity );
{
bool validChild = parseVectorLayerEntity( childEntity );
isValid = isValid || validChild;
}
}
return isValid;
}

void Qgs3DSceneExporter::parseTerrain( QgsTerrainEntity *terrain )
@@ -47,9 +47,9 @@ class Qgs3DSceneExporter : public Qt3DCore::QEntity

/**
* Creates necessary export objects from entity if it represents valid vector layer entity
* If the entity doesn't define exportable object it will be ignored
* Returns false if the entity doesn't represent a vector layer
*/
void parseVectorLayerEntity( Qt3DCore::QEntity *entity );
bool parseVectorLayerEntity( Qt3DCore::QEntity *entity );
//! Creates terrain export objects from the terrain entity
void parseTerrain( QgsTerrainEntity *terrain );
//! Saves the scene to a .obj file

0 comments on commit 38b72ef

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