mirror of
https://github.com/lucaspalomodevelop/meshlab.git
synced 2026-03-20 03:16:10 +00:00
added "append project to current" menu entry (first working draft), still have to define a policy for duplicated entries
This commit is contained in:
parent
974676ebde
commit
e93f57fb63
@ -79,6 +79,7 @@ private slots:
|
||||
public slots:
|
||||
bool importMesh(QString fileName=QString());
|
||||
bool openProject(QString fileName=QString());
|
||||
bool appendProject(QString fileName=QString());
|
||||
void updateCustomSettings();
|
||||
|
||||
private slots:
|
||||
@ -346,7 +347,7 @@ private:
|
||||
|
||||
//////////// Actions Menu File ///////////////////////
|
||||
QAction *newProjectAct;
|
||||
QAction *openProjectAct,*saveProjectAct,*saveProjectAsAct;
|
||||
QAction *openProjectAct, *appendProjectAct, *saveProjectAct, *saveProjectAsAct;
|
||||
QAction *importMeshAct, *exportMeshAct, *exportMeshAsAct;
|
||||
QAction *importRasterAct;
|
||||
QAction *closeProjectAct;
|
||||
|
||||
@ -119,6 +119,9 @@ void MainWindow::createActions()
|
||||
openProjectAct->setShortcut(Qt::CTRL+Qt::Key_O);
|
||||
connect(openProjectAct, SIGNAL(triggered()), this, SLOT(openProject()));
|
||||
|
||||
appendProjectAct = new QAction(tr("Append project to current..."), this);
|
||||
connect(appendProjectAct, SIGNAL(triggered()), this, SLOT(appendProject()));
|
||||
|
||||
saveProjectAct = new QAction(QIcon(":/images/save.png"),tr("&Save Project"), this);
|
||||
saveProjectAct->setShortcutContext(Qt::ApplicationShortcut);
|
||||
saveProjectAct->setShortcut(Qt::CTRL+Qt::Key_S);
|
||||
@ -468,6 +471,7 @@ void MainWindow::createMenus()
|
||||
fileMenu = menuBar()->addMenu(tr("&File"));
|
||||
fileMenu->addAction(newProjectAct);
|
||||
fileMenu->addAction(openProjectAct);
|
||||
fileMenu->addAction(appendProjectAct);
|
||||
fileMenu->addAction(saveProjectAct);
|
||||
fileMenu->addAction(closeProjectAct);
|
||||
fileMenu->addSeparator();
|
||||
|
||||
@ -1633,6 +1633,92 @@ bool MainWindow::openProject(QString fileName)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool MainWindow::appendProject(QString fileName)
|
||||
{
|
||||
QStringList fileNameList;
|
||||
|
||||
if (fileName.isEmpty())
|
||||
fileNameList = QFileDialog::getOpenFileNames(this,tr("Append Project File"), lastUsedDirectory.path(), "All Project Files (*.mlp *.aln);;MeshLab Project (*.mlp);;Align Project (*.aln)");
|
||||
else
|
||||
fileNameList.append(fileName);
|
||||
|
||||
if (fileNameList.isEmpty()) return false;
|
||||
|
||||
// Common Part: init a Doc if necessary, and
|
||||
bool activeDoc = (bool) !mdiarea->subWindowList().empty() && mdiarea->currentSubWindow();
|
||||
bool activeEmpty = activeDoc && meshDoc()->meshList.empty();
|
||||
|
||||
if (activeEmpty) // it is wrong to try appending to an empty project, even if it is possible
|
||||
{
|
||||
QMessageBox::critical(this, tr("Meshlab Opening Error"), "Current project is empty, cannot append");
|
||||
return false;
|
||||
}
|
||||
|
||||
meshDoc()->setBusy(true);
|
||||
|
||||
// load all projects
|
||||
foreach(fileName,fileNameList)
|
||||
{
|
||||
QFileInfo fi(fileName);
|
||||
lastUsedDirectory = fi.absoluteDir();
|
||||
|
||||
if((fi.suffix().toLower()!="aln") && (fi.suffix().toLower()!="mlp"))
|
||||
{
|
||||
QMessageBox::critical(this, tr("Meshlab Opening Error"), "Unknown project file extension");
|
||||
return false;
|
||||
}
|
||||
|
||||
// this change of dir is needed for subsequent textures/materials loading
|
||||
QDir::setCurrent(fi.absoluteDir().absolutePath());
|
||||
qb->show();
|
||||
|
||||
if (QString(fi.suffix()).toLower() == "aln")
|
||||
{
|
||||
vector<RangeMap> rmv;
|
||||
int retVal=ALNParser::ParseALN(rmv,qPrintable(fileName));
|
||||
if(retVal != ALNParser::NoError)
|
||||
{
|
||||
QMessageBox::critical(this, tr("Meshlab Opening Error"), "Unable to open ALN file");
|
||||
return false;
|
||||
}
|
||||
|
||||
bool openRes=true;
|
||||
vector<RangeMap>::iterator ir;
|
||||
for(ir=rmv.begin();ir!=rmv.end() && openRes;++ir)
|
||||
{
|
||||
QString relativeToProj = fi.absoluteDir().absolutePath() + "/" + (*ir).filename.c_str();
|
||||
meshDoc()->addNewMesh(relativeToProj,relativeToProj);
|
||||
loadMeshWithStandardParams(relativeToProj,this->meshDoc()->mm());
|
||||
if(openRes) meshDoc()->mm()->cm.Tr=(*ir).trasformation;
|
||||
}
|
||||
}
|
||||
|
||||
if (QString(fi.suffix()).toLower() == "mlp")
|
||||
{
|
||||
if (!MeshDocumentFromXML(*meshDoc(),fileName))
|
||||
{
|
||||
QMessageBox::critical(this, tr("Meshlab Opening Error"), "Unable to open MLP file");
|
||||
return false;
|
||||
}
|
||||
for (int i=0; i<meshDoc()->meshList.size(); i++)
|
||||
{
|
||||
QString fullPath = meshDoc()->meshList[i]->fullName();
|
||||
meshDoc()->setBusy(true);
|
||||
Matrix44f trm = this->meshDoc()->meshList[i]->cm.Tr; // save the matrix, because loadMeshClear it...
|
||||
loadMeshWithStandardParams(fullPath,this->meshDoc()->meshList[i]);
|
||||
this->meshDoc()->meshList[i]->cm.Tr=trm;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
meshDoc()->setBusy(false);
|
||||
if(this->GLA() == 0) return false;
|
||||
this->currentViewContainer()->resetAllTrackBall();
|
||||
qb->reset();
|
||||
saveRecentProjectList(fileName);
|
||||
return true;
|
||||
}
|
||||
|
||||
GLArea* MainWindow::newProject(const QString& projName)
|
||||
{
|
||||
filterMenu->setEnabled(!filterMenu->actions().isEmpty());
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user