mirror of
https://github.com/lucaspalomodevelop/meshlab.git
synced 2026-03-18 18:44:39 +00:00
Added standard plugin window support
This commit is contained in:
parent
1a7ec99497
commit
0b4e4be84e
@ -23,6 +23,9 @@
|
||||
/****************************************************************************
|
||||
History
|
||||
$Log$
|
||||
Revision 1.3 2006/12/13 17:37:02 pirosu
|
||||
Added standard plugin window support
|
||||
|
||||
Revision 1.2 2006/06/18 20:40:06 cignoni
|
||||
Completed Open/Save of scripts
|
||||
|
||||
@ -111,4 +114,152 @@ public:
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
// standard filter parameter types
|
||||
enum
|
||||
{
|
||||
MESHLAB_STDPAR_PARBOOL = 1,
|
||||
MESHLAB_STDPAR_PARINT = 2,
|
||||
MESHLAB_STDPAR_PARFLOAT = 3,
|
||||
MESHLAB_STDPAR_PARSTRING = 4
|
||||
};
|
||||
|
||||
// standard filter parameter descriptor
|
||||
typedef struct MESHLAB_STDFIELD
|
||||
{
|
||||
QString *fieldname;
|
||||
QString *fielddesc;
|
||||
QVariant *fieldval;
|
||||
int fieldtype;
|
||||
}MESHLAB_STDFIELD;
|
||||
|
||||
class StdParList
|
||||
{
|
||||
public:
|
||||
|
||||
StdParList()
|
||||
{
|
||||
}
|
||||
|
||||
~StdParList()
|
||||
{
|
||||
this->clear();
|
||||
}
|
||||
|
||||
void addField(char *name, char* desc, bool val)
|
||||
{
|
||||
MESHLAB_STDFIELD std;
|
||||
|
||||
std.fieldname = new QString(name);
|
||||
std.fielddesc = new QString(desc);
|
||||
std.fieldval = new QVariant(val);
|
||||
std.fieldtype = MESHLAB_STDPAR_PARBOOL;
|
||||
|
||||
v.push_back(std);
|
||||
}
|
||||
void addField(char *name, char* desc, float val)
|
||||
{
|
||||
MESHLAB_STDFIELD std;
|
||||
|
||||
std.fieldname = new QString(name);
|
||||
std.fielddesc = new QString(desc);
|
||||
std.fieldval = new QVariant(val);
|
||||
std.fieldtype = MESHLAB_STDPAR_PARFLOAT;
|
||||
|
||||
v.push_back(std);
|
||||
}
|
||||
void addField(char *name, char* desc, int val)
|
||||
{
|
||||
MESHLAB_STDFIELD std;
|
||||
|
||||
std.fieldname = new QString(name);
|
||||
std.fielddesc = new QString(desc);
|
||||
std.fieldval = new QVariant(val);
|
||||
std.fieldtype = MESHLAB_STDPAR_PARINT;
|
||||
|
||||
v.push_back(std);
|
||||
}
|
||||
void addField(char *name, char* desc, char *val)
|
||||
{
|
||||
MESHLAB_STDFIELD std;
|
||||
|
||||
std.fieldname = new QString(name);
|
||||
std.fielddesc = new QString(desc);
|
||||
std.fieldval = new QVariant(val);
|
||||
std.fieldtype = MESHLAB_STDPAR_PARSTRING;
|
||||
|
||||
v.push_back(std);
|
||||
}
|
||||
|
||||
int count()
|
||||
{
|
||||
return v.size();
|
||||
}
|
||||
|
||||
void clear()
|
||||
{
|
||||
for(int i = 0; i < v.size(); i++)
|
||||
{
|
||||
delete v[i].fieldname;
|
||||
delete v[i].fielddesc;
|
||||
delete v[i].fieldval;
|
||||
}
|
||||
|
||||
v.clear();
|
||||
}
|
||||
|
||||
void getPars(FilterParameter &srcpars)
|
||||
{
|
||||
srcpars.clear();
|
||||
|
||||
for(int i = 0; i < v.size(); i++)
|
||||
{
|
||||
switch(v[i].fieldtype)
|
||||
{
|
||||
case MESHLAB_STDPAR_PARBOOL:
|
||||
srcpars.addBool(*v[i].fieldname,v[i].fieldval->toBool());
|
||||
break;
|
||||
case MESHLAB_STDPAR_PARFLOAT:
|
||||
srcpars.addFloat(*v[i].fieldname,float(v[i].fieldval->toDouble()));
|
||||
break;
|
||||
case MESHLAB_STDPAR_PARINT:
|
||||
srcpars.addInt(*v[i].fieldname,v[i].fieldval->toInt());
|
||||
break;
|
||||
case MESHLAB_STDPAR_PARSTRING:
|
||||
srcpars.addString(*v[i].fieldname,v[i].fieldval->toString());
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
QString &getFieldName(int i)
|
||||
{
|
||||
return *v[i].fieldname;
|
||||
}
|
||||
|
||||
QString &getFieldDesc(int i)
|
||||
{
|
||||
return *v[i].fielddesc;
|
||||
}
|
||||
|
||||
QVariant &getFieldVal(int i)
|
||||
{
|
||||
return *v[i].fieldval;
|
||||
}
|
||||
|
||||
int &getFieldType(int i)
|
||||
{
|
||||
return v[i].fieldtype;
|
||||
}
|
||||
|
||||
protected:
|
||||
QVector<MESHLAB_STDFIELD> v;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@ -23,6 +23,9 @@
|
||||
/****************************************************************************
|
||||
History
|
||||
$Log$
|
||||
Revision 1.50 2006/12/13 17:37:02 pirosu
|
||||
Added standard plugin window support
|
||||
|
||||
Revision 1.49 2006/11/29 00:55:36 cignoni
|
||||
Cleaned plugins interface; changed useless help class into a plain string
|
||||
|
||||
@ -47,6 +50,8 @@ added Filter History Dialogs
|
||||
#include <QAction>
|
||||
#include "filterparameter.h"
|
||||
|
||||
|
||||
|
||||
class QWidget;
|
||||
class QGLWidget;
|
||||
class QString;
|
||||
@ -100,6 +105,16 @@ public:
|
||||
QWidget *parent= 0)=0 ; // prima istanza il dialogo di opzioni viene sempre.
|
||||
};
|
||||
|
||||
/* this is used to callback the executeFilter() function
|
||||
when the apply button of the standard plugin window
|
||||
is clicked
|
||||
*/
|
||||
class MainWindowInterface
|
||||
{
|
||||
public:
|
||||
virtual void executeFilter(QAction *action,FilterParameter *stdpar){};
|
||||
};
|
||||
|
||||
|
||||
class MeshFilterInterface
|
||||
{
|
||||
@ -136,6 +151,13 @@ public:
|
||||
virtual QList<QAction *> actions() const { return actionList;}
|
||||
virtual QList<FilterType> &types() { return typeList;}
|
||||
|
||||
/* Returns an array of standard parameters descriptors for the standard plugin window .NULL is returned by default if the plugin doesn't implement this */
|
||||
virtual bool getStdFields(QAction *, MeshModel &, StdParList &,char **,QWidget ** /* optional custom widget which is added after standard fields in the standard plugin window */){return false;}
|
||||
|
||||
/* Overloading of the function getParameters that supports the standard plugin window. If the plugin doesn't implement this, the classic function is called */
|
||||
virtual bool getParameters(QAction *qa, QWidget *qw /*parent*/, MeshModel &mm/*m*/, FilterParameter &fp /*par*/,FilterParameter * /* parameters obtained by the standard parameters' plugin window*/) {return getParameters(qa,qw,mm,fp);};
|
||||
|
||||
|
||||
protected:
|
||||
QList <QAction *> actionList;
|
||||
QList <FilterType> typeList;
|
||||
|
||||
@ -23,6 +23,9 @@
|
||||
/****************************************************************************
|
||||
History
|
||||
$Log$
|
||||
Revision 1.74 2006/12/13 17:37:02 pirosu
|
||||
Added standard plugin window support
|
||||
|
||||
Revision 1.73 2006/12/12 11:16:08 cignoni
|
||||
changed version string 0.9RC -> 0.9
|
||||
|
||||
@ -94,6 +97,7 @@ Added Apply Last Filter action
|
||||
#include <QColorDialog>
|
||||
#include "meshmodel.h"
|
||||
#include "glarea.h"
|
||||
#include "stdpardialog.h"
|
||||
|
||||
#define MAXRECENTFILES 4
|
||||
|
||||
@ -104,13 +108,20 @@ class QScrollArea;
|
||||
class QSignalMapper;
|
||||
class QProgressDialog;
|
||||
class QHttp;
|
||||
class MeshlabStdDialog;
|
||||
class MeshlabStdDialogFrame;
|
||||
|
||||
class MainWindow : public QMainWindow
|
||||
|
||||
|
||||
class MainWindow : public QMainWindow,MainWindowInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
MainWindow();
|
||||
// callback function to execute a filter
|
||||
void executeFilter(QAction *action,FilterParameter *srcpar);
|
||||
|
||||
MainWindow();
|
||||
static bool QCallBack(const int pos, const char * str);
|
||||
const QString appName() const {return tr("MeshLab v")+appVer(); }
|
||||
const QString appVer() const {return tr("0.9"); }
|
||||
@ -179,6 +190,7 @@ private slots:
|
||||
void connectionDone(bool status);
|
||||
|
||||
private:
|
||||
void createStdPluginWnd();
|
||||
void createActions();
|
||||
void createMenus();
|
||||
void createToolBars();
|
||||
@ -202,6 +214,8 @@ private:
|
||||
QStringList pluginFileNames;
|
||||
std::vector<MeshIOInterface*> meshIOPlugins;
|
||||
QByteArray toolbarState; //stato delle toolbar e dockwidgets
|
||||
MeshlabStdDialog *stddialog;
|
||||
|
||||
public:
|
||||
GLArea *GLA() const {return qobject_cast<GLArea *>(workspace->activeWindow()); }
|
||||
QMap<QString, QAction *> filterMap; // a map to retrieve an action from a name. Used for playing filter scripts.
|
||||
@ -297,5 +311,4 @@ private:
|
||||
QList<QAction *> TotalDecoratorsList;
|
||||
////////////////////////////////////////////////////
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@ -24,6 +24,9 @@
|
||||
History
|
||||
|
||||
$Log$
|
||||
Revision 1.66 2006/12/13 17:37:02 pirosu
|
||||
Added standard plugin window support
|
||||
|
||||
Revision 1.65 2006/12/06 00:48:17 cignoni
|
||||
Improved managment of http answer
|
||||
|
||||
@ -128,6 +131,7 @@ MainWindow::MainWindow()
|
||||
createActions();
|
||||
createMenus();
|
||||
createToolBars();
|
||||
createStdPluginWnd();
|
||||
updateMenus();
|
||||
setAcceptDrops(true);
|
||||
workspace->setAcceptDrops(true);
|
||||
@ -144,6 +148,17 @@ MainWindow::MainWindow()
|
||||
//qb->reset();
|
||||
}
|
||||
|
||||
|
||||
// creates the standard plugin window
|
||||
void MainWindow::createStdPluginWnd()
|
||||
{
|
||||
stddialog = new MeshlabStdDialog(this);
|
||||
addDockWidget(Qt::RightDockWidgetArea,stddialog);
|
||||
stddialog->setFloating(true);
|
||||
stddialog->move(0,120);
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::createActions()
|
||||
{
|
||||
//////////////Action Menu File ////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ -24,6 +24,10 @@
|
||||
History
|
||||
|
||||
$Log$
|
||||
Revision 1.113 2006/12/13 17:37:02 pirosu
|
||||
Added standard plugin window support
|
||||
|
||||
|
||||
Revision 1.112 2006/11/30 23:23:13 cignoni
|
||||
Open take care also of updating the bbox
|
||||
|
||||
@ -59,6 +63,7 @@ Added Drag n drog opening of files (thanks to Valentino Fiorin)
|
||||
#include "ui_aboutDialog.h"
|
||||
#include "savemaskexporter.h"
|
||||
#include "plugin_support.h"
|
||||
#include "stdpardialog.h"
|
||||
|
||||
#include <wrap/io_trimesh/io_mask.h>
|
||||
#include <vcg/complex/trimesh/update/normal.h>
|
||||
@ -248,14 +253,38 @@ void MainWindow::runFilterScript()
|
||||
GLA()->log.Log(GLLogStream::Info,"Re-Applied filter %s",qPrintable((*ii).first));
|
||||
}
|
||||
}
|
||||
|
||||
// /////////////////////////////////////////////////
|
||||
// The Very Important Procedure of applying a filter
|
||||
// /////////////////////////////////////////////////
|
||||
|
||||
void MainWindow::applyFilter()
|
||||
{
|
||||
QWidget *extraw = NULL;
|
||||
|
||||
QAction *action = qobject_cast<QAction *>(sender());
|
||||
MeshFilterInterface *iFilter = qobject_cast<MeshFilterInterface *>(action->parent());
|
||||
// Ask for filter requirements (eg a filter can need topology, border flags etc)
|
||||
// and statisfy them
|
||||
int req=iFilter->getRequirements(action);
|
||||
GLA()->mm->updateDataMask(req);
|
||||
|
||||
/*
|
||||
loads the plugin action in the standard plugin window.
|
||||
If the plugin action doesn't support the use of the standard
|
||||
plugin window, the function executeFilter() is immediately called
|
||||
*/
|
||||
stddialog->loadPluginAction(iFilter,GLA()->mm,action,this);
|
||||
}
|
||||
|
||||
/* callback function that applies the filter action */
|
||||
void MainWindow::executeFilter(QAction *action,FilterParameter *srcpar)
|
||||
{
|
||||
|
||||
if(GLA()==NULL)
|
||||
return;
|
||||
|
||||
MeshFilterInterface *iFilter = qobject_cast<MeshFilterInterface *>(action->parent());
|
||||
// (1) Ask for filter requirements (eg a filter can need topology, border flags etc)
|
||||
// and statisfy them
|
||||
int req=iFilter->getRequirements(action);
|
||||
@ -264,7 +293,7 @@ void MainWindow::applyFilter()
|
||||
|
||||
// (2) Ask for filter parameters (e.g. user defined threshold that could require a widget)
|
||||
FilterParameter par;
|
||||
bool ret=iFilter->getParameters(action, GLA(),*(GLA()->mm), par);
|
||||
bool ret=iFilter->getParameters(action, GLA(),*(GLA()->mm), par,srcpar);
|
||||
|
||||
if(!ret) return;
|
||||
|
||||
@ -307,8 +336,12 @@ if(iFilter->getClass(action)==MeshFilterInterface::Selection )
|
||||
|
||||
qb->reset();
|
||||
updateMenus();
|
||||
GLA()->update();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::endEditMode()
|
||||
{
|
||||
if(!GLA()) return;
|
||||
@ -738,4 +771,4 @@ void MainWindow::keyPressEvent(QKeyEvent *e)
|
||||
e->accept();
|
||||
}
|
||||
else e->ignore();
|
||||
}
|
||||
}
|
||||
|
||||
@ -14,6 +14,7 @@ HEADERS = interfaces.h \
|
||||
savemaskexporter.h \
|
||||
changetexturename.h \
|
||||
GenericELDialog.h \
|
||||
stdpardialog.h \
|
||||
../../../sf/wrap/gui/trackball.h\
|
||||
../../../sf/wrap/gui/trackmode.h\
|
||||
../../../sf/wrap/gl/trimesh.h
|
||||
@ -32,6 +33,7 @@ SOURCES = main.cpp \
|
||||
saveSnapshotDialog.cpp \
|
||||
savemaskexporter.cpp \
|
||||
changetexturename.cpp \
|
||||
stdpardialog.cpp \
|
||||
../../../sf/wrap/gui/trackball.cpp\
|
||||
../../../sf/wrap/gui/trackmode.cpp \
|
||||
../../../code/lib/glew/src/glew.c
|
||||
|
||||
158
src/meshlab/stdpardialog.cpp
Normal file
158
src/meshlab/stdpardialog.cpp
Normal file
@ -0,0 +1,158 @@
|
||||
|
||||
#include "stdpardialog.h"
|
||||
|
||||
|
||||
|
||||
|
||||
/* manages the setup of the standard plugin window, when the execution of a plugin filter is requested */
|
||||
void MeshlabStdDialog::loadPluginAction(MeshFilterInterface *mfi,MeshModel *mm,QAction *q,MainWindowInterface *mwi)
|
||||
{
|
||||
if(mm == NULL)
|
||||
return;
|
||||
|
||||
|
||||
QWidget *extraw = NULL;
|
||||
char *actiondesc = NULL;
|
||||
|
||||
resetMe();
|
||||
|
||||
/* checks wether the plugin action wants to handle parameters input by the standard plugin window or by itself */
|
||||
if(!mfi->getStdFields(q,*mm,parlist,&actiondesc,&extraw))
|
||||
{
|
||||
/* the plugin action wants to handle parameters input by itself: the executeFilter() function is directly called */
|
||||
mwi->executeFilter(q,NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* the plugin action wants to handle parameters input by the standard plugin window */
|
||||
if(this->isHidden())
|
||||
this->showNormal();
|
||||
|
||||
|
||||
setWindowTitle(QString(actiondesc));
|
||||
|
||||
curextra = extraw;
|
||||
curaction = q;
|
||||
|
||||
QGridLayout *gridLayout = new QGridLayout(qf);
|
||||
qf->setLayout(gridLayout);
|
||||
|
||||
QCheckBox *qcb;
|
||||
QLineEdit *qle;
|
||||
QLabel *ql;
|
||||
|
||||
/* creates widgets for the standard parameters */
|
||||
|
||||
|
||||
for(int i = 0; i < parlist.count(); i++)
|
||||
{
|
||||
switch(parlist.getFieldType(i))
|
||||
{
|
||||
case MESHLAB_STDPAR_PARBOOL:
|
||||
qcb = new QCheckBox(parlist.getFieldDesc(i),qf);
|
||||
|
||||
if(parlist.getFieldVal(i).toBool())
|
||||
qcb->setCheckState(Qt::Checked);
|
||||
|
||||
gridLayout->addWidget(qcb,i,0,1,2,Qt::AlignTop);
|
||||
|
||||
stdfieldwidgets.push_back(qcb);
|
||||
|
||||
break;
|
||||
case MESHLAB_STDPAR_PARINT:
|
||||
case MESHLAB_STDPAR_PARFLOAT:
|
||||
case MESHLAB_STDPAR_PARSTRING:
|
||||
ql = new QLabel(parlist.getFieldDesc(i),qf);
|
||||
qle = new QLineEdit(parlist.getFieldVal(i).toString(),qf);
|
||||
|
||||
gridLayout->addWidget(ql,i,0,Qt::AlignTop);
|
||||
gridLayout->addWidget(qle,i,1,Qt::AlignTop);
|
||||
|
||||
stdfieldwidgets.push_back(qle);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* creates the extra custom widget, if requested */
|
||||
|
||||
if(curextra != NULL)
|
||||
gridLayout->addWidget(curextra,parlist.count(),0,1,2,Qt::AlignTop);
|
||||
|
||||
/* appends the apply button */
|
||||
|
||||
int nbut = (curextra == NULL) ? parlist.count() : parlist.count()+1;
|
||||
|
||||
QPushButton *applyButton = new QPushButton("Apply", qf);
|
||||
|
||||
gridLayout->addWidget(applyButton,nbut,0,1,2,Qt::AlignBottom);
|
||||
gridLayout->setRowStretch(nbut,2);
|
||||
|
||||
curmwi = mwi;
|
||||
this->adjustSize();
|
||||
connect(applyButton,SIGNAL(clicked()),this,SLOT(applyClick()));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
void MeshlabStdDialog::initValues()
|
||||
{
|
||||
curaction = NULL;
|
||||
stdfieldwidgets.clear();
|
||||
curextra = NULL;
|
||||
}
|
||||
|
||||
void MeshlabStdDialog::resetMe()
|
||||
{
|
||||
stdfieldwidgets.clear();
|
||||
|
||||
parlist.clear();
|
||||
|
||||
QFrame *newqf = new MeshlabStdDialogFrame(this);
|
||||
|
||||
newqf->setFrameStyle(QFrame::Box | QFrame::Sunken);
|
||||
newqf->setMinimumSize(75, 75);
|
||||
setWidget(newqf);
|
||||
setWindowTitle(QString("Plugin"));
|
||||
|
||||
delete qf;
|
||||
qf = newqf;
|
||||
|
||||
|
||||
initValues();
|
||||
}
|
||||
|
||||
/* click event for the apply button of the standard plugin window */
|
||||
void MeshlabStdDialog::applyClick()
|
||||
{
|
||||
FilterParameter par;
|
||||
qf->setEnabled(false);
|
||||
|
||||
par.clear();
|
||||
for(int i = 0; i < parlist.count(); i++)
|
||||
{
|
||||
QString &sname = parlist.getFieldName(i);
|
||||
switch(parlist.getFieldType(i))
|
||||
{
|
||||
case MESHLAB_STDPAR_PARBOOL:
|
||||
par.addBool(sname,((QCheckBox *)stdfieldwidgets[i])->checkState() == Qt::Checked);
|
||||
break;
|
||||
case MESHLAB_STDPAR_PARINT:
|
||||
par.addInt(sname,((QLineEdit *)stdfieldwidgets[i])->text().toInt());
|
||||
break;
|
||||
case MESHLAB_STDPAR_PARFLOAT:
|
||||
par.addFloat(sname,((QLineEdit *)stdfieldwidgets[i])->text().toFloat());
|
||||
break;
|
||||
case MESHLAB_STDPAR_PARSTRING:
|
||||
par.addString(sname,((QLineEdit *)stdfieldwidgets[i])->text());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
this->repaint();
|
||||
curmwi->executeFilter(curaction,&par);
|
||||
resetMe();
|
||||
}
|
||||
59
src/meshlab/stdpardialog.h
Normal file
59
src/meshlab/stdpardialog.h
Normal file
@ -0,0 +1,59 @@
|
||||
#ifndef MESHLAB_STDPARDIALOG_H
|
||||
#define MESHLAB_STDPARDIALOG_H
|
||||
|
||||
#include <QtCore>
|
||||
#include <QAction>
|
||||
#include <QtGui>
|
||||
|
||||
#include "meshmodel.h"
|
||||
#include "filterparameter.h"
|
||||
#include "interfaces.h"
|
||||
|
||||
// frame for the standard plugin window
|
||||
class MeshlabStdDialogFrame : public QFrame
|
||||
{
|
||||
public:
|
||||
MeshlabStdDialogFrame(QWidget *parent)
|
||||
: QFrame(parent)
|
||||
{
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
// standard plugin window
|
||||
class MeshlabStdDialog : public QDockWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
MeshlabStdDialog(QWidget *p):QDockWidget(QString("Plugin"),p)
|
||||
{
|
||||
qf = NULL;
|
||||
initValues();
|
||||
//resetMe();
|
||||
}
|
||||
|
||||
void initValues();
|
||||
void resetMe();
|
||||
void loadPluginAction(MeshFilterInterface *mfi,MeshModel *mm,QAction *q,MainWindowInterface *mwi);
|
||||
|
||||
|
||||
|
||||
|
||||
private slots:
|
||||
void applyClick();
|
||||
|
||||
protected:
|
||||
QFrame *qf;
|
||||
QAction *curaction;
|
||||
MainWindowInterface *curmwi;
|
||||
QVector<QWidget *> stdfieldwidgets;
|
||||
QWidget *curextra;
|
||||
StdParList parlist;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
@ -24,6 +24,10 @@
|
||||
History
|
||||
|
||||
$Log$
|
||||
Revision 1.6 2006/12/13 17:37:27 pirosu
|
||||
Added standard plugin window support
|
||||
|
||||
|
||||
Revision 1.5 2006/11/29 00:59:15 cignoni
|
||||
Cleaned plugins interface; changed useless help class into a plain string
|
||||
|
||||
@ -67,82 +71,6 @@
|
||||
#include <vcg/complex/trimesh/update/normal.h>
|
||||
#include <vcg/space/normal_extrapolation.h>
|
||||
|
||||
/////////////////////// Accessory functions
|
||||
|
||||
bool askFloat(float &val, QString Title, QString Label, QWidget *parent)
|
||||
{
|
||||
QDialog *dialog=new QDialog(parent);
|
||||
dialog->setModal(true);
|
||||
dialog->setWindowTitle(Title);
|
||||
|
||||
QPushButton *okButton = new QPushButton("OK", dialog);
|
||||
QPushButton *cancButton = new QPushButton("cancel", dialog);
|
||||
QGridLayout *gridLayout = new QGridLayout(dialog);
|
||||
dialog->setLayout(gridLayout);
|
||||
|
||||
gridLayout->addWidget(okButton,1,1);
|
||||
gridLayout->addWidget(cancButton,1,0);
|
||||
|
||||
QLineEdit *floatEdit = new QLineEdit(dialog);
|
||||
floatEdit->setText(QString::number(val));
|
||||
QLabel *label = new QLabel(Label,dialog);
|
||||
gridLayout->addWidget(label,0,0 );
|
||||
gridLayout->addWidget(floatEdit,0,1);
|
||||
|
||||
QObject::connect(floatEdit, SIGNAL(returnPressed ()), dialog, SLOT(accept()));
|
||||
QObject::connect(okButton, SIGNAL(clicked()), dialog, SLOT(accept()));
|
||||
QObject::connect(cancButton, SIGNAL(clicked()), dialog, SLOT(reject()));
|
||||
|
||||
dialog->exec();
|
||||
if(dialog->result()== QDialog::Accepted )
|
||||
{
|
||||
val=floatEdit->text().toFloat();
|
||||
return true;
|
||||
}
|
||||
if(dialog->result()== QDialog::Rejected ) return false;
|
||||
assert(0);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool askInt(int &val, QString Title, QString Label, QWidget *parent)
|
||||
{
|
||||
QDialog *dialog=new QDialog(parent);
|
||||
dialog->setModal(true);
|
||||
dialog->setWindowTitle(Title);
|
||||
|
||||
QPushButton *okButton = new QPushButton("OK", dialog);
|
||||
QPushButton *cancButton = new QPushButton("cancel", dialog);
|
||||
QGridLayout *gridLayout = new QGridLayout(dialog);
|
||||
dialog->setLayout(gridLayout);
|
||||
|
||||
gridLayout->addWidget(okButton,1,1);
|
||||
gridLayout->addWidget(cancButton,1,0);
|
||||
|
||||
QLineEdit *floatEdit = new QLineEdit(dialog);
|
||||
floatEdit->setText(QString::number(val));
|
||||
QLabel *label = new QLabel(Label,dialog);
|
||||
gridLayout->addWidget(label,0,0 );
|
||||
gridLayout->addWidget(floatEdit,0,1);
|
||||
|
||||
QObject::connect(floatEdit, SIGNAL(returnPressed ()), dialog, SLOT(accept()));
|
||||
QObject::connect(okButton, SIGNAL(clicked()), dialog, SLOT(accept()));
|
||||
QObject::connect(cancButton, SIGNAL(clicked()), dialog, SLOT(reject()));
|
||||
|
||||
dialog->exec();
|
||||
if(dialog->result()== QDialog::Accepted )
|
||||
{
|
||||
val=floatEdit->text().toInt();
|
||||
return true;
|
||||
}
|
||||
if(dialog->result()== QDialog::Rejected ) return false;
|
||||
assert(0);
|
||||
return true;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
using namespace vcg;
|
||||
|
||||
CleanFilter::CleanFilter()
|
||||
@ -152,6 +80,12 @@ CleanFilter::CleanFilter()
|
||||
FilterType tt;
|
||||
foreach(tt , types())
|
||||
actionList << new QAction(ST(tt), this);
|
||||
|
||||
maxDiag1=0;
|
||||
maxDiag2=10;
|
||||
minCC=25;
|
||||
val1=1.0;
|
||||
|
||||
}
|
||||
|
||||
CleanFilter::~CleanFilter() {
|
||||
@ -218,57 +152,65 @@ const int CleanFilter::getRequirements(QAction *action)
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool CleanFilter::getParameters(QAction *action, QWidget *parent, MeshModel &m,FilterParameter &par)
|
||||
bool CleanFilter::getStdFields(QAction *action, MeshModel &m, StdParList &parlst,char **filterdesc,QWidget **extraw)
|
||||
{
|
||||
|
||||
*extraw = NULL;
|
||||
|
||||
switch(ID(action))
|
||||
{
|
||||
case FP_REBUILD_SURFACE :
|
||||
(*filterdesc) = "Ballpivoting Surface reconstruction";
|
||||
parlst.addField("BallRadius","Enter ball size as a diag perc. (0 autoguess))",(float)maxDiag1);
|
||||
break;
|
||||
case FP_REMOVE_ISOLATED_DIAMETER:
|
||||
(*filterdesc) = "Remove Small Connected Components under a given size";
|
||||
parlst.addField("MinComponentDiag","Enter size (as a diag perc 0..100)",(float)maxDiag2);
|
||||
break;
|
||||
case FP_REMOVE_ISOLATED_COMPLEXITY:
|
||||
(*filterdesc) = "Remove Small Connected Components";
|
||||
parlst.addField("MinComponentSize","Enter minimum conn. comp size:",(int)minCC);
|
||||
break;
|
||||
case FP_REMOVE_WRT_Q:
|
||||
(*filterdesc) = "Quality Filter";
|
||||
parlst.addField("MaxQualityThr","Delete all Vertices with quality under:",(float)val1);
|
||||
break;
|
||||
default:
|
||||
(*filterdesc) = NULL;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CleanFilter::getParameters(QAction *action, QWidget *parent, MeshModel &m,FilterParameter &par,FilterParameter *srcpar)
|
||||
{
|
||||
par.clear();
|
||||
switch(ID(action))
|
||||
{
|
||||
case FP_REBUILD_SURFACE :
|
||||
{
|
||||
static float maxDiag=0;
|
||||
if(askFloat(maxDiag, "Ballpivoting Surface reconstruction",
|
||||
"Enter ball size as a diag perc. (0 autoguess))",parent))
|
||||
{
|
||||
par.addFloat("BallRadius",m.cm.bbox.Diag()*maxDiag/100.0);
|
||||
case FP_REBUILD_SURFACE :
|
||||
maxDiag1 = srcpar->getFloat("BallRadius");
|
||||
par.addFloat("BallRadius",m.cm.bbox.Diag()*maxDiag1/100.0);
|
||||
return true;
|
||||
case FP_REMOVE_ISOLATED_DIAMETER:
|
||||
maxDiag2 = srcpar->getFloat("MinComponentDiag");
|
||||
par.addFloat("MinComponentDiag",m.cm.bbox.Diag()*maxDiag2/100.0);
|
||||
return true;
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
return true;
|
||||
case FP_REMOVE_ISOLATED_DIAMETER:
|
||||
{
|
||||
static float maxDiag=10;
|
||||
if(askFloat(maxDiag, "Remove Small Connected Components under a given size","Enter size (as a diag perc 0..100)",parent))
|
||||
{
|
||||
par.addFloat("MinComponentDiag",m.cm.bbox.Diag()*maxDiag/100.0);
|
||||
return true;
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
case FP_REMOVE_ISOLATED_COMPLEXITY:
|
||||
{
|
||||
static int minCC=25;
|
||||
if(askInt(minCC, "Remove Small Connected Components","Enter minimum conn. comp size:",parent))
|
||||
{
|
||||
par.addInt("MinComponentSize",minCC);
|
||||
return true;
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
minCC = srcpar->getInt("MinComponentSize");
|
||||
par.addInt("MinComponentSize",minCC);
|
||||
return true;
|
||||
case FP_REMOVE_WRT_Q:
|
||||
{
|
||||
static float val=1.0;
|
||||
if(askFloat(val, "Quality Filter","Delete all Vertices with quality under:",parent))
|
||||
{
|
||||
par.addFloat("MaxQualityThr",val);
|
||||
val1 = srcpar->getFloat("MaxQualityThr");
|
||||
par.addFloat("MaxQualityThr",val1);
|
||||
return true;
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool CleanFilter::applyFilter(QAction *filter, MeshModel &m, FilterParameter & par, vcg::CallBackPos * cb)
|
||||
{
|
||||
if(filter->text() == ST(FP_REBUILD_SURFACE) )
|
||||
|
||||
@ -24,6 +24,10 @@
|
||||
History
|
||||
|
||||
$Log$
|
||||
Revision 1.3 2006/12/13 17:37:27 pirosu
|
||||
Added standard plugin window support
|
||||
|
||||
|
||||
Revision 1.2 2006/11/29 00:59:15 cignoni
|
||||
Cleaned plugins interface; changed useless help class into a plain string
|
||||
|
||||
@ -62,6 +66,12 @@ class CleanFilter : public QObject, public MeshFilterInterface
|
||||
FP_REMOVE_WRT_Q
|
||||
} ;
|
||||
|
||||
/* default values for standard parameters' values of the plugin actions */
|
||||
float maxDiag1;
|
||||
float maxDiag2;
|
||||
int minCC;
|
||||
float val1;
|
||||
|
||||
|
||||
CleanFilter();
|
||||
~CleanFilter();
|
||||
@ -70,9 +80,13 @@ class CleanFilter : public QObject, public MeshFilterInterface
|
||||
virtual const PluginInfo &Info();
|
||||
|
||||
virtual const FilterClass getClass(QAction *);
|
||||
virtual bool getParameters(QAction *, QWidget *, MeshModel &m, FilterParameter &par);
|
||||
virtual const int getRequirements(QAction *);
|
||||
virtual bool applyFilter(QAction *filter, MeshModel &m, FilterParameter & /*parent*/, vcg::CallBackPos * cb) ;
|
||||
|
||||
bool getStdFields(QAction *, MeshModel &m, StdParList &parlst,char **filterdesc,QWidget **extraw);
|
||||
bool getParameters(QAction *action, QWidget *parent, MeshModel &m,FilterParameter &par,FilterParameter *srcpar);
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
};
|
||||
|
||||
@ -22,6 +22,9 @@
|
||||
/****************************************************************************
|
||||
History
|
||||
$Log$
|
||||
Revision 1.82 2006/12/13 17:37:27 pirosu
|
||||
Added standard plugin window support
|
||||
|
||||
Revision 1.81 2006/12/11 23:50:07 cignoni
|
||||
corrected border management after holefilling filter
|
||||
|
||||
@ -161,41 +164,6 @@ using namespace vcg;
|
||||
|
||||
void QuadricSimplification(CMeshO &cm,int TargetFaceNum,CallBackPos *cb);
|
||||
|
||||
bool askInt(int &val, QString Title, QString Label, QWidget *parent)
|
||||
{
|
||||
QDialog *dialog=new QDialog(parent);
|
||||
dialog->setModal(true);
|
||||
dialog->setWindowTitle(Title);
|
||||
|
||||
QPushButton *okButton = new QPushButton("OK", dialog);
|
||||
QPushButton *cancButton = new QPushButton("cancel", dialog);
|
||||
QGridLayout *gridLayout = new QGridLayout(dialog);
|
||||
dialog->setLayout(gridLayout);
|
||||
|
||||
gridLayout->addWidget(okButton,1,1);
|
||||
gridLayout->addWidget(cancButton,1,0);
|
||||
|
||||
QLineEdit *floatEdit = new QLineEdit(dialog);
|
||||
floatEdit->setText(QString::number(val));
|
||||
QLabel *label = new QLabel(Label,dialog);
|
||||
gridLayout->addWidget(label,0,0 );
|
||||
gridLayout->addWidget(floatEdit,0,1);
|
||||
|
||||
QObject::connect(floatEdit, SIGNAL(returnPressed ()), dialog, SLOT(accept()));
|
||||
QObject::connect(okButton, SIGNAL(clicked()), dialog, SLOT(accept()));
|
||||
QObject::connect(cancButton, SIGNAL(clicked()), dialog, SLOT(reject()));
|
||||
|
||||
dialog->exec();
|
||||
if(dialog->result()== QDialog::Accepted )
|
||||
{
|
||||
val=floatEdit->text().toInt();
|
||||
return true;
|
||||
}
|
||||
if(dialog->result()== QDialog::Rejected ) return false;
|
||||
assert(0);
|
||||
return true;
|
||||
}
|
||||
|
||||
ExtraMeshFilterPlugin::ExtraMeshFilterPlugin()
|
||||
{
|
||||
typeList << FP_LOOP_SS<<
|
||||
@ -359,6 +327,52 @@ const int ExtraMeshFilterPlugin::getRequirements(QAction *action)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool ExtraMeshFilterPlugin::getStdFields(QAction *action, MeshModel &m, StdParList &parlst,char **filterdesc,QWidget **extraw)
|
||||
{
|
||||
*extraw = NULL;
|
||||
|
||||
switch(ID(action))
|
||||
{
|
||||
case FP_QUADRIC_SIMPLIFICATION:
|
||||
(*filterdesc) = "Quadric Edge Collapse Simplification";
|
||||
parlst.addField("TargetFaceNum","Target number of faces",(int)(m.cm.fn/2));
|
||||
break;
|
||||
case FP_CLOSE_HOLES_LIEPA:
|
||||
(*filterdesc) = "Close hole";
|
||||
parlst.addField("MaxHoleSize","Max size to be closed ",(int)10);
|
||||
break;
|
||||
default:
|
||||
(*filterdesc) = NULL;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
bool ExtraMeshFilterPlugin::getParameters(QAction *action, QWidget *parent, MeshModel &m,FilterParameter &par,FilterParameter *srcpar)
|
||||
{
|
||||
par.clear();
|
||||
int val;
|
||||
|
||||
switch(ID(action))
|
||||
{
|
||||
case FP_QUADRIC_SIMPLIFICATION:
|
||||
val = srcpar->getInt("TargetFaceNum");
|
||||
par.addInt("TargetFaceNum",val);
|
||||
return true;
|
||||
case FP_CLOSE_HOLES_LIEPA:
|
||||
val = srcpar->getInt("MaxHoleSize");
|
||||
par.addInt("MaxHoleSize",val);
|
||||
return true;
|
||||
}
|
||||
|
||||
return getParameters(action,parent,m,par);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
bool ExtraMeshFilterPlugin::getParameters(QAction *action, QWidget *parent, MeshModel &m,FilterParameter &par)
|
||||
{
|
||||
par.clear();
|
||||
@ -406,27 +420,6 @@ bool ExtraMeshFilterPlugin::getParameters(QAction *action, QWidget *parent, Mesh
|
||||
case FP_REMOVE_NON_MANIFOLD:
|
||||
case FP_NORMAL_EXTRAPOLATION:
|
||||
return true; // no parameters
|
||||
case FP_QUADRIC_SIMPLIFICATION:
|
||||
{
|
||||
int NewFaceNum=m.cm.fn/2;
|
||||
if(askInt(NewFaceNum,"Quadric Edge Collapse Simplification","Target number of faces",parent))
|
||||
{
|
||||
par.addInt("TargetFaceNum",NewFaceNum);
|
||||
return true;
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
case FP_CLOSE_HOLES_LIEPA:
|
||||
{
|
||||
int maxHoleSize=10;
|
||||
if(askInt(maxHoleSize,"Close hole","Max size to be closed ",parent))
|
||||
{
|
||||
par.addInt("MaxHoleSize",maxHoleSize);
|
||||
return true;
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
|
||||
default :assert(0);
|
||||
}
|
||||
return true;
|
||||
|
||||
@ -22,6 +22,9 @@
|
||||
****************************************************************************/
|
||||
/* History
|
||||
$Log$
|
||||
Revision 1.36 2006/12/13 17:37:27 pirosu
|
||||
Added standard plugin window support
|
||||
|
||||
Revision 1.35 2006/11/29 00:59:18 cignoni
|
||||
Cleaned plugins interface; changed useless help class into a plain string
|
||||
|
||||
@ -97,6 +100,9 @@ class ExtraMeshFilterPlugin : public QObject, public MeshFilterInterface
|
||||
|
||||
|
||||
virtual bool applyFilter(QAction *filter, MeshModel &m, FilterParameter & /*parent*/, vcg::CallBackPos * cb) ;
|
||||
bool getStdFields(QAction *, MeshModel &m, StdParList &parlst,char **filterdesc,QWidget **extraw);
|
||||
bool getParameters(QAction *action, QWidget *parent, MeshModel &m,FilterParameter &par,FilterParameter *srcpar);
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user