Plugin Interface change: now filterName and filterInfo are pure virtual methods only of the Filter class of plugins. Decorations have their own decorationName and decorationInfo method.

This commit is contained in:
Paolo Cignoni cignoni 2011-09-19 07:20:09 +00:00
parent ffeb4b5fa1
commit b475adc177
8 changed files with 67 additions and 103 deletions

View File

@ -129,18 +129,6 @@ public:
If a filter wants to save some permanent stuff should set the permanent default values.
*/
virtual void initGlobalParameterSet(QAction * /*format*/, RichParameterSet & /*globalparam*/) {}
// The longer string describing each filtering action.
// This string is printed in the top of the parameter window
// so it should be at least one or two paragraphs long.
// you can use simple html formatting tags (like <br> <b> and <i>) to improve readability.
// This string is used in the About plugin dialog and by meshlabserver to create the filter list page.
virtual QString filterInfo(QAction* action) const =0;
// The very short string (a few words) describing each filtering action
// This string is used also to define the menu entry
virtual QString filterName(FilterIDType ) const =0;
};
/** \brief The MeshIOInterface is the base class for all the single mesh loading plugins.
*/
@ -161,20 +149,7 @@ public:
virtual QList<Format> importFormats() const = 0;
virtual QList<Format> exportFormats() const = 0;
// The longer string describing each filtering action.
// This string is printed in the top of the parameter window
// so it should be at least one or two paragraphs long.
// you can use simple html formatting tags (like <br> <b> and <i>) to improve readability.
// This string is used in the About plugin dialog and by meshlabserver to create the filter list page.
QString filterInfo(QAction* /*action*/) const {return QString();};
// The very short string (a few words) describing each filtering action
// This string is used also to define the menu entry
QString filterName(FilterIDType) const {return QString();};
// This function is called to initialize the list of additional parameters that a OPENING filter could require
// This function is called to initialize the list of additional parameters that a OPENING filter could require
// it is called by the framework BEFORE the actual mesh loading to perform to determine how parse the input file
// The instanced parameters are then passed to the open at the loading time.
// Typical example of use to decide what subportion of a mesh you have to load.
@ -268,6 +243,12 @@ public:
}
virtual ~MeshFilterInterface() {}
/** The very short string (a few words) describing each filtering action
// This string is used also to define the menu entry
*/
virtual QString filterName(FilterIDType ) const =0;
/** The long, formatted string describing each filtering action.
// This string is printed in the top of the parameter window
// so it should be at least one or two paragraphs long. The more the better.
@ -316,7 +297,7 @@ public:
// It is widely used by the meshlab's preview system.
//TO BE REPLACED WITH = 0
*/
virtual int postCondition( QAction* ) const {return MeshModel::MM_UNKNOWN;};
virtual int postCondition( QAction* ) const {return MeshModel::MM_UNKNOWN;}
/** \brief applies the selected filter with the already stabilished parameters
* This function is called by the framework after getting values for the parameters specified in the \ref InitParameterSet
@ -350,9 +331,8 @@ public:
* Failing filters should put some meaningful information inside the errorMessage string and return false with the \ref applyFilter
*/
const QString &errorMsg() {return this->errorMessage;}
virtual QString filterInfo(QAction *a) const {return this->filterInfo(ID(a));};
virtual QString filterName(QAction *a) const {return this->filterName(ID(a));};
virtual QString filterName(FilterIDType /*filterID*/) const =0;// const {return MeshLabInterface::filterName(filterID);};
virtual QString filterInfo(QAction *a) const {return this->filterInfo(ID(a));}
virtual QString filterName(QAction *a) const {return this->filterName(ID(a));}
virtual QString filterScriptFunctionName(FilterIDType /*filterID*/) {return "";}
@ -446,24 +426,11 @@ public:
MeshRenderInterface() :MeshCommonInterface() {}
virtual ~MeshRenderInterface() {}
virtual void Init(QAction * /*mode*/, MeshDocument &/*m*/, RenderMode &/*rm*/, QGLWidget * /*parent*/){};
virtual void Init(QAction * /*mode*/, MeshDocument &/*m*/, RenderMode &/*rm*/, QGLWidget * /*parent*/){}
virtual void Render(QAction * /*mode*/, MeshDocument &/*md*/, RenderMode &/*rm*/, QGLWidget * /*parent*/) = 0;
virtual void Finalize(QAction * /*mode*/, MeshDocument &/*m*/, GLArea * /*parent*/){};
virtual void Finalize(QAction * /*mode*/, MeshDocument &/*m*/, GLArea * /*parent*/){}
virtual bool isSupported() = 0;
virtual QList<QAction *> actions() = 0;
// The longer string describing each filtering action.
// This string is printed in the top of the parameter window
// so it should be at least one or two paragraphs long.
// you can use simple html formatting tags (like <br> <b> and <i>) to improve readability.
// This string is used in the About plugin dialog and by meshlabserver to create the filter list page.
QString filterInfo(QAction* /*action*/) const {return QString();};
// The very short string (a few words) describing each filtering action
// This string is used also to define the menu entry
QString filterName(FilterIDType /*action*/) const {return QString();};
};
/**
MeshDecorateInterface is the base class of all <b> decorators </b>
@ -504,17 +471,24 @@ public:
MeshDecorateInterface(): MeshCommonInterface() {}
virtual ~MeshDecorateInterface() {}
/** The very short string (a few words) describing each filtering action
// This string is used also to define the menu entry
*/
virtual QString decorationName(FilterIDType ) const =0;
virtual QString decorationInfo(FilterIDType ) const =0;
virtual QString decorationInfo(QAction *a) const {return decorationInfo(ID(a));}
virtual bool startDecorate(QAction * /*mode*/, MeshDocument &/*m*/, RichParameterSet * /*param*/, GLArea * /*parent*/) =0;
virtual void decorate(QAction * /*mode*/, MeshDocument &/*m*/, RichParameterSet *, GLArea * /*parent*/, QPainter */*p*/) = 0;
virtual void endDecorate(QAction * /*mode*/, MeshDocument &/*m*/, RichParameterSet *, GLArea * /*parent*/){};
virtual void endDecorate(QAction * /*mode*/, MeshDocument &/*m*/, RichParameterSet *, GLArea * /*parent*/){}
/** \brief tests if a decoration is applicable to a mesh.
For istance curvature cannot be shown on a mesh without curvature.
On failure (returning false) the function fills the MissingItems list with strings describing the missing items.
It is invoked only for decoration of \i PerMesh class;
*/
virtual bool isDecorationApplicable(QAction */*action*/, const MeshModel& /*m*/, QString&/*MissingItems*/) const {return true;};
virtual bool isDecorationApplicable(QAction */*action*/, const MeshModel& /*m*/, QString&/*MissingItems*/) const {return true;}
virtual int getDecorationClass(QAction */*action*/) const {return Generic;}
@ -526,7 +500,7 @@ protected:
virtual FilterIDType ID(QAction *a) const
{
foreach( FilterIDType tt, types())
if( a->text() == this->filterName(tt) ) return tt;
if( a->text() == this->decorationName(tt) ) return tt;
qDebug("unable to find the id corresponding to action '%s'",qPrintable(a->text()));
assert(0);
return -1;
@ -549,18 +523,7 @@ public:
//should return a sentence describing what the editing tool does
static const QString Info();
// The longer string describing each filtering action.
// This string is printed in the top of the parameter window
// so it should be at least one or two paragraphs long.
// you can use simple html formatting tags (like <br> <b> and <i>) to improve readability.
// This string is used in the About plugin dialog and by meshlabserver to create the filter list page.
QString filterInfo(QAction* /*action*/) const {return QString();};
// The very short string (a few words) describing each filtering action
// This string is used also to define the menu entry
QString filterName(FilterIDType ) const {return QString();};
// Called when the user press the first time the button
// Called when the user press the first time the button
virtual bool StartEdit(MeshModel &/*m*/, GLArea * /*parent*/){return true;};
virtual bool StartEdit(MeshDocument &md, GLArea *parent)
{

View File

@ -673,7 +673,7 @@ void MainWindow::fillDecorateMenu()
foreach(QAction *decorateAction, iDecorate->actions())
{
connect(decorateAction,SIGNAL(triggered()),this,SLOT(applyDecorateMode()));
decorateAction->setToolTip(iDecorate->filterInfo(decorateAction));
decorateAction->setToolTip(iDecorate->decorationInfo(decorateAction));
renderMenu->addAction(decorateAction);
}
}

View File

@ -37,9 +37,9 @@
using namespace vcg;
QString SampleMeshDecoratePlugin::filterInfo(QAction *action) const
QString SampleMeshDecoratePlugin::decorationInfo(FilterIDType id) const
{
switch(ID(action))
switch(id)
{
case DP_SHOW_CUBEMAPPED_ENV : return tr("Draws a customizable cube mapped background that is sync with trackball rotation");
case DP_SHOW_GRID : return tr("Draws a gridded background that can be used as a reference.");
@ -47,7 +47,7 @@ QString SampleMeshDecoratePlugin::filterInfo(QAction *action) const
assert(0);
return QString();
}
QString SampleMeshDecoratePlugin::filterName(FilterIDType id) const
QString SampleMeshDecoratePlugin::decorationName(FilterIDType id) const
{
switch(id)
{
@ -202,7 +202,7 @@ void DrawGridPlane(int axis, int side,
/* return true if the side of a box is front facing with respet of the give viewpoint.
side 0, axis i == min on than i-th axis
side 1, axis i == min on than i-th axis
qyuesto capita se il prodotto scalare tra il vettore cnormale entro della faccia
questo capita se il prodotto scalare tra il vettore normale entro della faccia
*/
bool FrontFacing(Point3f viewPos,
int axis, int side,
@ -230,28 +230,30 @@ bool FrontFacing(Point3f viewPos,
void SampleMeshDecoratePlugin::DrawGriddedCube(const Box3f &bb, float majorTick, float minorTick, GLArea *gla)
{
glPushAttrib(GL_ALL_ATTRIB_BITS);
Point3f minP,maxP, minG,maxG;
minP=bb.min;maxP=bb.max;
glPushAttrib(GL_ALL_ATTRIB_BITS);
Point3f minP,maxP, minG,maxG;
minP=bb.min;maxP=bb.max;
for(int i=0;i<3;++i)
{
if(minP[i] > 0 ) minG[i] = minP[i] - fmod(minP[i],majorTick) + majorTick;
if(minP[i] ==0 ) minG[i] = majorTick;
if(minP[i] < 0 ) minG[i] = minP[i] + fmod(fabs(minP[i]),majorTick);
}
glDisable(GL_LIGHTING);
glEnable(GL_LINE_SMOOTH);
glEnable(GL_BLEND);
glDepthMask(GL_FALSE);
Point3f viewPos = this->curShot.GetViewPoint();
qDebug("Current camera pos %f %f %f",viewPos[0],viewPos[1],viewPos[2]);
for (int ii=0;ii<3;++ii)
for(int jj=0;jj<2;++jj)
if(!FrontFacing(viewPos,ii,jj,minP,maxP))
DrawGridPlane(ii,jj,minP,maxP,minG,maxG,10,1);
// Make the box well rounded wrt to major tick
for(int i=0;i<3;++i) // foreach axis
{
if(minP[i] > 0 ) minG[i] = minP[i] - fmod(minP[i],majorTick) + majorTick;
if(minP[i] ==0 ) minG[i] = majorTick;
if(minP[i] < 0 ) minG[i] = minP[i] + fmod(fabs(minP[i]),majorTick);
}
glPopAttrib();
glDisable(GL_LIGHTING);
glEnable(GL_LINE_SMOOTH);
glEnable(GL_BLEND);
glDepthMask(GL_FALSE);
Point3f viewPos = this->curShot.GetViewPoint();
qDebug("Current camera pos %f %f %f",viewPos[0],viewPos[1],viewPos[2]);
for (int ii=0;ii<3;++ii)
for(int jj=0;jj<2;++jj)
if(!FrontFacing(viewPos,ii,jj,minP,maxP))
DrawGridPlane(ii,jj,minP,maxP,minG,maxG,10,1);
glPopAttrib();
}
void SampleMeshDecoratePlugin::setValue(QString name, vcg::Shotf val) {curShot=val;}

View File

@ -42,8 +42,8 @@ class SampleMeshDecoratePlugin : public QObject, public MeshDecorateInterface
{
Q_OBJECT
Q_INTERFACES(MeshDecorateInterface)
QString filterName(FilterIDType filter) const;
QString filterInfo(QAction *) const;
QString decorationName(FilterIDType id) const;
QString decorationInfo(FilterIDType id) const;
enum {
DP_SHOW_CUBEMAPPED_ENV,
@ -69,7 +69,7 @@ public:
FilterIDType tt;
foreach(tt , types()){
actionList << new QAction(filterName(tt), this);
actionList << new QAction(decorationName(tt), this);
}
QAction *ap;
foreach(ap,actionList){

View File

@ -34,9 +34,9 @@ using namespace std;
typedef pair<Point3f,Color4b> PointPC; // this type is used to have a simple coord+color pair to rapidly draw non manifold faces
QString ExtraMeshDecoratePlugin::filterInfo(QAction *action) const
QString ExtraMeshDecoratePlugin::decorationInfo(FilterIDType filter) const
{
switch(ID(action))
switch(filter)
{
case DP_SHOW_AXIS : return tr("Draws XYZ axes in world coordinates");
case DP_SHOW_BOX_CORNERS: return tr("Draws object's bounding box corners");
@ -62,7 +62,7 @@ QString ExtraMeshDecoratePlugin::filterInfo(QAction *action) const
return QString();
}
QString ExtraMeshDecoratePlugin::filterName(FilterIDType filter) const
QString ExtraMeshDecoratePlugin::decorationName(FilterIDType filter) const
{
switch(filter)
{
@ -1312,7 +1312,7 @@ void ExtraMeshDecoratePlugin::DrawColorHistogram(CHist &ch, GLArea *gla, QPainte
// This function performs the Scale/Translation transform
// that is needed to correctly draw a single texture.
// When more than a single texture is used they are stacked vertically
void ExtraMeshDecoratePlugin::PlaceTexParam(int TexInd, int TexNum)
void ExtraMeshDecoratePlugin::PlaceTexParam(int /*TexInd*/, int /*TexNum*/)
{
}

View File

@ -34,9 +34,9 @@ class ExtraMeshDecoratePlugin : public QObject, public MeshDecorateInterface
{
Q_OBJECT
Q_INTERFACES(MeshDecorateInterface)
virtual QString filterInfo(QAction *) const;
QString decorateInfo(QAction *) const;
QString decorationName(FilterIDType filter) const;
QString decorationInfo(FilterIDType filter) const;
enum {
DP_SHOW_FACE_NORMALS,
DP_SHOW_VERT_NORMALS,
@ -60,7 +60,6 @@ class ExtraMeshDecoratePlugin : public QObject, public MeshDecorateInterface
DP_SHOW_BOUNDARY_TEX
};
QString filterName(FilterIDType filter) const;
private:
float niceRound2(float value,float base);
@ -99,7 +98,7 @@ public:
FilterIDType tt;
foreach(tt , types()){
actionList << new QAction(filterName(tt), this);
actionList << new QAction(decorationName(tt), this);
}
QAction *ap;
foreach(ap,actionList){

View File

@ -25,16 +25,16 @@
using namespace vcg;
QString DecorateShadowPlugin::filterInfo(QAction *action) const
QString DecorateShadowPlugin::decorationInfo(FilterIDType id) const
{
switch(ID(action)){
switch(id){
case DP_SHOW_SHADOW : return tr("Enable shadow mapping");
case DP_SHOW_SSAO: return tr("Enable Screen Space Ambient Occlusion");
default: assert(0); return QString();
}
}
QString DecorateShadowPlugin::filterName(FilterIDType id) const
QString DecorateShadowPlugin::decorationName(FilterIDType id) const
{
switch(id){
case DP_SHOW_SHADOW : return tr("Enable shadow mapping");

View File

@ -56,8 +56,8 @@ class DecorateShadowPlugin : public QObject, public MeshDecorateInterface
<<"Variance shadow mapping with blur";
}
virtual QString filterInfo(QAction *) const;
virtual QString filterName(FilterIDType filter) const;
virtual QString decorationInfo(FilterIDType filter) const;
virtual QString decorationName(FilterIDType filter) const;
public:
@ -68,7 +68,7 @@ public:
FilterIDType tt;
foreach(tt , types()){
actionList << new QAction(filterName(tt), this);
actionList << new QAction(decorationName(tt), this);
}
QAction *ap;
foreach(ap,actionList){