Qt Viewer : Fixes for failed imports

Fix the UI when an import fail
pull/1664/head
Jean-Louis Boudrand 2017-12-28 13:55:41 +01:00
parent e5891e5a09
commit e030d374b9
2 changed files with 32 additions and 10 deletions

View File

@ -45,16 +45,16 @@ QTime time_begin = QTime::currentTime();
ui->leFileName->setText(pFileName.right(pFileName.length() - pFileName.lastIndexOf('/') - 1)); ui->leFileName->setText(pFileName.right(pFileName.length() - pFileName.lastIndexOf('/') - 1));
ui->lstLight->clear(); ui->lstLight->clear();
ui->lstCamera->clear(); ui->lstCamera->clear();
ui->cbxLighting->setChecked(true), mGLView->Lighting_Enable(); ui->cbxLighting->setChecked(true); mGLView->Lighting_Enable();
ui->cbxBBox->setChecked(false); mGLView->Enable_SceneBBox(false); ui->cbxBBox->setChecked(false); mGLView->Enable_SceneBBox(false);
ui->cbxTextures->setChecked(true), mGLView->Enable_Textures(true); ui->cbxTextures->setChecked(true); mGLView->Enable_Textures(true);
// //
// Fill info labels // Fill info labels
// //
// Cameras // Cameras
ui->lblCameraCount->setText(QString("%1").arg(mScene->mNumCameras)); ui->lblCameraCount->setText(QString::number(mScene->mNumCameras));
// Lights // Lights
ui->lblLightCount->setText(QString("%1").arg(mScene->mNumLights)); ui->lblLightCount->setText(QString::number(mScene->mNumLights));
// Meshes, faces, vertices. // Meshes, faces, vertices.
size_t qty_face = 0; size_t qty_face = 0;
size_t qty_vert = 0; size_t qty_vert = 0;
@ -65,9 +65,9 @@ QTime time_begin = QTime::currentTime();
qty_vert += mScene->mMeshes[idx_mesh]->mNumVertices; qty_vert += mScene->mMeshes[idx_mesh]->mNumVertices;
} }
ui->lblMeshCount->setText(QString("%1").arg(mScene->mNumMeshes)); ui->lblMeshCount->setText(QString::number(mScene->mNumMeshes));
ui->lblFaceCount->setText(QString("%1").arg(qty_face)); ui->lblFaceCount->setText(QString::number(qty_face));
ui->lblVertexCount->setText(QString("%1").arg(qty_vert)); ui->lblVertexCount->setText(QString::number(qty_vert));
// Animation // Animation
if(mScene->mNumAnimations) if(mScene->mNumAnimations)
ui->lblHasAnimation->setText("yes"); ui->lblHasAnimation->setText("yes");
@ -87,11 +87,26 @@ QTime time_begin = QTime::currentTime();
} }
else else
{ {
ui->lblLoadTime->clear(); ResetSceneInfos();
LogError(QString("Error parsing \'%1\' : \'%2\'").arg(pFileName).arg(mImporter.GetErrorString()));
QString errorMessage = QString("Error parsing \'%1\' : \'%2\'").arg(pFileName).arg(mImporter.GetErrorString();
QMessageBox::critical(this, "Import error", errorMessage);
LogError(errorMessage);
}// if(mScene != nullptr) }// if(mScene != nullptr)
} }
void MainWindow::ResetSceneInfos()
{
ui->lblLoadTime->clear();
ui->leFileName->clear();
ui->lblMeshCount->setText("0");
ui->lblFaceCount->setText("0");
ui->lblVertexCount->setText("0");
ui->lblCameraCount->setText("0");
ui->lblLightCount->setText("0");
ui->lblHasAnimation->setText("no");
}
/********************************************************************/ /********************************************************************/
/************************ Logging functions *************************/ /************************ Logging functions *************************/
/********************************************************************/ /********************************************************************/
@ -202,6 +217,8 @@ using namespace Assimp;
mLoggerView = new CLoggerView(ui->tbLog); mLoggerView = new CLoggerView(ui->tbLog);
DefaultLogger::create("", Logger::VERBOSE); DefaultLogger::create("", Logger::VERBOSE);
DefaultLogger::get()->attachStream(mLoggerView, DefaultLogger::Debugging | DefaultLogger::Info | DefaultLogger::Err | DefaultLogger::Warn); DefaultLogger::get()->attachStream(mLoggerView, DefaultLogger::Debugging | DefaultLogger::Info | DefaultLogger::Err | DefaultLogger::Warn);
ResetSceneInfos();
} }
MainWindow::~MainWindow() MainWindow::~MainWindow()

View File

@ -52,6 +52,11 @@ private:
/// \param [in] pFileName - path and name of the file. /// \param [in] pFileName - path and name of the file.
void ImportFile(const QString& pFileName); void ImportFile(const QString& pFileName);
/// \fn void ResetSceneInfos()
/// Reset informations about the scene
void ResetSceneInfos();
/********************************************************************/ /********************************************************************/
/************************ Logging functions *************************/ /************************ Logging functions *************************/
/********************************************************************/ /********************************************************************/