Skip to content

Commit

Permalink
qgs3dsceneexporter: Return save operation success state
Browse files Browse the repository at this point in the history
  • Loading branch information
ptitjano authored and lbartoletti committed Dec 18, 2024
1 parent 1600555 commit 04738f5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
9 changes: 5 additions & 4 deletions src/3d/qgs3dsceneexporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -808,11 +808,11 @@ Qgs3DExportObject *Qgs3DSceneExporter::processPoints( Qt3DCore::QEntity *entity,
return obj;
}

void Qgs3DSceneExporter::save( const QString &sceneName, const QString &sceneFolderPath, int precision )
bool Qgs3DSceneExporter::save( const QString &sceneName, const QString &sceneFolderPath, int precision )
{
if ( mObjects.isEmpty() )
{
return;
return false;
}

const QString objFilePath = QDir( sceneFolderPath ).filePath( sceneName + QStringLiteral( ".obj" ) );
Expand All @@ -822,13 +822,13 @@ void Qgs3DSceneExporter::save( const QString &sceneName, const QString &sceneFol
if ( !file.open( QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate ) )
{
QgsDebugError( QStringLiteral( "Scene can not be exported to '%1'. File access error." ).arg( objFilePath ) );
return;
return false;
}
QFile mtlFile( mtlFilePath );
if ( !mtlFile.open( QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate ) )
{
QgsDebugError( QStringLiteral( "Scene can not be exported to '%1'. File access error." ).arg( mtlFilePath ) );
return;
return false;
}

float maxfloat = std::numeric_limits<float>::max(), minFloat = std::numeric_limits<float>::lowest();
Expand Down Expand Up @@ -868,6 +868,7 @@ void Qgs3DSceneExporter::save( const QString &sceneName, const QString &sceneFol
}

QgsDebugMsgLevel( QStringLiteral( "Scene exported to '%1'" ).arg( objFilePath ), 2 );
return true;
}

QString Qgs3DSceneExporter::getObjectName( const QString &name )
Expand Down
7 changes: 5 additions & 2 deletions src/3d/qgs3dsceneexporter.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,11 @@ class _3D_EXPORT Qgs3DSceneExporter : public Qt3DCore::QEntity
//! Creates terrain export objects from the terrain entity
void parseTerrain( QgsTerrainEntity *terrain, const QString &layer );

//! Saves the scene to a .obj file
void save( const QString &sceneName, const QString &sceneFolderPath, int precision = 6 );
/**
* Saves the scene to a .obj file
* Returns FALSE if the operation failed
*/
bool save( const QString &sceneName, const QString &sceneFolderPath, int precision = 6 );

//! Sets whether the triangles will look smooth
void setSmoothEdges( bool smoothEdges ) { mSmoothEdges = smoothEdges; }
Expand Down

0 comments on commit 04738f5

Please sign in to comment.