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 10:07:58 +00:00
parent 7ba9c32597
commit 2084a3a38d
5 changed files with 139 additions and 48 deletions

View File

@ -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<QAction *> 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)

View File

@ -34,32 +34,28 @@ class ExtraMeshEditPlugin : public QObject, public MeshEditInterface
{
Q_OBJECT
Q_INTERFACES(MeshEditInterface)
QList <QAction *> 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<QAction *> actions() const ;
QPoint start;
QPoint cur;
QPoint prev;
bool isDragging;
std::vector<CMeshO::FacePointer> LastSel;
signals:
void setSelectionRendering(bool);
void setSelectionRendering(bool);
private:
typedef enum {SMAdd, SMClear,SMSub} SelMode;

View File

@ -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

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_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<QAction *> 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)

View File

@ -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 <meshlab/interfaces.h>
#include <QObject>
#include <QList>
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<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 *editSelect;
};
#endif