Updated to remove PluginInfo, to use new MeshEditInterface, and to use new factory way of creating edit tools

This commit is contained in:
Paolo Cignoni cignoni 2008-10-13 09:31:05 +00:00
parent 0b39ec0525
commit 62e8c75fb2
5 changed files with 138 additions and 48 deletions

View File

@ -35,15 +35,9 @@ using namespace vcg;
EditHolePlugin::EditHolePlugin() {
QAction* editFill = new QAction(QIcon(":/images/icon_filler.png"),"Fill Hole", this);
actionList << editFill;
QAction *editAction;
dialogFiller = 0;
holesModel = 0;
foreach(editAction, actionList)
editAction->setCheckable(true);
pickedFace = 0;
hasPick = false;
}
@ -64,31 +58,16 @@ EditHolePlugin::~EditHolePlugin()
}
}
QList<QAction *> EditHolePlugin::actions() const {
return actionList;
}
const QString EditHolePlugin::Info(QAction *action)
const QString EditHolePlugin::Info()
{
if( action->text() != tr("Fill mesh's hole") ) assert (0);
return tr("Allow fill one or more hole into place");
}
const PluginInfo &EditHolePlugin::Info()
{
static PluginInfo ai;
ai.Date=tr(__DATE__);
ai.Version = tr("0.1");
ai.Author = ("Michele Vannoni");
return ai;
}
void EditHolePlugin::mouseReleaseEvent (QAction *,QMouseEvent * e, MeshModel &/*m*/, GLArea * gla)
void EditHolePlugin::mouseReleaseEvent(QMouseEvent * e, MeshModel &/*m*/, GLArea * gla)
{
}
void EditHolePlugin::mousePressEvent(QAction *, QMouseEvent * e, MeshModel &m, GLArea * gla)
void EditHolePlugin::mousePressEvent(QMouseEvent * e, MeshModel &m, GLArea * gla)
{
if ( (e->button()==Qt::LeftButton) )
{
@ -98,11 +77,11 @@ void EditHolePlugin::mousePressEvent(QAction *, QMouseEvent * e, MeshModel &m, G
}
}
void EditHolePlugin::mouseMoveEvent(QAction *,QMouseEvent * e, MeshModel &/*m*/, GLArea * gla)
void EditHolePlugin::mouseMoveEvent(QMouseEvent * e, MeshModel &/*m*/, GLArea * gla)
{
}
void EditHolePlugin::StartEdit(QAction * , MeshModel &m, GLArea *gla )
void EditHolePlugin::StartEdit(MeshModel &m, GLArea *gla )
{
m.updateDataMask(MeshModel::MM_FACETOPO);
if ( !tri::Clean<CMeshO>::IsTwoManifoldFace(m.cm) )
@ -114,7 +93,7 @@ void EditHolePlugin::StartEdit(QAction * , MeshModel &m, GLArea *gla )
// necessario per evitare di avere 2 istanze del filtro se si cambia mesh
// senza chidere il filtro
if(dialogFiller != 0)
EndEdit(0, m, gla);
EndEdit(m, gla);
// if plugin restart with another mesh, recomputing of hole is forced
if(mesh != &m)
@ -158,11 +137,11 @@ void EditHolePlugin::StartEdit(QAction * , MeshModel &m, GLArea *gla )
holeSorter->setSourceModel(holesModel);
dialogFiller->ui.holeTree->setModel( holeSorter );
Decorate(0, m, gla);
Decorate(m, gla);
upGlA();
}
void EditHolePlugin::Decorate(QAction * ac, MeshModel &m, GLArea * gla)
void EditHolePlugin::Decorate(MeshModel &m, GLArea * gla)
{
if(holesModel==0)
return;
@ -180,7 +159,7 @@ void EditHolePlugin::Decorate(QAction * ac, MeshModel &m, GLArea * gla)
pickedFace =0;
int inverseY = gla->curSiz.height() - cur.y();
GLPickTri<CMeshO>::PickNearestFace(cur.x(), inverseY, m.cm, pickedFace, 4, 4);
// guardo se nella faccia più vicina uno dei vertici è di bordo
// guardo se nella faccia pi<EFBFBD> vicina uno dei vertici <20> di bordo
if( pickedFace != 0 )
{
bool oldAbutmentPresence;
@ -212,7 +191,7 @@ void EditHolePlugin::Decorate(QAction * ac, MeshModel &m, GLArea * gla)
glPopMatrix();
}
void EditHolePlugin::EndEdit(QAction * , MeshModel &m, GLArea *gla ){
void EditHolePlugin::EndEdit(MeshModel &m, GLArea *gla ){
if(holesModel == 0) // means editing is not started
return;
@ -367,5 +346,3 @@ void EditHolePlugin::skipTab(int index)
else
cancelFill();
}
Q_EXPORT_PLUGIN(EditHolePlugin)

View File

@ -35,8 +35,7 @@ class EditHolePlugin : public QObject, public MeshEditInterface
{
Q_OBJECT
Q_INTERFACES(MeshEditInterface)
QList <QAction *> actionList;
public:
typedef vcg::tri::Hole<CMeshO> vcgHole;
typedef vcgHole::Info HoleInfo;
@ -46,15 +45,13 @@ public:
EditHolePlugin();
virtual ~EditHolePlugin();
virtual const QString Info(QAction *);
virtual const PluginInfo &Info();
virtual void StartEdit(QAction * /*mode*/, MeshModel &/*m*/, GLArea * /*parent*/);
virtual void EndEdit(QAction * /*mode*/, MeshModel &/*m*/, GLArea * /*parent*/);
virtual void Decorate(QAction * /*mode*/, MeshModel &/*m*/, GLArea * /*parent*/);
virtual void mousePressEvent (QAction *, QMouseEvent *event, MeshModel &/*m*/, GLArea * );
virtual void mouseMoveEvent (QAction *,QMouseEvent *event, MeshModel &/*m*/, GLArea * );
virtual void mouseReleaseEvent (QAction *,QMouseEvent *event, MeshModel &/*m*/, GLArea * );
virtual QList<QAction *> actions() const ;
static const QString Info();
virtual void StartEdit(MeshModel &/*m*/, GLArea * /*parent*/);
virtual void EndEdit(MeshModel &/*m*/, GLArea * /*parent*/);
virtual void Decorate(MeshModel &/*m*/, GLArea * /*parent*/);
virtual void mousePressEvent(QMouseEvent *event, MeshModel &/*m*/, GLArea * );
virtual void mouseMoveEvent(QMouseEvent *event, MeshModel &/*m*/, GLArea * );
virtual void mouseReleaseEvent(QMouseEvent *event, MeshModel &/*m*/, GLArea * );
private:
void setInfoLabel();

View File

@ -1,13 +1,15 @@
include (../../shared.pri)
HEADERS = edit_hole.h \
HEADERS = edit_hole_factory.h \
edit_hole.h \
fillerDialog.h \
holeListModel.h \
fgtHole.h \
fgtBridge.h \
../../meshlab/meshmodel.h
SOURCES = edit_hole.cpp \
SOURCES = edit_hole_factory.cpp \
edit_hole.cpp \
fillerDialog.cpp\
holeListModel.cpp \
../../meshlab/meshmodel.cpp \

View File

@ -0,0 +1,57 @@
/****************************************************************************
* MeshLab o o *
* A versatile mesh processing toolbox o o *
* _ O _ *
* Copyright(C) 2005-2008 \/)\/ *
* Visual Computing Lab /\/| *
* ISTI - Italian National Research Council | *
* \ *
* All rights reserved. *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt) *
* for more details. *
* *
****************************************************************************/
#include "edit_hole_factory.h"
#include "edit_hole.h"
EditHoleFactory::EditHoleFactory()
{
editHole = new QAction(QIcon(":/images/icon_filler.png"),"Fill Hole", this);
actionList << editHole;
foreach(QAction *editAction, actionList)
editAction->setCheckable(true);
}
//gets a list of actions available from this plugin
QList<QAction *> EditHoleFactory::actions() const
{
return actionList;
}
//get the edit tool for the given action
MeshEditInterface* EditHoleFactory::getMeshEditInterface(QAction *action)
{
if(action == editHole)
{
return new EditHolePlugin();
} else assert(0); //should never be asked for an action that isnt here
}
const QString EditHoleFactory::getEditToolDescription(QAction *)
{
return EditHolePlugin::Info();
}
Q_EXPORT_PLUGIN(EditHoleFactory)

View File

@ -0,0 +1,57 @@
/****************************************************************************
* MeshLab o o *
* A versatile mesh processing toolbox o o *
* _ O _ *
* Copyright(C) 2005-2008 \/)\/ *
* Visual Computing Lab /\/| *
* ISTI - Italian National Research Council | *
* \ *
* All rights reserved. *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt) *
* for more details. *
* *
****************************************************************************/
#ifndef EditHoleFactoryPLUGIN_H
#define EditHoleFactoryPLUGIN_H
#include <meshlab/interfaces.h>
#include <QObject>
#include <QList>
class EditHoleFactory : public QObject, public MeshEditInterfaceFactory
{
Q_OBJECT
Q_INTERFACES(MeshEditInterfaceFactory)
public:
EditHoleFactory();
virtual ~EditHoleFactory() { delete editHole; }
//gets a list of actions available from this plugin
virtual QList<QAction *> actions() const;
//get the edit tool for the given action
virtual MeshEditInterface* getMeshEditInterface(QAction *);
//get the description for the given action
virtual const QString getEditToolDescription(QAction *);
private:
QList <QAction *> actionList;
QAction *editHole;
};
#endif