diff --git a/src/meshlab/mainwindow_Init.cpp b/src/meshlab/mainwindow_Init.cpp
index ed0326e0b..0296df1e0 100644
--- a/src/meshlab/mainwindow_Init.cpp
+++ b/src/meshlab/mainwindow_Init.cpp
@@ -1020,7 +1020,7 @@ void MainWindow::checkForUpdates(bool verboseFlag)
UID = QUuid::createUuid().toString();
settings.setValue("UID", UID);
}
- QString BaseCommand("/~cignoni/meshlab_latest.php");
+ QString baseCommand("/~cignoni/meshlab_latest.php");
#ifdef Q_OS_WIN
QString OS = "Win";
@@ -1029,7 +1029,7 @@ void MainWindow::checkForUpdates(bool verboseFlag)
#else
QString OS = "Lin";
#endif
- QString message = BaseCommand + QString("?code=%1&count=%2&scount=%3&totkv=%4&ver=%5&os=%6").arg(UID).arg(loadedMeshCounter).arg(savedMeshCounter).arg(totalKV).arg(MeshLabApplication::appVer()).arg(OS);
+ QString message = baseCommand + QString("?code=%1&count=%2&scount=%3&totkv=%4&ver=%5&os=%6").arg(UID).arg(loadedMeshCounter).arg(savedMeshCounter).arg(totalKV).arg(MeshLabApplication::appVer()).arg(OS);
QNetworkAccessManager stats;
QNetworkRequest statreq(MeshLabApplication::organizationHost() + message);
@@ -1045,17 +1045,21 @@ void MainWindow::connectionDone(QNetworkReply *reply)
QSettings::setDefaultFormat(QSettings::NativeFormat);
bool dontRemindMeAboutUpgradeVal = false;
+ bool checkForMonthlyAndBetasVal = false;
const QString dontRemindMeAboutUpgradeVar("dontRemindMeAboutUpgrade");
-
const QString checkForMonthlyAndBetasVar("checkForMonthlyAndBetas");
// Check if the user specified not to be reminded to upgrade
+ if (settings.contains(dontRemindMeAboutUpgradeVar))
+ dontRemindMeAboutUpgradeVal = settings.value(dontRemindMeAboutUpgradeVar).toBool();
if (!verboseCheckingFlag) {
- if (settings.contains(dontRemindMeAboutUpgradeVar))
- dontRemindMeAboutUpgradeVal = settings.value(dontRemindMeAboutUpgradeVar).toBool();
if (dontRemindMeAboutUpgradeVal)
return;
}
+
+ if (settings.contains(checkForMonthlyAndBetasVar)){
+ checkForMonthlyAndBetasVal = settings.value(checkForMonthlyAndBetasVar).toBool();;
+ }
QByteArray ddata = reply->readAll();
QString onlineVersion = QString::fromStdString(ddata.toStdString());
@@ -1073,6 +1077,12 @@ void MainWindow::connectionDone(QNetworkReply *reply)
if (splitOnlineVersion[1].toInt() > splitThisVersion[1].toInt()) {
newVersionAvailable = true;
}
+ else if (splitOnlineVersion[1].toInt() == splitThisVersion[1].toInt() && splitOnlineVersion.size() > 2) {
+ //case of beta version or very important fixes
+ if (splitThisVersion.size() == 2 || (splitThisVersion.size() > 2 && splitOnlineVersion[2] > splitThisVersion[2])){
+ newVersionAvailable = true;
+ }
+ }
}
// Set up a message box for the user
@@ -1082,11 +1092,25 @@ void MainWindow::connectionDone(QNetworkReply *reply)
QCheckBox dontShowCheckBox("Don't show this message again.");
dontShowCheckBox.blockSignals(true);
msgBox.addButton(&dontShowCheckBox, QMessageBox::ResetRole);
+ dontShowCheckBox.setChecked(dontRemindMeAboutUpgradeVal);
QCheckBox checkMonthlysCheckBox("Check for Monthly and Beta versions.");
checkMonthlysCheckBox.blockSignals(true);
msgBox.addButton(&checkMonthlysCheckBox, QMessageBox::ResetRole);
+ checkMonthlysCheckBox.setChecked(checkForMonthlyAndBetasVal);
if (newVersionAvailable){
+ QString message =
+ "
You are using an old version of MeshLab.
"
+ "Please, upgrade to the new version!
";
+ if (checkForMonthlyAndBetasVal){
+ message +=
+ " Download";
+ }
+ else {
+ message +=
+ " Download";
+ }
+
msgBox.setText(
"You are using an old version of MeshLab.
"
"Please, upgrade to the new version!
"
@@ -1104,8 +1128,14 @@ void MainWindow::connectionDone(QNetworkReply *reply)
settings.setValue(dontRemindMeAboutUpgradeVar, true);
else if (userReply == QMessageBox::Ok && dontShowCheckBox.checkState() == Qt::Unchecked)
settings.setValue(dontRemindMeAboutUpgradeVar, false);
- if (userReply == QMessageBox::Ok && checkMonthlysCheckBox.checkState() == Qt::Checked)
+ if (userReply == QMessageBox::Ok && checkMonthlysCheckBox.checkState() == Qt::Checked) {
settings.setValue(checkForMonthlyAndBetasVar, true);
+ if (!checkForMonthlyAndBetasVal) {
+ //the user changed the states: he now wants to check for betas
+ //need to check again with properly set
+ checkForUpdates(false);
+ }
+ }
else if (userReply == QMessageBox::Ok && checkMonthlysCheckBox.checkState() == Qt::Unchecked)
settings.setValue(checkForMonthlyAndBetasVar, false);
}
diff --git a/src/meshlab/mainwindow_RunTime.cpp b/src/meshlab/mainwindow_RunTime.cpp
index 2cd1c065e..4df183ba2 100644
--- a/src/meshlab/mainwindow_RunTime.cpp
+++ b/src/meshlab/mainwindow_RunTime.cpp
@@ -66,61 +66,61 @@ using namespace vcg;
void MainWindow::updateRecentFileActions()
{
- bool activeDoc = (bool) !mdiarea->subWindowList().empty() && mdiarea->currentSubWindow();
-
- QSettings settings;
- QStringList files = settings.value("recentFileList").toStringList();
-
- int numRecentFiles = qMin(files.size(), (int)MAXRECENTFILES);
-
- for (int i = 0; i < numRecentFiles; ++i)
- {
- QString text = tr("&%1 %2").arg(i + 1).arg(QFileInfo(files[i]).fileName());
- recentFileActs[i]->setText(text);
- recentFileActs[i]->setData(files[i]);
- recentFileActs[i]->setEnabled(activeDoc);
- }
- for (int j = numRecentFiles; j < MAXRECENTFILES; ++j)
- recentFileActs[j]->setVisible(false);
+ bool activeDoc = (bool) !mdiarea->subWindowList().empty() && mdiarea->currentSubWindow();
+
+ QSettings settings;
+ QStringList files = settings.value("recentFileList").toStringList();
+
+ int numRecentFiles = qMin(files.size(), (int)MAXRECENTFILES);
+
+ for (int i = 0; i < numRecentFiles; ++i)
+ {
+ QString text = tr("&%1 %2").arg(i + 1).arg(QFileInfo(files[i]).fileName());
+ recentFileActs[i]->setText(text);
+ recentFileActs[i]->setData(files[i]);
+ recentFileActs[i]->setEnabled(activeDoc);
+ }
+ for (int j = numRecentFiles; j < MAXRECENTFILES; ++j)
+ recentFileActs[j]->setVisible(false);
}
void MainWindow::updateRecentProjActions()
{
- //bool activeDoc = (bool) !mdiarea->subWindowList().empty() && mdiarea->currentSubWindow();
-
- QSettings settings;
- QStringList projs = settings.value("recentProjList").toStringList();
-
- int numRecentProjs = qMin(projs.size(), (int)MAXRECENTFILES);
- for (int i = 0; i < numRecentProjs; ++i)
- {
- QString text = tr("&%1 %2").arg(i + 1).arg(QFileInfo(projs[i]).fileName());
- recentProjActs[i]->setText(text);
- recentProjActs[i]->setData(projs[i]);
- recentProjActs[i]->setEnabled(true);
- }
- for (int j = numRecentProjs; j < MAXRECENTFILES; ++j)
- recentProjActs[j]->setVisible(false);
+ //bool activeDoc = (bool) !mdiarea->subWindowList().empty() && mdiarea->currentSubWindow();
+
+ QSettings settings;
+ QStringList projs = settings.value("recentProjList").toStringList();
+
+ int numRecentProjs = qMin(projs.size(), (int)MAXRECENTFILES);
+ for (int i = 0; i < numRecentProjs; ++i)
+ {
+ QString text = tr("&%1 %2").arg(i + 1).arg(QFileInfo(projs[i]).fileName());
+ recentProjActs[i]->setText(text);
+ recentProjActs[i]->setData(projs[i]);
+ recentProjActs[i]->setEnabled(true);
+ }
+ for (int j = numRecentProjs; j < MAXRECENTFILES; ++j)
+ recentProjActs[j]->setVisible(false);
}
// creates the standard plugin window
void MainWindow::createStdPluginWnd()
{
- //checks if a MeshlabStdDialog is already open and closes it
- if (stddialog!=0)
- {
- stddialog->close();
- delete stddialog;
- }
- stddialog = new MeshlabStdDialog(this);
- stddialog->setAllowedAreas ( Qt::NoDockWidgetArea);
- //addDockWidget(Qt::RightDockWidgetArea,stddialog);
-
- //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()));
+ //checks if a MeshlabStdDialog is already open and closes it
+ if (stddialog!=0)
+ {
+ stddialog->close();
+ delete stddialog;
+ }
+ stddialog = new MeshlabStdDialog(this);
+ stddialog->setAllowedAreas ( Qt::NoDockWidgetArea);
+ //addDockWidget(Qt::RightDockWidgetArea,stddialog);
+
+ //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()));
}
// When we switch the current model (and we change the active window)
@@ -128,125 +128,125 @@ void MainWindow::createStdPluginWnd()
// this one is called when user switch current window.
void MainWindow::updateStdDialog()
{
- if(stddialog!=0){
- if(GLA()!=0){
- if(stddialog->curModel != meshDoc()->mm()){
- stddialog->curgla=0; // invalidate the curgla member that is no more valid.
- stddialog->close();
- }
- }
- }
+ if(stddialog!=0){
+ if(GLA()!=0){
+ if(stddialog->curModel != meshDoc()->mm()){
+ stddialog->curgla=0; // invalidate the curgla member that is no more valid.
+ stddialog->close();
+ }
+ }
+ }
}
void MainWindow::updateCustomSettings()
{
- mwsettings.updateGlobalParameterList(currentGlobalParams);
- emit dispatchCustomSettings(currentGlobalParams);
+ mwsettings.updateGlobalParameterList(currentGlobalParams);
+ emit dispatchCustomSettings(currentGlobalParams);
}
void MainWindow::updateWindowMenu()
{
- windowsMenu->clear();
- windowsMenu->addAction(closeAllAct);
- windowsMenu->addSeparator();
- windowsMenu->addAction(windowsTileAct);
- windowsMenu->addAction(windowsCascadeAct);
- windowsMenu->addAction(windowsNextAct);
- windowsNextAct->setEnabled(mdiarea-> subWindowList().size()>1);
-
- windowsMenu->addSeparator();
-
-
- if((mdiarea-> subWindowList().size()>0)){
- // Split/Unsplit SUBmenu
- splitModeMenu = windowsMenu->addMenu(tr("&Split current view"));
-
- splitModeMenu->addAction(setSplitHAct);
- splitModeMenu->addAction(setSplitVAct);
-
- windowsMenu->addAction(setUnsplitAct);
-
- // Link act
- windowsMenu->addAction(linkViewersAct);
-
- // View From SUBmenu
- viewFromMenu = windowsMenu->addMenu(tr("&View from"));
- foreach(QAction *ac, viewFromGroupAct->actions())
- viewFromMenu->addAction(ac);
-
+ windowsMenu->clear();
+ windowsMenu->addAction(closeAllAct);
+ windowsMenu->addSeparator();
+ windowsMenu->addAction(windowsTileAct);
+ windowsMenu->addAction(windowsCascadeAct);
+ windowsMenu->addAction(windowsNextAct);
+ windowsNextAct->setEnabled(mdiarea-> subWindowList().size()>1);
+
+ windowsMenu->addSeparator();
+
+
+ if((mdiarea-> subWindowList().size()>0)){
+ // Split/Unsplit SUBmenu
+ splitModeMenu = windowsMenu->addMenu(tr("&Split current view"));
+
+ splitModeMenu->addAction(setSplitHAct);
+ splitModeMenu->addAction(setSplitVAct);
+
+ windowsMenu->addAction(setUnsplitAct);
+
+ // Link act
+ windowsMenu->addAction(linkViewersAct);
+
+ // View From SUBmenu
+ viewFromMenu = windowsMenu->addMenu(tr("&View from"));
+ foreach(QAction *ac, viewFromGroupAct->actions())
+ viewFromMenu->addAction(ac);
+
// Trackball Step SUBmenu
trackballStepMenu = windowsMenu->addMenu(tr("Trackball step"));
foreach(QAction *ac, trackballStepGroupAct->actions())
trackballStepMenu->addAction(ac);
-
- // View From File act
- windowsMenu->addAction(readViewFromFileAct);
- windowsMenu->addAction(saveViewToFileAct);
- windowsMenu->addAction(viewFromMeshAct);
- windowsMenu->addAction(viewFromRasterAct);
-
- // Copy and paste shot acts
- windowsMenu->addAction(copyShotToClipboardAct);
- windowsMenu->addAction(pasteShotFromClipboardAct);
-
- //Enabling the actions
- 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());
-
- linkViewersAct->setEnabled(currentViewContainer()->viewerCounter()>1);
- if(currentViewContainer()->viewerCounter()==1)
- linkViewersAct->setChecked(false);
-
- windowsMenu->addSeparator();
- }
- }
- }
-
- QList windows = mdiarea->subWindowList();
-
- if(windows.size() > 0)
- windowsMenu->addSeparator();
-
- int i=0;
- foreach(QWidget *w,windows)
- {
- QString text = tr("&%1. %2").arg(i+1).arg(QFileInfo(w->windowTitle()).fileName());
- QAction *action = windowsMenu->addAction(text);
- action->setCheckable(true);
- action->setChecked(w == mdiarea->currentSubWindow());
- // Connect the signal to activate the selected window
- connect(action, SIGNAL(triggered()), windowMapper, SLOT(map()));
- windowMapper->setMapping(action, w);
- ++i;
- }
+
+ // View From File act
+ windowsMenu->addAction(readViewFromFileAct);
+ windowsMenu->addAction(saveViewToFileAct);
+ windowsMenu->addAction(viewFromMeshAct);
+ windowsMenu->addAction(viewFromRasterAct);
+
+ // Copy and paste shot acts
+ windowsMenu->addAction(copyShotToClipboardAct);
+ windowsMenu->addAction(pasteShotFromClipboardAct);
+
+ //Enabling the actions
+ 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());
+
+ linkViewersAct->setEnabled(currentViewContainer()->viewerCounter()>1);
+ if(currentViewContainer()->viewerCounter()==1)
+ linkViewersAct->setChecked(false);
+
+ windowsMenu->addSeparator();
+ }
+ }
+ }
+
+ QList windows = mdiarea->subWindowList();
+
+ if(windows.size() > 0)
+ windowsMenu->addSeparator();
+
+ int i=0;
+ foreach(QWidget *w,windows)
+ {
+ QString text = tr("&%1. %2").arg(i+1).arg(QFileInfo(w->windowTitle()).fileName());
+ QAction *action = windowsMenu->addAction(text);
+ action->setCheckable(true);
+ action->setChecked(w == mdiarea->currentSubWindow());
+ // Connect the signal to activate the selected window
+ connect(action, SIGNAL(triggered()), windowMapper, SLOT(map()));
+ windowMapper->setMapping(action, w);
+ ++i;
+ }
}
void MainWindow::enableDocumentSensibleActionsContainer(const bool allowed)
{
- QAction* fileact = fileMenu->menuAction();
- if (fileact != NULL)
- fileact->setEnabled(allowed);
- if (mainToolBar != NULL)
- mainToolBar->setEnabled(allowed);
- if (searchToolBar != NULL)
- searchToolBar->setEnabled(allowed);
- QAction* filtact = filterMenu->menuAction();
- if (filtact != NULL)
- filtact->setEnabled(allowed);
- if (filterToolBar != NULL)
- filterToolBar->setEnabled(allowed);
- QAction* editact = editMenu->menuAction();
- if (editact != NULL)
- editact->setEnabled(allowed);
- if (editToolBar)
- editToolBar->setEnabled(allowed);
+ QAction* fileact = fileMenu->menuAction();
+ if (fileact != NULL)
+ fileact->setEnabled(allowed);
+ if (mainToolBar != NULL)
+ mainToolBar->setEnabled(allowed);
+ if (searchToolBar != NULL)
+ searchToolBar->setEnabled(allowed);
+ QAction* filtact = filterMenu->menuAction();
+ if (filtact != NULL)
+ filtact->setEnabled(allowed);
+ if (filterToolBar != NULL)
+ filterToolBar->setEnabled(allowed);
+ QAction* editact = editMenu->menuAction();
+ if (editact != NULL)
+ editact->setEnabled(allowed);
+ if (editToolBar)
+ editToolBar->setEnabled(allowed);
}
@@ -254,401 +254,401 @@ void MainWindow::enableDocumentSensibleActionsContainer(const bool allowed)
//menu create is not enabled only in case of not valid/existing meshdocument
void MainWindow::updateSubFiltersMenu( const bool createmenuenabled,const bool validmeshdoc )
{
- showFilterScriptAct->setEnabled(validmeshdoc);
- filterMenuSelect->setEnabled(validmeshdoc);
- updateMenuItems(filterMenuSelect,validmeshdoc);
- filterMenuClean->setEnabled(validmeshdoc);
- updateMenuItems(filterMenuClean,validmeshdoc);
- filterMenuCreate->setEnabled(createmenuenabled || validmeshdoc);
- updateMenuItems(filterMenuCreate,createmenuenabled || validmeshdoc);
- filterMenuRemeshing->setEnabled(validmeshdoc);
- updateMenuItems(filterMenuRemeshing,validmeshdoc);
- filterMenuPolygonal->setEnabled(validmeshdoc);
- updateMenuItems(filterMenuPolygonal,validmeshdoc);
- filterMenuColorize->setEnabled(validmeshdoc);
- updateMenuItems(filterMenuColorize,validmeshdoc);
- filterMenuSmoothing->setEnabled(validmeshdoc);
- updateMenuItems(filterMenuSmoothing,validmeshdoc);
- filterMenuQuality->setEnabled(validmeshdoc);
- updateMenuItems(filterMenuQuality,validmeshdoc);
- filterMenuNormal->setEnabled(validmeshdoc);
- updateMenuItems(filterMenuNormal,validmeshdoc);
- filterMenuMeshLayer->setEnabled(validmeshdoc);
- updateMenuItems(filterMenuMeshLayer,validmeshdoc);
- filterMenuRasterLayer->setEnabled(validmeshdoc);
- updateMenuItems(filterMenuRasterLayer,validmeshdoc);
- filterMenuRangeMap->setEnabled(validmeshdoc);
- updateMenuItems(filterMenuRangeMap,validmeshdoc);
- filterMenuPointSet->setEnabled(validmeshdoc);
- updateMenuItems(filterMenuPointSet,validmeshdoc);
- filterMenuSampling->setEnabled(validmeshdoc);
- updateMenuItems(filterMenuSampling,validmeshdoc);
- filterMenuTexture->setEnabled(validmeshdoc);
- updateMenuItems(filterMenuTexture,validmeshdoc);
- filterMenuCamera->setEnabled(validmeshdoc);
- updateMenuItems(filterMenuCamera,validmeshdoc);
-
+ showFilterScriptAct->setEnabled(validmeshdoc);
+ filterMenuSelect->setEnabled(validmeshdoc);
+ updateMenuItems(filterMenuSelect,validmeshdoc);
+ filterMenuClean->setEnabled(validmeshdoc);
+ updateMenuItems(filterMenuClean,validmeshdoc);
+ filterMenuCreate->setEnabled(createmenuenabled || validmeshdoc);
+ updateMenuItems(filterMenuCreate,createmenuenabled || validmeshdoc);
+ filterMenuRemeshing->setEnabled(validmeshdoc);
+ updateMenuItems(filterMenuRemeshing,validmeshdoc);
+ filterMenuPolygonal->setEnabled(validmeshdoc);
+ updateMenuItems(filterMenuPolygonal,validmeshdoc);
+ filterMenuColorize->setEnabled(validmeshdoc);
+ updateMenuItems(filterMenuColorize,validmeshdoc);
+ filterMenuSmoothing->setEnabled(validmeshdoc);
+ updateMenuItems(filterMenuSmoothing,validmeshdoc);
+ filterMenuQuality->setEnabled(validmeshdoc);
+ updateMenuItems(filterMenuQuality,validmeshdoc);
+ filterMenuNormal->setEnabled(validmeshdoc);
+ updateMenuItems(filterMenuNormal,validmeshdoc);
+ filterMenuMeshLayer->setEnabled(validmeshdoc);
+ updateMenuItems(filterMenuMeshLayer,validmeshdoc);
+ filterMenuRasterLayer->setEnabled(validmeshdoc);
+ updateMenuItems(filterMenuRasterLayer,validmeshdoc);
+ filterMenuRangeMap->setEnabled(validmeshdoc);
+ updateMenuItems(filterMenuRangeMap,validmeshdoc);
+ filterMenuPointSet->setEnabled(validmeshdoc);
+ updateMenuItems(filterMenuPointSet,validmeshdoc);
+ filterMenuSampling->setEnabled(validmeshdoc);
+ updateMenuItems(filterMenuSampling,validmeshdoc);
+ filterMenuTexture->setEnabled(validmeshdoc);
+ updateMenuItems(filterMenuTexture,validmeshdoc);
+ filterMenuCamera->setEnabled(validmeshdoc);
+ updateMenuItems(filterMenuCamera,validmeshdoc);
+
}
void MainWindow::updateMenuItems(QMenu* menu,const bool enabled)
{
- foreach(QAction* act,menu->actions())
- act->setEnabled(enabled);
+ foreach(QAction* act,menu->actions())
+ act->setEnabled(enabled);
}
void MainWindow::switchOffDecorator(QAction* decorator)
{
- if (GLA() != NULL)
- {
- int res = GLA()->iCurPerMeshDecoratorList().removeAll(decorator);
- if (res == 0)
- GLA()->iPerDocDecoratorlist.removeAll(decorator);
- updateMenus();
+ if (GLA() != NULL)
+ {
+ int res = GLA()->iCurPerMeshDecoratorList().removeAll(decorator);
+ if (res == 0)
+ GLA()->iPerDocDecoratorlist.removeAll(decorator);
+ updateMenus();
layerDialog->updateDecoratorParsView();
- GLA()->update();
- }
+ GLA()->update();
+ }
}
void MainWindow::updateLayerDialog()
{
if ((meshDoc() == NULL) || ((layerDialog != NULL) && !(layerDialog->isVisible())))
return;
- MultiViewer_Container* mvc = currentViewContainer();
- if (mvc == NULL)
- return;
- MLSceneGLSharedDataContext* shared = mvc->sharedDataContext();
- if (shared == NULL)
- return;
- if(GLA())
- {
- MLSceneGLSharedDataContext::PerMeshRenderingDataMap dtf;
- shared->getRenderInfoPerMeshView(GLA()->context(),dtf);
+ MultiViewer_Container* mvc = currentViewContainer();
+ if (mvc == NULL)
+ return;
+ MLSceneGLSharedDataContext* shared = mvc->sharedDataContext();
+ if (shared == NULL)
+ return;
+ if(GLA())
+ {
+ MLSceneGLSharedDataContext::PerMeshRenderingDataMap dtf;
+ shared->getRenderInfoPerMeshView(GLA()->context(),dtf);
/*Add to the table the info for the per view global rendering of the Project*/
MLRenderingData projdt;
//GLA()->getPerDocGlobalRenderingData(projdt);
dtf[-1] = projdt;
- layerDialog->updateTable(dtf);
- layerDialog->updateLog(meshDoc()->Log);
- layerDialog->updateDecoratorParsView();
- MLRenderingData dt;
- if (meshDoc()->mm() != NULL)
+ layerDialog->updateTable(dtf);
+ layerDialog->updateLog(meshDoc()->Log);
+ layerDialog->updateDecoratorParsView();
+ MLRenderingData dt;
+ if (meshDoc()->mm() != NULL)
{
MLSceneGLSharedDataContext::PerMeshRenderingDataMap::iterator it = dtf.find(meshDoc()->mm()->id());
if (it != dtf.end())
layerDialog->updateRenderingParametersTab(meshDoc()->mm()->id(),*it);
- }
+ }
if (globrendtoolbar != NULL)
{
shared->getRenderInfoPerMeshView(GLA()->context(), dtf);
globrendtoolbar->statusConsistencyCheck(dtf);
}
- }
+ }
}
void MainWindow::updateMenus()
{
-
- bool activeDoc = !(mdiarea->subWindowList().empty()) && (mdiarea->currentSubWindow() != NULL);
- bool notEmptyActiveDoc = activeDoc && (meshDoc() != NULL) && !(meshDoc()->meshList.empty());
-
+
+ bool activeDoc = !(mdiarea->subWindowList().empty()) && (mdiarea->currentSubWindow() != NULL);
+ bool notEmptyActiveDoc = activeDoc && (meshDoc() != NULL) && !(meshDoc()->meshList.empty());
+
//std::cout << "SubWindowsList empty: " << mdiarea->subWindowList().empty() << " Valid Current Sub Windows: " << (mdiarea->currentSubWindow() != NULL) << " MeshList empty: " << meshDoc()->meshList.empty() << "\n";
-
- importMeshAct->setEnabled(activeDoc);
-
- exportMeshAct->setEnabled(notEmptyActiveDoc);
- exportMeshAsAct->setEnabled(notEmptyActiveDoc);
- reloadMeshAct->setEnabled(notEmptyActiveDoc);
- reloadAllMeshAct->setEnabled(notEmptyActiveDoc);
- importRasterAct->setEnabled(activeDoc);
-
- saveProjectAct->setEnabled(activeDoc);
- closeProjectAct->setEnabled(activeDoc);
-
- saveSnapshotAct->setEnabled(activeDoc);
-
- updateRecentFileActions();
- updateRecentProjActions();
- filterMenu->setEnabled(!filterMenu->actions().isEmpty());
- if (!filterMenu->actions().isEmpty())
- updateSubFiltersMenu(GLA() != NULL,notEmptyActiveDoc);
- lastFilterAct->setEnabled(false);
- lastFilterAct->setText(QString("Apply filter"));
- editMenu->setEnabled(!editMenu->actions().isEmpty());
- updateMenuItems(editMenu,activeDoc);
- renderMenu->setEnabled(!renderMenu->actions().isEmpty());
- updateMenuItems(renderMenu,activeDoc);
- fullScreenAct->setEnabled(activeDoc);
- showLayerDlgAct->setEnabled(activeDoc);
- showTrackBallAct->setEnabled(activeDoc);
- resetTrackBallAct->setEnabled(activeDoc);
- showInfoPaneAct->setEnabled(activeDoc);
- windowsMenu->setEnabled(activeDoc);
- preferencesMenu->setEnabled(activeDoc);
-
- showToolbarStandardAct->setChecked(mainToolBar->isVisible());
- if(activeDoc && GLA())
- {
- if(GLA()->getLastAppliedFilter() != NULL)
- {
- lastFilterAct->setText(QString("Apply filter ") + GLA()->getLastAppliedFilter()->text());
- lastFilterAct->setEnabled(true);
- }
-
- // Management of the editing toolbar
- // when you enter in a editing mode you can toggle between editing
- // and camera moving by esc;
- // you exit from editing mode by pressing again the editing button
- // When you are in a editing mode all the other editing are disabled.
-
- foreach (QAction *a,PM.editActionList)
- {
- a->setChecked(false);
- a->setEnabled( GLA()->getCurrentEditAction() == NULL );
- }
-
- suspendEditModeAct->setChecked(GLA()->suspendedEditor);
- suspendEditModeAct->setDisabled(GLA()->getCurrentEditAction() == NULL);
-
- if(GLA()->getCurrentEditAction())
- {
- GLA()->getCurrentEditAction()->setChecked(! GLA()->suspendedEditor);
- GLA()->getCurrentEditAction()->setEnabled(true);
- }
-
- showInfoPaneAct->setChecked(GLA()->infoAreaVisible);
- showTrackBallAct->setChecked(GLA()->isTrackBallVisible());
-
- // Decorator Menu Checking and unChecking
- // First uncheck and disable all the decorators
- foreach (QAction *a, PM.decoratorActionList)
- {
- a->setChecked(false);
- a->setEnabled(true);
- }
- // Check the decorator per Document of the current glarea
- foreach (QAction *a, GLA()->iPerDocDecoratorlist)
- { a ->setChecked(true); }
-
- // Then check the decorator enabled for the current mesh.
- if(GLA()->mm())
- foreach (QAction *a, GLA()->iCurPerMeshDecoratorList())
- a ->setChecked(true);
- } // if active
- else
- {
- foreach (QAction *a,PM.editActionList)
- {
- a->setEnabled(false);
- }
- foreach (QAction *a,PM.decoratorActionList)
- a->setEnabled(false);
-
- }
+
+ importMeshAct->setEnabled(activeDoc);
+
+ exportMeshAct->setEnabled(notEmptyActiveDoc);
+ exportMeshAsAct->setEnabled(notEmptyActiveDoc);
+ reloadMeshAct->setEnabled(notEmptyActiveDoc);
+ reloadAllMeshAct->setEnabled(notEmptyActiveDoc);
+ importRasterAct->setEnabled(activeDoc);
+
+ saveProjectAct->setEnabled(activeDoc);
+ closeProjectAct->setEnabled(activeDoc);
+
+ saveSnapshotAct->setEnabled(activeDoc);
+
+ updateRecentFileActions();
+ updateRecentProjActions();
+ filterMenu->setEnabled(!filterMenu->actions().isEmpty());
+ if (!filterMenu->actions().isEmpty())
+ updateSubFiltersMenu(GLA() != NULL,notEmptyActiveDoc);
+ lastFilterAct->setEnabled(false);
+ lastFilterAct->setText(QString("Apply filter"));
+ editMenu->setEnabled(!editMenu->actions().isEmpty());
+ updateMenuItems(editMenu,activeDoc);
+ renderMenu->setEnabled(!renderMenu->actions().isEmpty());
+ updateMenuItems(renderMenu,activeDoc);
+ fullScreenAct->setEnabled(activeDoc);
+ showLayerDlgAct->setEnabled(activeDoc);
+ showTrackBallAct->setEnabled(activeDoc);
+ resetTrackBallAct->setEnabled(activeDoc);
+ showInfoPaneAct->setEnabled(activeDoc);
+ windowsMenu->setEnabled(activeDoc);
+ preferencesMenu->setEnabled(activeDoc);
+
+ showToolbarStandardAct->setChecked(mainToolBar->isVisible());
+ if(activeDoc && GLA())
+ {
+ if(GLA()->getLastAppliedFilter() != NULL)
+ {
+ lastFilterAct->setText(QString("Apply filter ") + GLA()->getLastAppliedFilter()->text());
+ lastFilterAct->setEnabled(true);
+ }
+
+ // Management of the editing toolbar
+ // when you enter in a editing mode you can toggle between editing
+ // and camera moving by esc;
+ // you exit from editing mode by pressing again the editing button
+ // When you are in a editing mode all the other editing are disabled.
+
+ foreach (QAction *a,PM.editActionList)
+ {
+ a->setChecked(false);
+ a->setEnabled( GLA()->getCurrentEditAction() == NULL );
+ }
+
+ suspendEditModeAct->setChecked(GLA()->suspendedEditor);
+ suspendEditModeAct->setDisabled(GLA()->getCurrentEditAction() == NULL);
+
+ if(GLA()->getCurrentEditAction())
+ {
+ GLA()->getCurrentEditAction()->setChecked(! GLA()->suspendedEditor);
+ GLA()->getCurrentEditAction()->setEnabled(true);
+ }
+
+ showInfoPaneAct->setChecked(GLA()->infoAreaVisible);
+ showTrackBallAct->setChecked(GLA()->isTrackBallVisible());
+
+ // Decorator Menu Checking and unChecking
+ // First uncheck and disable all the decorators
+ foreach (QAction *a, PM.decoratorActionList)
+ {
+ a->setChecked(false);
+ a->setEnabled(true);
+ }
+ // Check the decorator per Document of the current glarea
+ foreach (QAction *a, GLA()->iPerDocDecoratorlist)
+ { a ->setChecked(true); }
+
+ // Then check the decorator enabled for the current mesh.
+ if(GLA()->mm())
+ foreach (QAction *a, GLA()->iCurPerMeshDecoratorList())
+ a ->setChecked(true);
+ } // if active
+ else
+ {
+ foreach (QAction *a,PM.editActionList)
+ {
+ a->setEnabled(false);
+ }
+ foreach (QAction *a,PM.decoratorActionList)
+ a->setEnabled(false);
+
+ }
GLArea* tmp = GLA();
- if(tmp != NULL)
- {
- showLayerDlgAct->setChecked(layerDialog->isVisible());
- showRasterAct->setEnabled((meshDoc() != NULL) && (meshDoc()->rm() != 0));
- showRasterAct->setChecked(tmp->isRaster());
- }
- else
- {
- foreach (QAction *a,PM.decoratorActionList)
- {
- a->setChecked(false);
- a->setEnabled(false);
- }
-
-
- layerDialog->setVisible(false);
- }
- if (searchMenu != NULL)
- searchMenu->searchLineWidth() = longestActionWidthInAllMenus();
- updateWindowMenu();
+ if(tmp != NULL)
+ {
+ showLayerDlgAct->setChecked(layerDialog->isVisible());
+ showRasterAct->setEnabled((meshDoc() != NULL) && (meshDoc()->rm() != 0));
+ showRasterAct->setChecked(tmp->isRaster());
+ }
+ else
+ {
+ foreach (QAction *a,PM.decoratorActionList)
+ {
+ a->setChecked(false);
+ a->setEnabled(false);
+ }
+
+
+ layerDialog->setVisible(false);
+ }
+ if (searchMenu != NULL)
+ searchMenu->searchLineWidth() = longestActionWidthInAllMenus();
+ updateWindowMenu();
}
void MainWindow::setSplit(QAction *qa)
{
- MultiViewer_Container *mvc = currentViewContainer();
- if(mvc)
- {
- GLArea *glwClone=new GLArea(this, mvc, ¤tGlobalParams);
+ MultiViewer_Container *mvc = currentViewContainer();
+ if(mvc)
+ {
+ GLArea *glwClone=new GLArea(this, mvc, ¤tGlobalParams);
//connect(glwClone, SIGNAL(insertRenderingDataForNewlyGeneratedMesh(int)), this, SLOT(addRenderingDataIfNewlyGeneratedMesh(int)));
- 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());
- }
-
- updateMenus();
-
- glwClone->resetTrackBall();
- glwClone->update();
- }
-
+ 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());
+ }
+
+ updateMenus();
+
+ glwClone->resetTrackBall();
+ glwClone->update();
+ }
+
}
void MainWindow::setUnsplit()
{
- MultiViewer_Container *mvc = currentViewContainer();
- if(mvc)
- {
- assert(mvc->viewerCounter() >1);
-
- mvc->removeView(mvc->currentView()->getId());
-
- updateMenus();
- }
+ MultiViewer_Container *mvc = currentViewContainer();
+ if(mvc)
+ {
+ assert(mvc->viewerCounter() >1);
+
+ mvc->removeView(mvc->currentView()->getId());
+
+ updateMenus();
+ }
}
//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
-
- //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());
-
- //the viewer on top can be closed only if the splitter over the handle that originated 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());
-
- //the viewer below can be closed only if the splitter ounder the handle that originated 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);
-
- 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);
-
- //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 right can be closed only if the splitter on the right the handle that originated 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());
-
- //the viewer on the left can be closed only if the splitter on the left of the handle that originated 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);
-
- unsplitRightAct->setData(point);
- unsplitLeftAct->setData(point);
-
- unSplitMenu->addAction(unsplitRightAct);
- unSplitMenu->addAction(unsplitLeftAct);
- }
- handleMenu->popup(point);
+ MultiViewer_Container *mvc = currentViewContainer();
+ 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);
+
+ //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 originated 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());
+
+ //the viewer below can be closed only if the splitter ounder the handle that originated 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);
+
+ 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);
+
+ //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 right can be closed only if the splitter on the right the handle that originated 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());
+
+ //the viewer on the left can be closed only if the splitter on the left of the handle that originated 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);
+
+ unsplitRightAct->setData(point);
+ unsplitLeftAct->setData(point);
+
+ unSplitMenu->addAction(unsplitRightAct);
+ unSplitMenu->addAction(unsplitLeftAct);
+ }
+ handleMenu->popup(point);
}
void MainWindow::splitFromHandle(QAction *qa )
{
- MultiViewer_Container *mvc = currentViewContainer();
- QPoint point = qa->data().toPoint();
- int epsilon =10;
-
- if(qa->text() == tr("&Right"))
- point.setX(point.x()+ epsilon);
- else if(qa->text() == tr("&Left"))
- point.setX(point.x()- epsilon);
- else if(qa->text() == tr("&Up"))
- point.setY(point.y()- epsilon);
- else if(qa->text() == tr("&Down"))
- point.setY(point.y()+ epsilon);
-
- int newCurrent = mvc->getViewerByPicking(point);
- mvc->updateCurrent(newCurrent);
-
- if(qa->text() == tr("&Right") || qa->text() == tr("&Left"))
- setSplit(new QAction(tr("&Horizontally"), this));
- else
- setSplit( new QAction(tr("&Vertically"), this));
+ MultiViewer_Container *mvc = currentViewContainer();
+ QPoint point = qa->data().toPoint();
+ int epsilon =10;
+
+ if(qa->text() == tr("&Right"))
+ point.setX(point.x()+ epsilon);
+ else if(qa->text() == tr("&Left"))
+ point.setX(point.x()- epsilon);
+ else if(qa->text() == tr("&Up"))
+ point.setY(point.y()- epsilon);
+ else if(qa->text() == tr("&Down"))
+ point.setY(point.y()+ epsilon);
+
+ int newCurrent = mvc->getViewerByPicking(point);
+ mvc->updateCurrent(newCurrent);
+
+ if(qa->text() == tr("&Right") || qa->text() == tr("&Left"))
+ setSplit(new QAction(tr("&Horizontally"), this));
+ else
+ setSplit( new QAction(tr("&Vertically"), this));
}
void MainWindow::unsplitFromHandle(QAction * qa)
{
- MultiViewer_Container *mvc = currentViewContainer();
-
- QPoint point = qa->data().toPoint();
- int epsilon =10;
-
- if(qa->text() == tr("&Right"))
- point.setX(point.x()+ epsilon);
- else if(qa->text() == tr("&Left"))
- point.setX(point.x()- epsilon);
- else if(qa->text() == tr("&Up"))
- point.setY(point.y()- epsilon);
- else if(qa->text() == tr("&Down"))
- point.setY(point.y()+ epsilon);
-
- int newCurrent = mvc->getViewerByPicking(point);
- mvc->updateCurrent(newCurrent);
-
- setUnsplit();
+ MultiViewer_Container *mvc = currentViewContainer();
+
+ QPoint point = qa->data().toPoint();
+ int epsilon =10;
+
+ if(qa->text() == tr("&Right"))
+ point.setX(point.x()+ epsilon);
+ else if(qa->text() == tr("&Left"))
+ point.setX(point.x()- epsilon);
+ else if(qa->text() == tr("&Up"))
+ point.setY(point.y()- epsilon);
+ else if(qa->text() == tr("&Down"))
+ point.setY(point.y()+ epsilon);
+
+ int newCurrent = mvc->getViewerByPicking(point);
+ mvc->updateCurrent(newCurrent);
+
+ setUnsplit();
}
void MainWindow::linkViewers()
{
- MultiViewer_Container *mvc = currentViewContainer();
- mvc->updateTrackballInViewers();
+ MultiViewer_Container *mvc = currentViewContainer();
+ mvc->updateTrackballInViewers();
}
void MainWindow::toggleOrtho()
@@ -658,7 +658,7 @@ void MainWindow::toggleOrtho()
void MainWindow::viewFrom(QAction *qa)
{
- if(GLA()) GLA()->createOrthoView(qa->text());
+ if(GLA()) GLA()->createOrthoView(qa->text());
}
void MainWindow::trackballStep(QAction *qa)
@@ -668,74 +668,74 @@ void MainWindow::trackballStep(QAction *qa)
void MainWindow::readViewFromFile()
{
- if(GLA()) GLA()->readViewFromFile();
- updateMenus();
+ if(GLA()) GLA()->readViewFromFile();
+ updateMenus();
}
void MainWindow::saveViewToFile()
{
- if(GLA()) GLA()->saveViewToFile();
+ if(GLA()) GLA()->saveViewToFile();
}
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)
{
- //qDebug("dragEnterEvent: %s",event->format());
- event->accept();
+ //qDebug("dragEnterEvent: %s",event->format());
+ event->accept();
}
void MainWindow::dropEvent ( QDropEvent * event )
{
- //qDebug("dropEvent: %s",event->format());
- const QMimeData * data = event->mimeData();
- if (data->hasUrls())
- {
- QList< QUrl > url_list = data->urls();
- bool layervis = false;
- if (layerDialog != NULL)
- {
- layervis = layerDialog->isVisible();
- showLayerDlg(false);
- }
- 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("mlb", Qt::CaseInsensitive) || path.endsWith("aln",Qt::CaseInsensitive) || path.endsWith("out",Qt::CaseInsensitive) || path.endsWith("nvm",Qt::CaseInsensitive) )
- openProject(path);
- else
- {
- importMesh(path);
- }
- }
- showLayerDlg(layervis || meshDoc()->meshList.size() > 0);
- }
+ //qDebug("dropEvent: %s",event->format());
+ const QMimeData * data = event->mimeData();
+ if (data->hasUrls())
+ {
+ QList< QUrl > url_list = data->urls();
+ bool layervis = false;
+ if (layerDialog != NULL)
+ {
+ layervis = layerDialog->isVisible();
+ showLayerDlg(false);
+ }
+ 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("mlb", Qt::CaseInsensitive) || path.endsWith("aln",Qt::CaseInsensitive) || path.endsWith("out",Qt::CaseInsensitive) || path.endsWith("nvm",Qt::CaseInsensitive) )
+ openProject(path);
+ else
+ {
+ importMesh(path);
+ }
+ }
+ showLayerDlg(layervis || meshDoc()->meshList.size() > 0);
+ }
}
void MainWindow::endEdit()
@@ -743,8 +743,8 @@ void MainWindow::endEdit()
MultiViewer_Container* mvc = currentViewContainer();
if ((meshDoc() == NULL) || (GLA() == NULL) || (mvc == NULL))
return;
-
-
+
+
for (int ii = 0; ii < meshDoc()->meshList.size(); ++ii)
{
MeshModel* mm = meshDoc()->meshList[ii];
@@ -752,44 +752,44 @@ void MainWindow::endEdit()
addRenderingDataIfNewlyGeneratedMesh(mm->id());
}
meshDoc()->meshDocStateData().clear();
-
+
GLA()->endEdit();
updateLayerDialog();
}
void MainWindow::showFilterScript()
{
- if (meshDoc()->filterHistory != nullptr)
- {
- FilterScriptDialog dialog(this);
-
- dialog.setScript(meshDoc()->filterHistory);
- if (dialog.exec()==QDialog::Accepted)
- {
- runFilterScript();
- return ;
- }
- }
+ if (meshDoc()->filterHistory != nullptr)
+ {
+ FilterScriptDialog dialog(this);
+
+ dialog.setScript(meshDoc()->filterHistory);
+ if (dialog.exec()==QDialog::Accepted)
+ {
+ runFilterScript();
+ return ;
+ }
+ }
}
void MainWindow::runFilterScript()
{
- if ((meshDoc() == nullptr) || (meshDoc()->filterHistory == nullptr))
- return;
- for (FilterNameParameterValuesPair& pair : *meshDoc()->filterHistory)
- {
- QString filtnm = pair.filterName();
- int classes = 0;
- unsigned int postCondMask = MeshModel::MM_UNKNOWN;
- QAction *action = PM.actionFilterMap[ filtnm];
- FilterPluginInterface *iFilter = qobject_cast(action->parent());
-
- int req=iFilter->getRequirements(action);
- if (meshDoc()->mm() != NULL)
- meshDoc()->mm()->updateDataMask(req);
- iFilter->setLog(&meshDoc()->Log);
- RichParameterList ¶meterSet = pair.second;
-
+ if ((meshDoc() == nullptr) || (meshDoc()->filterHistory == nullptr))
+ return;
+ for (FilterNameParameterValuesPair& pair : *meshDoc()->filterHistory)
+ {
+ QString filtnm = pair.filterName();
+ int classes = 0;
+ unsigned int postCondMask = MeshModel::MM_UNKNOWN;
+ QAction *action = PM.actionFilterMap[ filtnm];
+ FilterPluginInterface *iFilter = qobject_cast(action->parent());
+
+ int req=iFilter->getRequirements(action);
+ if (meshDoc()->mm() != NULL)
+ meshDoc()->mm()->updateDataMask(req);
+ iFilter->setLog(&meshDoc()->Log);
+ RichParameterList ¶meterSet = pair.second;
+
for(RichParameter& parameter : parameterSet) {
//if this is a mesh parameter and the index is valid
if(parameter.value().isMesh()) {
@@ -804,99 +804,99 @@ void MainWindow::runFilterScript()
}
}
}
- //iFilter->applyFilter( action, *(meshDoc()->mm()), (*ii).second, QCallBack );
-
- bool created = false;
- MLSceneGLSharedDataContext* shar = NULL;
- if (currentViewContainer() != NULL)
- {
- shar = currentViewContainer()->sharedDataContext();
- //GLA() is only the parent
- QGLWidget* filterWidget = new QGLWidget(GLA(),shar);
- QGLFormat defForm = QGLFormat::defaultFormat();
- iFilter->glContext = new MLPluginGLContext(defForm,filterWidget->context()->device(),*shar);
- created = iFilter->glContext->create(filterWidget->context());
- shar->addView(iFilter->glContext);
- MLRenderingData dt;
- MLRenderingData::RendAtts atts;
- atts[MLRenderingData::ATT_NAMES::ATT_VERTPOSITION] = true;
- atts[MLRenderingData::ATT_NAMES::ATT_VERTNORMAL] = true;
-
-
- if (iFilter->filterArity(action) == FilterPluginInterface::SINGLE_MESH)
- {
- MLRenderingData::PRIMITIVE_MODALITY pm = MLPoliciesStandAloneFunctions::bestPrimitiveModalityAccordingToMesh(meshDoc()->mm());
- if ((pm != MLRenderingData::PR_ARITY) && (meshDoc()->mm() != NULL))
- {
- dt.set(pm,atts);
- shar->setRenderingDataPerMeshView(meshDoc()->mm()->id(),iFilter->glContext,dt);
- }
- }
- else
- {
- for(int ii = 0;ii < meshDoc()->meshList.size();++ii)
- {
- MeshModel* mm = meshDoc()->meshList[ii];
- MLRenderingData::PRIMITIVE_MODALITY pm = MLPoliciesStandAloneFunctions::bestPrimitiveModalityAccordingToMesh(mm);
- if ((pm != MLRenderingData::PR_ARITY) && (mm != NULL))
- {
- dt.set(pm,atts);
- shar->setRenderingDataPerMeshView(mm->id(),iFilter->glContext,dt);
- }
- }
- }
-
- }
- if ((!created) || (!iFilter->glContext->isValid()))
- throw MLException("A valid GLContext is required by the filter to work.\n");
- meshDoc()->setBusy(true);
- //WARNING!!!!!!!!!!!!
- /* to be changed */
- iFilter->applyFilter( action, *meshDoc(), postCondMask, pair.second, QCallBack);
- if (postCondMask == MeshModel::MM_UNKNOWN)
- postCondMask = iFilter->postCondition(action);
- for (MeshModel* mm = meshDoc()->nextMesh(); mm != NULL; mm = meshDoc()->nextMesh(mm))
- vcg::tri::Allocator::CompactEveryVector(mm->cm);
- meshDoc()->setBusy(false);
- if (shar != NULL)
- shar->removeView(iFilter->glContext);
- delete iFilter->glContext;
- classes = int(iFilter->getClass(action));
-
- if (meshDoc()->mm() != NULL)
- {
- if(classes & FilterPluginInterface::FaceColoring )
- {
- meshDoc()->mm()->updateDataMask(MeshModel::MM_FACECOLOR);
- }
- if(classes & FilterPluginInterface::VertexColoring )
- {
- meshDoc()->mm()->updateDataMask(MeshModel::MM_VERTCOLOR);
- }
- if(classes & MeshModel::MM_COLOR)
- {
- meshDoc()->mm()->updateDataMask(MeshModel::MM_COLOR);
- }
- if(classes & MeshModel::MM_CAMERA)
- meshDoc()->mm()->updateDataMask(MeshModel::MM_CAMERA);
- }
-
- bool newmeshcreated = false;
- if (classes & FilterPluginInterface::MeshCreation)
- newmeshcreated = true;
- updateSharedContextDataAfterFilterExecution(postCondMask, classes, newmeshcreated);
- meshDoc()->meshDocStateData().clear();
-
- if(classes & FilterPluginInterface::MeshCreation)
- GLA()->resetTrackBall();
- /* to be changed */
-
- qb->reset();
- GLA()->update();
- GLA()->Logf(GLLogStream::SYSTEM,"Re-Applied filter %s",qUtf8Printable(pair.filterName()));
- if (_currviewcontainer != NULL)
- _currviewcontainer->updateAllDecoratorsForAllViewers();
- }
+ //iFilter->applyFilter( action, *(meshDoc()->mm()), (*ii).second, QCallBack );
+
+ bool created = false;
+ MLSceneGLSharedDataContext* shar = NULL;
+ if (currentViewContainer() != NULL)
+ {
+ shar = currentViewContainer()->sharedDataContext();
+ //GLA() is only the parent
+ QGLWidget* filterWidget = new QGLWidget(GLA(),shar);
+ QGLFormat defForm = QGLFormat::defaultFormat();
+ iFilter->glContext = new MLPluginGLContext(defForm,filterWidget->context()->device(),*shar);
+ created = iFilter->glContext->create(filterWidget->context());
+ shar->addView(iFilter->glContext);
+ MLRenderingData dt;
+ MLRenderingData::RendAtts atts;
+ atts[MLRenderingData::ATT_NAMES::ATT_VERTPOSITION] = true;
+ atts[MLRenderingData::ATT_NAMES::ATT_VERTNORMAL] = true;
+
+
+ if (iFilter->filterArity(action) == FilterPluginInterface::SINGLE_MESH)
+ {
+ MLRenderingData::PRIMITIVE_MODALITY pm = MLPoliciesStandAloneFunctions::bestPrimitiveModalityAccordingToMesh(meshDoc()->mm());
+ if ((pm != MLRenderingData::PR_ARITY) && (meshDoc()->mm() != NULL))
+ {
+ dt.set(pm,atts);
+ shar->setRenderingDataPerMeshView(meshDoc()->mm()->id(),iFilter->glContext,dt);
+ }
+ }
+ else
+ {
+ for(int ii = 0;ii < meshDoc()->meshList.size();++ii)
+ {
+ MeshModel* mm = meshDoc()->meshList[ii];
+ MLRenderingData::PRIMITIVE_MODALITY pm = MLPoliciesStandAloneFunctions::bestPrimitiveModalityAccordingToMesh(mm);
+ if ((pm != MLRenderingData::PR_ARITY) && (mm != NULL))
+ {
+ dt.set(pm,atts);
+ shar->setRenderingDataPerMeshView(mm->id(),iFilter->glContext,dt);
+ }
+ }
+ }
+
+ }
+ if ((!created) || (!iFilter->glContext->isValid()))
+ throw MLException("A valid GLContext is required by the filter to work.\n");
+ meshDoc()->setBusy(true);
+ //WARNING!!!!!!!!!!!!
+ /* to be changed */
+ iFilter->applyFilter( action, *meshDoc(), postCondMask, pair.second, QCallBack);
+ if (postCondMask == MeshModel::MM_UNKNOWN)
+ postCondMask = iFilter->postCondition(action);
+ for (MeshModel* mm = meshDoc()->nextMesh(); mm != NULL; mm = meshDoc()->nextMesh(mm))
+ vcg::tri::Allocator::CompactEveryVector(mm->cm);
+ meshDoc()->setBusy(false);
+ if (shar != NULL)
+ shar->removeView(iFilter->glContext);
+ delete iFilter->glContext;
+ classes = int(iFilter->getClass(action));
+
+ if (meshDoc()->mm() != NULL)
+ {
+ if(classes & FilterPluginInterface::FaceColoring )
+ {
+ meshDoc()->mm()->updateDataMask(MeshModel::MM_FACECOLOR);
+ }
+ if(classes & FilterPluginInterface::VertexColoring )
+ {
+ meshDoc()->mm()->updateDataMask(MeshModel::MM_VERTCOLOR);
+ }
+ if(classes & MeshModel::MM_COLOR)
+ {
+ meshDoc()->mm()->updateDataMask(MeshModel::MM_COLOR);
+ }
+ if(classes & MeshModel::MM_CAMERA)
+ meshDoc()->mm()->updateDataMask(MeshModel::MM_CAMERA);
+ }
+
+ bool newmeshcreated = false;
+ if (classes & FilterPluginInterface::MeshCreation)
+ newmeshcreated = true;
+ updateSharedContextDataAfterFilterExecution(postCondMask, classes, newmeshcreated);
+ meshDoc()->meshDocStateData().clear();
+
+ if(classes & FilterPluginInterface::MeshCreation)
+ GLA()->resetTrackBall();
+ /* to be changed */
+
+ qb->reset();
+ GLA()->update();
+ GLA()->Logf(GLLogStream::SYSTEM,"Re-Applied filter %s",qUtf8Printable(pair.filterName()));
+ if (_currviewcontainer != NULL)
+ _currviewcontainer->updateAllDecoratorsForAllViewers();
+ }
}
// Receives the action that wants to show a tooltip and display it
@@ -905,8 +905,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);
}
// /////////////////////////////////////////////////
@@ -919,152 +919,152 @@ void MainWindow::showTooltip(QAction* q)
void MainWindow::startFilter()
{
- if(currentViewContainer() == NULL) return;
- if(GLA() == NULL) return;
-
- // In order to avoid that a filter changes something assumed by the current editing tool,
- // before actually starting the filter we close the current editing tool (if any).
- if (GLA()->getCurrentEditAction() != NULL)
- endEdit();
- updateMenus();
-
- QStringList missingPreconditions;
- QAction *action = qobject_cast(sender());
- if (action == NULL)
- throw MLException("Invalid filter action value.");
- FilterPluginInterface *iFilter = qobject_cast(action->parent());
- if (meshDoc() == NULL)
- return;
- //OLD FILTER PHILOSOPHY
- if (iFilter != NULL)
- {
- //if(iFilter->getClass(action) == MeshFilterInterface::MeshCreation)
- //{
- // qDebug("MeshCreation");
- // GLA()->meshDoc->addNewMesh("",iFilter->filterName(action) );
- //}
- //else
- if (!iFilter->isFilterApplicable(action,(*meshDoc()->mm()),missingPreconditions))
- {
- QString enstr = missingPreconditions.join(",");
- QMessageBox::warning(this, 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();
-
- // (2) Ask for filter parameters and eventually 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()) )
- {
- RichParameterList dummyParSet;
- executeFilter(action, dummyParSet, false);
-
- //Insert the filter to filterHistory
- FilterNameParameterValuesPair tmp;
- tmp.first = action->text(); tmp.second = dummyParSet;
- meshDoc()->filterHistory->append(tmp);
- }
- }
-
+ if(currentViewContainer() == NULL) return;
+ if(GLA() == NULL) return;
+
+ // In order to avoid that a filter changes something assumed by the current editing tool,
+ // before actually starting the filter we close the current editing tool (if any).
+ if (GLA()->getCurrentEditAction() != NULL)
+ endEdit();
+ updateMenus();
+
+ QStringList missingPreconditions;
+ QAction *action = qobject_cast(sender());
+ if (action == NULL)
+ throw MLException("Invalid filter action value.");
+ FilterPluginInterface *iFilter = qobject_cast(action->parent());
+ if (meshDoc() == NULL)
+ return;
+ //OLD FILTER PHILOSOPHY
+ if (iFilter != NULL)
+ {
+ //if(iFilter->getClass(action) == MeshFilterInterface::MeshCreation)
+ //{
+ // qDebug("MeshCreation");
+ // GLA()->meshDoc->addNewMesh("",iFilter->filterName(action) );
+ //}
+ //else
+ if (!iFilter->isFilterApplicable(action,(*meshDoc()->mm()),missingPreconditions))
+ {
+ QString enstr = missingPreconditions.join(",");
+ QMessageBox::warning(this, 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();
+
+ // (2) Ask for filter parameters and eventually 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()) )
+ {
+ RichParameterList dummyParSet;
+ executeFilter(action, dummyParSet, false);
+
+ //Insert the filter to filterHistory
+ FilterNameParameterValuesPair tmp;
+ tmp.first = action->text(); tmp.second = dummyParSet;
+ meshDoc()->filterHistory->append(tmp);
+ }
+ }
+
}//void MainWindow::startFilter()
void MainWindow::updateSharedContextDataAfterFilterExecution(int postcondmask,int fclasses,bool& newmeshcreated)
{
- MultiViewer_Container* mvc = currentViewContainer();
- if ((meshDoc() != NULL) && (mvc != NULL))
- {
- if (GLA() == NULL)
- return;
- MLSceneGLSharedDataContext* shared = mvc->sharedDataContext();
- if (shared != NULL)
- {
- for(MeshModel* mm = meshDoc()->nextMesh();mm != NULL;mm = meshDoc()->nextMesh(mm))
- {
- if (mm == NULL)
- continue;
- //Just to be sure that the filter author didn't forget to add changing tags to the postCondition field
- if ((mm->hasDataMask(MeshModel::MM_FACECOLOR)) && (fclasses & FilterPluginInterface::FaceColoring ))
- postcondmask = postcondmask | MeshModel::MM_FACECOLOR;
-
- if ((mm->hasDataMask(MeshModel::MM_VERTCOLOR)) && (fclasses & FilterPluginInterface::VertexColoring ))
- postcondmask = postcondmask | MeshModel::MM_VERTCOLOR;
-
- if ((mm->hasDataMask(MeshModel::MM_COLOR)) && (fclasses & FilterPluginInterface::MeshColoring ))
- postcondmask = postcondmask | MeshModel::MM_COLOR;
-
- if ((mm->hasDataMask(MeshModel::MM_FACEQUALITY)) && (fclasses & FilterPluginInterface::Quality ))
- postcondmask = postcondmask | MeshModel::MM_FACEQUALITY;
-
- if ((mm->hasDataMask(MeshModel::MM_VERTQUALITY)) && (fclasses & FilterPluginInterface::Quality ))
- postcondmask = postcondmask | MeshModel::MM_VERTQUALITY;
-
- MLRenderingData dttoberendered;
- QMap::Iterator existit = meshDoc()->meshDocStateData().find(mm->id());
+ MultiViewer_Container* mvc = currentViewContainer();
+ if ((meshDoc() != NULL) && (mvc != NULL))
+ {
+ if (GLA() == NULL)
+ return;
+ MLSceneGLSharedDataContext* shared = mvc->sharedDataContext();
+ if (shared != NULL)
+ {
+ for(MeshModel* mm = meshDoc()->nextMesh();mm != NULL;mm = meshDoc()->nextMesh(mm))
+ {
+ if (mm == NULL)
+ continue;
+ //Just to be sure that the filter author didn't forget to add changing tags to the postCondition field
+ if ((mm->hasDataMask(MeshModel::MM_FACECOLOR)) && (fclasses & FilterPluginInterface::FaceColoring ))
+ postcondmask = postcondmask | MeshModel::MM_FACECOLOR;
+
+ if ((mm->hasDataMask(MeshModel::MM_VERTCOLOR)) && (fclasses & FilterPluginInterface::VertexColoring ))
+ postcondmask = postcondmask | MeshModel::MM_VERTCOLOR;
+
+ if ((mm->hasDataMask(MeshModel::MM_COLOR)) && (fclasses & FilterPluginInterface::MeshColoring ))
+ postcondmask = postcondmask | MeshModel::MM_COLOR;
+
+ if ((mm->hasDataMask(MeshModel::MM_FACEQUALITY)) && (fclasses & FilterPluginInterface::Quality ))
+ postcondmask = postcondmask | MeshModel::MM_FACEQUALITY;
+
+ if ((mm->hasDataMask(MeshModel::MM_VERTQUALITY)) && (fclasses & FilterPluginInterface::Quality ))
+ postcondmask = postcondmask | MeshModel::MM_VERTQUALITY;
+
+ MLRenderingData dttoberendered;
+ QMap::Iterator existit = meshDoc()->meshDocStateData().find(mm->id());
if (existit != meshDoc()->meshDocStateData().end())
- {
-
- shared->getRenderInfoPerMeshView(mm->id(),GLA()->context(),dttoberendered);
- int updatemask = MeshModel::MM_NONE;
+ {
+
+ shared->getRenderInfoPerMeshView(mm->id(),GLA()->context(),dttoberendered);
+ int updatemask = MeshModel::MM_NONE;
bool connectivitychanged = false;
- if (((unsigned int)mm->cm.VN() != existit->_nvert) || ((unsigned int)mm->cm.FN() != existit->_nface) ||
- bool(postcondmask & MeshModel::MM_UNKNOWN) || bool(postcondmask & MeshModel::MM_VERTNUMBER) ||
- bool(postcondmask & MeshModel::MM_FACENUMBER) || bool(postcondmask & MeshModel::MM_FACEVERT) ||
- bool(postcondmask & MeshModel::MM_VERTFACETOPO) || bool(postcondmask & MeshModel::MM_FACEFACETOPO))
- {
+ if (((unsigned int)mm->cm.VN() != existit->_nvert) || ((unsigned int)mm->cm.FN() != existit->_nface) ||
+ bool(postcondmask & MeshModel::MM_UNKNOWN) || bool(postcondmask & MeshModel::MM_VERTNUMBER) ||
+ bool(postcondmask & MeshModel::MM_FACENUMBER) || bool(postcondmask & MeshModel::MM_FACEVERT) ||
+ bool(postcondmask & MeshModel::MM_VERTFACETOPO) || bool(postcondmask & MeshModel::MM_FACEFACETOPO))
+ {
updatemask = MeshModel::MM_ALL;
- connectivitychanged = true;
- }
- else
- {
- //masks differences bitwise operator (^) -> remove the attributes that didn't apparently change + the ones that for sure changed according to the postCondition function
- //this operation has been introduced in order to minimize problems with filters that didn't declared properly the postCondition mask
- updatemask = (existit->_mask ^ mm->dataMask()) | postcondmask;
- connectivitychanged = false;
- }
-
- MLRenderingData::RendAtts dttoupdate;
- //1) we convert the meshmodel updating mask to a RendAtts structure
- MLPoliciesStandAloneFunctions::fromMeshModelMaskToMLRenderingAtts(updatemask,dttoupdate);
- //2) The correspondent bos to the updated rendering attributes are set to invalid
- shared->meshAttributesUpdated(mm->id(),connectivitychanged,dttoupdate);
-
- //3) we took the current rendering modality for the mesh in the active gla
- MLRenderingData curr;
- shared->getRenderInfoPerMeshView(mm->id(),GLA()->context(),curr);
-
- //4) we add to the current rendering modality in the current GLArea just the minimum attributes having been updated
- // WARNING!!!! There are priority policies
- // ex1) suppose that the current rendering modality is PR_POINTS and ATT_VERTPOSITION, ATT_VERTNORMAL,ATT_VERTCOLOR
- // if i updated, for instance, just the ATT_FACECOLOR, we switch off in the active GLArea the per ATT_VERTCOLOR attribute
- // and turn on the ATT_FACECOLOR
- // ex2) suppose that the current rendering modality is PR_POINTS and ATT_VERTPOSITION, ATT_VERTNORMAL,ATT_VERTCOLOR
- // if i updated, for instance, both the ATT_FACECOLOR and the ATT_VERTCOLOR, we continue to render the updated value of the ATT_VERTCOLOR
- // ex3) suppose that in all the GLAreas the current rendering modality is PR_POINTS and we run a surface reconstruction filter
- // in the current GLA() we switch from the PR_POINTS to PR_SOLID primitive rendering modality. In the other GLArea we maintain the per points visualization
- for(MLRenderingData::PRIMITIVE_MODALITY pm = MLRenderingData::PRIMITIVE_MODALITY(0);pm < MLRenderingData::PR_ARITY;pm = MLRenderingData::next(pm))
- {
- bool wasprimitivemodalitymeaningful = MLPoliciesStandAloneFunctions::isPrimitiveModalityCompatibleWithMeshInfo((existit->_nvert > 0),(existit->_nface > 0),(existit->_nedge > 0),existit->_mask,pm);
- bool isprimitivemodalitymeaningful = MLPoliciesStandAloneFunctions::isPrimitiveModalityCompatibleWithMesh(mm,pm);
- bool isworthtobevisualized = MLPoliciesStandAloneFunctions::isPrimitiveModalityWorthToBeActivated(pm,curr.isPrimitiveActive(pm),wasprimitivemodalitymeaningful,isprimitivemodalitymeaningful);
-
-
- MLRenderingData::RendAtts rd;
+ connectivitychanged = true;
+ }
+ else
+ {
+ //masks differences bitwise operator (^) -> remove the attributes that didn't apparently change + the ones that for sure changed according to the postCondition function
+ //this operation has been introduced in order to minimize problems with filters that didn't declared properly the postCondition mask
+ updatemask = (existit->_mask ^ mm->dataMask()) | postcondmask;
+ connectivitychanged = false;
+ }
+
+ MLRenderingData::RendAtts dttoupdate;
+ //1) we convert the meshmodel updating mask to a RendAtts structure
+ MLPoliciesStandAloneFunctions::fromMeshModelMaskToMLRenderingAtts(updatemask,dttoupdate);
+ //2) The correspondent bos to the updated rendering attributes are set to invalid
+ shared->meshAttributesUpdated(mm->id(),connectivitychanged,dttoupdate);
+
+ //3) we took the current rendering modality for the mesh in the active gla
+ MLRenderingData curr;
+ shared->getRenderInfoPerMeshView(mm->id(),GLA()->context(),curr);
+
+ //4) we add to the current rendering modality in the current GLArea just the minimum attributes having been updated
+ // WARNING!!!! There are priority policies
+ // ex1) suppose that the current rendering modality is PR_POINTS and ATT_VERTPOSITION, ATT_VERTNORMAL,ATT_VERTCOLOR
+ // if i updated, for instance, just the ATT_FACECOLOR, we switch off in the active GLArea the per ATT_VERTCOLOR attribute
+ // and turn on the ATT_FACECOLOR
+ // ex2) suppose that the current rendering modality is PR_POINTS and ATT_VERTPOSITION, ATT_VERTNORMAL,ATT_VERTCOLOR
+ // if i updated, for instance, both the ATT_FACECOLOR and the ATT_VERTCOLOR, we continue to render the updated value of the ATT_VERTCOLOR
+ // ex3) suppose that in all the GLAreas the current rendering modality is PR_POINTS and we run a surface reconstruction filter
+ // in the current GLA() we switch from the PR_POINTS to PR_SOLID primitive rendering modality. In the other GLArea we maintain the per points visualization
+ for(MLRenderingData::PRIMITIVE_MODALITY pm = MLRenderingData::PRIMITIVE_MODALITY(0);pm < MLRenderingData::PR_ARITY;pm = MLRenderingData::next(pm))
+ {
+ bool wasprimitivemodalitymeaningful = MLPoliciesStandAloneFunctions::isPrimitiveModalityCompatibleWithMeshInfo((existit->_nvert > 0),(existit->_nface > 0),(existit->_nedge > 0),existit->_mask,pm);
+ bool isprimitivemodalitymeaningful = MLPoliciesStandAloneFunctions::isPrimitiveModalityCompatibleWithMesh(mm,pm);
+ bool isworthtobevisualized = MLPoliciesStandAloneFunctions::isPrimitiveModalityWorthToBeActivated(pm,curr.isPrimitiveActive(pm),wasprimitivemodalitymeaningful,isprimitivemodalitymeaningful);
+
+
+ MLRenderingData::RendAtts rd;
curr.get(pm, rd);
MLPoliciesStandAloneFunctions::updatedRendAttsAccordingToPriorities(pm, dttoupdate, rd, rd);
rd[MLRenderingData::ATT_NAMES::ATT_VERTPOSITION] = isworthtobevisualized;
- MLPoliciesStandAloneFunctions::filterUselessUdpateAccordingToMeshMask(mm,rd);
- curr.set(pm,rd);
- }
+ MLPoliciesStandAloneFunctions::filterUselessUdpateAccordingToMeshMask(mm,rd);
+ curr.set(pm,rd);
+ }
MLPerViewGLOptions opts;
curr.get(opts);
if (fclasses & FilterPluginInterface::MeshColoring)
@@ -1073,7 +1073,7 @@ void MainWindow::updateSharedContextDataAfterFilterExecution(int postcondmask,in
opts._perpoint_mesh_color_enabled = hasmeshcolor;
opts._perwire_mesh_color_enabled = hasmeshcolor;
opts._persolid_mesh_color_enabled = hasmeshcolor;
-
+
for (MLRenderingData::PRIMITIVE_MODALITY pm = MLRenderingData::PRIMITIVE_MODALITY(0); pm < MLRenderingData::PR_ARITY; pm = MLRenderingData::next(pm))
{
MLRenderingData::RendAtts atts;
@@ -1085,8 +1085,8 @@ void MainWindow::updateSharedContextDataAfterFilterExecution(int postcondmask,in
curr.set(opts);
}
MLPoliciesStandAloneFunctions::setPerViewGLOptionsAccordindToWireModality(mm, curr);
- MLPoliciesStandAloneFunctions::setPerViewGLOptionsPriorities(curr);
-
+ MLPoliciesStandAloneFunctions::setPerViewGLOptionsPriorities(curr);
+
if (mm == meshDoc()->mm())
{
/*HORRIBLE TRICK IN ORDER TO HAVE VALID ACTIONS ASSOCIATED WITH THE CURRENT WIRE RENDERING MODALITY*/
@@ -1096,15 +1096,15 @@ void MainWindow::updateSharedContextDataAfterFilterExecution(int postcondmask,in
delete fauxaction;
/****************************************************************************************************/
}
-
-
- shared->setRenderingDataPerMeshView(mm->id(),GLA()->context(),curr);
- }
- else
- {
- //A new mesh has been created by the filter. I have to add it in the shared context data structure
- newmeshcreated = true;
- MLPoliciesStandAloneFunctions::suggestedDefaultPerViewRenderingData(mm,dttoberendered,mwsettings.minpolygonpersmoothrendering);
+
+
+ shared->setRenderingDataPerMeshView(mm->id(),GLA()->context(),curr);
+ }
+ else
+ {
+ //A new mesh has been created by the filter. I have to add it in the shared context data structure
+ newmeshcreated = true;
+ MLPoliciesStandAloneFunctions::suggestedDefaultPerViewRenderingData(mm,dttoberendered,mwsettings.minpolygonpersmoothrendering);
if (mm == meshDoc()->mm())
{
/*HORRIBLE TRICK IN ORDER TO HAVE VALID ACTIONS ASSOCIATED WITH THE CURRENT WIRE RENDERING MODALITY*/
@@ -1115,16 +1115,16 @@ void MainWindow::updateSharedContextDataAfterFilterExecution(int postcondmask,in
/****************************************************************************************************/
}
foreach(GLArea* gla,mvc->viewerList)
- {
- if (gla != NULL)
- shared->setRenderingDataPerMeshView(mm->id(),gla->context(),dttoberendered);
- }
+ {
+ if (gla != NULL)
+ shared->setRenderingDataPerMeshView(mm->id(),gla->context(),dttoberendered);
+ }
}
shared->manageBuffers(mm->id());
- }
+ }
updateLayerDialog();
- }
- }
+ }
+ }
}
/*
@@ -1138,75 +1138,75 @@ from the user defined dialog
void MainWindow::executeFilter(const QAction* action, RichParameterList ¶ms, bool isPreview)
{
- FilterPluginInterface *iFilter = qobject_cast(action->parent());
- qb->show();
- iFilter->setLog(&meshDoc()->Log);
-
- // Ask for filter requirements (eg a filter can need topology, border flags etc)
- // and satisfy 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()->Log.ClearBookmark();
- else
- meshDoc()->Log.BackToBookmark();
- // (4) Apply the Filter
- bool ret;
- qApp->setOverrideCursor(QCursor(Qt::WaitCursor));
- QElapsedTimer tt; tt.start();
- meshDoc()->setBusy(true);
- RichParameterList mergedenvironment(params);
- mergedenvironment.join(currentGlobalParams);
-
- MLSceneGLSharedDataContext* shar = NULL;
- QGLWidget* filterWidget = NULL;
- if (currentViewContainer() != NULL)
- {
- shar = currentViewContainer()->sharedDataContext();
- //GLA() is only the parent
- filterWidget = new QGLWidget(NULL,shar);
- QGLFormat defForm = QGLFormat::defaultFormat();
- iFilter->glContext = new MLPluginGLContext(defForm,filterWidget->context()->device(),*shar);
- iFilter->glContext->create(filterWidget->context());
-
- MLRenderingData dt;
- MLRenderingData::RendAtts atts;
- atts[MLRenderingData::ATT_NAMES::ATT_VERTPOSITION] = true;
- atts[MLRenderingData::ATT_NAMES::ATT_VERTNORMAL] = true;
-
- if (iFilter->filterArity(action) == FilterPluginInterface::SINGLE_MESH)
- {
- MLRenderingData::PRIMITIVE_MODALITY pm = MLPoliciesStandAloneFunctions::bestPrimitiveModalityAccordingToMesh(meshDoc()->mm());
- if ((pm != MLRenderingData::PR_ARITY) && (meshDoc()->mm() != NULL))
- {
- dt.set(pm,atts);
- iFilter->glContext->initPerViewRenderingData(meshDoc()->mm()->id(),dt);
- }
- }
- else
- {
- for(int ii = 0;ii < meshDoc()->meshList.size();++ii)
- {
- MeshModel* mm = meshDoc()->meshList[ii];
- MLRenderingData::PRIMITIVE_MODALITY pm = MLPoliciesStandAloneFunctions::bestPrimitiveModalityAccordingToMesh(mm);
- if ((pm != MLRenderingData::PR_ARITY) && (mm != NULL))
- {
- dt.set(pm,atts);
- iFilter->glContext->initPerViewRenderingData(mm->id(),dt);
- }
- }
- }
- }
- bool newmeshcreated = false;
- try
- {
- meshDoc()->meshDocStateData().clear();
+ FilterPluginInterface *iFilter = qobject_cast(action->parent());
+ qb->show();
+ iFilter->setLog(&meshDoc()->Log);
+
+ // Ask for filter requirements (eg a filter can need topology, border flags etc)
+ // and satisfy 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()->Log.ClearBookmark();
+ else
+ meshDoc()->Log.BackToBookmark();
+ // (4) Apply the Filter
+ bool ret;
+ qApp->setOverrideCursor(QCursor(Qt::WaitCursor));
+ QElapsedTimer tt; tt.start();
+ meshDoc()->setBusy(true);
+ RichParameterList mergedenvironment(params);
+ mergedenvironment.join(currentGlobalParams);
+
+ MLSceneGLSharedDataContext* shar = NULL;
+ QGLWidget* filterWidget = NULL;
+ if (currentViewContainer() != NULL)
+ {
+ shar = currentViewContainer()->sharedDataContext();
+ //GLA() is only the parent
+ filterWidget = new QGLWidget(NULL,shar);
+ QGLFormat defForm = QGLFormat::defaultFormat();
+ iFilter->glContext = new MLPluginGLContext(defForm,filterWidget->context()->device(),*shar);
+ iFilter->glContext->create(filterWidget->context());
+
+ MLRenderingData dt;
+ MLRenderingData::RendAtts atts;
+ atts[MLRenderingData::ATT_NAMES::ATT_VERTPOSITION] = true;
+ atts[MLRenderingData::ATT_NAMES::ATT_VERTNORMAL] = true;
+
+ if (iFilter->filterArity(action) == FilterPluginInterface::SINGLE_MESH)
+ {
+ MLRenderingData::PRIMITIVE_MODALITY pm = MLPoliciesStandAloneFunctions::bestPrimitiveModalityAccordingToMesh(meshDoc()->mm());
+ if ((pm != MLRenderingData::PR_ARITY) && (meshDoc()->mm() != NULL))
+ {
+ dt.set(pm,atts);
+ iFilter->glContext->initPerViewRenderingData(meshDoc()->mm()->id(),dt);
+ }
+ }
+ else
+ {
+ for(int ii = 0;ii < meshDoc()->meshList.size();++ii)
+ {
+ MeshModel* mm = meshDoc()->meshList[ii];
+ MLRenderingData::PRIMITIVE_MODALITY pm = MLPoliciesStandAloneFunctions::bestPrimitiveModalityAccordingToMesh(mm);
+ if ((pm != MLRenderingData::PR_ARITY) && (mm != NULL))
+ {
+ dt.set(pm,atts);
+ iFilter->glContext->initPerViewRenderingData(mm->id(),dt);
+ }
+ }
+ }
+ }
+ bool newmeshcreated = false;
+ try
+ {
+ meshDoc()->meshDocStateData().clear();
meshDoc()->meshDocStateData().create(*meshDoc());
unsigned int postCondMask = MeshModel::MM_UNKNOWN;
ret=iFilter->applyFilter(action, *(meshDoc()), postCondMask, mergedenvironment, QCallBack);
@@ -1214,121 +1214,121 @@ void MainWindow::executeFilter(const QAction* action, RichParameterList ¶ms,
postCondMask = iFilter->postCondition(action);
for (MeshModel* mm = meshDoc()->nextMesh(); mm != NULL; mm = meshDoc()->nextMesh(mm))
vcg::tri::Allocator::CompactEveryVector(mm->cm);
-
+
if (shar != NULL)
{
shar->removeView(iFilter->glContext);
delete filterWidget;
}
-
- meshDoc()->setBusy(false);
-
- qApp->restoreOverrideCursor();
-
- // (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",qUtf8Printable(action->text()),tt.elapsed());
- if (meshDoc()->mm() != NULL)
+
+ meshDoc()->setBusy(false);
+
+ qApp->restoreOverrideCursor();
+
+ // (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",qUtf8Printable(action->text()),tt.elapsed());
+ if (meshDoc()->mm() != NULL)
meshDoc()->mm()->setMeshModified();
- MainWindow::globalStatusBar()->showMessage("Filter successfully completed...",2000);
- if(GLA())
- {
- GLA()->setLastAppliedFilter(action);
- }
- lastFilterAct->setText(QString("Apply filter ") + action->text());
- lastFilterAct->setEnabled(true);
- }
- 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",qUtf8Printable(iFilter->errorMsg()));
- MainWindow::globalStatusBar()->showMessage("Filter failed...",2000);
- }
-
-
- FilterPluginInterface::FILTER_ARITY arity = iFilter->filterArity(action);
- QList tmp;
- switch(arity)
- {
- case (FilterPluginInterface::SINGLE_MESH):
- {
- tmp.push_back(meshDoc()->mm());
- break;
- }
- case (FilterPluginInterface::FIXED):
- {
- for(const RichParameter& p : mergedenvironment)
- {
- if (p.value().isMesh())
- {
- MeshModel* mm = p.value().getMesh();
- if (mm != NULL)
- tmp.push_back(mm);
- }
- }
- break;
- }
- case (FilterPluginInterface::VARIABLE):
- {
- for(MeshModel* mm = meshDoc()->nextMesh();mm != NULL;mm=meshDoc()->nextMesh(mm))
- {
- if (mm->isVisible())
- tmp.push_back(mm);
- }
- break;
- }
- default:
- break;
- }
-
- if(iFilter->getClass(action) & FilterPluginInterface::MeshCreation )
- GLA()->resetTrackBall();
-
- for(int jj = 0;jj < tmp.size();++jj)
- {
- MeshModel* mm = tmp[jj];
- if (mm != NULL)
- {
- // at the end for filters that change the color, or selection set the appropriate rendering mode
- if(iFilter->getClass(action) & FilterPluginInterface::FaceColoring )
- mm->updateDataMask(MeshModel::MM_FACECOLOR);
-
- if(iFilter->getClass(action) & FilterPluginInterface::VertexColoring )
- mm->updateDataMask(MeshModel::MM_VERTCOLOR);
-
- if(iFilter->getClass(action) & FilterPluginInterface::MeshColoring )
- mm->updateDataMask(MeshModel::MM_COLOR);
-
- if(postCondMask & MeshModel::MM_CAMERA)
- mm->updateDataMask(MeshModel::MM_CAMERA);
-
- if(iFilter->getClass(action) & FilterPluginInterface::Texture )
- updateTexture(mm->id());
- }
- }
-
- int fclasses = iFilter->getClass(action);
- //MLSceneGLSharedDataContext* sharedcont = GLA()->getSceneGLSharedContext();
-
- updateSharedContextDataAfterFilterExecution(postCondMask,fclasses,newmeshcreated);
- meshDoc()->meshDocStateData().clear();
- }
- catch (const 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'
").arg(action->text())+bdall.what()); // text
- MainWindow::globalStatusBar()->showMessage("Filter failed...",2000);
- }
- qb->reset();
- layerDialog->setVisible(layerDialog->isVisible() || ((newmeshcreated) && (meshDoc()->size() > 0)));
- updateLayerDialog();
- updateMenus();
- MultiViewer_Container* mvc = currentViewContainer();
+ MainWindow::globalStatusBar()->showMessage("Filter successfully completed...",2000);
+ if(GLA())
+ {
+ GLA()->setLastAppliedFilter(action);
+ }
+ lastFilterAct->setText(QString("Apply filter ") + action->text());
+ lastFilterAct->setEnabled(true);
+ }
+ 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",qUtf8Printable(iFilter->errorMsg()));
+ MainWindow::globalStatusBar()->showMessage("Filter failed...",2000);
+ }
+
+
+ FilterPluginInterface::FILTER_ARITY arity = iFilter->filterArity(action);
+ QList tmp;
+ switch(arity)
+ {
+ case (FilterPluginInterface::SINGLE_MESH):
+ {
+ tmp.push_back(meshDoc()->mm());
+ break;
+ }
+ case (FilterPluginInterface::FIXED):
+ {
+ for(const RichParameter& p : mergedenvironment)
+ {
+ if (p.value().isMesh())
+ {
+ MeshModel* mm = p.value().getMesh();
+ if (mm != NULL)
+ tmp.push_back(mm);
+ }
+ }
+ break;
+ }
+ case (FilterPluginInterface::VARIABLE):
+ {
+ for(MeshModel* mm = meshDoc()->nextMesh();mm != NULL;mm=meshDoc()->nextMesh(mm))
+ {
+ if (mm->isVisible())
+ tmp.push_back(mm);
+ }
+ break;
+ }
+ default:
+ break;
+ }
+
+ if(iFilter->getClass(action) & FilterPluginInterface::MeshCreation )
+ GLA()->resetTrackBall();
+
+ for(int jj = 0;jj < tmp.size();++jj)
+ {
+ MeshModel* mm = tmp[jj];
+ if (mm != NULL)
+ {
+ // at the end for filters that change the color, or selection set the appropriate rendering mode
+ if(iFilter->getClass(action) & FilterPluginInterface::FaceColoring )
+ mm->updateDataMask(MeshModel::MM_FACECOLOR);
+
+ if(iFilter->getClass(action) & FilterPluginInterface::VertexColoring )
+ mm->updateDataMask(MeshModel::MM_VERTCOLOR);
+
+ if(iFilter->getClass(action) & FilterPluginInterface::MeshColoring )
+ mm->updateDataMask(MeshModel::MM_COLOR);
+
+ if(postCondMask & MeshModel::MM_CAMERA)
+ mm->updateDataMask(MeshModel::MM_CAMERA);
+
+ if(iFilter->getClass(action) & FilterPluginInterface::Texture )
+ updateTexture(mm->id());
+ }
+ }
+
+ int fclasses = iFilter->getClass(action);
+ //MLSceneGLSharedDataContext* sharedcont = GLA()->getSceneGLSharedContext();
+
+ updateSharedContextDataAfterFilterExecution(postCondMask,fclasses,newmeshcreated);
+ meshDoc()->meshDocStateData().clear();
+ }
+ catch (const 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'
").arg(action->text())+bdall.what()); // text
+ MainWindow::globalStatusBar()->showMessage("Filter failed...",2000);
+ }
+ qb->reset();
+ layerDialog->setVisible(layerDialog->isVisible() || ((newmeshcreated) && (meshDoc()->size() > 0)));
+ updateLayerDialog();
+ updateMenus();
+ MultiViewer_Container* mvc = currentViewContainer();
if (mvc)
{
mvc->updateAllDecoratorsForAllViewers();
@@ -1346,117 +1346,117 @@ void MainWindow::executeFilter(const QAction* action, RichParameterList ¶ms,
void MainWindow::suspendEditMode()
{
- // return if no window is open
- if(!GLA()) return;
-
- // return if no editing action is currently ongoing
- if(!GLA()->getCurrentEditAction()) return;
-
- GLA()->suspendEditToggle();
- updateMenus();
- GLA()->update();
+ // return if no window is open
+ if(!GLA()) return;
+
+ // return if no editing action is currently ongoing
+ if(!GLA()->getCurrentEditAction()) return;
+
+ GLA()->suspendEditToggle();
+ updateMenus();
+ GLA()->update();
}
void MainWindow::applyEditMode()
{
- if(!GLA()) { //prevents crash without mesh
- QAction *action = qobject_cast(sender());
- action->setChecked(false);
- return;
- }
-
- 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(GLA()->suspendedEditor)
- {
- suspendEditMode();
- return;
- }
+ if(!GLA()) { //prevents crash without mesh
+ QAction *action = qobject_cast(sender());
+ action->setChecked(false);
+ return;
+ }
+
+ 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(GLA()->suspendedEditor)
+ {
+ suspendEditMode();
+ return;
+ }
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))
- {
- EditPluginInterfaceFactory *iEditFactory = qobject_cast(action->parent());
- EditPluginInterface *iEdit = iEditFactory->getMeshEditInterface(action);
- GLA()->addMeshEditor(action, iEdit);
- }
+ 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))
+ {
+ EditPluginInterfaceFactory *iEditFactory = qobject_cast(action->parent());
+ EditPluginInterface *iEdit = iEditFactory->getMeshEditInterface(action);
+ GLA()->addMeshEditor(action, iEdit);
+ }
meshDoc()->meshDocStateData().create(*meshDoc());
- GLA()->setCurrentEditAction(action);
- updateMenus();
- GLA()->update();
+ GLA()->setCurrentEditAction(action);
+ updateMenus();
+ GLA()->update();
}
void MainWindow::applyRenderMode()
{
- QAction *action = qobject_cast(sender()); // find the action which has sent the signal
- if ((GLA()!= NULL) && (GLA()->getRenderer() != NULL))
- {
- GLA()->getRenderer()->Finalize(GLA()->getCurrentShaderAction(),meshDoc(),GLA());
- GLA()->setRenderer(NULL,NULL);
- }
- // Make the call to the plugin core
- RenderPluginInterface *iRenderTemp = qobject_cast(action->parent());
- bool initsupport = false;
-
+ QAction *action = qobject_cast(sender()); // find the action which has sent the signal
+ if ((GLA()!= NULL) && (GLA()->getRenderer() != NULL))
+ {
+ GLA()->getRenderer()->Finalize(GLA()->getCurrentShaderAction(),meshDoc(),GLA());
+ GLA()->setRenderer(NULL,NULL);
+ }
+ // Make the call to the plugin core
+ RenderPluginInterface *iRenderTemp = qobject_cast(action->parent());
+ bool initsupport = false;
+
if (currentViewContainer() == NULL)
return;
-
+
MLSceneGLSharedDataContext* shared = currentViewContainer()->sharedDataContext();
-
- if ((shared != NULL) && (iRenderTemp != NULL))
- {
+
+ if ((shared != NULL) && (iRenderTemp != NULL))
+ {
MLSceneGLSharedDataContext::PerMeshRenderingDataMap rdmap;
shared->getRenderInfoPerMeshView(GLA()->context(), rdmap);
- iRenderTemp->Init(action,*(meshDoc()),rdmap, GLA());
- initsupport = iRenderTemp->isSupported();
- if (initsupport)
- GLA()->setRenderer(iRenderTemp,action);
- else
- {
- if (!initsupport)
- {
- QString msg = "The selected shader is not supported by your graphic hardware!";
- GLA()->Log(GLLogStream::SYSTEM,qUtf8Printable(msg));
- }
- iRenderTemp->Finalize(action,meshDoc(),GLA());
- }
- }
-
- /*I clicked None in renderMenu */
- if ((action->parent() == this) || (!initsupport))
- {
- QString msg("No Shader.");
- GLA()->Log(GLLogStream::SYSTEM,qUtf8Printable(msg));
- GLA()->setRenderer(0,0); //default opengl pipeline or vertex and fragment programs not supported
- }
- GLA()->update();
+ iRenderTemp->Init(action,*(meshDoc()),rdmap, GLA());
+ initsupport = iRenderTemp->isSupported();
+ if (initsupport)
+ GLA()->setRenderer(iRenderTemp,action);
+ else
+ {
+ if (!initsupport)
+ {
+ QString msg = "The selected shader is not supported by your graphic hardware!";
+ GLA()->Log(GLLogStream::SYSTEM,qUtf8Printable(msg));
+ }
+ iRenderTemp->Finalize(action,meshDoc(),GLA());
+ }
+ }
+
+ /*I clicked None in renderMenu */
+ if ((action->parent() == this) || (!initsupport))
+ {
+ QString msg("No Shader.");
+ GLA()->Log(GLLogStream::SYSTEM,qUtf8Printable(msg));
+ GLA()->setRenderer(0,0); //default opengl pipeline or vertex and fragment programs not supported
+ }
+ GLA()->update();
}
void MainWindow::applyDecorateMode()
{
- if(GLA()->mm() == 0) return;
- QAction *action = qobject_cast(sender()); // find the action which has sent the signal
-
- DecoratePluginInterface *iDecorateTemp = qobject_cast(action->parent());
-
- GLA()->toggleDecorator(iDecorateTemp->decorationName(action));
-
+ if(GLA()->mm() == 0) return;
+ QAction *action = qobject_cast(sender()); // find the action which has sent the signal
+
+ DecoratePluginInterface *iDecorateTemp = qobject_cast(action->parent());
+
+ GLA()->toggleDecorator(iDecorateTemp->decorationName(action));
+
updateMenus();
- layerDialog->updateDecoratorParsView();
- layerDialog->updateLog(meshDoc()->Log);
- layerDialog->update();
- GLA()->update();
+ layerDialog->updateDecoratorParsView();
+ layerDialog->updateLog(meshDoc()->Log);
+ layerDialog->update();
+ GLA()->update();
}
@@ -1465,394 +1465,394 @@ Save project. It saves the info of all the layers and the layer themselves. So
*/
void MainWindow::saveProject()
{
- if (meshDoc() == NULL)
- return;
- //if a mesh has been created by a create filter we must before to save it. Otherwise the project will refer to a mesh without file name path.
- foreach(MeshModel * mp, meshDoc()->meshList)
- {
- if ((mp != NULL) && (mp->fullName().isEmpty()))
- {
- bool saved = exportMesh(tr(""),mp,false);
- if (!saved)
- {
- QString msg = "Mesh layer " + mp->label() + " cannot be saved on a file.\nProject \"" + meshDoc()->docLabel() + "\" saving has been aborted.";
- QMessageBox::warning(this,tr("Project Saving Aborted"),msg);
- return;
- }
- }
- }
- QFileDialog* saveDiag = new QFileDialog(this,tr("Save Project File"),lastUsedDirectory.path().append(""), tr("MeshLab Project (*.mlp);;MeshLab Binary Project (*.mlb);;Align Project (*.aln)"));
+ if (meshDoc() == NULL)
+ return;
+ //if a mesh has been created by a create filter we must before to save it. Otherwise the project will refer to a mesh without file name path.
+ foreach(MeshModel * mp, meshDoc()->meshList)
+ {
+ if ((mp != NULL) && (mp->fullName().isEmpty()))
+ {
+ bool saved = exportMesh(tr(""),mp,false);
+ if (!saved)
+ {
+ QString msg = "Mesh layer " + mp->label() + " cannot be saved on a file.\nProject \"" + meshDoc()->docLabel() + "\" saving has been aborted.";
+ QMessageBox::warning(this,tr("Project Saving Aborted"),msg);
+ return;
+ }
+ }
+ }
+ QFileDialog* saveDiag = new QFileDialog(this,tr("Save Project File"),lastUsedDirectory.path().append(""), tr("MeshLab Project (*.mlp);;MeshLab Binary Project (*.mlb);;Align Project (*.aln)"));
#if defined(Q_OS_WIN)
- saveDiag->setOption(QFileDialog::DontUseNativeDialog);
+ saveDiag->setOption(QFileDialog::DontUseNativeDialog);
#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);
+ 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);
QCheckBox* saveViewState = new QCheckBox(QString("Save View State"), saveDiag);
saveViewState->setCheckState(Qt::Checked);
- QGridLayout* layout = qobject_cast(saveDiag->layout());
- if (layout != NULL)
- {
+ QGridLayout* layout = qobject_cast(saveDiag->layout());
+ if (layout != NULL)
+ {
layout->addWidget(onlyVisibleLayers, 4, 0);
layout->addWidget(saveViewState, 4, 1);
layout->addWidget(saveAllFile, 4, 2);
- }
- 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;
+ }
+ 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", qUtf8Printable(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))
- {
+ 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(qUtf8Printable(mp->relativePathName()));
- transfVector.push_back(mp->cm.Tr);
- }
- }
+ transfVector.push_back(mp->cm.Tr);
+ }
+ }
ret = ALNParser::SaveALN(qUtf8Printable(fileName), meshNameVector, transfVector);
- }
- else
- {
- std::map rendOpt;
- foreach(MeshModel * mp, meshDoc()->meshList)
- {
- MLRenderingData ml;
- getRenderingData(mp->id(), ml);
- rendOpt.insert(std::pair(mp->id(), ml));
- }
- ret = MeshDocumentToXMLFile(*meshDoc(), fileName, onlyVisibleLayers->isChecked(), saveViewState->isChecked(), QString(fi.suffix()).toLower() == "mlb", rendOpt);
- }
-
- 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));
+ }
+ else
+ {
+ std::map rendOpt;
+ foreach(MeshModel * mp, meshDoc()->meshList)
+ {
+ MLRenderingData ml;
+ getRenderingData(mp->id(), ml);
+ rendOpt.insert(std::pair(mp->id(), ml));
+ }
+ ret = MeshDocumentToXMLFile(*meshDoc(), fileName, onlyVisibleLayers->isChecked(), saveViewState->isChecked(), QString(fi.suffix()).toLower() == "mlb", rendOpt);
+ }
+
+ 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)
{
- bool visiblelayer = layerDialog->isVisible();
- //showLayerDlg(false);
+ bool visiblelayer = layerDialog->isVisible();
+ //showLayerDlg(false);
globrendtoolbar->setEnabled(false);
- if (fileName.isEmpty())
- fileName = QFileDialog::getOpenFileName(this,tr("Open Project File"), lastUsedDirectory.path(), tr("All Project Files (*.mlp *.mlb *.aln *.out *.nvm);;MeshLab Project (*.mlp);;MeshLab Binary Project (*.mlb);;Align Project (*.aln);;Bundler Output (*.out);;VisualSFM Output (*.nvm)"));
-
- if (fileName.isEmpty()) return false;
-
- QFileInfo fi(fileName);
- lastUsedDirectory = fi.absoluteDir();
- if((fi.suffix().toLower()!="aln") && (fi.suffix().toLower()!="mlp") && (fi.suffix().toLower() != "mlb") && (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;
+ if (fileName.isEmpty())
+ fileName = QFileDialog::getOpenFileName(this,tr("Open Project File"), lastUsedDirectory.path(), tr("All Project Files (*.mlp *.mlb *.aln *.out *.nvm);;MeshLab Project (*.mlp);;MeshLab Binary Project (*.mlb);;Align Project (*.aln);;Bundler Output (*.out);;VisualSFM Output (*.nvm)"));
+
+ if (fileName.isEmpty()) return false;
+
+ QFileInfo fi(fileName);
+ lastUsedDirectory = fi.absoluteDir();
+ if((fi.suffix().toLower()!="aln") && (fi.suffix().toLower()!="mlp") && (fi.suffix().toLower() != "mlb") && (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, qUtf8Printable(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(),ir->trasformation);
- if(!openRes)
- meshDoc()->delMesh(meshDoc()->mm());
- }
- }
-
- if (QString(fi.suffix()).toLower() == "mlp" || QString(fi.suffix()).toLower() == "mlb")
- {
- std::map rendOpt;
- if (!MeshDocumentFromXML(*meshDoc(), fileName, (QString(fi.suffix()).toLower() == "mlb"), rendOpt))
- {
- QMessageBox::critical(this, tr("Meshlab Opening Error"), "Unable to open MeshLab Project file");
- return false;
- }
+ 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(),ir->trasformation);
+ if(!openRes)
+ meshDoc()->delMesh(meshDoc()->mm());
+ }
+ }
+
+ if (QString(fi.suffix()).toLower() == "mlp" || QString(fi.suffix()).toLower() == "mlb")
+ {
+ std::map rendOpt;
+ if (!MeshDocumentFromXML(*meshDoc(), fileName, (QString(fi.suffix()).toLower() == "mlb"), rendOpt))
+ {
+ QMessageBox::critical(this, tr("Meshlab Opening Error"), "Unable to open MeshLab Project file");
+ return false;
+ }
GLA()->updateMeshSetVisibilities();
- for (int i=0; imeshList.size(); i++)
- {
- QString fullPath = meshDoc()->meshList[i]->fullName();
- //meshDoc()->setBusy(true);
- Matrix44m trm = this->meshDoc()->meshList[i]->cm.Tr; // save the matrix, because loadMeshClear it...
- MLRenderingData* ptr = NULL;
- if (rendOpt.find(meshDoc()->meshList[i]->id()) != rendOpt.end())
- ptr = &rendOpt[meshDoc()->meshList[i]->id()];
- if (!loadMeshWithStandardParams(fullPath, this->meshDoc()->meshList[i], trm, false, ptr))
- meshDoc()->delMesh(meshDoc()->meshList[i]);
- }
- }
-
- ////// BUNDLER
- 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;
-
- if(!MeshDocumentFromBundler(*meshDoc(),cameras_filename,image_list_filename,model_filename)){
- QMessageBox::critical(this, tr("Meshlab Opening Error"), "Unable to open OUTs file");
- return false;
- }
-
-
-//WARNING!!!!! i suppose it's not useful anymore but.......
-/*GLA()->setColorMode(GLW::CMPerVert);
+ for (int i=0; imeshList.size(); i++)
+ {
+ QString fullPath = meshDoc()->meshList[i]->fullName();
+ //meshDoc()->setBusy(true);
+ Matrix44m trm = this->meshDoc()->meshList[i]->cm.Tr; // save the matrix, because loadMeshClear it...
+ MLRenderingData* ptr = NULL;
+ if (rendOpt.find(meshDoc()->meshList[i]->id()) != rendOpt.end())
+ ptr = &rendOpt[meshDoc()->meshList[i]->id()];
+ if (!loadMeshWithStandardParams(fullPath, this->meshDoc()->meshList[i], trm, false, ptr))
+ meshDoc()->delMesh(meshDoc()->meshList[i]);
+ }
+ }
+
+ ////// BUNDLER
+ 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;
+
+ if(!MeshDocumentFromBundler(*meshDoc(),cameras_filename,image_list_filename,model_filename)){
+ QMessageBox::critical(this, tr("Meshlab Opening Error"), "Unable to open OUTs file");
+ return false;
+ }
+
+
+ //WARNING!!!!! i suppose it's not useful anymore but.......
+ /*GLA()->setColorMode(GLW::CMPerVert);
GLA()->setDrawMode(GLW::DMPoints);*/
-/////////////////////////////////////////////////////////
- }
-
- //////NVM
- if (QString(fi.suffix()).toLower() == "nvm"){
-
- QString cameras_filename = fileName;
- QString model_filename;
-
- if(!MeshDocumentFromNvm(*meshDoc(),cameras_filename,model_filename)){
- QMessageBox::critical(this, tr("Meshlab Opening Error"), "Unable to open NVMs file");
- return false;
- }
-//WARNING!!!!! i suppose it's not useful anymore but.......
-/*GLA()->setColorMode(GLW::CMPerVert);
+ /////////////////////////////////////////////////////////
+ }
+
+ //////NVM
+ if (QString(fi.suffix()).toLower() == "nvm"){
+
+ QString cameras_filename = fileName;
+ QString model_filename;
+
+ if(!MeshDocumentFromNvm(*meshDoc(),cameras_filename,model_filename)){
+ QMessageBox::critical(this, tr("Meshlab Opening Error"), "Unable to open NVMs file");
+ return false;
+ }
+ //WARNING!!!!! i suppose it's not useful anymore but.......
+ /*GLA()->setColorMode(GLW::CMPerVert);
GLA()->setDrawMode(GLW::DMPoints);*/
-/////////////////////////////////////////////////////////
- }
-
- meshDoc()->setBusy(false);
- if(this->GLA() == 0) return false;
-
- MultiViewer_Container* mvc = currentViewContainer();
+ /////////////////////////////////////////////////////////
+ }
+
+ meshDoc()->setBusy(false);
+ if(this->GLA() == 0) return false;
+
+ MultiViewer_Container* mvc = currentViewContainer();
if (mvc != NULL)
{
mvc->resetAllTrackBall();
mvc->updateAllDecoratorsForAllViewers();
}
-
+
setCurrentMeshBestTab();
- qb->reset();
- saveRecentProjectList(fileName);
+ qb->reset();
+ saveRecentProjectList(fileName);
globrendtoolbar->setEnabled(true);
- showLayerDlg(visiblelayer || (meshDoc()->meshList.size() > 0));
-
- return true;
+ showLayerDlg(visiblelayer || (meshDoc()->meshList.size() > 0));
+
+ return true;
}
bool MainWindow::appendProject(QString fileName)
{
- QStringList fileNameList;
+ QStringList fileNameList;
globrendtoolbar->setEnabled(false);
- if (fileName.isEmpty())
- fileNameList = QFileDialog::getOpenFileNames(this, tr("Append Project File"), lastUsedDirectory.path(), "All Project Files (*.mlp *.mlb *.aln *.out *.nvm);;MeshLab Project (*.mlp);;MeshLab Binary Project (*.mlb);;Align Project (*.aln);;Bundler Output (*.out);;VisualSFM Output (*.nvm)");
- else
- fileNameList.append(fileName);
-
- if (fileNameList.isEmpty()) return false;
-
- // Ccheck if we have a doc and if it is empty
- bool activeDoc = (bool) !mdiarea->subWindowList().empty() && mdiarea->currentSubWindow();
+ if (fileName.isEmpty())
+ fileNameList = QFileDialog::getOpenFileNames(this, tr("Append Project File"), lastUsedDirectory.path(), "All Project Files (*.mlp *.mlb *.aln *.out *.nvm);;MeshLab Project (*.mlp);;MeshLab Binary Project (*.mlb);;Align Project (*.aln);;Bundler Output (*.out);;VisualSFM Output (*.nvm)");
+ else
+ fileNameList.append(fileName);
+
+ if (fileNameList.isEmpty()) return false;
+
+ // Ccheck if we have a doc and if it is empty
+ bool activeDoc = (bool) !mdiarea->subWindowList().empty() && mdiarea->currentSubWindow();
if (!activeDoc || meshDoc()->meshList.empty()) // 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") && (fi.suffix().toLower() != "mlb") && (fi.suffix().toLower() != "out") && (fi.suffix().toLower() != "nvm"))
- {
- 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;
+ {
+ 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") && (fi.suffix().toLower() != "mlb") && (fi.suffix().toLower() != "out") && (fi.suffix().toLower() != "nvm"))
+ {
+ 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, qUtf8Printable(fileName));
- if(retVal != ALNParser::NoError)
- {
- QMessageBox::critical(this, tr("Meshlab Opening Error"), "Unable to open ALN file");
- return false;
- }
-
- for(vector::iterator ir=rmv.begin();ir!=rmv.end();++ir)
- {
- QString relativeToProj = fi.absoluteDir().absolutePath() + "/" + (*ir).filename.c_str();
- meshDoc()->addNewMesh(relativeToProj,relativeToProj);
- if(!loadMeshWithStandardParams(relativeToProj,this->meshDoc()->mm(),(*ir).trasformation))
- meshDoc()->delMesh(meshDoc()->mm());
- }
- }
-
- if (QString(fi.suffix()).toLower() == "mlp" || QString(fi.suffix()).toLower() == "mlb")
- {
+ if(retVal != ALNParser::NoError)
+ {
+ QMessageBox::critical(this, tr("Meshlab Opening Error"), "Unable to open ALN file");
+ return false;
+ }
+
+ for(vector::iterator ir=rmv.begin();ir!=rmv.end();++ir)
+ {
+ QString relativeToProj = fi.absoluteDir().absolutePath() + "/" + (*ir).filename.c_str();
+ meshDoc()->addNewMesh(relativeToProj,relativeToProj);
+ if(!loadMeshWithStandardParams(relativeToProj,this->meshDoc()->mm(),(*ir).trasformation))
+ meshDoc()->delMesh(meshDoc()->mm());
+ }
+ }
+
+ if (QString(fi.suffix()).toLower() == "mlp" || QString(fi.suffix()).toLower() == "mlb")
+ {
int alreadyLoadedNum = meshDoc()->meshList.size();
- std::map rendOpt;
- if (!MeshDocumentFromXML(*meshDoc(),fileName, QString(fi.suffix()).toLower() == "mlb", rendOpt))
- {
- QMessageBox::critical(this, tr("Meshlab Opening Error"), "Unable to open MeshLab Project file");
- return false;
- }
+ std::map rendOpt;
+ if (!MeshDocumentFromXML(*meshDoc(),fileName, QString(fi.suffix()).toLower() == "mlb", rendOpt))
+ {
+ QMessageBox::critical(this, tr("Meshlab Opening Error"), "Unable to open MeshLab Project file");
+ return false;
+ }
GLA()->updateMeshSetVisibilities();
for (int i = alreadyLoadedNum; imeshList.size(); i++)
- {
- QString fullPath = meshDoc()->meshList[i]->fullName();
- meshDoc()->setBusy(true);
- Matrix44m trm = this->meshDoc()->meshList[i]->cm.Tr; // save the matrix, because loadMeshClear it...
- MLRenderingData* ptr = NULL;
- if (rendOpt.find(meshDoc()->meshList[i]->id()) != rendOpt.end())
- ptr = &rendOpt[meshDoc()->meshList[i]->id()];
- if(!loadMeshWithStandardParams(fullPath,this->meshDoc()->meshList[i],trm, false, ptr))
- meshDoc()->delMesh(meshDoc()->meshList[i]);
- }
- }
-
- 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;
-
- if (!MeshDocumentFromBundler(*meshDoc(), cameras_filename, image_list_filename, model_filename)) {
- QMessageBox::critical(this, tr("Meshlab Opening Error"), "Unable to open OUTs file");
- return false;
- }
- }
-
- if (QString(fi.suffix()).toLower() == "nvm") {
-
- QString cameras_filename = fileName;
- QString model_filename;
-
- if (!MeshDocumentFromNvm(*meshDoc(), cameras_filename, model_filename)) {
- QMessageBox::critical(this, tr("Meshlab Opening Error"), "Unable to open NVMs file");
- return false;
- }
- }
- }
-
+ {
+ QString fullPath = meshDoc()->meshList[i]->fullName();
+ meshDoc()->setBusy(true);
+ Matrix44m trm = this->meshDoc()->meshList[i]->cm.Tr; // save the matrix, because loadMeshClear it...
+ MLRenderingData* ptr = NULL;
+ if (rendOpt.find(meshDoc()->meshList[i]->id()) != rendOpt.end())
+ ptr = &rendOpt[meshDoc()->meshList[i]->id()];
+ if(!loadMeshWithStandardParams(fullPath,this->meshDoc()->meshList[i],trm, false, ptr))
+ meshDoc()->delMesh(meshDoc()->meshList[i]);
+ }
+ }
+
+ 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;
+
+ if (!MeshDocumentFromBundler(*meshDoc(), cameras_filename, image_list_filename, model_filename)) {
+ QMessageBox::critical(this, tr("Meshlab Opening Error"), "Unable to open OUTs file");
+ return false;
+ }
+ }
+
+ if (QString(fi.suffix()).toLower() == "nvm") {
+
+ QString cameras_filename = fileName;
+ QString model_filename;
+
+ if (!MeshDocumentFromNvm(*meshDoc(), cameras_filename, model_filename)) {
+ QMessageBox::critical(this, tr("Meshlab Opening Error"), "Unable to open NVMs file");
+ return false;
+ }
+ }
+ }
+
globrendtoolbar->setEnabled(true);
- meshDoc()->setBusy(false);
- if(this->GLA() == 0) return false;
+ meshDoc()->setBusy(false);
+ if(this->GLA() == 0) return false;
MultiViewer_Container* mvc = currentViewContainer();
if (mvc != NULL)
{
mvc->updateAllDecoratorsForAllViewers();
mvc->resetAllTrackBall();
}
-
+
setCurrentMeshBestTab();
- qb->reset();
- saveRecentProjectList(fileName);
- return true;
+ qb->reset();
+ saveRecentProjectList(fileName);
+ return true;
}
void MainWindow::setCurrentMeshBestTab()
{
if (layerDialog == NULL)
return;
-
+
MultiViewer_Container* mvc = currentViewContainer();
if (mvc != NULL)
{
@@ -1868,39 +1868,39 @@ void MainWindow::setCurrentMeshBestTab()
void MainWindow::newProject(const QString& projName)
{
- if (gpumeminfo == NULL)
- return;
- MultiViewer_Container *mvcont = new MultiViewer_Container(*gpumeminfo,mwsettings.highprecision,mwsettings.perbatchprimitives,mwsettings.minpolygonpersmoothrendering,mdiarea);
- connect(&mvcont->meshDoc,SIGNAL(meshAdded(int)),this,SLOT(meshAdded(int)));
- connect(&mvcont->meshDoc,SIGNAL(meshRemoved(int)),this,SLOT(meshRemoved(int)));
+ if (gpumeminfo == NULL)
+ return;
+ MultiViewer_Container *mvcont = new MultiViewer_Container(*gpumeminfo,mwsettings.highprecision,mwsettings.perbatchprimitives,mwsettings.minpolygonpersmoothrendering,mdiarea);
+ connect(&mvcont->meshDoc,SIGNAL(meshAdded(int)),this,SLOT(meshAdded(int)));
+ connect(&mvcont->meshDoc,SIGNAL(meshRemoved(int)),this,SLOT(meshRemoved(int)));
connect(&mvcont->meshDoc, SIGNAL(documentUpdated()), this, SLOT(documentUpdateRequested()));
connect(mvcont, SIGNAL(closingMultiViewerContainer()), this, SLOT(closeCurrentDocument()));
- mdiarea->addSubWindow(mvcont);
- connect(mvcont,SIGNAL(updateMainWindowMenus()),this,SLOT(updateMenus()));
- connect(mvcont,SIGNAL(updateDocumentViewer()),this,SLOT(updateLayerDialog()));
+ mdiarea->addSubWindow(mvcont);
+ connect(mvcont,SIGNAL(updateMainWindowMenus()),this,SLOT(updateMenus()));
+ connect(mvcont,SIGNAL(updateDocumentViewer()),this,SLOT(updateLayerDialog()));
connect(&mvcont->meshDoc.Log, SIGNAL(logUpdated()), this, SLOT(updateLog()));
- filterMenu->setEnabled(!filterMenu->actions().isEmpty());
- if (!filterMenu->actions().isEmpty())
- updateSubFiltersMenu(true,false);
- GLArea *gla=new GLArea(this, mvcont, ¤tGlobalParams);
+ filterMenu->setEnabled(!filterMenu->actions().isEmpty());
+ if (!filterMenu->actions().isEmpty())
+ updateSubFiltersMenu(true,false);
+ GLArea *gla=new GLArea(this, mvcont, ¤tGlobalParams);
//connect(gla, SIGNAL(insertRenderingDataForNewlyGeneratedMesh(int)), this, SLOT(addRenderingDataIfNewlyGeneratedMesh(int)));
- mvcont->addView(gla, Qt::Horizontal);
-
- if (projName.isEmpty())
- {
- static int docCounter = 1;
- mvcont->meshDoc.setDocLabel(QString("Project_") + QString::number(docCounter));
- ++docCounter;
- }
- else
- mvcont->meshDoc.setDocLabel(projName);
- mvcont->setWindowTitle(mvcont->meshDoc.docLabel());
+ mvcont->addView(gla, Qt::Horizontal);
+
+ if (projName.isEmpty())
+ {
+ static int docCounter = 1;
+ mvcont->meshDoc.setDocLabel(QString("Project_") + QString::number(docCounter));
+ ++docCounter;
+ }
+ else
+ mvcont->meshDoc.setDocLabel(projName);
+ mvcont->setWindowTitle(mvcont->meshDoc.docLabel());
if (layerDialog != NULL)
layerDialog->reset();
//if(mdiarea->isVisible())
- updateLayerDialog();
- mvcont->showMaximized();
- connect(mvcont->sharedDataContext(),SIGNAL(currentAllocatedGPUMem(int,int,int,int)),this,SLOT(updateGPUMemBar(int,int,int,int)));
+ updateLayerDialog();
+ mvcont->showMaximized();
+ connect(mvcont->sharedDataContext(),SIGNAL(currentAllocatedGPUMem(int,int,int,int)),this,SLOT(updateGPUMemBar(int,int,int,int)));
}
void MainWindow::documentUpdateRequested()
@@ -1926,8 +1926,8 @@ void MainWindow::documentUpdateRequested()
void MainWindow::updateGPUMemBar(int nv_allmem, int nv_currentallocated, int ati_free_tex, int ati_free_vbo)
{
#ifdef Q_OS_WIN
- if (nvgpumeminfo != NULL)
- {
+ if (nvgpumeminfo != NULL)
+ {
if (nv_allmem + nv_currentallocated > 0)
{
nvgpumeminfo->setFormat("Mem %p% %v/%m MB");
@@ -1953,14 +1953,14 @@ void MainWindow::updateGPUMemBar(int nv_allmem, int nv_currentallocated, int ati
nvgpumeminfo->setValue(0);
nvgpumeminfo->setFixedWidth(300);
}
- }
+ }
#else
- //avoid unused parameter warning
- (void) nv_allmem;
- (void) nv_currentallocated;
- (void) ati_free_tex;
- (void) ati_free_vbo;
- nvgpumeminfo->hide();
+ //avoid unused parameter warning
+ (void) nv_allmem;
+ (void) nv_currentallocated;
+ (void) ati_free_tex;
+ (void) ati_free_vbo;
+ nvgpumeminfo->hide();
#endif
}
//WARNING!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@@ -1977,225 +1977,225 @@ bool MainWindow::importRaster(const QString& fileImg)
if (!GLA())
return false;
}
-
- QStringList filters;
- filters.push_back("Images (*.jpg *.png *.xpm)");
- filters.push_back("*.jpg");
- filters.push_back("*.png");
- filters.push_back("*.xpm");
-
- QStringList fileNameList;
- if (fileImg.isEmpty())
- fileNameList = QFileDialog::getOpenFileNames(this,tr("Open File"), lastUsedDirectory.path(), filters.join(";;"));
- else
- fileNameList.push_back(fileImg);
-
- foreach(QString fileName,fileNameList)
- {
- QFileInfo fi(fileName);
- if( fi.suffix().toLower()=="png" || fi.suffix().toLower()=="xpm" || fi.suffix().toLower()=="jpg")
- {
- qb->show();
-
- if(!fi.exists()) {
- QString errorMsgFormat = "Unable to open file:\n\"%1\"\n\nError details: file %1 does not exist.";
- QMessageBox::critical(this, tr("Meshlab Opening Error"), errorMsgFormat.arg(fileName));
- return false;
- }
- if(!fi.isReadable()) {
- QString errorMsgFormat = "Unable to open file:\n\"%1\"\n\nError details: file %1 is not readable.";
- QMessageBox::critical(this, tr("Meshlab Opening Error"), errorMsgFormat.arg(fileName));
- return false;
- }
-
- 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
+
+ QStringList filters;
+ filters.push_back("Images (*.jpg *.png *.xpm)");
+ filters.push_back("*.jpg");
+ filters.push_back("*.png");
+ filters.push_back("*.xpm");
+
+ QStringList fileNameList;
+ if (fileImg.isEmpty())
+ fileNameList = QFileDialog::getOpenFileNames(this,tr("Open File"), lastUsedDirectory.path(), filters.join(";;"));
+ else
+ fileNameList.push_back(fileImg);
+
+ foreach(QString fileName,fileNameList)
+ {
+ QFileInfo fi(fileName);
+ if( fi.suffix().toLower()=="png" || fi.suffix().toLower()=="xpm" || fi.suffix().toLower()=="jpg")
+ {
+ qb->show();
- ::ResetJpgfile();
+ if(!fi.exists()) {
+ QString errorMsgFormat = "Unable to open file:\n\"%1\"\n\nError details: file %1 does not exist.";
+ QMessageBox::critical(this, tr("Meshlab Opening Error"), errorMsgFormat.arg(fileName));
+ return false;
+ }
+ if(!fi.isReadable()) {
+ QString errorMsgFormat = "Unable to open file:\n\"%1\"\n\nError details: file %1 is not readable.";
+ QMessageBox::critical(this, tr("Meshlab Opening Error"), errorMsgFormat.arg(fileName));
+ return false;
+ }
+
+ 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
+
+ ::ResetJpgfile();
FILE * pFile = fopen(qUtf8Printable(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 = Point2m(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 = Point2m(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
- {
- rm->shot.Intrinsics.ViewportPx = vcg::Point2i(ImageInfo.Width, ImageInfo.Height);
- rm->shot.Intrinsics.CenterPx = Point2m(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;
- }
-
+
+ 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 = Point2m(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 = Point2m(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
+ {
+ rm->shot.Intrinsics.ViewportPx = vcg::Point2i(ImageInfo.Width, ImageInfo.Height);
+ rm->shot.Intrinsics.CenterPx = Point2m(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
-
+
//// Since no extrinsic are available, the current trackball is reset (except for the FOV) and assigned to the raster
GLA()->resetTrackBall();
GLA()->fov = rm->shot.GetFovFromFocal();
rm->shot = GLA()->shotFromTrackball().first;
GLA()->resetTrackBall(); // and then we reset the trackball again, to have the standard view
-
+
if (_currviewcontainer != NULL)
_currviewcontainer->updateAllDecoratorsForAllViewers();
-
- // if(mdiarea->isVisible()) GLA()->mvc->showMaximized();
- updateMenus();
- updateLayerDialog();
-
- }
- else
- return false;
- }
- return true;
+
+ // if(mdiarea->isVisible()) GLA()->mvc->showMaximized();
+ updateMenus();
+ updateLayerDialog();
+
+ }
+ else
+ return false;
+ }
+ return true;
}
bool MainWindow::loadMesh(const QString& fileName, IOPluginInterface *pCurrentIOPlugin, MeshModel* mm, int& mask,RichParameterList* prePar, const Matrix44m &mtr, bool isareload, MLRenderingData* rendOpt)
{
- if ((GLA() == NULL) || (mm == NULL))
- return false;
-
- QFileInfo fi(fileName);
- QString extension = fi.suffix();
- if(!fi.exists())
- {
- QString errorMsgFormat = "Unable to open file:\n\"%1\"\n\nError details: file %1 does not exist.";
- QMessageBox::critical(this, tr("Meshlab Opening Error"), errorMsgFormat.arg(fileName));
- return false;
- }
- if(!fi.isReadable())
- {
- QString errorMsgFormat = "Unable to open file:\n\"%1\"\n\nError details: file %1 is not readable.";
- QMessageBox::critical(this, tr("Meshlab Opening Error"), errorMsgFormat.arg(fileName));
- return false;
- }
-
- // the original directory path before we switch it
- QString origDir = QDir::current().path();
-
- // this change of dir is needed for subsequent textures/materials loading
- QDir::setCurrent(fi.absoluteDir().absolutePath());
-
- // Adjust the file name after changing the directory
- QString fileNameSansDir = fi.fileName();
-
- // 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));
- QDir::setCurrent(origDir); // undo the change of directory before leaving
- return false;
- }
- meshDoc()->setBusy(true);
- pCurrentIOPlugin->setLog(&meshDoc()->Log);
-
- if (!pCurrentIOPlugin->open(extension, fileNameSansDir, *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);
- QDir::setCurrent(origDir); // undo the change of directory before leaving
- return false;
- }
-
-
+ if ((GLA() == NULL) || (mm == NULL))
+ return false;
+
+ QFileInfo fi(fileName);
+ QString extension = fi.suffix();
+ if(!fi.exists())
+ {
+ QString errorMsgFormat = "Unable to open file:\n\"%1\"\n\nError details: file %1 does not exist.";
+ QMessageBox::critical(this, tr("Meshlab Opening Error"), errorMsgFormat.arg(fileName));
+ return false;
+ }
+ if(!fi.isReadable())
+ {
+ QString errorMsgFormat = "Unable to open file:\n\"%1\"\n\nError details: file %1 is not readable.";
+ QMessageBox::critical(this, tr("Meshlab Opening Error"), errorMsgFormat.arg(fileName));
+ return false;
+ }
+
+ // the original directory path before we switch it
+ QString origDir = QDir::current().path();
+
+ // this change of dir is needed for subsequent textures/materials loading
+ QDir::setCurrent(fi.absoluteDir().absolutePath());
+
+ // Adjust the file name after changing the directory
+ QString fileNameSansDir = fi.fileName();
+
+ // 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));
+ QDir::setCurrent(origDir); // undo the change of directory before leaving
+ return false;
+ }
+ meshDoc()->setBusy(true);
+ pCurrentIOPlugin->setLog(&meshDoc()->Log);
+
+ if (!pCurrentIOPlugin->open(extension, fileNameSansDir, *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);
+ QDir::setCurrent(origDir); // undo the change of directory before leaving
+ return false;
+ }
+
+
//std::cout << "Opened mesh: in " << tm.elapsed() << " secs\n";
// 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();
- }
-
- saveRecentFileList(fileName);
-
- if (!(mm->cm.textures.empty()))
- updateTexture(mm->id());
-
- // 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)
- {
- if(mask & vcg::tri::io::Mask::IOM_VERTNORMAL)
- mm->updateDataMask(MeshModel::MM_VERTNORMAL);
- }
-
- if(mm->cm.fn==0 && mm->cm.en>0)
- {
- if (mask & vcg::tri::io::Mask::IOM_VERTNORMAL)
- mm->updateDataMask(MeshModel::MM_VERTNORMAL);
- }
-
- updateMenus();
- int delVertNum = vcg::tri::Clean::RemoveDegenerateVertex(mm->cm);
- int delFaceNum = vcg::tri::Clean::RemoveDegenerateFace(mm->cm);
- tri::Allocator::CompactEveryVector(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) );
- mm->cm.Tr = mtr;
-
+ // 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();
+ }
+
+ saveRecentFileList(fileName);
+
+ if (!(mm->cm.textures.empty()))
+ updateTexture(mm->id());
+
+ // 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)
+ {
+ if(mask & vcg::tri::io::Mask::IOM_VERTNORMAL)
+ mm->updateDataMask(MeshModel::MM_VERTNORMAL);
+ }
+
+ if(mm->cm.fn==0 && mm->cm.en>0)
+ {
+ if (mask & vcg::tri::io::Mask::IOM_VERTNORMAL)
+ mm->updateDataMask(MeshModel::MM_VERTNORMAL);
+ }
+
+ updateMenus();
+ int delVertNum = vcg::tri::Clean::RemoveDegenerateVertex(mm->cm);
+ int delFaceNum = vcg::tri::Clean::RemoveDegenerateFace(mm->cm);
+ tri::Allocator::CompactEveryVector(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) );
+ mm->cm.Tr = mtr;
+
computeRenderingDataOnLoading(mm,isareload, rendOpt);
updateLayerDialog();
-
-
- meshDoc()->setBusy(false);
-
- QDir::setCurrent(origDir); // undo the change of directory before leaving
-
- return true;
+
+
+ meshDoc()->setBusy(false);
+
+ QDir::setCurrent(origDir); // undo the change of directory before leaving
+
+ return true;
}
void MainWindow::computeRenderingDataOnLoading(MeshModel* mm,bool isareload, MLRenderingData* rendOpt)
@@ -2207,9 +2207,9 @@ void MainWindow::computeRenderingDataOnLoading(MeshModel* mm,bool isareload, MLR
if ((shared != NULL) && (mm != NULL))
{
MLRenderingData defdt;
- MLPoliciesStandAloneFunctions::suggestedDefaultPerViewRenderingData(mm, defdt,mwsettings.minpolygonpersmoothrendering);
- if (rendOpt != NULL)
- defdt = *rendOpt;
+ MLPoliciesStandAloneFunctions::suggestedDefaultPerViewRenderingData(mm, defdt,mwsettings.minpolygonpersmoothrendering);
+ if (rendOpt != NULL)
+ defdt = *rendOpt;
for (int glarid = 0; glarid < mv->viewerCounter(); ++glarid)
{
GLArea* ar = mv->getViewer(glarid);
@@ -2238,194 +2238,194 @@ void MainWindow::computeRenderingDataOnLoading(MeshModel* mm,bool isareload, MLR
bool MainWindow::importMeshWithLayerManagement(QString fileName)
{
- bool layervisible = false;
- if (layerDialog != NULL)
- {
- layervisible = layerDialog->isVisible();
- //showLayerDlg(false);
- }
+ bool layervisible = false;
+ if (layerDialog != NULL)
+ {
+ layervisible = layerDialog->isVisible();
+ //showLayerDlg(false);
+ }
globrendtoolbar->setEnabled(false);
- bool res = importMesh(fileName,false);
+ bool res = importMesh(fileName,false);
globrendtoolbar->setEnabled(true);
if (layerDialog != NULL)
showLayerDlg(layervisible || meshDoc()->meshList.size());
setCurrentMeshBestTab();
- return res;
+ return res;
}
// Opening files in a transparent form (IO plugins contribution is hidden to user)
bool MainWindow::importMesh(QString fileName,bool isareload)
{
- 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);
-
- if (fileNameList.isEmpty()) return false;
- else
- {
- //save path away so we can use it again
- QString path = fileNameList.first();
- path.truncate(path.lastIndexOf("/"));
- lastUsedDirectory.setPath(path);
- }
-
- QElapsedTimer allFileTime;
- allFileTime.start();
- foreach(fileName,fileNameList)
- {
- QFileInfo fi(fileName);
- QString extension = fi.suffix();
- IOPluginInterface *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;
- }
-
- RichParameterList prePar;
- pCurrentIOPlugin->initPreOpenParameter(extension, fileName,prePar);
- if(!prePar.isEmpty())
- {
+ 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);
+
+ if (fileNameList.isEmpty()) return false;
+ else
+ {
+ //save path away so we can use it again
+ QString path = fileNameList.first();
+ path.truncate(path.lastIndexOf("/"));
+ lastUsedDirectory.setPath(path);
+ }
+
+ QElapsedTimer allFileTime;
+ allFileTime.start();
+ foreach(fileName,fileNameList)
+ {
+ QFileInfo fi(fileName);
+ QString extension = fi.suffix();
+ IOPluginInterface *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;
+ }
+
+ RichParameterList prePar;
+ pCurrentIOPlugin->initPreOpenParameter(extension, fileName,prePar);
+ if(!prePar.isEmpty())
+ {
RichParameterListDialog preOpenDialog(this, prePar, tr("Pre-Open Options"));
- preOpenDialog.setFocus();
- preOpenDialog.exec();
- }
+ preOpenDialog.setFocus();
+ preOpenDialog.exec();
+ }
prePar.join(currentGlobalParams);
- int mask = 0;
- //MeshModel *mm= new MeshModel(gla->meshDoc);
- QFileInfo info(fileName);
+ int mask = 0;
+ //MeshModel *mm= new MeshModel(gla->meshDoc);
+ QFileInfo info(fileName);
MeshModel *mm = meshDoc()->addNewMesh(fileName, info.fileName());
- qb->show();
- QElapsedTimer t;
+ qb->show();
+ QElapsedTimer t;
t.start();
Matrix44m mtr;
mtr.SetIdentity();
- bool open = loadMesh(fileName,pCurrentIOPlugin,mm,mask,&prePar,mtr,isareload);
- if(open)
- {
+ bool open = loadMesh(fileName,pCurrentIOPlugin,mm,mask,&prePar,mtr,isareload);
+ if(open)
+ {
GLA()->Logf(0, "Opened mesh %s in %i msec", qUtf8Printable(fileName), t.elapsed());
- RichParameterList par;
- pCurrentIOPlugin->initOpenParameter(extension, *mm, par);
- if(!par.isEmpty())
- {
+ RichParameterList par;
+ pCurrentIOPlugin->initOpenParameter(extension, *mm, par);
+ if(!par.isEmpty())
+ {
RichParameterListDialog postOpenDialog(this, par, tr("Post-Open Processing"));
- postOpenDialog.setFocus();
- postOpenDialog.exec();
- pCurrentIOPlugin->applyOpenParameter(extension, *mm, par);
- }
- /*MultiViewer_Container* mv = GLA()->mvc();
- if (mv != NULL)
- {
- for(int glarid = 0;glarid < mv->viewerCounter();++glarid)
- {
- GLArea* ar = mv->getViewer(glarid);
- if (ar != NULL)
- MLSceneRenderModeAdapter::setupRequestedAttributesAccordingToRenderMode(mm->id(),*ar);
- }
- }*/
- }
- else
- {
- meshDoc()->delMesh(mm);
+ postOpenDialog.setFocus();
+ postOpenDialog.exec();
+ pCurrentIOPlugin->applyOpenParameter(extension, *mm, par);
+ }
+ /*MultiViewer_Container* mv = GLA()->mvc();
+ if (mv != NULL)
+ {
+ for(int glarid = 0;glarid < mv->viewerCounter();++glarid)
+ {
+ GLArea* ar = mv->getViewer(glarid);
+ if (ar != NULL)
+ MLSceneRenderModeAdapter::setupRequestedAttributesAccordingToRenderMode(mm->id(),*ar);
+ }
+ }*/
+ }
+ else
+ {
+ meshDoc()->delMesh(mm);
GLA()->Logf(0, "Warning: Mesh %s has not been opened", qUtf8Printable(fileName));
- }
- }// end foreach file of the input list
- GLA()->Logf(0,"All files opened in %i msec",allFileTime.elapsed());
-
+ }
+ }// end foreach file of the input list
+ GLA()->Logf(0,"All files opened in %i msec",allFileTime.elapsed());
+
if (_currviewcontainer != NULL)
{
_currviewcontainer->resetAllTrackBall();
_currviewcontainer->updateAllDecoratorsForAllViewers();
}
qb->reset();
- return true;
+ return true;
}
void MainWindow::openRecentMesh()
{
- if(!GLA()) return;
- if(meshDoc()->isBusy()) return;
- QAction *action = qobject_cast(sender());
- if (action) importMeshWithLayerManagement(action->data().toString());
+ if(!GLA()) return;
+ if(meshDoc()->isBusy()) return;
+ QAction *action = qobject_cast(sender());
+ if (action) importMeshWithLayerManagement(action->data().toString());
}
void MainWindow::openRecentProj()
{
- QAction *action = qobject_cast(sender());
- if (action) openProject(action->data().toString());
+ QAction *action = qobject_cast(sender());
+ if (action) openProject(action->data().toString());
}
bool MainWindow::loadMeshWithStandardParams(QString& fullPath, MeshModel* mm, const Matrix44m &mtr, bool isreload, MLRenderingData* rendOpt)
{
- if ((meshDoc() == NULL) || (mm == NULL))
- return false;
- bool ret = false;
- if (!mm->isVisible())
- {
- mm->Clear();
- mm->visible = false;
- }
- else
- mm->Clear();
- QFileInfo fi(fullPath);
- QString extension = fi.suffix();
- IOPluginInterface *pCurrentIOPlugin = PM.allKnowInputFormats[extension.toLower()];
-
- if(pCurrentIOPlugin != NULL)
- {
- RichParameterList prePar;
- pCurrentIOPlugin->initPreOpenParameter(extension, fullPath,prePar);
+ if ((meshDoc() == NULL) || (mm == NULL))
+ return false;
+ bool ret = false;
+ if (!mm->isVisible())
+ {
+ mm->Clear();
+ mm->visible = false;
+ }
+ else
+ mm->Clear();
+ QFileInfo fi(fullPath);
+ QString extension = fi.suffix();
+ IOPluginInterface *pCurrentIOPlugin = PM.allKnowInputFormats[extension.toLower()];
+
+ if(pCurrentIOPlugin != NULL)
+ {
+ RichParameterList prePar;
+ pCurrentIOPlugin->initPreOpenParameter(extension, fullPath,prePar);
prePar.join(currentGlobalParams);
- int mask = 0;
- QElapsedTimer t;t.start();
- bool open = loadMesh(fullPath,pCurrentIOPlugin,mm,mask,&prePar,mtr,isreload, rendOpt);
- if(open)
- {
+ int mask = 0;
+ QElapsedTimer t;t.start();
+ bool open = loadMesh(fullPath,pCurrentIOPlugin,mm,mask,&prePar,mtr,isreload, rendOpt);
+ if(open)
+ {
GLA()->Logf(0, "Opened mesh %s in %i msec", qUtf8Printable(fullPath), t.elapsed());
- RichParameterList par;
- pCurrentIOPlugin->initOpenParameter(extension, *mm, par);
- pCurrentIOPlugin->applyOpenParameter(extension,*mm,par);
- ret = true;
- }
- else
+ RichParameterList par;
+ pCurrentIOPlugin->initOpenParameter(extension, *mm, par);
+ pCurrentIOPlugin->applyOpenParameter(extension,*mm,par);
+ ret = true;
+ }
+ else
GLA()->Logf(0, "Warning: Mesh %s has not been opened", qUtf8Printable(fullPath));
- }
- else
+ }
+ else
GLA()->Logf(0, "Warning: Mesh %s cannot be opened. Your MeshLab version has not plugin to read %s file format", qUtf8Printable(fullPath), qUtf8Printable(extension));
- return ret;
+ return ret;
}
void MainWindow::reloadAllMesh()
{
- // Discards changes and reloads current file
- // save current file name
- qb->show();
- foreach(MeshModel *mmm,meshDoc()->meshList)
- {
- QString fileName = mmm->fullName();
+ // Discards changes and reloads current file
+ // save current file name
+ qb->show();
+ foreach(MeshModel *mmm,meshDoc()->meshList)
+ {
+ QString fileName = mmm->fullName();
Matrix44m mat;
mat.SetIdentity();
- loadMeshWithStandardParams(fileName,mmm,mat,true);
- }
- qb->reset();
-
+ loadMeshWithStandardParams(fileName,mmm,mat,true);
+ }
+ qb->reset();
+
if (_currviewcontainer != NULL)
{
_currviewcontainer->updateAllDecoratorsForAllViewers();
@@ -2435,12 +2435,12 @@ void MainWindow::reloadAllMesh()
void MainWindow::reload()
{
- if ((meshDoc() == NULL) || (meshDoc()->mm() == NULL))
- return;
- // Discards changes and reloads current file
- // save current file name
- qb->show();
- QString fileName = meshDoc()->mm()->fullName();
+ if ((meshDoc() == NULL) || (meshDoc()->mm() == NULL))
+ return;
+ // Discards changes and reloads current file
+ // save current file name
+ qb->show();
+ QString fileName = meshDoc()->mm()->fullName();
if (fileName.isEmpty())
{
QMessageBox::critical(this, "Reload Error", "Impossible to reload an unsaved mesh model!!");
@@ -2448,8 +2448,8 @@ void MainWindow::reload()
}
Matrix44m mat;
mat.SetIdentity();
- loadMeshWithStandardParams(fileName,meshDoc()->mm(),mat,true);
- qb->reset();
+ loadMeshWithStandardParams(fileName,meshDoc()->mm(),mat,true);
+ qb->reset();
if (_currviewcontainer != NULL)
{
_currviewcontainer->updateAllDecoratorsForAllViewers();
@@ -2460,7 +2460,7 @@ void MainWindow::reload()
bool MainWindow::exportMesh(QString fileName,MeshModel* mod,const bool saveAllPossibleAttributes)
{
QStringList& suffixList = PM.outFilters;
-
+
//QHash allKnownFormats;
QFileInfo fi(fileName);
//PM.LoadFormats( suffixList, allKnownFormats,PluginManager::EXPORT);
@@ -2471,100 +2471,100 @@ bool MainWindow::exportMesh(QString fileName,MeshModel* mod,const bool saveAllPo
if (mod == NULL)
return false;
mod->setMeshModified(false);
- QString laylabel = "Save \"" + mod->label() + "\" Layer";
- QString ss = fi.absoluteFilePath();
- QFileDialog* saveDialog = new QFileDialog(this,laylabel, fi.absolutePath());
+ QString laylabel = "Save \"" + mod->label() + "\" Layer";
+ QString ss = fi.absoluteFilePath();
+ QFileDialog* saveDialog = new QFileDialog(this,laylabel, fi.absolutePath());
#if defined(Q_OS_WIN)
- saveDialog->setOption(QFileDialog::DontUseNativeDialog);
+ saveDialog->setOption(QFileDialog::DontUseNativeDialog);
#endif
- saveDialog->setNameFilters(suffixList);
- saveDialog->setAcceptMode(QFileDialog::AcceptSave);
- saveDialog->setFileMode(QFileDialog::AnyFile);
- saveDialog->selectFile(fileName);
- QStringList matchingExtensions=suffixList.filter(defaultExt);
- if(!matchingExtensions.isEmpty())
- saveDialog->selectNameFilter(matchingExtensions.last());
- connect(saveDialog,SIGNAL(filterSelected(const QString&)),this,SLOT(changeFileExtension(const QString&)));
-
- if (fileName.isEmpty()){
- saveDialog->selectFile(meshDoc()->mm()->fullName());
- int dialogRet = saveDialog->exec();
- if(dialogRet==QDialog::Rejected )
- return false;
- fileName=saveDialog->selectedFiles ().first();
- QFileInfo fni(fileName);
- if(fni.suffix().isEmpty())
- {
- QString ext = saveDialog->selectedNameFilter();
- ext.chop(1); ext = ext.right(4);
- fileName = fileName + ext;
+ saveDialog->setNameFilters(suffixList);
+ saveDialog->setAcceptMode(QFileDialog::AcceptSave);
+ saveDialog->setFileMode(QFileDialog::AnyFile);
+ saveDialog->selectFile(fileName);
+ QStringList matchingExtensions=suffixList.filter(defaultExt);
+ if(!matchingExtensions.isEmpty())
+ saveDialog->selectNameFilter(matchingExtensions.last());
+ connect(saveDialog,SIGNAL(filterSelected(const QString&)),this,SLOT(changeFileExtension(const QString&)));
+
+ if (fileName.isEmpty()){
+ saveDialog->selectFile(meshDoc()->mm()->fullName());
+ int dialogRet = saveDialog->exec();
+ if(dialogRet==QDialog::Rejected )
+ return false;
+ fileName=saveDialog->selectedFiles ().first();
+ QFileInfo fni(fileName);
+ if(fni.suffix().isEmpty())
+ {
+ QString ext = saveDialog->selectedNameFilter();
+ ext.chop(1); ext = ext.right(4);
+ fileName = fileName + ext;
qDebug("File without extension adding it by hand '%s'", qUtf8Printable(fileName));
- }
- }
-
-
- bool ret = false;
-
- QStringList fs = fileName.split(".");
-
- if(!fileName.isEmpty() && fs.size() < 2)
- {
- QMessageBox::warning(this,"Save Error","You must specify file extension!!");
- return ret;
- }
-
- if (!fileName.isEmpty())
- {
- //save path away so we can use it again
- QString path = fileName;
- path.truncate(path.lastIndexOf("/"));
- lastUsedDirectory.setPath(path);
-
- QString extension = fileName;
- extension.remove(0, fileName.lastIndexOf('.')+1);
-
- QStringListIterator itFilter(suffixList);
-
- IOPluginInterface *pCurrentIOPlugin = PM.allKnowOutputFormats[extension.toLower()];
- if (pCurrentIOPlugin == 0)
- {
- QMessageBox::warning(this, "Unknown type", "File extension not supported!");
- return false;
- }
- //MeshIOInterface* pCurrentIOPlugin = meshIOPlugins[idx-1];
- pCurrentIOPlugin->setLog(&meshDoc()->Log);
-
- int capability=0,defaultBits=0;
- pCurrentIOPlugin->GetExportMaskCapability(extension,capability,defaultBits);
-
- // optional saving parameters (like ascii/binary encoding)
- RichParameterList savePar;
-
- pCurrentIOPlugin->initSaveParameter(extension,*(mod),savePar);
-
- SaveMaskExporterDialog maskDialog(new QWidget(),mod,capability,defaultBits,&savePar,this->GLA());
- if (!saveAllPossibleAttributes)
- maskDialog.exec();
- else
- {
- maskDialog.SlotSelectionAllButton();
- maskDialog.updateMask();
- }
- int mask = maskDialog.GetNewMask();
- if (!saveAllPossibleAttributes)
- {
- maskDialog.close();
- if(maskDialog.result() == QDialog::Rejected)
- return false;
- }
- if(mask == -1)
- return false;
-
- qApp->setOverrideCursor(QCursor(Qt::WaitCursor));
- qb->show();
- QElapsedTimer tt; tt.start();
- ret = pCurrentIOPlugin->save(extension, fileName, *mod ,mask,savePar,QCallBack,this);
- qb->reset();
+ }
+ }
+
+
+ bool ret = false;
+
+ QStringList fs = fileName.split(".");
+
+ if(!fileName.isEmpty() && fs.size() < 2)
+ {
+ QMessageBox::warning(this,"Save Error","You must specify file extension!!");
+ return ret;
+ }
+
+ if (!fileName.isEmpty())
+ {
+ //save path away so we can use it again
+ QString path = fileName;
+ path.truncate(path.lastIndexOf("/"));
+ lastUsedDirectory.setPath(path);
+
+ QString extension = fileName;
+ extension.remove(0, fileName.lastIndexOf('.')+1);
+
+ QStringListIterator itFilter(suffixList);
+
+ IOPluginInterface *pCurrentIOPlugin = PM.allKnowOutputFormats[extension.toLower()];
+ if (pCurrentIOPlugin == 0)
+ {
+ QMessageBox::warning(this, "Unknown type", "File extension not supported!");
+ return false;
+ }
+ //MeshIOInterface* pCurrentIOPlugin = meshIOPlugins[idx-1];
+ pCurrentIOPlugin->setLog(&meshDoc()->Log);
+
+ int capability=0,defaultBits=0;
+ pCurrentIOPlugin->GetExportMaskCapability(extension,capability,defaultBits);
+
+ // optional saving parameters (like ascii/binary encoding)
+ RichParameterList savePar;
+
+ pCurrentIOPlugin->initSaveParameter(extension,*(mod),savePar);
+
+ SaveMaskExporterDialog maskDialog(new QWidget(),mod,capability,defaultBits,&savePar,this->GLA());
+ if (!saveAllPossibleAttributes)
+ maskDialog.exec();
+ else
+ {
+ maskDialog.SlotSelectionAllButton();
+ maskDialog.updateMask();
+ }
+ int mask = maskDialog.GetNewMask();
+ if (!saveAllPossibleAttributes)
+ {
+ maskDialog.close();
+ if(maskDialog.result() == QDialog::Rejected)
+ return false;
+ }
+ if(mask == -1)
+ return false;
+
+ qApp->setOverrideCursor(QCursor(Qt::WaitCursor));
+ qb->show();
+ QElapsedTimer tt; tt.start();
+ ret = pCurrentIOPlugin->save(extension, fileName, *mod ,mask,savePar,QCallBack,this);
+ qb->reset();
if (ret)
{
GLA()->Logf(GLLogStream::SYSTEM, "Saved Mesh %s in %i msec", qUtf8Printable(fileName), tt.elapsed());
@@ -2578,94 +2578,94 @@ bool MainWindow::exportMesh(QString fileName,MeshModel* mod,const bool saveAllPo
GLA()->Logf(GLLogStream::SYSTEM, "Error Saving Mesh %s", qUtf8Printable(fileName));
QMessageBox::critical(this, tr("Meshlab Saving Error"), pCurrentIOPlugin->errorMessage);
}
- qApp->restoreOverrideCursor();
+ qApp->restoreOverrideCursor();
updateLayerDialog();
-
+
if (ret)
QDir::setCurrent(fi.absoluteDir().absolutePath()); //set current dir
- }
- return ret;
+ }
+ return ret;
}
void MainWindow::changeFileExtension(const QString& st)
{
- QFileDialog* fd = qobject_cast(sender());
- if (fd == NULL)
- return;
- QRegExp extlist("\\*.\\w+");
- int start = st.indexOf(extlist);
- (void)start;
- QString ext = extlist.cap().remove("*");
- QStringList stlst = fd->selectedFiles();
- if (!stlst.isEmpty())
- {
- QFileInfo fi(stlst[0]);
- fd->selectFile(fi.baseName() + ext);
- }
+ QFileDialog* fd = qobject_cast(sender());
+ if (fd == NULL)
+ return;
+ QRegExp extlist("\\*.\\w+");
+ int start = st.indexOf(extlist);
+ (void)start;
+ QString ext = extlist.cap().remove("*");
+ QStringList stlst = fd->selectedFiles();
+ if (!stlst.isEmpty())
+ {
+ QFileInfo fi(stlst[0]);
+ fd->selectFile(fi.baseName() + ext);
+ }
}
bool MainWindow::save(const bool saveAllPossibleAttributes)
{
- return exportMesh(meshDoc()->mm()->fullName(),meshDoc()->mm(),saveAllPossibleAttributes);
+ return exportMesh(meshDoc()->mm()->fullName(),meshDoc()->mm(),saveAllPossibleAttributes);
}
bool MainWindow::saveAs(QString fileName,const bool saveAllPossibleAttributes)
{
- return exportMesh(fileName,meshDoc()->mm(),saveAllPossibleAttributes);
+ return exportMesh(fileName,meshDoc()->mm(),saveAllPossibleAttributes);
}
void MainWindow::readViewFromFile(QString const& filename){
- if(GLA() != 0)
- GLA()->readViewFromFile(filename);
+ if(GLA() != 0)
+ GLA()->readViewFromFile(filename);
}
bool MainWindow::saveSnapshot()
{
if (!GLA()) return false;
if (meshDoc()->isBusy()) return false;
-
- SaveSnapshotDialog dialog(this);
- dialog.setValues(GLA()->ss);
-
- if (dialog.exec()==QDialog::Accepted)
- {
- GLA()->ss=dialog.getValues();
- GLA()->saveSnapshot();
- return true;
- }
-
- return false;
+
+ SaveSnapshotDialog dialog(this);
+ dialog.setValues(GLA()->ss);
+
+ if (dialog.exec()==QDialog::Accepted)
+ {
+ GLA()->ss=dialog.getValues();
+ GLA()->saveSnapshot();
+ return true;
+ }
+
+ return false;
}
void MainWindow::about()
{
- QDialog *about_dialog = new QDialog();
- Ui::aboutDialog temp;
- temp.setupUi(about_dialog);
- temp.labelMLName->setText(MeshLabApplication::completeName(MeshLabApplication::HW_ARCHITECTURE(QSysInfo::WordSize))+" (built on "+__DATE__+")");
- //about_dialog->setFixedSize(566,580);
- about_dialog->show();
+ QDialog *about_dialog = new QDialog();
+ Ui::aboutDialog temp;
+ temp.setupUi(about_dialog);
+ temp.labelMLName->setText(MeshLabApplication::completeName(MeshLabApplication::HW_ARCHITECTURE(QSysInfo::WordSize))+" (built on "+__DATE__+")");
+ //about_dialog->setFixedSize(566,580);
+ about_dialog->show();
}
void MainWindow::aboutPlugins()
{
- qDebug( "aboutPlugins(): Current Plugins Dir: %s ",qUtf8Printable(pluginManager().getDefaultPluginDirPath()));
- PluginDialog dialog(pluginManager().getDefaultPluginDirPath(), pluginManager().pluginsLoaded, this);
- dialog.exec();
+ qDebug( "aboutPlugins(): Current Plugins Dir: %s ",qUtf8Printable(pluginManager().getDefaultPluginDirPath()));
+ 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://www.meshlab.net/#support"));
+ checkForUpdates(false);
+ QDesktopServices::openUrl(QUrl("http://www.meshlab.net/#support"));
}
void MainWindow::showToolbarFile(){
- mainToolBar->setVisible(!mainToolBar->isVisible());
+ mainToolBar->setVisible(!mainToolBar->isVisible());
}
void MainWindow::showInfoPane() {if(GLA() != 0) GLA()->infoAreaVisible =!GLA()->infoAreaVisible;}
@@ -2674,60 +2674,60 @@ void MainWindow::resetTrackBall(){if(GLA() != 0) GLA()->resetTrackBall();}
void MainWindow::showRaster() {if(GLA() != 0) GLA()->showRaster((QApplication::keyboardModifiers () & Qt::ShiftModifier));}
void MainWindow::showLayerDlg(bool visible)
{
- if ((GLA() != 0) && (layerDialog != NULL))
- {
- layerDialog->setVisible( visible);
- showLayerDlgAct->setChecked(visible);
- }
+ if ((GLA() != 0) && (layerDialog != NULL))
+ {
+ layerDialog->setVisible( visible);
+ showLayerDlgAct->setChecked(visible);
+ }
}
void MainWindow::setCustomize()
{
- MeshLabSettingsDialog dialog(currentGlobalParams,defaultGlobalParams, this);
+ MeshLabSettingsDialog dialog(currentGlobalParams,defaultGlobalParams, this);
connect(&dialog, SIGNAL(applyCustomSetting()), this, SLOT(updateCustomSettings()));
- dialog.exec();
+ dialog.exec();
}
void MainWindow::fullScreen(){
- if(!isFullScreen())
- {
- toolbarState = saveState();
- menuBar()->hide();
- mainToolBar->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;
- //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();}
- }
- fullScreenAct->setChecked(false);
- }
+ if(!isFullScreen())
+ {
+ toolbarState = saveState();
+ menuBar()->hide();
+ mainToolBar->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;
+ //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();}
+ }
+ 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();
}
/**
@@ -2741,7 +2741,7 @@ bool MainWindow::QCallBack(const int pos, const char * str)
int static lastPos = -1;
if (pos == lastPos) return true;
lastPos = pos;
-
+
static QElapsedTimer currTime;
if (currTime.isValid() && currTime.elapsed() < 100)
return true;
@@ -2752,82 +2752,82 @@ bool MainWindow::QCallBack(const int pos, const char * str)
qb->setValue(pos);
MainWindow::globalStatusBar()->update();
qApp->processEvents();
- return true;
+ return true;
}
void MainWindow::updateTexture(int meshid)
{
- MultiViewer_Container* mvc = currentViewContainer();
- if ((mvc == NULL) || (meshDoc() == NULL))
- return;
-
- MLSceneGLSharedDataContext* shared = mvc->sharedDataContext();
- if (shared == NULL)
- return;
-
- MeshModel* mymesh = meshDoc()->getMesh(meshid);
- if (mymesh == NULL)
- return;
-
- shared->deAllocateTexturesPerMesh(mymesh->id());
-
- int textmemMB = int(mwsettings.maxTextureMemory / ((float) 1024 * 1024));
-
- size_t totalTextureNum = 0;
- foreach (MeshModel *mp, meshDoc()->meshList)
- totalTextureNum+=mp->cm.textures.size();
-
- int singleMaxTextureSizeMpx = int(textmemMB/((totalTextureNum != 0)? totalTextureNum : 1));
- bool sometextfailed = false;
- QString unexistingtext = "In mesh file " + mymesh->fullName() + " : Failure loading textures:
";
- for(size_t i =0; i< mymesh->cm.textures.size();++i)
- {
- QImage img;
- QFileInfo fi(mymesh->cm.textures[i].c_str());
- QString filename = fi.absoluteFilePath();
- bool res = img.load(filename);
- sometextfailed = sometextfailed || !res;
- if(!res)
- {
- res = img.load(filename);
- if(!res)
- {
- QString errmsg = QString("Failure of loading texture %1").arg(fi.fileName());
- meshDoc()->Log.Log(GLLogStream::WARNING,qUtf8Printable(errmsg));
- unexistingtext += "" + filename + "
";
- }
- }
-
-/*PLEASE EXPLAIN ME!*********************************************************************************************************************************************************************************/
- //if(!res && filename.endsWith("dds",Qt::CaseInsensitive))
- //{
- // qDebug("DDS binding!");
- // int newTexId = shared->bindTexture(filename);
- // shared->txtcont.push_back(newTexId);
- //}
-/*PLEASE EXPLAIN ME!*********************************************************************************************************************************************************************************/
-
- if (!res)
- res = img.load(":/images/dummy.png");
- GLuint textid = shared->allocateTexturePerMesh(meshid,img,singleMaxTextureSizeMpx);
-
- if (sometextfailed)
- QMessageBox::warning(this,"Texture file has not been correctly loaded",unexistingtext);
-
- for(int tt = 0;tt < mvc->viewerCounter();++tt)
- {
- GLArea* ar = mvc->getViewer(tt);
- if (ar != NULL)
- ar->setupTextureEnv(textid);
- }
- }
- if (sometextfailed)
- QMessageBox::warning(this,"Texture file has not been correctly loaded",unexistingtext);
+ MultiViewer_Container* mvc = currentViewContainer();
+ if ((mvc == NULL) || (meshDoc() == NULL))
+ return;
+
+ MLSceneGLSharedDataContext* shared = mvc->sharedDataContext();
+ if (shared == NULL)
+ return;
+
+ MeshModel* mymesh = meshDoc()->getMesh(meshid);
+ if (mymesh == NULL)
+ return;
+
+ shared->deAllocateTexturesPerMesh(mymesh->id());
+
+ int textmemMB = int(mwsettings.maxTextureMemory / ((float) 1024 * 1024));
+
+ size_t totalTextureNum = 0;
+ foreach (MeshModel *mp, meshDoc()->meshList)
+ totalTextureNum+=mp->cm.textures.size();
+
+ int singleMaxTextureSizeMpx = int(textmemMB/((totalTextureNum != 0)? totalTextureNum : 1));
+ bool sometextfailed = false;
+ QString unexistingtext = "In mesh file " + mymesh->fullName() + " : Failure loading textures:
";
+ for(size_t i =0; i< mymesh->cm.textures.size();++i)
+ {
+ QImage img;
+ QFileInfo fi(mymesh->cm.textures[i].c_str());
+ QString filename = fi.absoluteFilePath();
+ bool res = img.load(filename);
+ sometextfailed = sometextfailed || !res;
+ if(!res)
+ {
+ res = img.load(filename);
+ if(!res)
+ {
+ QString errmsg = QString("Failure of loading texture %1").arg(fi.fileName());
+ meshDoc()->Log.Log(GLLogStream::WARNING,qUtf8Printable(errmsg));
+ unexistingtext += "" + filename + "
";
+ }
+ }
+
+ /*PLEASE EXPLAIN ME!*********************************************************************************************************************************************************************************/
+ //if(!res && filename.endsWith("dds",Qt::CaseInsensitive))
+ //{
+ // qDebug("DDS binding!");
+ // int newTexId = shared->bindTexture(filename);
+ // shared->txtcont.push_back(newTexId);
+ //}
+ /*PLEASE EXPLAIN ME!*********************************************************************************************************************************************************************************/
+
+ if (!res)
+ res = img.load(":/images/dummy.png");
+ GLuint textid = shared->allocateTexturePerMesh(meshid,img,singleMaxTextureSizeMpx);
+
+ if (sometextfailed)
+ QMessageBox::warning(this,"Texture file has not been correctly loaded",unexistingtext);
+
+ for(int tt = 0;tt < mvc->viewerCounter();++tt)
+ {
+ GLArea* ar = mvc->getViewer(tt);
+ if (ar != NULL)
+ ar->setupTextureEnv(textid);
+ }
+ }
+ if (sometextfailed)
+ QMessageBox::warning(this,"Texture file has not been correctly loaded",unexistingtext);
}
void MainWindow::updateProgressBar( const int pos,const QString& text )
{
- this->QCallBack(pos,qUtf8Printable(text));
+ this->QCallBack(pos,qUtf8Printable(text));
}
//WARNING!!!! Probably it's useless
@@ -2920,10 +2920,10 @@ void MainWindow::showEvent(QShowEvent * event)
{
QWidget::showEvent(event);
QSettings settings;
- QSettings::setDefaultFormat(QSettings::NativeFormat);
+ QSettings::setDefaultFormat(QSettings::NativeFormat);
const QString versioncheckeddatestring("lastTimeMeshLabVersionCheckedOnStart");
QDate today = QDate::currentDate();
- QString todayStr = today.toString();
+ QString todayStr = today.toString();
if (settings.contains(versioncheckeddatestring))
{
QDate lasttimechecked = QDate::fromString(settings.value(versioncheckeddatestring).toString());
@@ -2943,52 +2943,52 @@ void MainWindow::showEvent(QShowEvent * event)
void MainWindow::meshAdded(int mid)
{
- MultiViewer_Container* mvc = currentViewContainer();
- if (mvc != NULL)
- {
- MLSceneGLSharedDataContext* shared = mvc->sharedDataContext();
- if (shared != NULL)
- {
- shared->meshInserted(mid);
- QList contlist;
- for(int glarid = 0;glarid < mvc->viewerCounter();++glarid)
- {
- GLArea* ar = mvc->getViewer(glarid);
- if (ar != NULL)
- contlist.push_back(ar->context());
- }
- MLRenderingData defdt;
- if (meshDoc() != NULL)
- {
- MeshModel* mm = meshDoc()->getMesh(mid);
- if (mm != NULL)
- {
- for(int glarid = 0;glarid < mvc->viewerCounter();++glarid)
- {
- GLArea* ar = mvc->getViewer(glarid);
- if (ar != NULL)
- shared->setRenderingDataPerMeshView(mid,ar->context(),defdt);
- }
- shared->manageBuffers(mid);
- }
+ MultiViewer_Container* mvc = currentViewContainer();
+ if (mvc != NULL)
+ {
+ MLSceneGLSharedDataContext* shared = mvc->sharedDataContext();
+ if (shared != NULL)
+ {
+ shared->meshInserted(mid);
+ QList contlist;
+ for(int glarid = 0;glarid < mvc->viewerCounter();++glarid)
+ {
+ GLArea* ar = mvc->getViewer(glarid);
+ if (ar != NULL)
+ contlist.push_back(ar->context());
+ }
+ MLRenderingData defdt;
+ if (meshDoc() != NULL)
+ {
+ MeshModel* mm = meshDoc()->getMesh(mid);
+ if (mm != NULL)
+ {
+ for(int glarid = 0;glarid < mvc->viewerCounter();++glarid)
+ {
+ GLArea* ar = mvc->getViewer(glarid);
+ if (ar != NULL)
+ shared->setRenderingDataPerMeshView(mid,ar->context(),defdt);
+ }
+ shared->manageBuffers(mid);
+ }
//layerDialog->setVisible(meshDoc()->meshList.size() > 0);
updateLayerDialog();
- }
- }
-
- }
+ }
+ }
+
+ }
}
void MainWindow::meshRemoved(int mid)
{
- MultiViewer_Container* mvc = currentViewContainer();
- if (mvc != NULL)
- {
- MLSceneGLSharedDataContext* shared = mvc->sharedDataContext();
- if (shared != NULL)
- shared->meshRemoved(mid);
- }
- updateLayerDialog();
+ MultiViewer_Container* mvc = currentViewContainer();
+ if (mvc != NULL)
+ {
+ MLSceneGLSharedDataContext* shared = mvc->sharedDataContext();
+ if (shared != NULL)
+ shared->meshRemoved(mid);
+ }
+ updateLayerDialog();
}
void MainWindow::getRenderingData( int mid,MLRenderingData& dt) const
@@ -2996,7 +2996,7 @@ void MainWindow::getRenderingData( int mid,MLRenderingData& dt) const
if (mid == -1)
{
//if (GLA() != NULL)
- //GLA()->getPerDocGlobalRenderingData(dt);
+ //GLA()->getPerDocGlobalRenderingData(dt);
}
else
{
@@ -3042,31 +3042,31 @@ void MainWindow::setRenderingData(int mid,const MLRenderingData& dt)
void MainWindow::addRenderingSystemLogInfo(unsigned mmid)
{
- MultiViewer_Container* cont = currentViewContainer();
- if (cont != NULL)
- {
- MLRenderingData::DebugInfo deb;
- MLSceneGLSharedDataContext* share = cont->sharedDataContext();
- if ((share != NULL) && (GLA() != NULL))
- {
- share->getLog(mmid,deb);
- MeshModel* mm = meshDoc()->getMesh(mmid);
- if (mm != NULL)
- {
- QString data = QString(deb._currentlyallocated.c_str()) + "\n" + QString(deb._tobedeallocated.c_str()) + "\n" + QString(deb._tobeallocated.c_str()) + "\n" + QString(deb._tobeupdated.c_str()) + "\n";
- for(std::vector::iterator it = deb._perviewdata.begin();it != deb._perviewdata.end();++it)
- data += QString((*it).c_str()) + "
";
- meshDoc()->Log.Log(GLLogStream::SYSTEM, data);
- }
- }
- }
+ MultiViewer_Container* cont = currentViewContainer();
+ if (cont != NULL)
+ {
+ MLRenderingData::DebugInfo deb;
+ MLSceneGLSharedDataContext* share = cont->sharedDataContext();
+ if ((share != NULL) && (GLA() != NULL))
+ {
+ share->getLog(mmid,deb);
+ MeshModel* mm = meshDoc()->getMesh(mmid);
+ if (mm != NULL)
+ {
+ QString data = QString(deb._currentlyallocated.c_str()) + "\n" + QString(deb._tobedeallocated.c_str()) + "\n" + QString(deb._tobeallocated.c_str()) + "\n" + QString(deb._tobeupdated.c_str()) + "\n";
+ for(std::vector::iterator it = deb._perviewdata.begin();it != deb._perviewdata.end();++it)
+ data += QString((*it).c_str()) + "
";
+ meshDoc()->Log.Log(GLLogStream::SYSTEM, data);
+ }
+ }
+ }
}
void MainWindow::updateRenderingDataAccordingToActionsCommonCode(int meshid, const QList& acts)
{
if (meshDoc() == NULL)
return;
-
+
MLRenderingData olddt;
getRenderingData(meshid, olddt);
MLRenderingData dt(olddt);
@@ -3082,7 +3082,7 @@ void MainWindow::updateRenderingDataAccordingToActionsCommonCode(int meshid, con
MLPoliciesStandAloneFunctions::computeRequestedRenderingDataCompatibleWithMeshSameGLOpts(mm, dt, dt);
}
setRenderingData(meshid, dt);
-
+
/*if (meshid == -1)
{
foreach(MeshModel* mm, meshDoc()->meshList)
@@ -3096,13 +3096,13 @@ void MainWindow::updateRenderingDataAccordingToActionsCommonCode(int meshid, con
}
else
{*/
- if (mm != NULL)
- {
- MLDefaultMeshDecorators dec(this);
- dec.updateMeshDecorationData(*mm, olddt, dt);
- }
+ if (mm != NULL)
+ {
+ MLDefaultMeshDecorators dec(this);
+ dec.updateMeshDecorationData(*mm, olddt, dt);
+ }
/*}*/
-
+
}
@@ -3134,7 +3134,7 @@ void MainWindow::updateRenderingDataAccordingToActions(int /*meshid*/, MLRenderi
{
if ((meshDoc() == NULL) || (act == NULL))
return;
-
+
QList tmpacts;
for (int ii = 0; ii < acts.size(); ++ii)
{
@@ -3146,20 +3146,20 @@ void MainWindow::updateRenderingDataAccordingToActions(int /*meshid*/, MLRenderi
tmpacts.push_back(sisteract);
}
}
-
+
for (int hh = 0; hh < meshDoc()->meshList.size(); ++hh)
{
if (meshDoc()->meshList[hh] != NULL)
updateRenderingDataAccordingToActionsCommonCode(meshDoc()->meshList[hh]->id(), tmpacts);
}
-
+
for (int ii = 0; ii < tmpacts.size(); ++ii)
delete tmpacts[ii];
tmpacts.clear();
-
+
if (GLA() != NULL)
GLA()->update();
-
+
updateLayerDialog();
}
@@ -3168,7 +3168,7 @@ void MainWindow::updateRenderingDataAccordingToActionCommonCode(int meshid, MLRe
{
if ((meshDoc() == NULL) || (act == NULL))
return;
-
+
if (meshid != -1)
{
MLRenderingData olddt;
@@ -3201,7 +3201,7 @@ void MainWindow::updateRenderingDataAccordingToActionToAllVisibleLayers(MLRender
{
if (meshDoc() == NULL)
return;
-
+
for (int ii = 0; ii < meshDoc()->meshList.size(); ++ii)
{
MeshModel* mm = meshDoc()->meshList[ii];
@@ -3219,7 +3219,7 @@ void MainWindow::updateRenderingDataAccordingToActions(QListmeshList.size(); ++ii)
{
MeshModel* mm = meshDoc()->meshList[ii];
@@ -3229,7 +3229,7 @@ void MainWindow::updateRenderingDataAccordingToActions(QListmainActions())
updateRenderingDataAccordingToActionCommonCode(mm->id(), ract);
-
+
foreach(MLRenderingAction* ract, act->relatedActions())
updateRenderingDataAccordingToActionCommonCode(mm->id(), ract);
}