From 62e8c75fb240f804cbe75ad31087f6bbd5ef4a13 Mon Sep 17 00:00:00 2001 From: Paolo Cignoni cignoni Date: Mon, 13 Oct 2008 09:31:05 +0000 Subject: [PATCH] Updated to remove PluginInfo, to use new MeshEditInterface, and to use new factory way of creating edit tools --- src/fgt/edit_hole/edit_hole.cpp | 45 +++++-------------- src/fgt/edit_hole/edit_hole.h | 19 ++++----- src/fgt/edit_hole/edit_hole.pro | 8 ++-- src/fgt/edit_hole/edit_hole_factory.cpp | 57 +++++++++++++++++++++++++ src/fgt/edit_hole/edit_hole_factory.h | 57 +++++++++++++++++++++++++ 5 files changed, 138 insertions(+), 48 deletions(-) create mode 100644 src/fgt/edit_hole/edit_hole_factory.cpp create mode 100644 src/fgt/edit_hole/edit_hole_factory.h diff --git a/src/fgt/edit_hole/edit_hole.cpp b/src/fgt/edit_hole/edit_hole.cpp index 4bdf79d31..1ea9dea8a 100644 --- a/src/fgt/edit_hole/edit_hole.cpp +++ b/src/fgt/edit_hole/edit_hole.cpp @@ -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 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::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::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� vicina uno dei vertici � 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) diff --git a/src/fgt/edit_hole/edit_hole.h b/src/fgt/edit_hole/edit_hole.h index cf6ceb617..2ac08931b 100644 --- a/src/fgt/edit_hole/edit_hole.h +++ b/src/fgt/edit_hole/edit_hole.h @@ -35,8 +35,7 @@ class EditHolePlugin : public QObject, public MeshEditInterface { Q_OBJECT Q_INTERFACES(MeshEditInterface) - QList actionList; - + public: typedef vcg::tri::Hole 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 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(); diff --git a/src/fgt/edit_hole/edit_hole.pro b/src/fgt/edit_hole/edit_hole.pro index 470848e99..27cfa94ba 100644 --- a/src/fgt/edit_hole/edit_hole.pro +++ b/src/fgt/edit_hole/edit_hole.pro @@ -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 \ diff --git a/src/fgt/edit_hole/edit_hole_factory.cpp b/src/fgt/edit_hole/edit_hole_factory.cpp new file mode 100644 index 000000000..cbb5c4247 --- /dev/null +++ b/src/fgt/edit_hole/edit_hole_factory.cpp @@ -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 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) diff --git a/src/fgt/edit_hole/edit_hole_factory.h b/src/fgt/edit_hole/edit_hole_factory.h new file mode 100644 index 000000000..2304fd8a2 --- /dev/null +++ b/src/fgt/edit_hole/edit_hole_factory.h @@ -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 +#include +#include + +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 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 actionList; + + QAction *editHole; + +}; + +#endif