From f6dc496bf5f078f6fcbf48c9f28841e2afeff610 Mon Sep 17 00:00:00 2001 From: Guido Ranzuglia granzuglia Date: Thu, 5 Dec 2013 10:08:49 +0000 Subject: [PATCH] - removed previous bug also for project referring missing mesh files --- src/meshlab/mainwindow_RunTime.cpp | 1888 ++++++++++++++-------------- 1 file changed, 951 insertions(+), 937 deletions(-) diff --git a/src/meshlab/mainwindow_RunTime.cpp b/src/meshlab/mainwindow_RunTime.cpp index 50f57f84e..2bbfd2f5a 100644 --- a/src/meshlab/mainwindow_RunTime.cpp +++ b/src/meshlab/mainwindow_RunTime.cpp @@ -107,8 +107,8 @@ void MainWindow::createStdPluginWnd() //stddialog->setAttribute(Qt::WA_DeleteOnClose,true); stddialog->setFloating(true); stddialog->hide(); - connect(GLA(),SIGNAL(glareaClosed()),this,SLOT(updateStdDialog())); - connect(GLA(),SIGNAL(glareaClosed()),stddialog,SLOT(closeClick())); + connect(GLA(),SIGNAL(glareaClosed()),this,SLOT(updateStdDialog())); + connect(GLA(),SIGNAL(glareaClosed()),stddialog,SLOT(closeClick())); } void MainWindow::createXMLStdPluginWnd() @@ -138,7 +138,7 @@ void MainWindow::updateStdDialog() { if(stddialog!=0){ if(GLA()!=0){ - if(stddialog->curModel != meshDoc()->mm()){ + if(stddialog->curModel != meshDoc()->mm()){ stddialog->curgla=0; // invalidate the curgla member that is no more valid. stddialog->close(); } @@ -193,42 +193,42 @@ void MainWindow::updateWindowMenu() // View From SUBmenu viewFromMenu = windowsMenu->addMenu(tr("&View from")); - foreach(QAction *ac, viewFromGroupAct->actions()) - viewFromMenu->addAction(ac); + foreach(QAction *ac, viewFromGroupAct->actions()) + viewFromMenu->addAction(ac); // View From File act windowsMenu->addAction(viewFromFileAct); - windowsMenu->addAction(viewFromMeshAct); - windowsMenu->addAction(viewFromRasterAct); + windowsMenu->addAction(viewFromMeshAct); + windowsMenu->addAction(viewFromRasterAct); // Copy and paste shot acts windowsMenu->addAction(copyShotToClipboardAct); windowsMenu->addAction(pasteShotFromClipboardAct); //Enabling the actions - MultiViewer_Container *mvc = currentViewContainer(); + MultiViewer_Container *mvc = currentViewContainer(); if(mvc) { setUnsplitAct->setEnabled(mvc->viewerCounter()>1); - GLArea* current = mvc->currentView(); - if(current) - { - setSplitHAct->setEnabled(current->size().height()/2 > current->minimumSizeHint().height()); - setSplitVAct->setEnabled(current->size().width()/2 > current->minimumSizeHint().width()); + GLArea* current = mvc->currentView(); + if(current) + { + setSplitHAct->setEnabled(current->size().height()/2 > current->minimumSizeHint().height()); + setSplitVAct->setEnabled(current->size().width()/2 > current->minimumSizeHint().width()); - linkViewersAct->setEnabled(currentViewContainer()->viewerCounter()>1); - if(currentViewContainer()->viewerCounter()==1) - linkViewersAct->setChecked(false); + linkViewersAct->setEnabled(currentViewContainer()->viewerCounter()>1); + if(currentViewContainer()->viewerCounter()==1) + linkViewersAct->setChecked(false); - windowsMenu->addSeparator(); - } + windowsMenu->addSeparator(); + } } } QList windows = mdiarea->subWindowList(); if(windows.size() > 0) - windowsMenu->addSeparator(); + windowsMenu->addSeparator(); int i=0; foreach(QWidget *w,windows) @@ -433,14 +433,14 @@ void MainWindow::updateMenus() switch (rendtmp.drawMode) { - case GLW::DMBox: renderBboxAct->setChecked(true); break; - case GLW::DMPoints: renderModePointsAct->setChecked(true); break; - case GLW::DMWire: renderModeWireAct->setChecked(true); break; - case GLW::DMFlat: renderModeFlatAct->setChecked(true); break; - case GLW::DMSmooth: renderModeSmoothAct->setChecked(true); break; - case GLW::DMFlatWire: renderModeFlatLinesAct->setChecked(true); break; - case GLW::DMHidden: renderModeHiddenLinesAct->setChecked(true); break; - default: break; + case GLW::DMBox: renderBboxAct->setChecked(true); break; + case GLW::DMPoints: renderModePointsAct->setChecked(true); break; + case GLW::DMWire: renderModeWireAct->setChecked(true); break; + case GLW::DMFlat: renderModeFlatAct->setChecked(true); break; + case GLW::DMSmooth: renderModeSmoothAct->setChecked(true); break; + case GLW::DMFlatWire: renderModeFlatLinesAct->setChecked(true); break; + case GLW::DMHidden: renderModeHiddenLinesAct->setChecked(true); break; + default: break; } foreach(QAction* ac,colorModeGroupAct->actions()) @@ -448,11 +448,11 @@ void MainWindow::updateMenus() switch (rendtmp.colorMode) { - case GLW::CMNone: colorModeNoneAct->setChecked(true); break; - case GLW::CMPerMesh: colorModePerMeshAct->setChecked(true); break; - case GLW::CMPerVert: colorModePerVertexAct->setChecked(true); break; - case GLW::CMPerFace: colorModePerFaceAct->setChecked(true); break; - default: break; + case GLW::CMNone: colorModeNoneAct->setChecked(true); break; + case GLW::CMPerMesh: colorModePerMeshAct->setChecked(true); break; + case GLW::CMPerVert: colorModePerVertexAct->setChecked(true); break; + case GLW::CMPerFace: colorModePerFaceAct->setChecked(true); break; + default: break; } backFaceCullAct->setChecked(rendtmp.backFaceCull); @@ -479,7 +479,7 @@ void MainWindow::updateMenus() // Then check the decorator enabled for the current mesh. if(GLA()->mm()) foreach (QAction *a, GLA()->iCurPerMeshDecoratorList()) - a ->setChecked(true); + a ->setChecked(true); } // if active else { @@ -521,20 +521,20 @@ void MainWindow::updateMenus() void MainWindow::setSplit(QAction *qa) { - MultiViewer_Container *mvc = currentViewContainer(); - if(mvc) - { - GLArea *glwClone=new GLArea(mvc, ¤tGlobalParams); - if(qa->text() == tr("&Horizontally")) - mvc->addView(glwClone, Qt::Vertical); - else if(qa->text() == tr("&Vertically")) - mvc->addView(glwClone, Qt::Horizontal); + MultiViewer_Container *mvc = currentViewContainer(); + if(mvc) + { + GLArea *glwClone=new GLArea(mvc, ¤tGlobalParams); + if(qa->text() == tr("&Horizontally")) + mvc->addView(glwClone, Qt::Vertical); + else if(qa->text() == tr("&Vertically")) + mvc->addView(glwClone, Qt::Horizontal); //The loading of the raster must be here if(GLA()->isRaster()){ glwClone->setIsRaster(true); - if(this->meshDoc()->rm()->id()>=0) - glwClone->loadRaster(this->meshDoc()->rm()->id()); + if(this->meshDoc()->rm()->id()>=0) + glwClone->loadRaster(this->meshDoc()->rm()->id()); } updateMenus(); @@ -547,12 +547,12 @@ void MainWindow::setSplit(QAction *qa) void MainWindow::setUnsplit() { - MultiViewer_Container *mvc = currentViewContainer(); - if(mvc) - { - assert(mvc->viewerCounter() >1); + MultiViewer_Container *mvc = currentViewContainer(); + if(mvc) + { + assert(mvc->viewerCounter() >1); - mvc->removeView(mvc->currentView()->getId()); + mvc->removeView(mvc->currentView()->getId()); updateMenus(); } @@ -561,99 +561,99 @@ void MainWindow::setUnsplit() //set the split/unsplit menu that appears right clicking on a splitter's handle void MainWindow::setHandleMenu(QPoint point, Qt::Orientation orientation, QSplitter *origin){ MultiViewer_Container *mvc = currentViewContainer(); - int epsilon =10; - splitMenu->clear(); - unSplitMenu->clear(); - //the viewer to split/unsplit is chosen through picking + int epsilon =10; + splitMenu->clear(); + unSplitMenu->clear(); + //the viewer to split/unsplit is chosen through picking - //Vertical handle allows to split horizontally - if(orientation == Qt::Vertical) - { - splitUpAct->setData(point); - splitDownAct->setData(point); + //Vertical handle allows to split horizontally + if(orientation == Qt::Vertical) + { + splitUpAct->setData(point); + splitDownAct->setData(point); - //check if the viewer on the top is splittable according to its size - int pickingId = mvc->getViewerByPicking(QPoint(point.x(), point.y()-epsilon)); - if(pickingId>=0) - splitUpAct->setEnabled(mvc->getViewer(pickingId)->size().width()/2 > mvc->getViewer(pickingId)->minimumSizeHint().width()); + //check if the viewer on the top is splittable according to its size + int pickingId = mvc->getViewerByPicking(QPoint(point.x(), point.y()-epsilon)); + if(pickingId>=0) + splitUpAct->setEnabled(mvc->getViewer(pickingId)->size().width()/2 > mvc->getViewer(pickingId)->minimumSizeHint().width()); - //the viewer on top can be closed only if the splitter over the handle that orginated the event has one child - bool unSplittabilityUp = true; - Splitter * upSplitter = qobject_cast(origin->widget(0)); - if(upSplitter) - unSplittabilityUp = !(upSplitter->count()>1); - unsplitUpAct->setEnabled(unSplittabilityUp); + //the viewer on top can be closed only if the splitter over the handle that orginated the event has one child + bool unSplittabilityUp = true; + Splitter * upSplitter = qobject_cast(origin->widget(0)); + if(upSplitter) + unSplittabilityUp = !(upSplitter->count()>1); + unsplitUpAct->setEnabled(unSplittabilityUp); - //check if the viewer below is splittable according to its size - pickingId = mvc->getViewerByPicking(QPoint(point.x(), point.y()+epsilon)); - if(pickingId>=0) - splitDownAct->setEnabled(mvc->getViewer(pickingId)->size().width()/2 > mvc->getViewer(pickingId)->minimumSizeHint().width()); + //check if the viewer below is splittable according to its size + pickingId = mvc->getViewerByPicking(QPoint(point.x(), point.y()+epsilon)); + if(pickingId>=0) + splitDownAct->setEnabled(mvc->getViewer(pickingId)->size().width()/2 > mvc->getViewer(pickingId)->minimumSizeHint().width()); - //the viewer below can be closed only if the splitter ounder the handle that orginated the event has one child - bool unSplittabilityDown = true; - Splitter * downSplitter = qobject_cast(origin->widget(1)); - if(downSplitter) - unSplittabilityDown = !(downSplitter->count()>1); - unsplitDownAct->setEnabled(unSplittabilityDown); + //the viewer below can be closed only if the splitter ounder the handle that orginated the event has one child + bool unSplittabilityDown = true; + Splitter * downSplitter = qobject_cast(origin->widget(1)); + if(downSplitter) + unSplittabilityDown = !(downSplitter->count()>1); + unsplitDownAct->setEnabled(unSplittabilityDown); - splitMenu->addAction(splitUpAct); - splitMenu->addAction(splitDownAct); + splitMenu->addAction(splitUpAct); + splitMenu->addAction(splitDownAct); - unsplitUpAct->setData(point); - unsplitDownAct->setData(point); + unsplitUpAct->setData(point); + unsplitDownAct->setData(point); - unSplitMenu->addAction(unsplitUpAct); - unSplitMenu->addAction(unsplitDownAct); - } - //Horizontal handle allows to split vertically - else if (orientation == Qt::Horizontal) - { - splitRightAct->setData(point); - splitLeftAct->setData(point); + unSplitMenu->addAction(unsplitUpAct); + unSplitMenu->addAction(unsplitDownAct); + } + //Horizontal handle allows to split vertically + else if (orientation == Qt::Horizontal) + { + splitRightAct->setData(point); + splitLeftAct->setData(point); - //check if the viewer on the right is splittable according to its size - int pickingId =mvc->getViewerByPicking(QPoint(point.x()+epsilon, point.y())); - if(pickingId>=0) - splitRightAct->setEnabled(mvc->getViewer(pickingId)->size().height()/2 > mvc->getViewer(pickingId)->minimumSizeHint().height()); + //check if the viewer on the right is splittable according to its size + int pickingId =mvc->getViewerByPicking(QPoint(point.x()+epsilon, point.y())); + if(pickingId>=0) + splitRightAct->setEnabled(mvc->getViewer(pickingId)->size().height()/2 > mvc->getViewer(pickingId)->minimumSizeHint().height()); - //the viewer on the rigth can be closed only if the splitter on the right the handle that orginated the event has one child - bool unSplittabilityRight = true; - Splitter * rightSplitter = qobject_cast(origin->widget(1)); - if(rightSplitter) - unSplittabilityRight = !(rightSplitter->count()>1); - unsplitRightAct->setEnabled(unSplittabilityRight); + //the viewer on the rigth can be closed only if the splitter on the right the handle that orginated the event has one child + bool unSplittabilityRight = true; + Splitter * rightSplitter = qobject_cast(origin->widget(1)); + if(rightSplitter) + unSplittabilityRight = !(rightSplitter->count()>1); + unsplitRightAct->setEnabled(unSplittabilityRight); - //check if the viewer on the left is splittable according to its size - pickingId =mvc->getViewerByPicking(QPoint(point.x()-epsilon, point.y())); - if(pickingId>=0) - splitLeftAct->setEnabled(mvc->getViewer(pickingId)->size().height()/2 > mvc->getViewer(pickingId)->minimumSizeHint().height()); + //check if the viewer on the left is splittable according to its size + pickingId =mvc->getViewerByPicking(QPoint(point.x()-epsilon, point.y())); + if(pickingId>=0) + splitLeftAct->setEnabled(mvc->getViewer(pickingId)->size().height()/2 > mvc->getViewer(pickingId)->minimumSizeHint().height()); - //the viewer on the left can be closed only if the splitter on the left of the handle that orginated the event has one child - bool unSplittabilityLeft = true; - Splitter * leftSplitter = qobject_cast(origin->widget(0)); - if(leftSplitter) - unSplittabilityLeft = !(leftSplitter->count()>1); - unsplitLeftAct->setEnabled(unSplittabilityLeft); + //the viewer on the left can be closed only if the splitter on the left of the handle that orginated the event has one child + bool unSplittabilityLeft = true; + Splitter * leftSplitter = qobject_cast(origin->widget(0)); + if(leftSplitter) + unSplittabilityLeft = !(leftSplitter->count()>1); + unsplitLeftAct->setEnabled(unSplittabilityLeft); - splitMenu->addAction(splitRightAct); - splitMenu->addAction(splitLeftAct); + splitMenu->addAction(splitRightAct); + splitMenu->addAction(splitLeftAct); - unsplitRightAct->setData(point); - unsplitLeftAct->setData(point); + unsplitRightAct->setData(point); + unsplitLeftAct->setData(point); - unSplitMenu->addAction(unsplitRightAct); - unSplitMenu->addAction(unsplitLeftAct); - } + unSplitMenu->addAction(unsplitRightAct); + unSplitMenu->addAction(unsplitLeftAct); + } - handleMenu->popup(point); + handleMenu->popup(point); } void MainWindow::splitFromHandle(QAction *qa ) { - MultiViewer_Container *mvc = currentViewContainer(); - QPoint point = qa->data().toPoint(); - int epsilon =10; + MultiViewer_Container *mvc = currentViewContainer(); + QPoint point = qa->data().toPoint(); + int epsilon =10; if(qa->text() == tr("&Right")) point.setX(point.x()+ epsilon); @@ -678,7 +678,7 @@ void MainWindow::splitFromHandle(QAction *qa ) void MainWindow::unsplitFromHandle(QAction * qa) { - MultiViewer_Container *mvc = currentViewContainer(); + MultiViewer_Container *mvc = currentViewContainer(); QPoint point = qa->data().toPoint(); int epsilon =10; @@ -700,43 +700,43 @@ void MainWindow::unsplitFromHandle(QAction * qa) void MainWindow::linkViewers() { - MultiViewer_Container *mvc = currentViewContainer(); - mvc->updateTrackballInViewers(); + MultiViewer_Container *mvc = currentViewContainer(); + mvc->updateTrackballInViewers(); } void MainWindow::viewFrom(QAction *qa) { - if(GLA()) GLA()->createOrthoView(qa->text()); + if(GLA()) GLA()->createOrthoView(qa->text()); } void MainWindow::readViewFromFile() { - if(GLA()) GLA()->viewFromFile(); - updateMenus(); + if(GLA()) GLA()->viewFromFile(); + updateMenus(); } void MainWindow::viewFromCurrentMeshShot() { - if(GLA()) GLA()->viewFromCurrentShot("Mesh"); - updateMenus(); + if(GLA()) GLA()->viewFromCurrentShot("Mesh"); + updateMenus(); } void MainWindow::viewFromCurrentRasterShot() { - if(GLA()) GLA()->viewFromCurrentShot("Raster"); - updateMenus(); + if(GLA()) GLA()->viewFromCurrentShot("Raster"); + updateMenus(); } void MainWindow::copyViewToClipBoard() { - if(GLA()) GLA()->viewToClipboard(); + if(GLA()) GLA()->viewToClipboard(); } void MainWindow::pasteViewFromClipboard() { - if(GLA()) GLA()->viewFromClipboard(); - updateMenus(); + if(GLA()) GLA()->viewFromClipboard(); + updateMenus(); } void MainWindow::dragEnterEvent(QDragEnterEvent *event) @@ -747,76 +747,76 @@ void MainWindow::dragEnterEvent(QDragEnterEvent *event) void MainWindow::dropEvent ( QDropEvent * event ) { - //qDebug("dropEvent: %s",event->format()); - const QMimeData * data = event->mimeData(); - if (data->hasUrls()) - { - QList< QUrl > url_list = data->urls(); - for (int i=0, size=url_list.size(); ikeyboardModifiers () == Qt::ControlModifier ) || ( QApplication::keyboardModifiers () == Qt::ControlModifier )) - { - this->newProject(); - } + //qDebug("dropEvent: %s",event->format()); + const QMimeData * data = event->mimeData(); + if (data->hasUrls()) + { + QList< QUrl > url_list = data->urls(); + for (int i=0, size=url_list.size(); ikeyboardModifiers () == Qt::ControlModifier ) || ( QApplication::keyboardModifiers () == Qt::ControlModifier )) + { + this->newProject(); + } - if(path.endsWith("mlp",Qt::CaseInsensitive) || path.endsWith("aln",Qt::CaseInsensitive)) - openProject(path); - else - importMesh(path); + if(path.endsWith("mlp",Qt::CaseInsensitive) || path.endsWith("aln",Qt::CaseInsensitive)) + openProject(path); + else + importMesh(path); + } } - } } void MainWindow::delCurrentMesh() { - //MeshDoc accessed through current container - currentViewContainer()->meshDoc.delMesh(currentViewContainer()->meshDoc.mm()); - currentViewContainer()->updateAllViewer(); - updateMenus(); + //MeshDoc accessed through current container + currentViewContainer()->meshDoc.delMesh(currentViewContainer()->meshDoc.mm()); + currentViewContainer()->updateAllViewer(); + updateMenus(); } void MainWindow::delCurrentRaster() { - //MeshDoc accessed through current container - currentViewContainer()->meshDoc.delRaster(currentViewContainer()->meshDoc.rm()); - updateMenus(); + //MeshDoc accessed through current container + currentViewContainer()->meshDoc.delRaster(currentViewContainer()->meshDoc.rm()); + updateMenus(); } void MainWindow::endEdit() { - GLA()->endEdit(); + GLA()->endEdit(); } void MainWindow::applyLastFilter() { - if(GLA()==0) return; - GLA()->getLastAppliedFilter()->activate(QAction::Trigger); + if(GLA()==0) return; + GLA()->getLastAppliedFilter()->activate(QAction::Trigger); } void MainWindow::showFilterScript() { - FilterScriptDialog dialog(this); - dialog.setScript(&(meshDoc()->filterHistory)); - if (dialog.exec()==QDialog::Accepted) - { - runFilterScript(); - return ; - } + FilterScriptDialog dialog(this); + dialog.setScript(&(meshDoc()->filterHistory)); + if (dialog.exec()==QDialog::Accepted) + { + runFilterScript(); + return ; + } } void MainWindow::runFilterScript() { - FilterScript::iterator ii; - for(ii= meshDoc()->filterHistory.actionList.begin();ii!= meshDoc()->filterHistory.actionList.end();++ii) - { - QAction *action = PM.actionFilterMap[ (*ii).first]; - MeshFilterInterface *iFilter = qobject_cast(action->parent()); + FilterScript::iterator ii; + for(ii= meshDoc()->filterHistory.actionList.begin();ii!= meshDoc()->filterHistory.actionList.end();++ii) + { + QAction *action = PM.actionFilterMap[ (*ii).first]; + MeshFilterInterface *iFilter = qobject_cast(action->parent()); - int req=iFilter->getRequirements(action); - meshDoc()->mm()->updateDataMask(req); - iFilter->setLog(&meshDoc()->Log); + int req=iFilter->getRequirements(action); + meshDoc()->mm()->updateDataMask(req); + iFilter->setLog(&meshDoc()->Log); - RichParameterSet ¶meterSet = (*ii).second; + RichParameterSet ¶meterSet = (*ii).second; for(int i = 0; i < parameterSet.paramList.size(); i++) { @@ -827,52 +827,52 @@ void MainWindow::runFilterScript() if(parameter->val->isMesh()) { MeshDecoration* md = reinterpret_cast(parameter->pd); - if( md->meshindex < meshDoc()->size() && + if( md->meshindex < meshDoc()->size() && md->meshindex >= 0 ) { - RichMesh* rmesh = new RichMesh(parameter->name,meshDoc()->getMesh(md->meshindex),meshDoc()); + RichMesh* rmesh = new RichMesh(parameter->name,meshDoc()->getMesh(md->meshindex),meshDoc()); parameterSet.paramList.replace(i,rmesh); } else { - printf("Meshes loaded: %i, meshes asked for: %i \n", meshDoc()->size(), md->meshindex ); + printf("Meshes loaded: %i, meshes asked for: %i \n", meshDoc()->size(), md->meshindex ); printf("One of the filters in the script needs more meshes than you have loaded.\n"); exit(-1); } delete parameter; } } - //iFilter->applyFilter( action, *(meshDoc()->mm()), (*ii).second, QCallBack ); + //iFilter->applyFilter( action, *(meshDoc()->mm()), (*ii).second, QCallBack ); //WARNING!!!!!!!!!!!! /* to be changed */ - iFilter->applyFilter( action, *meshDoc(), (*ii).second, QCallBack ); + iFilter->applyFilter( action, *meshDoc(), (*ii).second, QCallBack ); if(iFilter->getClass(action) & MeshFilterInterface::FaceColoring ) { GLA()->setColorMode(vcg::GLW::CMPerFace); - meshDoc()->mm()->updateDataMask(MeshModel::MM_FACECOLOR); + meshDoc()->mm()->updateDataMask(MeshModel::MM_FACECOLOR); } if(iFilter->getClass(action) & MeshFilterInterface::VertexColoring ){ GLA()->setColorMode(vcg::GLW::CMPerVert); - meshDoc()->mm()->updateDataMask(MeshModel::MM_VERTCOLOR); + meshDoc()->mm()->updateDataMask(MeshModel::MM_VERTCOLOR); } if(iFilter->postCondition(action) & MeshModel::MM_COLOR) { GLA()->setColorMode(vcg::GLW::CMPerMesh); - meshDoc()->mm()->updateDataMask(MeshModel::MM_COLOR); + meshDoc()->mm()->updateDataMask(MeshModel::MM_COLOR); } if(iFilter->getClass(action) & MeshFilterInterface::Selection ) - { - GLA()->setSelectFaceRendering(true); - GLA()->setSelectVertRendering(true); - } + { + GLA()->setSelectFaceRendering(true); + GLA()->setSelectVertRendering(true); + } if(iFilter->postCondition(action) & MeshModel::MM_CAMERA) - meshDoc()->mm()->updateDataMask(MeshModel::MM_CAMERA); + meshDoc()->mm()->updateDataMask(MeshModel::MM_CAMERA); if(iFilter->getClass(action) & MeshFilterInterface::MeshCreation ) GLA()->resetTrackBall(); /* to be changed */ - GLA()->Logf(GLLogStream::SYSTEM,"Re-Applied filter %s",qPrintable((*ii).first)); + GLA()->Logf(GLLogStream::SYSTEM,"Re-Applied filter %s",qPrintable((*ii).first)); } } @@ -882,8 +882,8 @@ void MainWindow::runFilterScript() // hand side of the menu entry (not invasive) void MainWindow::showTooltip(QAction* q) { - QString tip = q->toolTip(); - QToolTip::showText(QCursor::pos(), tip); + QString tip = q->toolTip(); + QToolTip::showText(QCursor::pos(), tip); } // ///////////////////////////////////////////////// @@ -918,36 +918,36 @@ void MainWindow::startFilter() // GLA()->meshDoc->addNewMesh("",iFilter->filterName(action) ); //} //else - if (!iFilter->isFilterApplicable(action,(*meshDoc()->mm()),missingPreconditions)) - { - QString enstr = missingPreconditions.join(","); - QMessageBox::warning(0, tr("PreConditions' Failure"), QString("Warning the filter '" + iFilter->filterName(action) + "' has not been applied.
" - "Current mesh does not have " + enstr + ".")); - return; - } + if (!iFilter->isFilterApplicable(action,(*meshDoc()->mm()),missingPreconditions)) + { + QString enstr = missingPreconditions.join(","); + QMessageBox::warning(0, tr("PreConditions' Failure"), QString("Warning the filter '" + iFilter->filterName(action) + "' has not been applied.
" + "Current mesh does not have " + enstr + ".")); + return; + } - if(currentViewContainer()) - { - iFilter->setLog(currentViewContainer()->LogPtr()); - currentViewContainer()->LogPtr()->SetBookmark(); - } - // just to be sure... - createStdPluginWnd(); + if(currentViewContainer()) + { + iFilter->setLog(currentViewContainer()->LogPtr()); + currentViewContainer()->LogPtr()->SetBookmark(); + } + // just to be sure... + createStdPluginWnd(); - if (xmldialog != NULL) - { - xmldialog->close(); - delete xmldialog; - xmldialog = NULL; - } - // (2) Ask for filter parameters and eventally directly invoke the filter - // showAutoDialog return true if a dialog have been created (and therefore the execution is demanded to the apply event) - // if no dialog is created the filter must be executed immediately - if(! stddialog->showAutoDialog(iFilter, meshDoc()->mm(), (meshDoc()), action, this, GLA()) ) - { - RichParameterSet dummyParSet; - executeFilter(action, dummyParSet, false); - } + if (xmldialog != NULL) + { + xmldialog->close(); + delete xmldialog; + xmldialog = NULL; + } + // (2) Ask for filter parameters and eventally directly invoke the filter + // showAutoDialog return true if a dialog have been created (and therefore the execution is demanded to the apply event) + // if no dialog is created the filter must be executed immediately + if(! stddialog->showAutoDialog(iFilter, meshDoc()->mm(), (meshDoc()), action, this, GLA()) ) + { + RichParameterSet dummyParSet; + executeFilter(action, dummyParSet, false); + } } else // NEW XML PHILOSOPHY { @@ -960,8 +960,8 @@ void MainWindow::startFilter() QStringList filterClassesList = filterClasses.split(QRegExp("\\W+"), QString::SkipEmptyParts); if(filterClassesList.contains("MeshCreation")) { - qDebug("MeshCreation"); - meshDoc()->addNewMesh("","untitled.ply"); + qDebug("MeshCreation"); + meshDoc()->addNewMesh("","untitled.ply"); } else { @@ -972,7 +972,7 @@ void MainWindow::startFilter() { QString enstr = missingPreconditions.join(","); QMessageBox::warning(0, tr("PreConditions' Failure"), QString("Warning the filter '" + fname + "' has not been applied.
" - "Current mesh does not have " + enstr + ".")); + "Current mesh does not have " + enstr + ".")); return; } } @@ -1044,108 +1044,108 @@ void MainWindow::startFilter() } /* - callback function that actually start the chosen filter. - it is called once the parameters have been filled. - It can be called - from the automatic dialog - from the user defined dialog +callback function that actually start the chosen filter. +it is called once the parameters have been filled. +It can be called +from the automatic dialog +from the user defined dialog */ void MainWindow::executeFilter(QAction *action, RichParameterSet ¶ms, bool isPreview) { - MeshFilterInterface *iFilter = qobject_cast< MeshFilterInterface *>(action->parent()); + MeshFilterInterface *iFilter = qobject_cast< MeshFilterInterface *>(action->parent()); - qb->show(); - iFilter->setLog(&meshDoc()->Log); + qb->show(); + iFilter->setLog(&meshDoc()->Log); - // Ask for filter requirements (eg a filter can need topology, border flags etc) - // and statisfy them - qApp->setOverrideCursor(QCursor(Qt::WaitCursor)); - MainWindow::globalStatusBar()->showMessage("Starting Filter...",5000); - int req=iFilter->getRequirements(action); - if (!meshDoc()->meshList.isEmpty()) - meshDoc()->mm()->updateDataMask(req); - qApp->restoreOverrideCursor(); + // Ask for filter requirements (eg a filter can need topology, border flags etc) + // and statisfy them + qApp->setOverrideCursor(QCursor(Qt::WaitCursor)); + MainWindow::globalStatusBar()->showMessage("Starting Filter...",5000); + int req=iFilter->getRequirements(action); + if (!meshDoc()->meshList.isEmpty()) + meshDoc()->mm()->updateDataMask(req); + qApp->restoreOverrideCursor(); - // (3) save the current filter and its parameters in the history - if(!isPreview) - { - meshDoc()->filterHistory.actionList.append(qMakePair(action->text(),params)); - meshDoc()->Log.ClearBookmark(); - } - else - meshDoc()->Log.BackToBookmark(); - // (4) Apply the Filter - bool ret; - qApp->setOverrideCursor(QCursor(Qt::WaitCursor)); - QTime tt; tt.start(); - meshDoc()->setBusy(true); - RichParameterSet MergedEnvironment(params); - MergedEnvironment.join(currentGlobalParams); + // (3) save the current filter and its parameters in the history + if(!isPreview) + { + meshDoc()->filterHistory.actionList.append(qMakePair(action->text(),params)); + meshDoc()->Log.ClearBookmark(); + } + else + meshDoc()->Log.BackToBookmark(); + // (4) Apply the Filter + bool ret; + qApp->setOverrideCursor(QCursor(Qt::WaitCursor)); + QTime tt; tt.start(); + meshDoc()->setBusy(true); + RichParameterSet MergedEnvironment(params); + MergedEnvironment.join(currentGlobalParams); - //GLA() is only the parent - QGLWidget* filterWidget = new QGLWidget(GLA()); - QGLFormat defForm = QGLFormat::defaultFormat(); - iFilter->glContext = new QGLContext(defForm,filterWidget->context()->device()); - iFilter->glContext->create(filterWidget->context()); - try - { - ret=iFilter->applyFilter(action, *(meshDoc()), MergedEnvironment, QCallBack); + //GLA() is only the parent + QGLWidget* filterWidget = new QGLWidget(GLA()); + QGLFormat defForm = QGLFormat::defaultFormat(); + iFilter->glContext = new QGLContext(defForm,filterWidget->context()->device()); + iFilter->glContext->create(filterWidget->context()); + try + { + ret=iFilter->applyFilter(action, *(meshDoc()), MergedEnvironment, QCallBack); - meshDoc()->setBusy(false); + meshDoc()->setBusy(false); - qApp->restoreOverrideCursor(); + qApp->restoreOverrideCursor(); - // (5) Apply post filter actions (e.g. recompute non updated stuff if needed) + // (5) Apply post filter actions (e.g. recompute non updated stuff if needed) if(ret) { - meshDoc()->Log.Logf(GLLogStream::SYSTEM,"Applied filter %s in %i msec",qPrintable(action->text()),tt.elapsed()); - if (meshDoc()->mm() != NULL) - meshDoc()->mm()->meshModified() = true; - MainWindow::globalStatusBar()->showMessage("Filter successfully completed...",2000); - if(GLA()) - { - GLA()->setWindowModified(true); - GLA()->setLastAppliedFilter(action); - } + meshDoc()->Log.Logf(GLLogStream::SYSTEM,"Applied filter %s in %i msec",qPrintable(action->text()),tt.elapsed()); + if (meshDoc()->mm() != NULL) + meshDoc()->mm()->meshModified() = true; + MainWindow::globalStatusBar()->showMessage("Filter successfully completed...",2000); + if(GLA()) + { + GLA()->setWindowModified(true); + GLA()->setLastAppliedFilter(action); + } lastFilterAct->setText(QString("Apply filter ") + action->text()); lastFilterAct->setEnabled(true); } - else // filter has failed. show the message error. + else // filter has failed. show the message error. { QMessageBox::warning(this, tr("Filter Failure"), QString("Failure of filter : '%1'

