diff --git a/src/meshlabplugins/edit_select/edit_select.cpp b/src/meshlabplugins/edit_select/edit_select.cpp index 8eb0c9817..159ef2807 100644 --- a/src/meshlabplugins/edit_select/edit_select.cpp +++ b/src/meshlabplugins/edit_select/edit_select.cpp @@ -34,37 +34,16 @@ using namespace std; using namespace vcg; ExtraMeshEditPlugin::ExtraMeshEditPlugin() { - isDragging=false; - - actionList << new QAction(QIcon(":/images/select_face.png"),"Select Faces in a region", this); - QAction *editAction; - foreach(editAction, actionList) - editAction->setCheckable(true); - + isDragging=false; } -QList ExtraMeshEditPlugin::actions() const { - return actionList; -} - - -const QString ExtraMeshEditPlugin::Info(QAction *action) +const QString ExtraMeshEditPlugin::Info() { - if( action->text() != tr("Select Faces in a region") ) assert (0); - return tr("Interactive selection of faces inside a dragged rectangle in screen space"); } -const PluginInfo &ExtraMeshEditPlugin::Info() +void ExtraMeshEditPlugin::mousePressEvent(QMouseEvent * event, MeshModel &m, GLArea * gla) { - static PluginInfo ai; - ai.Date=tr(__DATE__); - ai.Version = tr("0.5"); - ai.Author = ("Paolo Cignoni"); - return ai; - } - void ExtraMeshEditPlugin::mousePressEvent (QAction *, QMouseEvent * event, MeshModel &m, GLArea * gla) - { LastSel.clear(); if(event->modifiers() == Qt::ControlModifier || @@ -85,7 +64,7 @@ const PluginInfo &ExtraMeshEditPlugin::Info() return; } - void ExtraMeshEditPlugin::mouseMoveEvent (QAction *,QMouseEvent * event, MeshModel &/*m*/, GLArea * gla) + void ExtraMeshEditPlugin::mouseMoveEvent(QMouseEvent * event, MeshModel &/*m*/, GLArea * gla) { prev=cur; cur=event->pos(); @@ -105,12 +84,13 @@ const PluginInfo &ExtraMeshEditPlugin::Info() } } - void ExtraMeshEditPlugin::mouseReleaseEvent (QAction *,QMouseEvent * event, MeshModel &/*m*/, GLArea * gla) + void ExtraMeshEditPlugin::mouseReleaseEvent(QMouseEvent * event, MeshModel &/*m*/, GLArea * gla) { gla->update(); prev=cur; cur=event->pos(); } + void ExtraMeshEditPlugin::DrawXORRect(GLArea * gla, bool doubleDraw) { glMatrixMode(GL_PROJECTION); @@ -152,7 +132,8 @@ const PluginInfo &ExtraMeshEditPlugin::Info() glMatrixMode(GL_MODELVIEW); } - void ExtraMeshEditPlugin::Decorate(QAction * ac, MeshModel &m, GLArea * gla) + + void ExtraMeshEditPlugin::Decorate(MeshModel &m, GLArea * gla) { if(isDragging) { @@ -212,7 +193,7 @@ const PluginInfo &ExtraMeshEditPlugin::Info() } -void ExtraMeshEditPlugin::StartEdit(QAction * /*mode*/, MeshModel &m, GLArea *gla ) +void ExtraMeshEditPlugin::StartEdit(MeshModel &m, GLArea *gla ) { LastSel.clear(); CMeshO::FaceIterator fi; @@ -227,7 +208,3 @@ void ExtraMeshEditPlugin::StartEdit(QAction * /*mode*/, MeshModel &m, GLArea *gl setSelectionRendering(true); } - - - -Q_EXPORT_PLUGIN(ExtraMeshEditPlugin) diff --git a/src/meshlabplugins/edit_select/edit_select.h b/src/meshlabplugins/edit_select/edit_select.h index 9224eac6a..dacfff2aa 100644 --- a/src/meshlabplugins/edit_select/edit_select.h +++ b/src/meshlabplugins/edit_select/edit_select.h @@ -34,32 +34,28 @@ class ExtraMeshEditPlugin : public QObject, public MeshEditInterface { Q_OBJECT Q_INTERFACES(MeshEditInterface) - - QList actionList; - + public: ExtraMeshEditPlugin(); virtual ~ExtraMeshEditPlugin() {} - virtual const QString Info(QAction *); - virtual const PluginInfo &Info(); + 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 * ); - 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 void wheelEvent (QAction *QWheelEvent*e, MeshModel &/*m*/, GLArea * ); - virtual QList actions() const ; QPoint start; QPoint cur; QPoint prev; bool isDragging; std::vector LastSel; + signals: - void setSelectionRendering(bool); + void setSelectionRendering(bool); private: typedef enum {SMAdd, SMClear,SMSub} SelMode; diff --git a/src/meshlabplugins/edit_select/edit_select.pro b/src/meshlabplugins/edit_select/edit_select.pro index 00f77b139..545d9a558 100644 --- a/src/meshlabplugins/edit_select/edit_select.pro +++ b/src/meshlabplugins/edit_select/edit_select.pro @@ -1,7 +1,12 @@ include (../../shared.pri) -HEADERS = edit_select.h -SOURCES = edit_select.cpp $$GLEWCODE +HEADERS = edit_select_factory.h \ + edit_select.h + +SOURCES = edit_select_factory.cpp \ + edit_select.cpp \ + $$GLEWCODE + TARGET = edit_select QT += opengl diff --git a/src/meshlabplugins/edit_select/edit_select_factory.cpp b/src/meshlabplugins/edit_select/edit_select_factory.cpp new file mode 100644 index 000000000..cd3db4183 --- /dev/null +++ b/src/meshlabplugins/edit_select/edit_select_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_select_factory.h" +#include "edit_select.h" + +EditSelectFactory::EditSelectFactory() +{ + editSelect = new QAction(QIcon(":/images/select_face.png"),"Select Faces in a region", this); + + actionList << editSelect; + + foreach(QAction *editAction, actionList) + editAction->setCheckable(true); +} + +//gets a list of actions available from this plugin +QList EditSelectFactory::actions() const +{ + return actionList; +} + +//get the edit tool for the given action +MeshEditInterface* EditSelectFactory::getMeshEditInterface(QAction *action) +{ + if(action == editSelect) + { + return new ExtraMeshEditPlugin(); + } else assert(0); //should never be asked for an action that isnt here +} + +const QString EditSelectFactory::getEditToolDescription(QAction *) +{ + return ExtraMeshEditPlugin::Info(); +} + +Q_EXPORT_PLUGIN(EditSelectFactory) diff --git a/src/meshlabplugins/edit_select/edit_select_factory.h b/src/meshlabplugins/edit_select/edit_select_factory.h new file mode 100644 index 000000000..634b514e0 --- /dev/null +++ b/src/meshlabplugins/edit_select/edit_select_factory.h @@ -0,0 +1,56 @@ +/**************************************************************************** +* 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 EditSelectFactoryPLUGIN_H +#define EditSelectFactoryPLUGIN_H + +#include +#include +#include + +class EditSelectFactory : public QObject, public MeshEditInterfaceFactory +{ + Q_OBJECT + Q_INTERFACES(MeshEditInterfaceFactory) + +public: + EditSelectFactory(); + virtual ~EditSelectFactory() { delete editSelect; } + + //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 *editSelect; +}; + +#endif