diff --git a/src/common/interfaces.cpp b/src/common/interfaces.cpp index d32e87d2f..b5c15dc8f 100644 --- a/src/common/interfaces.cpp +++ b/src/common/interfaces.cpp @@ -69,9 +69,13 @@ bool MeshFilterInterface::isFilterApplicable(QAction *act, const MeshModel& m, Q if (preMask & MeshModel::MM_VERTRADIUS && !m.hasDataMask(MeshModel::MM_VERTRADIUS)) MissingItems.push_back("Vertex Radius"); + if (preMask & MeshModel::MM_CAMERA && !m.hasDataMask(MeshModel::MM_CAMERA)) + MissingItems.push_back("Camera"); + if (preMask & MeshModel::MM_FACENUMBER && (m.cm.fn==0)) MissingItems.push_back("Non empty Face Set"); + return MissingItems.isEmpty(); } diff --git a/src/common/xmlfilterinfo.cpp b/src/common/xmlfilterinfo.cpp index d9041aed7..aac5c2262 100644 --- a/src/common/xmlfilterinfo.cpp +++ b/src/common/xmlfilterinfo.cpp @@ -578,6 +578,7 @@ QString MLXMLUtilityFunctions::generateXMLFilter( const MLXMLFilterSubTree& filt + xmlAttrNameValue(filter.filterinfo,MLXMLElNames::filterPreCond) + " " + xmlAttrNameValue(filter.filterinfo,MLXMLElNames::filterPostCond) + " " + xmlAttrNameValue(filter.filterinfo,MLXMLElNames::filterArity) + " " + + MLXMLElNames::filterRasterArity + "=\"" + MLXMLElNames::singleRasterArity + "\" " + xmlAttrNameValue(filter.filterinfo,MLXMLElNames::filterIsInterruptible) + ">"; result += "<" + MLXMLElNames::filterHelpTag + ">" + filter.filterinfo[MLXMLElNames::filterHelpTag] + ""; if (!(filter.filterinfo[MLXMLElNames::filterJSCodeTag].isEmpty())) diff --git a/src/meshlab/additionalgui.cpp b/src/meshlab/additionalgui.cpp index 39ea9df1d..00413e549 100644 --- a/src/meshlab/additionalgui.cpp +++ b/src/meshlab/additionalgui.cpp @@ -1063,23 +1063,3 @@ void MenuLineEdit::keyPressEvent( QKeyEvent * event ) emit arrowPressed(k); } -MenuWithToolTip::MenuWithToolTip(const QString & title,QWidget* parent) - :QMenu(title,parent) -{ -} - -MenuWithToolTip::~MenuWithToolTip() -{ -} - -bool MenuWithToolTip::event(QEvent *event) -{ - const QHelpEvent *helpEvent = static_cast (event); - //qDebug() << event << " " << event->type(); - if (helpEvent->type() == QEvent::ToolTip) - QToolTip::showText(helpEvent->globalPos(), activeAction()->toolTip()); - else - QToolTip::hideText(); - return QMenu::event(event); -} - diff --git a/src/meshlab/additionalgui.h b/src/meshlab/additionalgui.h index f77e5ffe0..fbf6cc243 100644 --- a/src/meshlab/additionalgui.h +++ b/src/meshlab/additionalgui.h @@ -281,15 +281,4 @@ private slots: void changeFocus(const int k); }; -class MenuWithToolTip : public QMenu -{ - Q_OBJECT -public: - MenuWithToolTip(const QString & title,QWidget* parent = 0); - ~MenuWithToolTip(); - -protected: - bool event(QEvent *event); -}; - #endif diff --git a/src/meshlab/mainwindow_Init.cpp b/src/meshlab/mainwindow_Init.cpp index f2387e4fe..ff507c2a6 100644 --- a/src/meshlab/mainwindow_Init.cpp +++ b/src/meshlab/mainwindow_Init.cpp @@ -643,8 +643,8 @@ void MainWindow::createMenus() //////////////////// Menu Preferences ///////////////////////////////////////////////////////////////////// preferencesMenu=menuBar()->addMenu(tr("&Tools")); - //preferencesMenu->addAction(showFilterEditAct); - //preferencesMenu->addSeparator(); + /*preferencesMenu->addAction(showFilterEditAct); + preferencesMenu->addSeparator();*/ preferencesMenu->addAction(setCustomizeAct); @@ -725,54 +725,56 @@ void MainWindow::fillFilterMenu() //filterMenu->addSeparator(); // Connects the events of the actions within colorize to the method which shows their tooltip - filterMenuSelect = new MenuWithToolTip(tr("Selection"),this); + filterMenuSelect = new QMenu(tr("Selection"),this); filterMenu->addMenu(filterMenuSelect); - filterMenuClean = new MenuWithToolTip(tr("Cleaning and Repairing"),this); + filterMenuClean = new QMenu(tr("Cleaning and Repairing"),this); filterMenu->addMenu(filterMenuClean); - filterMenuCreate = new MenuWithToolTip(tr("Create New Mesh Layer"),this); + filterMenuCreate = new QMenu(tr("Create New Mesh Layer"),this); filterMenu->addMenu(filterMenuCreate); - filterMenuRemeshing = new MenuWithToolTip(tr("Remeshing, Simplification and Reconstruction"),this); + filterMenuRemeshing = new QMenu(tr("Remeshing, Simplification and Reconstruction"),this); filterMenu->addMenu(filterMenuRemeshing); - filterMenuPolygonal = new MenuWithToolTip(tr("Polygonal and Quad Mesh"),this); + filterMenuPolygonal = new QMenu(tr("Polygonal and Quad Mesh"),this); filterMenu->addMenu(filterMenuPolygonal); - filterMenuColorize = new MenuWithToolTip(tr("Color Creation and Processing"),this); + filterMenuColorize = new QMenu(tr("Color Creation and Processing"),this); filterMenu->addMenu(filterMenuColorize); - filterMenuSmoothing = new MenuWithToolTip(tr("Smoothing, Fairing and Deformation"),this); + filterMenuSmoothing = new QMenu(tr("Smoothing, Fairing and Deformation"),this); filterMenu->addMenu(filterMenuSmoothing); - filterMenuQuality = new MenuWithToolTip(tr("Quality Measure and Computations"),this); + filterMenuQuality = new QMenu(tr("Quality Measure and Computations"),this); filterMenu->addMenu(filterMenuQuality); - filterMenuNormal = new MenuWithToolTip(tr("Normals, Curvatures and Orientation"),this); + filterMenuNormal = new QMenu(tr("Normals, Curvatures and Orientation"),this); filterMenu->addMenu(filterMenuNormal); - filterMenuMeshLayer = new MenuWithToolTip(tr("Mesh Layer"),this); + filterMenuMeshLayer = new QMenu(tr("Mesh Layer"),this); filterMenu->addMenu(filterMenuMeshLayer); - filterMenuRasterLayer = new MenuWithToolTip(tr("Raster Layer"),this); + filterMenuRasterLayer = new QMenu(tr("Raster Layer"),this); filterMenu->addMenu(filterMenuRasterLayer); - filterMenuRangeMap = new MenuWithToolTip(tr("Range Map"),this); + filterMenuRangeMap = new QMenu(tr("Range Map"),this); filterMenu->addMenu(filterMenuRangeMap); - filterMenuPointSet = new MenuWithToolTip(tr("Point Set"),this); + filterMenuPointSet = new QMenu(tr("Point Set"),this); filterMenu->addMenu(filterMenuPointSet); - filterMenuSampling = new MenuWithToolTip(tr("Sampling"),this); + filterMenuSampling = new QMenu(tr("Sampling"),this); filterMenu->addMenu(filterMenuSampling); - filterMenuTexture = new MenuWithToolTip(tr("Texture"),this); + filterMenuTexture = new QMenu(tr("Texture"),this); filterMenu->addMenu(filterMenuTexture); - filterMenuCamera = new MenuWithToolTip(tr("Camera"),this); + filterMenuCamera = new QMenu(tr("Camera"),this); filterMenu->addMenu(filterMenuCamera); -// connect(filterMenuSelect, SIGNAL(hovered(QAction*)), this, SLOT(showTooltip(QAction*)) ); -// connect(filterMenuClean, SIGNAL(hovered(QAction*)), this, SLOT(showTooltip(QAction*)) ); -// connect(filterMenuCreate, SIGNAL(hovered(QAction*)), this, SLOT(showTooltip(QAction*)) ); -// connect(filterMenuRemeshing, SIGNAL(hovered(QAction*)), this, SLOT(showTooltip(QAction*)) ); -// connect(filterMenuPolygonal, SIGNAL(hovered(QAction*)), this, SLOT(showTooltip(QAction*)) ); -// connect(filterMenuColorize, SIGNAL(hovered(QAction*)), this, SLOT(showTooltip(QAction*)) ); -// connect(filterMenuQuality, SIGNAL(hovered(QAction*)), this, SLOT(showTooltip(QAction*)) ); -// connect(filterMenuNormal, SIGNAL(hovered(QAction*)), this, SLOT(showTooltip(QAction*)) ); -// connect(filterMenuMeshLayer, SIGNAL(hovered(QAction*)), this, SLOT(showTooltip(QAction*)) ); -// connect(filterMenuRasterLayer, SIGNAL(hovered(QAction*)), this, SLOT(showTooltip(QAction*)) ); -// connect(filterMenuRangeMap, SIGNAL(hovered(QAction*)), this, SLOT(showTooltip(QAction*)) ); -// connect(filterMenuPointSet, SIGNAL(hovered(QAction*)), this, SLOT(showTooltip(QAction*)) ); -// connect(filterMenuSampling, SIGNAL(hovered(QAction*)), this, SLOT(showTooltip(QAction*)) ); -// connect(filterMenuTexture, SIGNAL(hovered(QAction*)), this, SLOT(showTooltip(QAction*)) ); -// connect(filterMenuCamera, SIGNAL(hovered(QAction*)), this, SLOT(showTooltip(QAction*)) ); +#if !defined(Q_OS_MAC) + connect(filterMenuSelect, SIGNAL(hovered(QAction*)), this, SLOT(showTooltip(QAction*)) ); + connect(filterMenuClean, SIGNAL(hovered(QAction*)), this, SLOT(showTooltip(QAction*)) ); + connect(filterMenuCreate, SIGNAL(hovered(QAction*)), this, SLOT(showTooltip(QAction*)) ); + connect(filterMenuRemeshing, SIGNAL(hovered(QAction*)), this, SLOT(showTooltip(QAction*)) ); + connect(filterMenuPolygonal, SIGNAL(hovered(QAction*)), this, SLOT(showTooltip(QAction*)) ); + connect(filterMenuColorize, SIGNAL(hovered(QAction*)), this, SLOT(showTooltip(QAction*)) ); + connect(filterMenuQuality, SIGNAL(hovered(QAction*)), this, SLOT(showTooltip(QAction*)) ); + connect(filterMenuNormal, SIGNAL(hovered(QAction*)), this, SLOT(showTooltip(QAction*)) ); + connect(filterMenuMeshLayer, SIGNAL(hovered(QAction*)), this, SLOT(showTooltip(QAction*)) ); + connect(filterMenuRasterLayer, SIGNAL(hovered(QAction*)), this, SLOT(showTooltip(QAction*)) ); + connect(filterMenuRangeMap, SIGNAL(hovered(QAction*)), this, SLOT(showTooltip(QAction*)) ); + connect(filterMenuPointSet, SIGNAL(hovered(QAction*)), this, SLOT(showTooltip(QAction*)) ); + connect(filterMenuSampling, SIGNAL(hovered(QAction*)), this, SLOT(showTooltip(QAction*)) ); + connect(filterMenuTexture, SIGNAL(hovered(QAction*)), this, SLOT(showTooltip(QAction*)) ); + connect(filterMenuCamera, SIGNAL(hovered(QAction*)), this, SLOT(showTooltip(QAction*)) ); +#endif QMap::iterator msi; for(msi = PM.stringFilterMap.begin(); msi != PM.stringFilterMap.end();++msi) diff --git a/src/meshlab/mainwindow_RunTime.cpp b/src/meshlab/mainwindow_RunTime.cpp index 0e0ff43cd..d2fd00357 100644 --- a/src/meshlab/mainwindow_RunTime.cpp +++ b/src/meshlab/mainwindow_RunTime.cpp @@ -799,6 +799,9 @@ void MainWindow::runFilterScript() GLA()->setSelectFaceRendering(true); GLA()->setSelectVertRendering(true); } + + if(iFilter->postCondition(action) & MeshModel::MM_CAMERA) + meshDoc()->mm()->updateDataMask(MeshModel::MM_CAMERA); if(iFilter->getClass(action) & MeshFilterInterface::MeshCreation ) GLA()->resetTrackBall(); /* to be changed */ @@ -1053,6 +1056,11 @@ void MainWindow::executeFilter(QAction *action, RichParameterSet ¶ms, bool i GLA()->setColorMode(vcg::GLW::CMPerMesh); meshDoc()->mm()->updateDataMask(MeshModel::MM_COLOR); } + + + if(iFilter->postCondition(action) & MeshModel::MM_CAMERA) + meshDoc()->mm()->updateDataMask(MeshModel::MM_CAMERA); + if(iFilter->getClass(action) & MeshFilterInterface::Selection ) { GLA()->setSelectVertRendering(true); @@ -1278,6 +1286,7 @@ void MainWindow::executeFilter(MeshLabXMLFilterContainer* mfc, EnvWrap& env, boo env.loadMLScriptEnv(*meshDoc(),PM); QScriptValue result = env.evaluate(funcall); scriptCodeExecuted(result,t.elapsed(),""); + postFilterExecution(); } /*if (isinter) @@ -1299,6 +1308,15 @@ void MainWindow::postFilterExecution() { emit filterExecuted(); meshDoc()->renderState().clearState(); + qApp->restoreOverrideCursor(); + qb->reset(); + + updateMenus(); + GLA()->update(); //now there is the container + MultiViewer_Container* mvc = currentViewContainer(); + if(mvc) + mvc->updateAllViewer(); + FilterThread* obj = qobject_cast(QObject::sender()); if (obj == NULL) return; @@ -1311,7 +1329,7 @@ void MainWindow::postFilterExecution() QString fname = mfc->act->text(); //meshDoc()->setBusy(false); - qApp->restoreOverrideCursor(); + //// (5) Apply post filter actions (e.g. recompute non updated stuff if needed) @@ -1349,6 +1367,11 @@ void MainWindow::postFilterExecution() GLA()->setColorMode(vcg::GLW::CMPerMesh); meshDoc()->mm()->updateDataMask(MeshModel::MM_COLOR); } + + + //if(iFilter->postCondition(action) & MeshModel::MM_CAMERA) + // meshDoc()->mm()->updateDataMask(MeshModel::MM_CAMERA); + if(mask & MeshFilterInterface::Selection ) { GLA()->setSelectVertRendering(true); @@ -1360,14 +1383,6 @@ void MainWindow::postFilterExecution() if(mask & MeshFilterInterface::Texture ) GLA()->updateTexture(); - qb->reset(); - - updateMenus(); - GLA()->update(); //now there is the container - MultiViewer_Container* mvc = currentViewContainer(); - if(mvc) - mvc->updateAllViewer(); - delete obj; } diff --git a/src/meshlab/xmlgeneratorgui.cpp b/src/meshlab/xmlgeneratorgui.cpp index d7559e5ed..9fb772988 100644 --- a/src/meshlab/xmlgeneratorgui.cpp +++ b/src/meshlab/xmlgeneratorgui.cpp @@ -769,9 +769,9 @@ void PluginGeneratorGUI::saveScriptCode() void PluginGeneratorGUI::saveAsXMLPlugin() { QFileDialog* saveDiag = new QFileDialog(this,tr("Save XML Plugin File"),finfo.absolutePath(), tr("MeshLab XML Plugin (*.xml)")); -#if defined(Q_OS_MAC) +//#if defined(Q_OS_MAC) saveDiag->setOption(QFileDialog::DontUseNativeDialog,true); -#endif +//#endif QLabel* namelab = new QLabel(tr("JScript Plugin Name"),saveDiag); QLineEdit* jsline= new QLineEdit(plugscriptname,saveDiag); QLabel* authlab = new QLabel(tr("Author Name"),saveDiag); diff --git a/src/meshlabplugins/filter_camera/filter_camera.cpp b/src/meshlabplugins/filter_camera/filter_camera.cpp index 93b781c06..b822e472f 100644 --- a/src/meshlabplugins/filter_camera/filter_camera.cpp +++ b/src/meshlabplugins/filter_camera/filter_camera.cpp @@ -514,8 +514,10 @@ int FilterCameraPlugin::postCondition(QAction * filter) const case FP_CAMERA_ROTATE : case FP_CAMERA_TRANSLATE : case FP_CAMERA_TRANSFORM: - case FP_CAMERA_SCALE : return MeshModel::MM_CAMERA; - case FP_QUALITY_FROM_CAMERA : return MeshModel::MM_VERTQUALITY + MeshModel::MM_VERTCOLOR; + case FP_CAMERA_SCALE : + return MeshModel::MM_CAMERA; + case FP_QUALITY_FROM_CAMERA : + return MeshModel::MM_VERTQUALITY + MeshModel::MM_VERTCOLOR; default : return MeshModel::MM_UNKNOWN; } } @@ -541,4 +543,22 @@ int FilterCameraPlugin::postCondition(QAction * filter) const assert(0); } + int FilterCameraPlugin::getPreConditions( QAction * a) const + { + switch(ID(a)) + { + case FP_CAMERA_ROTATE : + case FP_CAMERA_SCALE : + case FP_CAMERA_TRANSLATE : + case FP_CAMERA_EDIT : + case FP_CAMERA_TRANSFORM: + case FP_QUALITY_FROM_CAMERA : + return MeshModel::MM_CAMERA; + case FP_SET_RASTER_CAMERA : + case FP_SET_MESH_CAMERA : + return MeshModel::MM_NONE; + } + assert(0); + } + MESHLAB_PLUGIN_NAME_EXPORTER(FilterCameraPlugin) diff --git a/src/meshlabplugins/filter_camera/filter_camera.h b/src/meshlabplugins/filter_camera/filter_camera.h index 168394e26..282e00f0d 100644 --- a/src/meshlabplugins/filter_camera/filter_camera.h +++ b/src/meshlabplugins/filter_camera/filter_camera.h @@ -31,27 +31,27 @@ class FilterCameraPlugin : public QObject, public MeshFilterInterface { Q_OBJECT - MESHLAB_PLUGIN_IID_EXPORTER(MESH_FILTER_INTERFACE_IID) - Q_INTERFACES(MeshFilterInterface) + MESHLAB_PLUGIN_IID_EXPORTER(MESH_FILTER_INTERFACE_IID) + Q_INTERFACES(MeshFilterInterface) public: - enum { FP_SET_MESH_CAMERA, - FP_SET_RASTER_CAMERA, - FP_QUALITY_FROM_CAMERA, - FP_CAMERA_ROTATE, - FP_CAMERA_SCALE, - FP_CAMERA_TRANSLATE, - FP_CAMERA_TRANSFORM, - FP_CAMERA_EDIT}; + enum { FP_SET_MESH_CAMERA, + FP_SET_RASTER_CAMERA, + FP_QUALITY_FROM_CAMERA, + FP_CAMERA_ROTATE, + FP_CAMERA_SCALE, + FP_CAMERA_TRANSLATE, + FP_CAMERA_TRANSFORM, + FP_CAMERA_EDIT}; - FilterCameraPlugin(); - - int postCondition(QAction * filter) const; - virtual QString filterName(FilterIDType filter) const; + FilterCameraPlugin(); + int getPreConditions(QAction *) const; + int postCondition(QAction * filter) const; + virtual QString filterName(FilterIDType filter) const; virtual QString filterInfo(FilterIDType filter) const; - virtual FilterClass getClass(QAction *); + virtual FilterClass getClass(QAction *); virtual void initParameterSet(QAction *,MeshDocument &/*m*/, RichParameterSet & /*parent*/); - virtual bool applyFilter(QAction *filter, MeshDocument &md, RichParameterSet & /*parent*/, vcg::CallBackPos * cb) ; + virtual bool applyFilter(QAction *filter, MeshDocument &md, RichParameterSet & /*parent*/, vcg::CallBackPos * cb) ; }; #endif diff --git a/src/sampleplugins/samplefilter/samplefilter.cpp b/src/sampleplugins/samplefilter/samplefilter.cpp index f733e159b..ed9d04f63 100644 --- a/src/sampleplugins/samplefilter/samplefilter.cpp +++ b/src/sampleplugins/samplefilter/samplefilter.cpp @@ -128,13 +128,4 @@ bool ExtraSamplePlugin::applyFilter(QAction */*filter*/, MeshDocument &md, RichP return true; } -QString ExtraSamplePlugin::filterScriptFunctionName( FilterIDType filterID ) -{ - switch(filterID) { - case FP_MOVE_VERTEX : return QString("randomVerticesDisplacement"); - default : assert(0); - } - return QString(); -} - MESHLAB_PLUGIN_NAME_EXPORTER(ExtraSamplePlugin) diff --git a/src/sampleplugins/samplefilter/samplefilter.h b/src/sampleplugins/samplefilter/samplefilter.h index d5ae751f5..4c6dcbcf5 100644 --- a/src/sampleplugins/samplefilter/samplefilter.h +++ b/src/sampleplugins/samplefilter/samplefilter.h @@ -34,10 +34,7 @@ add sampleplugins #ifndef SAMPLEFILTERSPLUGIN_H #define SAMPLEFILTERSPLUGIN_H -#include - #include -class QScriptEngine; class ExtraSamplePlugin : public QObject, public MeshFilterInterface { @@ -58,7 +55,6 @@ public: bool applyFilter(QAction *filter, MeshDocument &md, RichParameterSet & /*parent*/, vcg::CallBackPos * cb) ; int postCondition( QAction* ) const {return MeshModel::MM_VERTCOORD | MeshModel::MM_FACENORMAL | MeshModel::MM_VERTNORMAL;}; FilterClass getClass(QAction *a); - QString filterScriptFunctionName(FilterIDType filterID); };