diff --git a/src/fgt/edit_quality/edit_quality.pro b/src/fgt/edit_quality/edit_quality.pro index 2d6555165..5cf30568d 100644 --- a/src/fgt/edit_quality/edit_quality.pro +++ b/src/fgt/edit_quality/edit_quality.pro @@ -1,6 +1,7 @@ include (../../shared.pri) HEADERS = common/const_types.h \ + edit_quality_factory.h \ qualitymapper.h \ qualitymapperdialog.h \ common/transferfunction.h \ @@ -10,7 +11,8 @@ HEADERS = common/const_types.h \ eqhandle.h \ tfhandle.h -SOURCES = qualitymapper.cpp\ +SOURCES = edit_quality_factory.cpp \ + qualitymapper.cpp\ qualitymapperdialog.cpp\ common/transferfunction.cpp\ common/util.cpp \ diff --git a/src/fgt/edit_quality/edit_quality_factory.cpp b/src/fgt/edit_quality/edit_quality_factory.cpp new file mode 100644 index 000000000..2b3b01d02 --- /dev/null +++ b/src/fgt/edit_quality/edit_quality_factory.cpp @@ -0,0 +1,58 @@ +/**************************************************************************** +* 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_quality_factory.h" +#include "qualitymapper.h" + +QualityMapperFactory::QualityMapperFactory() +{ + //setting-up plugin + editQuality = new QAction(QIcon(":/images/qualitymapper.png"),"Quality Mapper", this); + + actionList << editQuality; + + foreach(QAction *editAction, actionList) + editAction->setCheckable(true); +} + +//gets a list of actions available from this plugin +QList QualityMapperFactory::actions() const +{ + return actionList; +} + +//get the edit tool for the given action +MeshEditInterface* QualityMapperFactory::getMeshEditInterface(QAction *action) +{ + if(action == editQuality) + { + return new QualityMapperPlugin(); + } else assert(0); //should never be asked for an action that isnt here +} + +const QString QualityMapperFactory::getEditToolDescription(QAction *) +{ + return QualityMapperPlugin::Info(); +} + +Q_EXPORT_PLUGIN(QualityMapperFactory) diff --git a/src/fgt/edit_quality/edit_quality_factory.h b/src/fgt/edit_quality/edit_quality_factory.h new file mode 100644 index 000000000..952260f5b --- /dev/null +++ b/src/fgt/edit_quality/edit_quality_factory.h @@ -0,0 +1,59 @@ +/**************************************************************************** +* 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 QualityMapperFactoryPLUGIN_H +#define QualityMapperFactoryPLUGIN_H + +#include +#include +#include + +class QualityMapperFactory : public QObject, public MeshEditInterfaceFactory +{ + Q_OBJECT + Q_INTERFACES(MeshEditInterfaceFactory) + +public: + QualityMapperFactory(); + virtual ~QualityMapperFactory() { delete editQuality; } + + //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 *editQuality; + + +}; + +#endif + diff --git a/src/fgt/edit_quality/qualitymapper.cpp b/src/fgt/edit_quality/qualitymapper.cpp index 181141842..0ad3fdb14 100644 --- a/src/fgt/edit_quality/qualitymapper.cpp +++ b/src/fgt/edit_quality/qualitymapper.cpp @@ -37,37 +37,16 @@ using namespace vcg; QualityMapperPlugin::QualityMapperPlugin() { - //setting-up plugin - actionList << new QAction(QIcon(":/images/qualitymapper.png"),"Quality Mapper", this); - QAction *editAction; - foreach(editAction, actionList) - editAction->setCheckable(true); - //initializing dialog pointer _qualityMapperDialog = 0; } -QList QualityMapperPlugin::actions() const -{ return actionList; } - - -const QString QualityMapperPlugin::Info(QAction *action) +const QString QualityMapperPlugin::Info() { - if( action->text() != tr("Get Info") ) assert (0); - return tr("Colorize mesh vertexes by Quality"); } -const PluginInfo &QualityMapperPlugin::Info() -{ - static PluginInfo ai; - ai.Date=tr("Jan 2008"); - ai.Version = tr("1.0"); - ai.Author = ("Alessandro Maione, Federico Bellucci"); - return ai; -} - -void QualityMapperPlugin::StartEdit(QAction *mode, MeshModel& m, GLArea *gla ) +void QualityMapperPlugin::StartEdit(MeshModel& m, GLArea *gla ) { if(_qualityMapperDialog==0) _qualityMapperDialog = new QualityMapperDialog(gla->window(), m, gla); @@ -76,7 +55,7 @@ void QualityMapperPlugin::StartEdit(QAction *mode, MeshModel& m, GLArea *gla ) //bool ret = _qualityMapperDialog->initEqualizerHistogram(); if ( !_qualityMapperDialog->initEqualizerHistogram() ) { - EndEdit(mode, m, gla); + EndEdit(m, gla); return; } @@ -89,7 +68,7 @@ void QualityMapperPlugin::StartEdit(QAction *mode, MeshModel& m, GLArea *gla ) connect(_qualityMapperDialog, SIGNAL(closingDialog()),gla,SLOT(endEdit()) ); } -void QualityMapperPlugin::EndEdit(QAction * , MeshModel &, GLArea * ) +void QualityMapperPlugin::EndEdit(MeshModel &, GLArea * ) { //if a dialog exists, it's time to destroy it if ( _qualityMapperDialog ) @@ -102,7 +81,7 @@ void QualityMapperPlugin::EndEdit(QAction * , MeshModel &, GLArea * ) } } -void QualityMapperPlugin::Decorate(QAction*, MeshModel&, GLArea*) +void QualityMapperPlugin::Decorate(MeshModel&, GLArea*) { // Draw a vertical bar // Enter in 2D screen Mode again @@ -157,6 +136,3 @@ void QualityMapperPlugin::Decorate(QAction*, MeshModel&, GLArea*) glPopMatrix(); glMatrixMode(GL_MODELVIEW); } - -Q_EXPORT_PLUGIN(QualityMapperPlugin) - diff --git a/src/fgt/edit_quality/qualitymapper.h b/src/fgt/edit_quality/qualitymapper.h index 9a64cc766..112d8bc18 100644 --- a/src/fgt/edit_quality/qualitymapper.h +++ b/src/fgt/edit_quality/qualitymapper.h @@ -47,21 +47,18 @@ class QualityMapperPlugin : public QObject, public MeshEditInterface private: QualityMapperDialog *_qualityMapperDialog; - QList actionList; public: QualityMapperPlugin(void); ~QualityMapperPlugin(void){}; - virtual const QString Info(QAction *); - virtual const PluginInfo &Info(); - virtual QList actions() const ; - virtual void StartEdit(QAction*, MeshModel&, GLArea*); - virtual void EndEdit(QAction*, MeshModel&, GLArea*); - virtual void Decorate(QAction*, MeshModel&, GLArea*); - virtual void mousePressEvent(QAction*, QMouseEvent*, MeshModel&, GLArea*) {}; - virtual void mouseMoveEvent(QAction*, QMouseEvent*, MeshModel&, GLArea*) {}; - virtual void mouseReleaseEvent(QAction*, QMouseEvent *event, MeshModel&, GLArea*){}; + static const QString Info(); + virtual void StartEdit(MeshModel&, GLArea*); + virtual void EndEdit(MeshModel&, GLArea*); + virtual void Decorate(MeshModel&, GLArea*); + virtual void mousePressEvent(QMouseEvent*, MeshModel&, GLArea*) {}; + virtual void mouseMoveEvent(QMouseEvent*, MeshModel&, GLArea*) {}; + virtual void mouseReleaseEvent(QMouseEvent *event, MeshModel&, GLArea*){}; QPoint cur; bool haveToPick;