mirror of
https://github.com/lucaspalomodevelop/meshlab.git
synced 2026-03-18 02:24:38 +00:00
- script system fixed up for the release
- removed crash on filter_camera
This commit is contained in:
parent
fae09f7121
commit
5bcccfe9f4
@ -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();
|
||||
}
|
||||
|
||||
|
||||
@ -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] + "</" + MLXMLElNames::filterHelpTag + ">";
|
||||
if (!(filter.filterinfo[MLXMLElNames::filterJSCodeTag].isEmpty()))
|
||||
|
||||
@ -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 <QHelpEvent *>(event);
|
||||
//qDebug() << event << " " << event->type();
|
||||
if (helpEvent->type() == QEvent::ToolTip)
|
||||
QToolTip::showText(helpEvent->globalPos(), activeAction()->toolTip());
|
||||
else
|
||||
QToolTip::hideText();
|
||||
return QMenu::event(event);
|
||||
}
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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<QString,MeshFilterInterface *>::iterator msi;
|
||||
for(msi = PM.stringFilterMap.begin(); msi != PM.stringFilterMap.end();++msi)
|
||||
|
||||
@ -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<FilterThread*>(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;
|
||||
}
|
||||
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -34,10 +34,7 @@ add sampleplugins
|
||||
#ifndef SAMPLEFILTERSPLUGIN_H
|
||||
#define SAMPLEFILTERSPLUGIN_H
|
||||
|
||||
#include <QObject>
|
||||
|
||||
#include <common/interfaces.h>
|
||||
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);
|
||||
|
||||
};
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user