From ea43bed1e15f8d3798ae98cd26a984541da4dd76 Mon Sep 17 00:00:00 2001 From: Paolo Cignoni cignoni Date: Wed, 21 Dec 2005 01:17:05 +0000 Subject: [PATCH] Better handling of errors residing inside opened file --- src/meshlab/mainwindow_RunTime.cpp | 27 +++++++++++---------------- src/meshlabplugins/meshio/meshio.cpp | 28 ++++++++++++++++++---------- 2 files changed, 29 insertions(+), 26 deletions(-) diff --git a/src/meshlab/mainwindow_RunTime.cpp b/src/meshlab/mainwindow_RunTime.cpp index 475181b3b..09f29e3c0 100644 --- a/src/meshlab/mainwindow_RunTime.cpp +++ b/src/meshlab/mainwindow_RunTime.cpp @@ -24,6 +24,9 @@ History $Log$ +Revision 1.52 2005/12/21 01:16:15 buzzelli +Better handling of errors residing inside opened file + Revision 1.51 2005/12/19 19:05:53 davide_portelli Now decorations in render menu are consistent when we have tiled windows. @@ -613,17 +616,16 @@ void MainWindow::open(QString fileName) // Opening files in a transparent form (IO plugins contribution is hidden to user) QStringList filters; - // HashTable storing all supported formats, preserving for each - // of them, the index of first plugin which is able to open it + // HashTable storing all supported formats togheter with + // the index of first plugin which is able to open it QHash allKnownFormats; LoadKnownFilters(filters, allKnownFormats); if (fileName.isEmpty()) fileName = QFileDialog::getOpenFileName(this,tr("Open File"),".", filters.join("\n")); - - if (fileName.isEmpty()) - return; + + if (fileName.isEmpty()) return; // this change of dir is needed for subsequent texture loading QString fileNameDir = fileName.left(fileName.lastIndexOf("/")); @@ -636,21 +638,13 @@ void MainWindow::open(QString fileName) QString extension = fileName; extension.remove(0, fileName.lastIndexOf('.')+1); - bool success = false; - + // retrieving corresponding IO plugin int idx = allKnownFormats[extension.toLower()]; - MeshIOInterface* pCurrentIOPlugin = meshIOPlugins[idx]; int mask = -1; - success = pCurrentIOPlugin->open(extension, fileName, *mm ,mask,QCallBack,this /*gla?*/); - - - if (!success) - { - QMessageBox::warning(this, tr("Error"),tr("Cannot load %1.").arg(fileName)); - delete mm; - } + if (!pCurrentIOPlugin->open(extension, fileName, *mm ,mask,QCallBack,this /*gla*/)) + delete mm; else{ GLArea *gla; gla=new GLArea(workspace); @@ -669,6 +663,7 @@ void MainWindow::open(QString fileName) GLA()->setTextureMode(GLW::TMPerWedgeMulti); } } + qb->hide(); } diff --git a/src/meshlabplugins/meshio/meshio.cpp b/src/meshlabplugins/meshio/meshio.cpp index 0ab97ea81..8965e7b8a 100644 --- a/src/meshlabplugins/meshio/meshio.cpp +++ b/src/meshlabplugins/meshio/meshio.cpp @@ -24,6 +24,9 @@ History $Log$ + Revision 1.31 2005/12/21 01:17:05 buzzelli + Better handling of errors residing inside opened file + Revision 1.30 2005/12/16 17:14:42 fmazzant added control file's extension @@ -140,7 +143,7 @@ bool ExtraMeshIOPlugin::open(const QString &formatName, QString &fileName,MeshMo QString FileNameDir = fileName.left(fileName.lastIndexOf("/")); QDir::setCurrent(FileNameDir); - QString errorMsgFormat = "Error encountered while loading file %1: %2"; + QString errorMsgFormat = "Error encountered while loading file %1:\n%2"; string filename = fileName.toUtf8().data(); if(formatName.toUpper() == tr("OBJ")) //if (format == tr("Import OBJ")) @@ -151,16 +154,15 @@ bool ExtraMeshIOPlugin::open(const QString &formatName, QString &fileName,MeshMo if(mask & vcg::ply::PLYMask::PM_WEDGTEXCOORD) { - //QMessageBox::information(parent, tr("OBJ Opening"), tr("Model has wedge text coords")); + qDebug("Has Wedge Text Coords\n"); m.cm.face.EnableWedgeTex(); } m.cm.face.EnableNormal(); - // load from disk int result = vcg::tri::io::ImporterOBJ::Open(m.cm, filename.c_str(), oi); if (result != vcg::tri::io::ImporterOBJ::E_NOERROR) { - QMessageBox::warning(parent, tr("OBJ Opening"), errorMsgFormat.arg(fileName, vcg::tri::io::ImporterOBJ::ErrorMsg(result))); + QMessageBox::warning(parent, tr("OBJ Opening Error"), errorMsgFormat.arg(fileName, vcg::tri::io::ImporterOBJ::ErrorMsg(result))); return false; } } @@ -182,16 +184,22 @@ bool ExtraMeshIOPlugin::open(const QString &formatName, QString &fileName,MeshMo int result = vcg::tri::io::ImporterPLY::Open(m.cm,filename.c_str(),cb); if (result != ::vcg::ply::E_NOERROR) { - // print error msg + QMessageBox::warning(parent, tr("PLY Opening Error"), errorMsgFormat.arg(fileName, vcg::tri::io::ImporterPLY::ErrorMsg(result))); return false; } } + else if (formatName.toUpper() == tr("OFF")) + { + } + else if (formatName.toUpper() == tr("STL")) + { + } + else if (formatName.toUpper() == tr("3DS")) + { + } - // update bounding box - vcg::tri::UpdateBounding::Box(m.cm); - - // update normals - vcg::tri::UpdateNormals::PerVertex(m.cm); + vcg::tri::UpdateBounding::Box(m.cm); // update bounding box + vcg::tri::UpdateNormals::PerVertex(m.cm); // update normals return true; }