mirror of
https://github.com/lucaspalomodevelop/meshlab.git
synced 2026-03-15 17:14:39 +00:00
Better handling of errors residing inside opened file
This commit is contained in:
parent
a4f100227c
commit
ea43bed1e1
@ -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<QString, int> 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();
|
||||
}
|
||||
|
||||
|
||||
@ -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<CMeshO>::Open(m.cm, filename.c_str(), oi);
|
||||
if (result != vcg::tri::io::ImporterOBJ<CMeshO>::E_NOERROR)
|
||||
{
|
||||
QMessageBox::warning(parent, tr("OBJ Opening"), errorMsgFormat.arg(fileName, vcg::tri::io::ImporterOBJ<CMeshO>::ErrorMsg(result)));
|
||||
QMessageBox::warning(parent, tr("OBJ Opening Error"), errorMsgFormat.arg(fileName, vcg::tri::io::ImporterOBJ<CMeshO>::ErrorMsg(result)));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -182,16 +184,22 @@ bool ExtraMeshIOPlugin::open(const QString &formatName, QString &fileName,MeshMo
|
||||
int result = vcg::tri::io::ImporterPLY<CMeshO>::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<CMeshO>::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<CMeshO>::Box(m.cm);
|
||||
|
||||
// update normals
|
||||
vcg::tri::UpdateNormals<CMeshO>::PerVertex(m.cm);
|
||||
vcg::tri::UpdateBounding<CMeshO>::Box(m.cm); // update bounding box
|
||||
vcg::tri::UpdateNormals<CMeshO>::PerVertex(m.cm); // update normals
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user