").arg(action->text())+iFilter->errorMsg()); // text meshDoc()->Log.Logf(GLLogStream::SYSTEM,"Filter failed: %s",qPrintable(iFilter->errorMsg())); - MainWindow::globalStatusBar()->showMessage("Filter failed...",2000); + MainWindow::globalStatusBar()->showMessage("Filter failed...",2000); + } + // at the end for filters that change the color, or selection set the appropriate rendering mode + if(iFilter->getClass(action) & MeshFilterInterface::FaceColoring ) { + GLA()->setColorMode(vcg::GLW::CMPerFace); + meshDoc()->mm()->updateDataMask(MeshModel::MM_FACECOLOR); + } + if(iFilter->getClass(action) & MeshFilterInterface::VertexColoring ){ + GLA()->setColorMode(vcg::GLW::CMPerVert); + meshDoc()->mm()->updateDataMask(MeshModel::MM_VERTCOLOR); + } + if(iFilter->postCondition(action) & MeshModel::MM_COLOR) + { + GLA()->setColorMode(vcg::GLW::CMPerMesh); + meshDoc()->mm()->updateDataMask(MeshModel::MM_COLOR); } - // at the end for filters that change the color, or selection set the appropriate rendering mode - if(iFilter->getClass(action) & MeshFilterInterface::FaceColoring ) { - GLA()->setColorMode(vcg::GLW::CMPerFace); - meshDoc()->mm()->updateDataMask(MeshModel::MM_FACECOLOR); - } - if(iFilter->getClass(action) & MeshFilterInterface::VertexColoring ){ - GLA()->setColorMode(vcg::GLW::CMPerVert); - meshDoc()->mm()->updateDataMask(MeshModel::MM_VERTCOLOR); - } - if(iFilter->postCondition(action) & MeshModel::MM_COLOR) - { - GLA()->setColorMode(vcg::GLW::CMPerMesh); - meshDoc()->mm()->updateDataMask(MeshModel::MM_COLOR); - } - if(iFilter->postCondition(action) & MeshModel::MM_CAMERA) - meshDoc()->mm()->updateDataMask(MeshModel::MM_CAMERA); + if(iFilter->postCondition(action) & MeshModel::MM_CAMERA) + meshDoc()->mm()->updateDataMask(MeshModel::MM_CAMERA); if(iFilter->getClass(action) & MeshFilterInterface::Selection ) - { - GLA()->setSelectVertRendering(true); - GLA()->setSelectFaceRendering(true); - } - if(iFilter->getClass(action) & MeshFilterInterface::MeshCreation ) - GLA()->resetTrackBall(); + { + GLA()->setSelectVertRendering(true); + GLA()->setSelectFaceRendering(true); + } + if(iFilter->getClass(action) & MeshFilterInterface::MeshCreation ) + GLA()->resetTrackBall(); if(iFilter->getClass(action) & MeshFilterInterface::Texture ) { @@ -1156,21 +1156,21 @@ void MainWindow::executeFilter(QAction *action, RichParameterSet ¶ms, bool i it.value().setTextureMode(GLW::TMPerWedgeMulti); GLA()->updateTexture(); } - } - catch (std::bad_alloc& bdall) - { - meshDoc()->setBusy(false); - qApp->restoreOverrideCursor(); - QMessageBox::warning(this, tr("Filter Failure"), QString("Operating system was not able to allocate the requested memory.
Failure of filter : '%1'
We warmly suggest you to try a 64-bit version of MeshLab.
").arg(action->text())+bdall.what()); // text - MainWindow::globalStatusBar()->showMessage("Filter failed...",2000); - } - qb->reset(); + } + catch (std::bad_alloc& bdall) + { + meshDoc()->setBusy(false); + qApp->restoreOverrideCursor(); + QMessageBox::warning(this, tr("Filter Failure"), QString("Operating system was not able to allocate the requested memory.
Failure of filter : '%1'
We warmly suggest you to try a 64-bit version of MeshLab.
").arg(action->text())+bdall.what()); // text + MainWindow::globalStatusBar()->showMessage("Filter failed...",2000); + } + qb->reset(); - updateMenus(); - GLA()->update(); //now there is the container - MultiViewer_Container* mvc = currentViewContainer(); - if(mvc) - mvc->updateAllViewer(); + updateMenus(); + GLA()->update(); //now there is the container + MultiViewer_Container* mvc = currentViewContainer(); + if(mvc) + mvc->updateAllViewer(); } @@ -1235,27 +1235,27 @@ void MainWindow::initDocumentRasterRenderState(MeshLabXMLFilterContainer* mfc, E if (ar == MLXMLElNames::fixedRasterArity) { - // TO DO!!!!!! I have to add RasterType in order to understand which are the parameters working on Raster!!! + // TO DO!!!!!! I have to add RasterType in order to understand which are the parameters working on Raster!!! - // //I have to check which are the meshes requested as parameters by the filter. It's disgusting but there is not other way. - // MLXMLPluginInfo::XMLMapList params = mfc->xmlInfo->filterParameters(fname); - // for(int ii = 0;ii < params.size();++ii) - // { - // if (params[ii][MLXMLElNames::paramType] == MLXMLElNames::meshType) - // { - // try - // { - // MeshModel* tmp = env.evalMesh(params[ii][MLXMLElNames::paramName]); - // if (tmp != NULL) - // meshDoc()->renderState().add(tmp->id(),tmp->cm); - // } - // catch (ExpressionHasNotThisTypeException& e) - // { - // QString st = "parameter " + params[ii][MLXMLElNames::paramName] + "declared of type mesh contains a not mesh value.\n"; - // meshDoc()->Log.Logf(GLLogStream::FILTER,qPrintable(st)); - // } - // } - // } + // //I have to check which are the meshes requested as parameters by the filter. It's disgusting but there is not other way. + // MLXMLPluginInfo::XMLMapList params = mfc->xmlInfo->filterParameters(fname); + // for(int ii = 0;ii < params.size();++ii) + // { + // if (params[ii][MLXMLElNames::paramType] == MLXMLElNames::meshType) + // { + // try + // { + // MeshModel* tmp = env.evalMesh(params[ii][MLXMLElNames::paramName]); + // if (tmp != NULL) + // meshDoc()->renderState().add(tmp->id(),tmp->cm); + // } + // catch (ExpressionHasNotThisTypeException& e) + // { + // QString st = "parameter " + params[ii][MLXMLElNames::paramName] + "declared of type mesh contains a not mesh value.\n"; + // meshDoc()->Log.Logf(GLLogStream::FILTER,qPrintable(st)); + // } + // } + // } return; } @@ -1321,19 +1321,19 @@ void MainWindow::executeFilter(MeshLabXMLFilterContainer* mfc, EnvWrap& env, boo /*if (filtercpp) { - QGLWidget* filterWidget = new QGLWidget(GLA()); - QGLFormat defForm = QGLFormat::defaultFormat(); - iFilter->glContext = new QGLContext(defForm,filterWidget->context()->device()); - iFilter->glContext->create(filterWidget->context()); + QGLWidget* filterWidget = new QGLWidget(GLA()); + QGLFormat defForm = QGLFormat::defaultFormat(); + iFilter->glContext = new QGLContext(defForm,filterWidget->context()->device()); + iFilter->glContext->create(filterWidget->context()); }*/ try { /*bool isinter = */(mfc->xmlInfo->filterAttribute(fname,MLXMLElNames::filterIsInterruptible) == "true"); /*if (isinter) { - showInterruptButton(true); - if (filtercpp) - connect(iFilter,SIGNAL(filterUpdateRequest(const bool&,bool*)),this,SLOT(filterUpdateRequest(const bool&,bool*)),Qt::DirectConnection); + showInterruptButton(true); + if (filtercpp) + connect(iFilter,SIGNAL(filterUpdateRequest(const bool&,bool*)),this,SLOT(filterUpdateRequest(const bool&,bool*)),Qt::DirectConnection); }*/ MLXMLPluginInfo::XMLMapList ml = mfc->xmlInfo->filterParametersExtendedInfo(fname); QString funcall = "Plugins." + mfc->xmlInfo->pluginAttribute(MLXMLElNames::pluginScriptName) + "." + mfc->xmlInfo->filterAttribute(fname,MLXMLElNames::filterScriptFunctName) + "("; @@ -1377,9 +1377,9 @@ void MainWindow::executeFilter(MeshLabXMLFilterContainer* mfc, EnvWrap& env, boo } /*if (isinter) { - showInterruptButton(false); - if (filtercpp) - disconnect(iFilter,SIGNAL(filterUpdateRequest(const bool&,bool*)),this,SLOT(filterUpdateRequest(const bool&,bool*))); + showInterruptButton(false); + if (filtercpp) + disconnect(iFilter,SIGNAL(filterUpdateRequest(const bool&,bool*)),this,SLOT(filterUpdateRequest(const bool&,bool*))); }*/ } catch(MeshLabException& e) @@ -1433,7 +1433,7 @@ void MainWindow::postFilterExecution() } else // filter has failed. show the message error. { - MeshLabFilterInterface *iFilter = obj->_mfc->filterInterface; + MeshLabFilterInterface *iFilter = obj->_mfc->filterInterface; QMessageBox::warning(this, tr("Filter Failure"), QString("Failure of filter: '%1'\n\n").arg(fname)+iFilter->errorMsg()); // text meshDoc()->Log.Logf(GLLogStream::SYSTEM,"Filter failed: %s",qPrintable(iFilter->errorMsg())); MainWindow::globalStatusBar()->showMessage("Filter failed...",2000); @@ -1504,11 +1504,11 @@ void MainWindow::scriptCodeExecuted( const QScriptValue& val,const int time,cons void MainWindow::suspendEditMode() { - // return if no window is open - if(!GLA()) return; + // return if no window is open + if(!GLA()) return; - // return if no editing action is currently ongoing - if(!GLA()->getCurrentEditAction()) return; + // return if no editing action is currently ongoing + if(!GLA()->getCurrentEditAction()) return; GLA()->suspendEditToggle(); updateMenus(); @@ -1525,21 +1525,21 @@ void MainWindow::applyEditMode() QAction *action = qobject_cast(sender()); if(GLA()->getCurrentEditAction()) //prevents multiple buttons pushed + { + if(action==GLA()->getCurrentEditAction()) // We have double pressed the same action and that means disable that actioon { - if(action==GLA()->getCurrentEditAction()) // We have double pressed the same action and that means disable that actioon + if(GLA()->suspendedEditor) { - if(GLA()->suspendedEditor) - { - suspendEditMode(); - return; - } - GLA()->endEdit(); - updateMenus(); + suspendEditMode(); return; } - assert(0); // it should be impossible to start an action without having ended the previous one. + GLA()->endEdit(); + updateMenus(); return; } + assert(0); // it should be impossible to start an action without having ended the previous one. + return; + } //if this GLArea does not have an instance of this action's MeshEdit tool then give it one if(!GLA()->editorExistsForAction(action)) @@ -1592,59 +1592,59 @@ void MainWindow::applyRenderMode() void MainWindow::applyDecorateMode() { - if(GLA()->mm() == 0) return; - QAction *action = qobject_cast(sender()); // find the action which has sent the signal + if(GLA()->mm() == 0) return; + QAction *action = qobject_cast(sender()); // find the action which has sent the signal - MeshDecorateInterface *iDecorateTemp = qobject_cast(action->parent()); + MeshDecorateInterface *iDecorateTemp = qobject_cast(action->parent()); - if(iDecorateTemp->getDecorationClass(action)== MeshDecorateInterface::PerDocument) - { - bool found=GLA()->iPerDocDecoratorlist.removeOne(action); - if(found) - { - iDecorateTemp->endDecorate(action,*meshDoc(),GLA()->glas.currentGlobalParamSet,GLA()); - iDecorateTemp->setLog(NULL); - GLA()->Logf(GLLogStream::SYSTEM,"Disabled Decorate mode %s",qPrintable(action->text())); - } - else{ - iDecorateTemp->setLog(&meshDoc()->Log); - bool ret = iDecorateTemp->startDecorate(action,*meshDoc(), ¤tGlobalParams, GLA()); - if(ret) { - GLA()->iPerDocDecoratorlist.push_back(action); - GLA()->Logf(GLLogStream::SYSTEM,"Enabled Decorate mode %s",qPrintable(action->text())); - } - else GLA()->Logf(GLLogStream::SYSTEM,"Failed start of Decorate mode %s",qPrintable(action->text())); - } - } + if(iDecorateTemp->getDecorationClass(action)== MeshDecorateInterface::PerDocument) + { + bool found=GLA()->iPerDocDecoratorlist.removeOne(action); + if(found) + { + iDecorateTemp->endDecorate(action,*meshDoc(),GLA()->glas.currentGlobalParamSet,GLA()); + iDecorateTemp->setLog(NULL); + GLA()->Logf(GLLogStream::SYSTEM,"Disabled Decorate mode %s",qPrintable(action->text())); + } + else{ + iDecorateTemp->setLog(&meshDoc()->Log); + bool ret = iDecorateTemp->startDecorate(action,*meshDoc(), ¤tGlobalParams, GLA()); + if(ret) { + GLA()->iPerDocDecoratorlist.push_back(action); + GLA()->Logf(GLLogStream::SYSTEM,"Enabled Decorate mode %s",qPrintable(action->text())); + } + else GLA()->Logf(GLLogStream::SYSTEM,"Failed start of Decorate mode %s",qPrintable(action->text())); + } + } - if(iDecorateTemp->getDecorationClass(action)== MeshDecorateInterface::PerMesh) - { - MeshModel ¤tMeshModel = *(meshDoc()->mm()); - bool found=GLA()->iCurPerMeshDecoratorList().removeOne(action); - if(found) - { - iDecorateTemp->endDecorate(action,currentMeshModel,GLA()->glas.currentGlobalParamSet,GLA()); - iDecorateTemp->setLog(NULL); - GLA()->Logf(0,"Disabled Decorate mode %s",qPrintable(action->text())); - } - else{ - QString errorMessage; - if (iDecorateTemp->isDecorationApplicable(action,currentMeshModel,errorMessage)) { - iDecorateTemp->setLog(&meshDoc()->Log); - bool ret = iDecorateTemp->startDecorate(action,currentMeshModel, ¤tGlobalParams, GLA()); - if(ret) { - GLA()->iCurPerMeshDecoratorList().push_back(action); - GLA()->Logf(GLLogStream::SYSTEM,"Enabled Decorate mode %s",qPrintable(action->text())); - } - else GLA()->Logf(GLLogStream::SYSTEM,"Failed Decorate mode %s",qPrintable(action->text())); - } - } - } + if(iDecorateTemp->getDecorationClass(action)== MeshDecorateInterface::PerMesh) + { + MeshModel ¤tMeshModel = *(meshDoc()->mm()); + bool found=GLA()->iCurPerMeshDecoratorList().removeOne(action); + if(found) + { + iDecorateTemp->endDecorate(action,currentMeshModel,GLA()->glas.currentGlobalParamSet,GLA()); + iDecorateTemp->setLog(NULL); + GLA()->Logf(0,"Disabled Decorate mode %s",qPrintable(action->text())); + } + else{ + QString errorMessage; + if (iDecorateTemp->isDecorationApplicable(action,currentMeshModel,errorMessage)) { + iDecorateTemp->setLog(&meshDoc()->Log); + bool ret = iDecorateTemp->startDecorate(action,currentMeshModel, ¤tGlobalParams, GLA()); + if(ret) { + GLA()->iCurPerMeshDecoratorList().push_back(action); + GLA()->Logf(GLLogStream::SYSTEM,"Enabled Decorate mode %s",qPrintable(action->text())); + } + else GLA()->Logf(GLLogStream::SYSTEM,"Failed Decorate mode %s",qPrintable(action->text())); + } + } + } - layerDialog->updateDecoratorParsView(); - layerDialog->updateLog(meshDoc()->Log); - layerDialog->update(); - GLA()->update(); + layerDialog->updateDecoratorParsView(); + layerDialog->updateLog(meshDoc()->Log); + layerDialog->update(); + GLA()->update(); } //void MainWindow::setLight() @@ -1693,8 +1693,8 @@ void MainWindow::applyDecorateMode() //} /* - Save project. It saves the info of all the layers and the layer themselves. So - */ +Save project. It saves the info of all the layers and the layer themselves. So +*/ void MainWindow::saveProject() { if (meshDoc() == NULL) @@ -1715,290 +1715,116 @@ void MainWindow::saveProject() } QFileDialog* saveDiag = new QFileDialog(this,tr("Save Project File"),lastUsedDirectory.path().append(""), tr("MeshLab Project (*.mlp);;Align Project (*.aln)")); #if defined(Q_OS_MAC) - saveDiag->setOption(QFileDialog::DontUseNativeDialog,true); + saveDiag->setOption(QFileDialog::DontUseNativeDialog,true); #endif - QCheckBox* saveAllFile = new QCheckBox(QString("Save All Files"),saveDiag); - saveAllFile->setCheckState(Qt::Unchecked); - QCheckBox* onlyVisibleLayers = new QCheckBox(QString("Only Visible Layers"),saveDiag); - onlyVisibleLayers->setCheckState(Qt::Unchecked); - QGridLayout* layout = (QGridLayout*) saveDiag->layout(); - layout->addWidget(saveAllFile,4,2); - layout->addWidget(onlyVisibleLayers,4,1); + QCheckBox* saveAllFile = new QCheckBox(QString("Save All Files"),saveDiag); + saveAllFile->setCheckState(Qt::Unchecked); + QCheckBox* onlyVisibleLayers = new QCheckBox(QString("Only Visible Layers"),saveDiag); + onlyVisibleLayers->setCheckState(Qt::Unchecked); + QGridLayout* layout = (QGridLayout*) saveDiag->layout(); + layout->addWidget(saveAllFile,4,2); + layout->addWidget(onlyVisibleLayers,4,1); saveDiag->setAcceptMode(QFileDialog::AcceptSave); saveDiag->exec(); QStringList files = saveDiag->selectedFiles(); if (files.size() != 1) return; - QString fileName = files[0]; - // this change of dir is needed for subsequent textures/materials loading - QFileInfo fi(fileName); - if (fi.isDir()) - return; - if (fi.suffix().isEmpty()) - { - QRegExp reg("\\.\\w+"); - saveDiag->selectedNameFilter().indexOf(reg); - QString ext = reg.cap(); - fileName.append(ext); - fi.setFile(fileName); - } - QDir::setCurrent(fi.absoluteDir().absolutePath()); - - /*********WARNING!!!!!! CHANGE IT!!! ALSO IN THE OPENPROJECT FUNCTION********/ - meshDoc()->setDocLabel(fileName); - QMdiSubWindow* sub = mdiarea->currentSubWindow(); - if (sub != NULL) - { - sub->setWindowTitle(meshDoc()->docLabel()); - layerDialog->setWindowTitle(meshDoc()->docLabel()); - } - /****************************************************************************/ - - - bool ret; - qDebug("Saving aln file %s\n",qPrintable(fileName)); - if (fileName.isEmpty()) return; - else - { - //save path away so we can use it again - QString path = fileName; - path.truncate(path.lastIndexOf("/")); - lastUsedDirectory.setPath(path); - } - if (QString(fi.suffix()).toLower() == "aln") - { - vector meshNameVector; - vector transfVector; - - foreach(MeshModel * mp, meshDoc()->meshList) + QString fileName = files[0]; + // this change of dir is needed for subsequent textures/materials loading + QFileInfo fi(fileName); + if (fi.isDir()) + return; + if (fi.suffix().isEmpty()) { - if((!onlyVisibleLayers->isChecked()) || (mp->visible)) - { - meshNameVector.push_back(qPrintable(mp->relativePathName())); - transfVector.push_back(mp->cm.Tr); - } + QRegExp reg("\\.\\w+"); + saveDiag->selectedNameFilter().indexOf(reg); + QString ext = reg.cap(); + fileName.append(ext); + fi.setFile(fileName); } - ret= ALNParser::SaveALN(qPrintable(fileName),meshNameVector,transfVector); - } - else - ret = MeshDocumentToXMLFile(*meshDoc(),fileName,onlyVisibleLayers->isChecked()); + QDir::setCurrent(fi.absoluteDir().absolutePath()); - if (saveAllFile->isChecked()) - { - for(int ii = 0; ii < meshDoc()->meshList.size();++ii) - { - MeshModel* mp = meshDoc()->meshList[ii]; - if((!onlyVisibleLayers->isChecked()) || (mp->visible)) - { - ret |= exportMesh(mp->fullName(),mp,true); - } - } - } - if(!ret) - QMessageBox::critical(this, tr("Meshlab Saving Error"), QString("Unable to save project file %1\n").arg(fileName)); + /*********WARNING!!!!!! CHANGE IT!!! ALSO IN THE OPENPROJECT FUNCTION********/ + meshDoc()->setDocLabel(fileName); + QMdiSubWindow* sub = mdiarea->currentSubWindow(); + if (sub != NULL) + { + sub->setWindowTitle(meshDoc()->docLabel()); + layerDialog->setWindowTitle(meshDoc()->docLabel()); + } + /****************************************************************************/ + + + bool ret; + qDebug("Saving aln file %s\n",qPrintable(fileName)); + if (fileName.isEmpty()) return; + else + { + //save path away so we can use it again + QString path = fileName; + path.truncate(path.lastIndexOf("/")); + lastUsedDirectory.setPath(path); + } + if (QString(fi.suffix()).toLower() == "aln") + { + vector meshNameVector; + vector transfVector; + + foreach(MeshModel * mp, meshDoc()->meshList) + { + if((!onlyVisibleLayers->isChecked()) || (mp->visible)) + { + meshNameVector.push_back(qPrintable(mp->relativePathName())); + transfVector.push_back(mp->cm.Tr); + } + } + ret= ALNParser::SaveALN(qPrintable(fileName),meshNameVector,transfVector); + } + else + ret = MeshDocumentToXMLFile(*meshDoc(),fileName,onlyVisibleLayers->isChecked()); + + if (saveAllFile->isChecked()) + { + for(int ii = 0; ii < meshDoc()->meshList.size();++ii) + { + MeshModel* mp = meshDoc()->meshList[ii]; + if((!onlyVisibleLayers->isChecked()) || (mp->visible)) + { + ret |= exportMesh(mp->fullName(),mp,true); + } + } + } + if(!ret) + QMessageBox::critical(this, tr("Meshlab Saving Error"), QString("Unable to save project file %1\n").arg(fileName)); } bool MainWindow::openProject(QString fileName) { - if (fileName.isEmpty()) - fileName = QFileDialog::getOpenFileName(this,tr("Open Project File"), lastUsedDirectory.path(), "All Project Files (*.mlp *.aln *.out *.nvm);;MeshLab Project (*.mlp);;Align Project (*.aln);;Bundler Output (*.out);;VisualSFM Output (*.nvm)"); + if (fileName.isEmpty()) + fileName = QFileDialog::getOpenFileName(this,tr("Open Project File"), lastUsedDirectory.path(), "All Project Files (*.mlp *.aln *.out *.nvm);;MeshLab Project (*.mlp);;Align Project (*.aln);;Bundler Output (*.out);;VisualSFM Output (*.nvm)"); - if (fileName.isEmpty()) return false; + if (fileName.isEmpty()) return false; - QFileInfo fi(fileName); - lastUsedDirectory = fi.absoluteDir(); + QFileInfo fi(fileName); + lastUsedDirectory = fi.absoluteDir(); - if((fi.suffix().toLower()!="aln") && (fi.suffix().toLower()!="mlp") && (fi.suffix().toLower()!="out") && (fi.suffix().toLower()!="nvm")) - { - QMessageBox::critical(this, tr("Meshlab Opening Error"), "Unknown project file extension"); - 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) newProject(fileName); - - meshDoc()->setFileName(fileName); - mdiarea->currentSubWindow()->setWindowTitle(fileName); - meshDoc()->setDocLabel(fileName); - meshDoc()->setBusy(true); - - // 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 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::iterator ir; - for(ir=rmv.begin();ir!=rmv.end() && openRes;++ir) + if((fi.suffix().toLower()!="aln") && (fi.suffix().toLower()!="mlp") && (fi.suffix().toLower()!="out") && (fi.suffix().toLower()!="nvm")) { - 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; + QMessageBox::critical(this, tr("Meshlab Opening Error"), "Unknown project file extension"); + return false; } - } - 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; imeshList.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; - } - } + // Common Part: init a Doc if necessary, and + bool activeDoc = (bool) !mdiarea->subWindowList().empty() && mdiarea->currentSubWindow(); + bool activeEmpty = activeDoc && meshDoc()->meshList.empty(); - if (QString(fi.suffix()).toLower() == "out"){ + if (!activeEmpty) newProject(fileName); - QString cameras_filename = fileName; - QString image_list_filename; - QString model_filename; - - image_list_filename = QFileDialog::getOpenFileName( - this , tr("Open image list file"), - QFileInfo(fileName).absolutePath(), - tr("Bundler images list file (*.txt)") - ); - if(image_list_filename.isEmpty()) - return false; - - - //model_filename = QFileDialog::getOpenFileName( - // this, tr("Open 3D model file"), - // QFileInfo(fileName).absolutePath(), - // tr("Bunler 3D model file (*.ply)") - // ); - //if(model_filename.isEmpty()) - // return false; - - if(!MeshDocumentFromBundler(*meshDoc(),cameras_filename,image_list_filename,model_filename)){ - QMessageBox::critical(this, tr("Meshlab Opening Error"), "Unable to open OUTs file"); - return false; - } - - GLA()->setColorMode(GLW::CMPerVert); - GLA()->setDrawMode(GLW::DMPoints); - //else{ - // for (int i=0; imeshList.size(); i++) - // { - // QString fullPath = meshDoc()->meshList[i]->fullName(); - // meshDoc()->setBusy(true); - // loadMeshWithStandardParams(fullPath,this->meshDoc()->meshList[i]); - // } - //} - - - } - - //////NVM - - if (QString(fi.suffix()).toLower() == "nvm"){ - - QString cameras_filename = fileName; - //QString image_list_filename; - QString model_filename; - - /*image_list_filename = QFileDialog::getOpenFileName( - this , tr("Open image list file"), - QFileInfo(fileName).absolutePath(), - tr("Bundler images list file (*.txt)") - ); - if(image_list_filename.isEmpty()) - return false;*/ - - - //model_filename = QFileDialog::getOpenFileName( - // this, tr("Open 3D model file"), - // QFileInfo(fileName).absolutePath(), - // tr("Bunler 3D model file (*.ply)") - // ); - //if(model_filename.isEmpty()) - // return false; - - - if(!MeshDocumentFromNvm(*meshDoc(),cameras_filename,model_filename)){ - QMessageBox::critical(this, tr("Meshlab Opening Error"), "Unable to open NVMs file"); - return false; - } - GLA()->setColorMode(GLW::CMPerVert); - GLA()->setDrawMode(GLW::DMPoints); - - //else{ - // for (int i=0; imeshList.size(); i++) - // { - // QString fullPath = meshDoc()->meshList[i]->fullName(); - // meshDoc()->setBusy(true); - // loadMeshWithStandardParams(fullPath,this->meshDoc()->meshList[i]); - // } - //} - - - } - - //////NVM - - meshDoc()->setBusy(false); - if(this->GLA() == 0) return false; - this->currentViewContainer()->resetAllTrackBall(); - qb->reset(); - saveRecentProjectList(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; - } + meshDoc()->setFileName(fileName); + mdiarea->currentSubWindow()->setWindowTitle(fileName); + meshDoc()->setDocLabel(fileName); + meshDoc()->setBusy(true); // this change of dir is needed for subsequent textures/materials loading QDir::setCurrent(fi.absoluteDir().absolutePath()); @@ -2006,59 +1832,243 @@ bool MainWindow::appendProject(QString fileName) if (QString(fi.suffix()).toLower() == "aln") { - vector 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; - } + vector 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::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; - } + bool openRes=true; + vector::iterator ir; + for(ir=rmv.begin();ir!=rmv.end() && openRes;++ir) + { + QString relativeToProj = fi.absoluteDir().absolutePath() + "/" + (*ir).filename.c_str(); + meshDoc()->addNewMesh(relativeToProj,relativeToProj); + openRes = loadMeshWithStandardParams(relativeToProj,this->meshDoc()->mm()); + if(openRes) + meshDoc()->mm()->cm.Tr=(*ir).trasformation; + else + meshDoc()->delMesh(meshDoc()->mm()); + } } 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; imeshList.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; - } + if (!MeshDocumentFromXML(*meshDoc(),fileName)) + { + QMessageBox::critical(this, tr("Meshlab Opening Error"), "Unable to open MLP file"); + return false; + } + for (int i=0; imeshList.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... + if (!loadMeshWithStandardParams(fullPath,this->meshDoc()->meshList[i])) + meshDoc()->delMesh(meshDoc()->meshList[i]); + else + 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; + if (QString(fi.suffix()).toLower() == "out"){ + + QString cameras_filename = fileName; + QString image_list_filename; + QString model_filename; + + image_list_filename = QFileDialog::getOpenFileName( + this , tr("Open image list file"), + QFileInfo(fileName).absolutePath(), + tr("Bundler images list file (*.txt)") + ); + if(image_list_filename.isEmpty()) + return false; + + + //model_filename = QFileDialog::getOpenFileName( + // this, tr("Open 3D model file"), + // QFileInfo(fileName).absolutePath(), + // tr("Bunler 3D model file (*.ply)") + // ); + //if(model_filename.isEmpty()) + // return false; + + if(!MeshDocumentFromBundler(*meshDoc(),cameras_filename,image_list_filename,model_filename)){ + QMessageBox::critical(this, tr("Meshlab Opening Error"), "Unable to open OUTs file"); + return false; + } + + GLA()->setColorMode(GLW::CMPerVert); + GLA()->setDrawMode(GLW::DMPoints); + //else{ + // for (int i=0; imeshList.size(); i++) + // { + // QString fullPath = meshDoc()->meshList[i]->fullName(); + // meshDoc()->setBusy(true); + // loadMeshWithStandardParams(fullPath,this->meshDoc()->meshList[i]); + // } + //} + + + } + + //////NVM + + if (QString(fi.suffix()).toLower() == "nvm"){ + + QString cameras_filename = fileName; + //QString image_list_filename; + QString model_filename; + + /*image_list_filename = QFileDialog::getOpenFileName( + this , tr("Open image list file"), + QFileInfo(fileName).absolutePath(), + tr("Bundler images list file (*.txt)") + ); + if(image_list_filename.isEmpty()) + return false;*/ + + + //model_filename = QFileDialog::getOpenFileName( + // this, tr("Open 3D model file"), + // QFileInfo(fileName).absolutePath(), + // tr("Bunler 3D model file (*.ply)") + // ); + //if(model_filename.isEmpty()) + // return false; + + + if(!MeshDocumentFromNvm(*meshDoc(),cameras_filename,model_filename)){ + QMessageBox::critical(this, tr("Meshlab Opening Error"), "Unable to open NVMs file"); + return false; + } + GLA()->setColorMode(GLW::CMPerVert); + GLA()->setDrawMode(GLW::DMPoints); + + //else{ + // for (int i=0; imeshList.size(); i++) + // { + // QString fullPath = meshDoc()->meshList[i]->fullName(); + // meshDoc()->setBusy(true); + // loadMeshWithStandardParams(fullPath,this->meshDoc()->meshList[i]); + // } + //} + + + } + + //////NVM + + meshDoc()->setBusy(false); + if(this->GLA() == 0) return false; + this->currentViewContainer()->resetAllTrackBall(); + qb->reset(); + saveRecentProjectList(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 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::iterator ir; + for(ir=rmv.begin();ir!=rmv.end() && openRes;++ir) + { + QString relativeToProj = fi.absoluteDir().absolutePath() + "/" + (*ir).filename.c_str(); + meshDoc()->addNewMesh(relativeToProj,relativeToProj); + openRes = loadMeshWithStandardParams(relativeToProj,this->meshDoc()->mm()); + if(openRes) + meshDoc()->mm()->cm.Tr=(*ir).trasformation; + else + meshDoc()->delMesh(meshDoc()->mm()); + } + } + + 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; imeshList.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... + if(!loadMeshWithStandardParams(fullPath,this->meshDoc()->meshList[i])) + meshDoc()->delMesh(meshDoc()->meshList[i]); + else + 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) { MultiViewer_Container *mvcont = new MultiViewer_Container(mdiarea); mdiarea->addSubWindow(mvcont); - connect(mvcont,SIGNAL(updateMainWindowMenus()),this,SLOT(updateMenus())); - filterMenu->setEnabled(!filterMenu->actions().isEmpty()); - if (!filterMenu->actions().isEmpty()) - updateSubFiltersMenu(true,false); + connect(mvcont,SIGNAL(updateMainWindowMenus()),this,SLOT(updateMenus())); + filterMenu->setEnabled(!filterMenu->actions().isEmpty()); + if (!filterMenu->actions().isEmpty()) + updateSubFiltersMenu(true,false); GLArea *gla=new GLArea(mvcont, ¤tGlobalParams); if (gla != NULL) { @@ -2121,56 +2131,56 @@ bool MainWindow::importRaster(const QString& fileImg) return false; } - this->meshDoc()->setBusy(true); + this->meshDoc()->setBusy(true); RasterModel *rm= meshDoc()->addNewRaster(); rm->setLabel(fileImg); rm->addPlane(new Plane(fileName,Plane::RGBA)); meshDoc()->setBusy(false); showLayerDlg(true); -/// Intrinsics extraction from EXIF -/// If no CCD Width value is provided, the intrinsics are extracted using the Equivalent 35mm focal -/// If no or invalid EXIF info is found, the Intrinsics are initialized as a "plausible" 35mm sensor, with 50mm focal + /// Intrinsics extraction from EXIF + /// If no CCD Width value is provided, the intrinsics are extracted using the Equivalent 35mm focal + /// If no or invalid EXIF info is found, the Intrinsics are initialized as a "plausible" 35mm sensor, with 50mm focal - ::ResetJpgfile(); - FILE * pFile = fopen(qPrintable(fileName), "rb"); + ::ResetJpgfile(); + FILE * pFile = fopen(qPrintable(fileName), "rb"); - int ret = ::ReadJpegSections (pFile, READ_METADATA); - fclose(pFile); - if (!ret || (ImageInfo.CCDWidth==0.0f && ImageInfo.FocalLength35mmEquiv==0.0f)) - { - rm->shot.Intrinsics.ViewportPx = vcg::Point2i(rm->currentPlane->image.width(), rm->currentPlane->image.height()); - rm->shot.Intrinsics.CenterPx = vcg::Point2f(float(rm->currentPlane->image.width()/2.0), float(rm->currentPlane->image.width()/2.0)); - rm->shot.Intrinsics.PixelSizeMm[0]=36.0f/(float)rm->currentPlane->image.width(); - rm->shot.Intrinsics.PixelSizeMm[1]=rm->shot.Intrinsics.PixelSizeMm[0]; - rm->shot.Intrinsics.FocalMm = 50.0f; - } - else if (ImageInfo.CCDWidth!=0) - { - rm->shot.Intrinsics.ViewportPx = vcg::Point2i(ImageInfo.Width, ImageInfo.Height); - rm->shot.Intrinsics.CenterPx = vcg::Point2f(float(ImageInfo.Width/2.0), float(ImageInfo.Height/2.0)); - float ratio; - if (ImageInfo.Width>ImageInfo.Height) - ratio=(float)ImageInfo.Width/(float)ImageInfo.Height; + int ret = ::ReadJpegSections (pFile, READ_METADATA); + fclose(pFile); + if (!ret || (ImageInfo.CCDWidth==0.0f && ImageInfo.FocalLength35mmEquiv==0.0f)) + { + rm->shot.Intrinsics.ViewportPx = vcg::Point2i(rm->currentPlane->image.width(), rm->currentPlane->image.height()); + rm->shot.Intrinsics.CenterPx = vcg::Point2f(float(rm->currentPlane->image.width()/2.0), float(rm->currentPlane->image.width()/2.0)); + rm->shot.Intrinsics.PixelSizeMm[0]=36.0f/(float)rm->currentPlane->image.width(); + rm->shot.Intrinsics.PixelSizeMm[1]=rm->shot.Intrinsics.PixelSizeMm[0]; + rm->shot.Intrinsics.FocalMm = 50.0f; + } + else if (ImageInfo.CCDWidth!=0) + { + rm->shot.Intrinsics.ViewportPx = vcg::Point2i(ImageInfo.Width, ImageInfo.Height); + rm->shot.Intrinsics.CenterPx = vcg::Point2f(float(ImageInfo.Width/2.0), float(ImageInfo.Height/2.0)); + float ratio; + if (ImageInfo.Width>ImageInfo.Height) + ratio=(float)ImageInfo.Width/(float)ImageInfo.Height; + else + ratio=(float)ImageInfo.Height/(float)ImageInfo.Width; + rm->shot.Intrinsics.PixelSizeMm[0]=ImageInfo.CCDWidth/(float)ImageInfo.Width; + rm->shot.Intrinsics.PixelSizeMm[1]=ImageInfo.CCDWidth/((float)ImageInfo.Height*ratio); + rm->shot.Intrinsics.FocalMm = ImageInfo.FocalLength; + } else - ratio=(float)ImageInfo.Height/(float)ImageInfo.Width; - rm->shot.Intrinsics.PixelSizeMm[0]=ImageInfo.CCDWidth/(float)ImageInfo.Width; - rm->shot.Intrinsics.PixelSizeMm[1]=ImageInfo.CCDWidth/((float)ImageInfo.Height*ratio); - rm->shot.Intrinsics.FocalMm = ImageInfo.FocalLength; - } - else - { - rm->shot.Intrinsics.ViewportPx = vcg::Point2i(ImageInfo.Width, ImageInfo.Height); - rm->shot.Intrinsics.CenterPx = vcg::Point2f(float(ImageInfo.Width/2.0), float(ImageInfo.Height/2.0)); - float ratioFocal=ImageInfo.FocalLength/ImageInfo.FocalLength35mmEquiv; - rm->shot.Intrinsics.PixelSizeMm[0]=(36.0f*ratioFocal)/(float)ImageInfo.Width; - rm->shot.Intrinsics.PixelSizeMm[1]=(24.0f*ratioFocal)/(float)ImageInfo.Height; - rm->shot.Intrinsics.FocalMm = ImageInfo.FocalLength; - } + { + rm->shot.Intrinsics.ViewportPx = vcg::Point2i(ImageInfo.Width, ImageInfo.Height); + rm->shot.Intrinsics.CenterPx = vcg::Point2f(float(ImageInfo.Width/2.0), float(ImageInfo.Height/2.0)); + float ratioFocal=ImageInfo.FocalLength/ImageInfo.FocalLength35mmEquiv; + rm->shot.Intrinsics.PixelSizeMm[0]=(36.0f*ratioFocal)/(float)ImageInfo.Width; + rm->shot.Intrinsics.PixelSizeMm[1]=(24.0f*ratioFocal)/(float)ImageInfo.Height; + rm->shot.Intrinsics.FocalMm = ImageInfo.FocalLength; + } -// End of EXIF reading + // End of EXIF reading -// if(mdiarea->isVisible()) GLA()->mvc->showMaximized(); + // if(mdiarea->isVisible()) GLA()->mvc->showMaximized(); updateMenus(); } else @@ -2183,7 +2193,7 @@ bool MainWindow::loadMesh(const QString& fileName, MeshIOInterface *pCurrentIOPl { if ((GLA() == NULL) || (mm == NULL)) return false; - + QMap::iterator it = GLA()->rendermodemap.find(mm->id()); if (it == GLA()->rendermodemap.end()) return false; @@ -2203,126 +2213,126 @@ bool MainWindow::loadMesh(const QString& fileName, MeshIOInterface *pCurrentIOPl return false; } - // this change of dir is needed for subsequent textures/materials loading + // this change of dir is needed for subsequent textures/materials loading QDir::setCurrent(fi.absoluteDir().absolutePath()); - // retrieving corresponding IO plugin + // retrieving corresponding IO plugin if (pCurrentIOPlugin == 0) { QString errorMsgFormat = "Error encountered while opening file:\n\"%1\"\n\nError details: The \"%2\" file extension does not correspond to any supported format."; QMessageBox::critical(this, tr("Opening Error"), errorMsgFormat.arg(fileName, extension)); return false; } - meshDoc()->setBusy(true); - pCurrentIOPlugin->setLog(&meshDoc()->Log); - if (!pCurrentIOPlugin->open(extension, fileName, *mm ,mask,*prePar,QCallBack,this /*gla*/)) - { - QMessageBox::warning(this, tr("Opening Failure"), QString("While opening: '%1'\n\n").arg(fileName)+pCurrentIOPlugin->errorMsg()); // text+ - pCurrentIOPlugin->clearErrorString(); - meshDoc()->setBusy(false); - return false; - } - // After opening the mesh lets ask to the io plugin if this format - // requires some optional, or userdriven post-opening processing. - // and in that case ask for the required parameters and then - // ask to the plugin to perform that processing - //RichParameterSet par; - //pCurrentIOPlugin->initOpenParameter(extension, *mm, par); - //pCurrentIOPlugin->applyOpenParameter(extension, *mm, par); + meshDoc()->setBusy(true); + pCurrentIOPlugin->setLog(&meshDoc()->Log); + if (!pCurrentIOPlugin->open(extension, fileName, *mm ,mask,*prePar,QCallBack,this /*gla*/)) + { + QMessageBox::warning(this, tr("Opening Failure"), QString("While opening: '%1'\n\n").arg(fileName)+pCurrentIOPlugin->errorMsg()); // text+ + pCurrentIOPlugin->clearErrorString(); + meshDoc()->setBusy(false); + return false; + } + // After opening the mesh lets ask to the io plugin if this format + // requires some optional, or userdriven post-opening processing. + // and in that case ask for the required parameters and then + // ask to the plugin to perform that processing + //RichParameterSet par; + //pCurrentIOPlugin->initOpenParameter(extension, *mm, par); + //pCurrentIOPlugin->applyOpenParameter(extension, *mm, par); - QString err = pCurrentIOPlugin->errorMsg(); - if (!err.isEmpty()) - { - QMessageBox::warning(this, tr("Opening Problems"), QString("While opening: '%1'\n\n").arg(fileName)+pCurrentIOPlugin->errorMsg()); - pCurrentIOPlugin->clearErrorString(); - } + QString err = pCurrentIOPlugin->errorMsg(); + if (!err.isEmpty()) + { + QMessageBox::warning(this, tr("Opening Problems"), QString("While opening: '%1'\n\n").arg(fileName)+pCurrentIOPlugin->errorMsg()); + pCurrentIOPlugin->clearErrorString(); + } - saveRecentFileList(fileName); + saveRecentFileList(fileName); - if( mask & vcg::tri::io::Mask::IOM_FACECOLOR) - GLA()->setColorMode(GLW::CMPerFace); - if( mask & vcg::tri::io::Mask::IOM_VERTCOLOR) - GLA()->setColorMode(GLW::CMPerVert); + if( mask & vcg::tri::io::Mask::IOM_FACECOLOR) + GLA()->setColorMode(GLW::CMPerFace); + if( mask & vcg::tri::io::Mask::IOM_VERTCOLOR) + GLA()->setColorMode(GLW::CMPerVert); - renderModeTextureWedgeAct->setChecked(false); - //renderModeTextureWedgeAct->setEnabled(false); - if(!meshDoc()->mm()->cm.textures.empty()) - { - renderModeTextureWedgeAct->setChecked(true); - //renderModeTextureWedgeAct->setEnabled(true); - if(tri::HasPerVertexTexCoord(meshDoc()->mm()->cm) ) - GLA()->setTextureMode(rm,GLW::TMPerVert); - if(tri::HasPerWedgeTexCoord(meshDoc()->mm()->cm) ) - GLA()->setTextureMode(rm,GLW::TMPerWedgeMulti); - } + renderModeTextureWedgeAct->setChecked(false); + //renderModeTextureWedgeAct->setEnabled(false); + if(!meshDoc()->mm()->cm.textures.empty()) + { + renderModeTextureWedgeAct->setChecked(true); + //renderModeTextureWedgeAct->setEnabled(true); + if(tri::HasPerVertexTexCoord(meshDoc()->mm()->cm) ) + GLA()->setTextureMode(rm,GLW::TMPerVert); + if(tri::HasPerWedgeTexCoord(meshDoc()->mm()->cm) ) + GLA()->setTextureMode(rm,GLW::TMPerWedgeMulti); + } - // In case of polygonal meshes the normal should be updated accordingly - if( mask & vcg::tri::io::Mask::IOM_BITPOLYGONAL) - { - mm->updateDataMask(MeshModel::MM_POLYGONAL); // just to be sure. Hopefully it should be done in the plugin... - int degNum = tri::Clean::RemoveDegenerateFace(mm->cm); - if(degNum) - GLA()->Logf(0,"Warning model contains %i degenerate faces. Removed them.",degNum); - mm->updateDataMask(MeshModel::MM_FACEFACETOPO); - vcg::tri::UpdateNormal::PerBitQuadFaceNormalized(mm->cm); - vcg::tri::UpdateNormal::PerVertexFromCurrentFaceNormal(mm->cm); - } // standard case - else - { - vcg::tri::UpdateNormal::PerFaceNormalized(mm->cm); - if(!( mask & vcg::tri::io::Mask::IOM_VERTNORMAL) ) - vcg::tri::UpdateNormal::PerVertexAngleWeighted(mm->cm); - } - vcg::tri::UpdateBounding::Box(mm->cm); // updates bounding box - if(mm->cm.fn==0 && mm->cm.en==0){ - GLA()->setDrawMode(rm,vcg::GLW::DMPoints); - if(!(mask & vcg::tri::io::Mask::IOM_VERTNORMAL)) - GLA()->setLight(false); - else - mm->updateDataMask(MeshModel::MM_VERTNORMAL); - } - if(mm->cm.fn==0 && mm->cm.en>0){ - GLA()->setDrawMode(rm,vcg::GLW::DMWire); - if(!(mask & vcg::tri::io::Mask::IOM_VERTNORMAL)) - GLA()->setLight(false); - else - mm->updateDataMask(MeshModel::MM_VERTNORMAL); - } - else - mm->updateDataMask(MeshModel::MM_VERTNORMAL); + // In case of polygonal meshes the normal should be updated accordingly + if( mask & vcg::tri::io::Mask::IOM_BITPOLYGONAL) + { + mm->updateDataMask(MeshModel::MM_POLYGONAL); // just to be sure. Hopefully it should be done in the plugin... + int degNum = tri::Clean::RemoveDegenerateFace(mm->cm); + if(degNum) + GLA()->Logf(0,"Warning model contains %i degenerate faces. Removed them.",degNum); + mm->updateDataMask(MeshModel::MM_FACEFACETOPO); + vcg::tri::UpdateNormal::PerBitQuadFaceNormalized(mm->cm); + vcg::tri::UpdateNormal::PerVertexFromCurrentFaceNormal(mm->cm); + } // standard case + else + { + vcg::tri::UpdateNormal::PerFaceNormalized(mm->cm); + if(!( mask & vcg::tri::io::Mask::IOM_VERTNORMAL) ) + vcg::tri::UpdateNormal::PerVertexAngleWeighted(mm->cm); + } + vcg::tri::UpdateBounding::Box(mm->cm); // updates bounding box + if(mm->cm.fn==0 && mm->cm.en==0){ + GLA()->setDrawMode(rm,vcg::GLW::DMPoints); + if(!(mask & vcg::tri::io::Mask::IOM_VERTNORMAL)) + GLA()->setLight(false); + else + mm->updateDataMask(MeshModel::MM_VERTNORMAL); + } + if(mm->cm.fn==0 && mm->cm.en>0){ + GLA()->setDrawMode(rm,vcg::GLW::DMWire); + if(!(mask & vcg::tri::io::Mask::IOM_VERTNORMAL)) + GLA()->setLight(false); + else + mm->updateDataMask(MeshModel::MM_VERTNORMAL); + } + else + mm->updateDataMask(MeshModel::MM_VERTNORMAL); - updateMenus(); - int delVertNum = vcg::tri::Clean::RemoveDegenerateVertex(mm->cm); - int delFaceNum = vcg::tri::Clean::RemoveDegenerateFace(mm->cm); + updateMenus(); + int delVertNum = vcg::tri::Clean::RemoveDegenerateVertex(mm->cm); + int delFaceNum = vcg::tri::Clean::RemoveDegenerateFace(mm->cm); - if(delVertNum>0 || delFaceNum>0 ) - QMessageBox::warning(this, "MeshLab Warning", QString("Warning mesh contains %1 vertices with NAN coords and %2 degenerated faces.\nCorrected.").arg(delVertNum).arg(delFaceNum) ); - meshDoc()->setBusy(false); - return true; + if(delVertNum>0 || delFaceNum>0 ) + QMessageBox::warning(this, "MeshLab Warning", QString("Warning mesh contains %1 vertices with NAN coords and %2 degenerated faces.\nCorrected.").arg(delVertNum).arg(delFaceNum) ); + meshDoc()->setBusy(false); + return true; } // Opening files in a transparent form (IO plugins contribution is hidden to user) bool MainWindow::importMesh(QString fileName) { - if (!GLA()) - { - this->newProject(); - if(!GLA()) - return false; - } + if (!GLA()) + { + this->newProject(); + if(!GLA()) + return false; + } - //QStringList suffixList; - // HashTable storing all supported formats together with - // the (1-based) index of first plugin which is able to open it - //QHash allKnownFormats; - //PM.LoadFormats(suffixList, allKnownFormats,PluginManager::IMPORT); - QStringList fileNameList; - if (fileName.isEmpty()) - fileNameList = QFileDialog::getOpenFileNames(this,tr("Import Mesh"), lastUsedDirectory.path(), PM.inpFilters.join(";;")); - else - fileNameList.push_back(fileName); + //QStringList suffixList; + // HashTable storing all supported formats together with + // the (1-based) index of first plugin which is able to open it + //QHash allKnownFormats; + //PM.LoadFormats(suffixList, allKnownFormats,PluginManager::IMPORT); + QStringList fileNameList; + if (fileName.isEmpty()) + fileNameList = QFileDialog::getOpenFileNames(this,tr("Import Mesh"), lastUsedDirectory.path(), PM.inpFilters.join(";;")); + else + fileNameList.push_back(fileName); if (fileNameList.isEmpty()) return false; else @@ -2341,12 +2351,12 @@ bool MainWindow::importMesh(QString fileName) QString extension = fi.suffix(); MeshIOInterface *pCurrentIOPlugin = PM.allKnowInputFormats[extension.toLower()]; //pCurrentIOPlugin->setLog(gla->log); - if (pCurrentIOPlugin == NULL) - { - QString errorMsgFormat("Unable to open file:\n\"%1\"\n\nError details: file format " + extension + " not supported."); - QMessageBox::critical(this, tr("Meshlab Opening Error"), errorMsgFormat.arg(fileName)); - return false; - } + if (pCurrentIOPlugin == NULL) + { + QString errorMsgFormat("Unable to open file:\n\"%1\"\n\nError details: file format " + extension + " not supported."); + QMessageBox::critical(this, tr("Meshlab Opening Error"), errorMsgFormat.arg(fileName)); + return false; + } RichParameterSet prePar; pCurrentIOPlugin->initPreOpenParameter(extension, fileName,prePar); @@ -2358,11 +2368,11 @@ bool MainWindow::importMesh(QString fileName) } int mask = 0; //MeshModel *mm= new MeshModel(gla->meshDoc); - QFileInfo info(fileName); - MeshModel *mm=meshDoc()->addNewMesh(qPrintable(fileName),info.fileName()); + QFileInfo info(fileName); + MeshModel *mm=meshDoc()->addNewMesh(qPrintable(fileName),info.fileName()); qb->show(); QTime t;t.start(); - bool open = loadMesh(fileName,pCurrentIOPlugin,mm,mask,&prePar); + bool open = loadMesh(fileName,pCurrentIOPlugin,mm,mask,&prePar); if(open) { GLA()->Logf(0,"Opened mesh %s in %i msec",qPrintable(fileName),t.elapsed()); @@ -2384,9 +2394,9 @@ bool MainWindow::importMesh(QString fileName) GLA()->Logf(0,"Warning: Mesh %s has not been opened",qPrintable(fileName)); } }// end foreach file of the input list - GLA()->Logf(0,"All files opened in %i msec",allFileTime.elapsed()); + GLA()->Logf(0,"All files opened in %i msec",allFileTime.elapsed()); - this->currentViewContainer()->resetAllTrackBall(); + this->currentViewContainer()->resetAllTrackBall(); qb->reset(); return true; @@ -2394,10 +2404,10 @@ bool MainWindow::importMesh(QString fileName) void MainWindow::openRecentMesh() { - if(!GLA()) return; - if(meshDoc()->isBusy()) return; - QAction *action = qobject_cast(sender()); - if (action) importMesh(action->data().toString()); + if(!GLA()) return; + if(meshDoc()->isBusy()) return; + QAction *action = qobject_cast(sender()); + if (action) importMesh(action->data().toString()); } void MainWindow::openRecentProj() @@ -2408,6 +2418,8 @@ void MainWindow::openRecentProj() bool MainWindow::loadMeshWithStandardParams(QString& fullPath,MeshModel* mm) { + if ((meshDoc() == nullptr) || (mm == nullptr)) + return false; bool ret = false; mm->Clear(); QFileInfo fi(fullPath); @@ -2418,8 +2430,8 @@ bool MainWindow::loadMeshWithStandardParams(QString& fullPath,MeshModel* mm) RichParameterSet prePar; pCurrentIOPlugin->initPreOpenParameter(extension, fullPath,prePar); int mask = 0; - QTime t;t.start(); - bool open = loadMesh(fullPath,pCurrentIOPlugin,mm,mask,&prePar); + QTime t;t.start(); + bool open = loadMesh(fullPath,pCurrentIOPlugin,mm,mask,&prePar); if(open) { GLA()->Logf(0,"Opened mesh %s in %i msec",qPrintable(fullPath),t.elapsed()); @@ -2438,20 +2450,22 @@ bool MainWindow::loadMeshWithStandardParams(QString& fullPath,MeshModel* mm) void MainWindow::reloadAllMesh() { - // Discards changes and reloads current file - // save current file name - qb->show(); - foreach(MeshModel *mmm,meshDoc()->meshList) - { - QString fileName = mmm->fullName(); - loadMeshWithStandardParams(fileName,mmm); - } - qb->reset(); - update(); + // Discards changes and reloads current file + // save current file name + qb->show(); + foreach(MeshModel *mmm,meshDoc()->meshList) + { + QString fileName = mmm->fullName(); + loadMeshWithStandardParams(fileName,mmm); + } + qb->reset(); + update(); } void MainWindow::reload() { + if ((meshDoc() == nullptr) || (meshDoc()->mm() == nullptr)) + return; // Discards changes and reloads current file // save current file name qb->show(); @@ -2463,26 +2477,26 @@ void MainWindow::reload() bool MainWindow::exportMesh(QString fileName,MeshModel* mod,const bool saveAllPossibleAttributes) { - QStringList& suffixList = PM.outFilters; + QStringList& suffixList = PM.outFilters; - //QHash allKnownFormats; - QFileInfo fi(fileName); - //PM.LoadFormats( suffixList, allKnownFormats,PluginManager::EXPORT); - //QString defaultExt = "*." + mod->suffixName().toLower(); - QString defaultExt = "*." + fi.suffix().toLower(); - if(defaultExt == "*.") - defaultExt = "*.ply"; - if (mod == NULL) - return false; - mod->meshModified() = false; - QString laylabel = "Save \"" + mod->label() + "\" Layer"; - QFileDialog* saveDialog = new QFileDialog(this,laylabel, mod->fullName()); - saveDialog->setNameFilters(suffixList); - saveDialog->setAcceptMode(QFileDialog::AcceptSave); + //QHash allKnownFormats; + QFileInfo fi(fileName); + //PM.LoadFormats( suffixList, allKnownFormats,PluginManager::EXPORT); + //QString defaultExt = "*." + mod->suffixName().toLower(); + QString defaultExt = "*." + fi.suffix().toLower(); + if(defaultExt == "*.") + defaultExt = "*.ply"; + if (mod == NULL) + return false; + mod->meshModified() = false; + QString laylabel = "Save \"" + mod->label() + "\" Layer"; + QFileDialog* saveDialog = new QFileDialog(this,laylabel, mod->fullName()); + saveDialog->setNameFilters(suffixList); + saveDialog->setAcceptMode(QFileDialog::AcceptSave); connect(saveDialog,SIGNAL(filterSelected(const QString&)),this,SLOT(changeFileExtension(const QString&))); - QStringList matchingExtensions=suffixList.filter(defaultExt); - if(!matchingExtensions.isEmpty()) - saveDialog->selectNameFilter(matchingExtensions.last()); + QStringList matchingExtensions=suffixList.filter(defaultExt); + if(!matchingExtensions.isEmpty()) + saveDialog->selectNameFilter(matchingExtensions.last()); if (fileName.isEmpty()){ int dialogRet = saveDialog->exec(); @@ -2518,7 +2532,7 @@ bool MainWindow::exportMesh(QString fileName,MeshModel* mod,const bool saveAllPo QString extension = fileName; extension.remove(0, fileName.lastIndexOf('.')+1); - QStringListIterator itFilter(suffixList); + QStringListIterator itFilter(suffixList); MeshIOInterface *pCurrentIOPlugin = PM.allKnowOutputFormats[extension.toLower()]; if (pCurrentIOPlugin == 0) @@ -2596,31 +2610,31 @@ bool MainWindow::save(const bool saveAllPossibleAttributes) bool MainWindow::saveAs(QString fileName,const bool saveAllPossibleAttributes) { - return exportMesh(fileName,meshDoc()->mm(),saveAllPossibleAttributes); + return exportMesh(fileName,meshDoc()->mm(),saveAllPossibleAttributes); } bool MainWindow::saveSnapshot() { - SaveSnapshotDialog dialog(this); + SaveSnapshotDialog dialog(this); - dialog.setValues(GLA()->ss); + dialog.setValues(GLA()->ss); if (dialog.exec()==QDialog::Accepted) { - GLA()->ss=dialog.getValues(); - GLA()->saveSnapshot(); + GLA()->ss=dialog.getValues(); + GLA()->saveSnapshot(); - // if user ask to add the snapshot to raster layers - /* - if(dialog.addToRasters()) - { - QString savedfile = QString("%1/%2%3.png") + // if user ask to add the snapshot to raster layers + /* + if(dialog.addToRasters()) + { + QString savedfile = QString("%1/%2%3.png") .arg(GLA()->ss.outdir).arg(GLA()->ss.basename) .arg(GLA()->ss.counter,2,10,QChar('0')); - importRaster(savedfile); - } -*/ + importRaster(savedfile); + } + */ return true; } @@ -2639,24 +2653,24 @@ void MainWindow::about() void MainWindow::aboutPlugins() { qDebug( "aboutPlugins(): Current Plugins Dir: %s ",qPrintable(pluginManager().getDefaultPluginDirPath())); - PluginDialog dialog(pluginManager().getDefaultPluginDirPath(), pluginManager().pluginsLoaded, this); + PluginDialog dialog(pluginManager().getDefaultPluginDirPath(), pluginManager().pluginsLoaded, this); dialog.exec(); } void MainWindow::helpOnscreen() { -if(GLA()) GLA()->toggleHelpVisible(); + if(GLA()) GLA()->toggleHelpVisible(); } void MainWindow::helpOnline() { - checkForUpdates(false); - QDesktopServices::openUrl(QUrl("http://sourceforge.net/apps/mediawiki/meshlab")); + checkForUpdates(false); + QDesktopServices::openUrl(QUrl("http://sourceforge.net/apps/mediawiki/meshlab")); } void MainWindow::showToolbarFile(){ - mainToolBar->setVisible(!mainToolBar->isVisible()); + mainToolBar->setVisible(!mainToolBar->isVisible()); } void MainWindow::showToolbarRender(){ @@ -2707,26 +2721,26 @@ void MainWindow::setCustomize() void MainWindow::fullScreen(){ - if(!isFullScreen()) - { - toolbarState = saveState(); - menuBar()->hide(); - mainToolBar->hide(); - renderToolBar->hide(); - globalStatusBar()->hide(); - setWindowState(windowState()^Qt::WindowFullScreen); - bool found=true; - //Caso di piu' finestre aperte in tile: - if((mdiarea->subWindowList()).size()>1){ - foreach(QWidget *w,mdiarea->subWindowList()){if(w->isMaximized()) found=false;} - if (found)mdiarea->tileSubWindows(); - } - } - else - { - menuBar()->show(); - restoreState(toolbarState); - globalStatusBar()->show(); + if(!isFullScreen()) + { + toolbarState = saveState(); + menuBar()->hide(); + mainToolBar->hide(); + renderToolBar->hide(); + globalStatusBar()->hide(); + setWindowState(windowState()^Qt::WindowFullScreen); + bool found=true; + //Caso di piu' finestre aperte in tile: + if((mdiarea->subWindowList()).size()>1){ + foreach(QWidget *w,mdiarea->subWindowList()){if(w->isMaximized()) found=false;} + if (found)mdiarea->tileSubWindows(); + } + } + else + { + menuBar()->show(); + restoreState(toolbarState); + globalStatusBar()->show(); setWindowState(windowState()^ Qt::WindowFullScreen); bool found=true; @@ -2736,17 +2750,17 @@ void MainWindow::fullScreen(){ if (found){mdiarea->tileSubWindows();} } fullScreenAct->setChecked(false); - } + } } void MainWindow::keyPressEvent(QKeyEvent *e) { - if(e->key()==Qt::Key_Return && e->modifiers()==Qt::AltModifier) - { - fullScreen(); - e->accept(); - } - else e->ignore(); + if(e->key()==Qt::Key_Return && e->modifiers()==Qt::AltModifier) + { + fullScreen(); + e->accept(); + } + else e->ignore(); } bool MainWindow::QCallBack(const int pos, const char * str)