better load/save raster management

This commit is contained in:
alemuntoni 2021-05-31 18:10:26 +02:00
parent d7fd47abbe
commit 3fd2941c09
3 changed files with 7 additions and 12 deletions

View File

@ -181,7 +181,7 @@ void reloadMesh(
loadMesh(filename, ioPlugin, prePar, meshList, masks, cb);
}
void loadRaster(const QString& filename, MeshDocument& md, vcg::CallBackPos* cb)
void loadRaster(const QString& filename, RasterModel& rm, vcg::CallBackPos* cb)
{
QFileInfo fi(filename);
QString extension = fi.suffix();
@ -193,14 +193,7 @@ void loadRaster(const QString& filename, MeshDocument& md, vcg::CallBackPos* cb)
"Raster " + filename + " cannot be opened. Your MeshLab version "
"has not plugin to read " + extension + " file format.");
RasterModel *rm = md.addNewRaster();
try {
ioPlugin->openRaster(extension, filename, *rm, cb);
}
catch(const MLException& e){
md.delRaster(rm);
throw e;
}
ioPlugin->openRaster(extension, filename, rm, cb);
}
}

View File

@ -54,7 +54,7 @@ void reloadMesh(
void loadRaster(
const QString& filename,
MeshDocument& md,
RasterModel& rm,
vcg::CallBackPos *cb);
}

View File

@ -2125,11 +2125,12 @@ bool MainWindow::importRaster(const QString& fileImg)
allFileTime.start();
for(const QString& fileName : fileNameList) {
RasterModel *rm = nullptr;
try {
QElapsedTimer t;
t.start();
meshlab::loadRaster(fileName, *meshDoc(), QCallBack);
rm = meshDoc()->addNewRaster();
meshlab::loadRaster(fileName, *rm, QCallBack);
GLA()->Logf(0, "Opened raster %s in %i msec", qUtf8Printable(fileName), t.elapsed());
GLA()->resetTrackBall();
GLA()->fov = meshDoc()->rm()->shot.GetFovFromFocal();
@ -2140,6 +2141,7 @@ bool MainWindow::importRaster(const QString& fileImg)
GLA()->Logf(0,"All files opened in %i msec",allFileTime.elapsed());
}
catch(const MLException& e){
meshDoc()->delRaster(rm);
QMessageBox::warning(
this,
tr("Opening Failure"),