From 7ba9c325974ea82cfecc33c7c2ded68dc309c587 Mon Sep 17 00:00:00 2001 From: Paolo Cignoni cignoni Date: Mon, 13 Oct 2008 10:07:23 +0000 Subject: [PATCH] Updated to remove PluginInfo, to use new MeshEditInterface, and to use new factory way of creating edit tools --- src/meshlabplugins/edit_fit/edit_fit.pro | 6 ++-- src/meshlabplugins/edit_fit/editfit.cpp | 42 +++++++++--------------- src/meshlabplugins/edit_fit/editfit.h | 22 +++++-------- 3 files changed, 28 insertions(+), 42 deletions(-) diff --git a/src/meshlabplugins/edit_fit/edit_fit.pro b/src/meshlabplugins/edit_fit/edit_fit.pro index 322e92172..71018d6f5 100644 --- a/src/meshlabplugins/edit_fit/edit_fit.pro +++ b/src/meshlabplugins/edit_fit/edit_fit.pro @@ -3,13 +3,15 @@ include (../../shared.pri) # Lib name TARGET = edit_fit -HEADERS = editfit.h\ +HEADERS = edit_fit_factory.h \ + editfit.h\ cylinder.h\ box.h\ primitive.h\ fittoolbox.h -SOURCES = editfit.cpp\ +SOURCES = edit_fit_factory.cpp \ + editfit.cpp\ fittoolbox.cpp\ primitive.cpp\ $$GLEWCODE diff --git a/src/meshlabplugins/edit_fit/editfit.cpp b/src/meshlabplugins/edit_fit/editfit.cpp index c4b478da2..4b1ff9a12 100644 --- a/src/meshlabplugins/edit_fit/editfit.cpp +++ b/src/meshlabplugins/edit_fit/editfit.cpp @@ -27,30 +27,19 @@ $Log: editfit.cpp,v $ #include "editfit.h" using namespace vcg; -EditFitPlugin::EditFitPlugin():startGesture(false),pickMode(false){ - actionList << new QAction(QIcon(":/images/icon_measure.png"),"Fitting Tool", this); - foreach(QAction *editAction, actionList) - editAction->setCheckable(true); + +EditFitPlugin::EditFitPlugin():startGesture(false),pickMode(false) +{ toolBox=NULL; showGesture3D=true; } -QList EditFitPlugin::actions() const { - return actionList; -} -const QString EditFitPlugin::Info(QAction *action){ - if( action->text() != tr("Fitting Tool") ) assert (0); +const QString EditFitPlugin::Info() +{ return tr("Allow to fit some primitive."); } -const PluginInfo &EditFitPlugin::Info(){ - static PluginInfo ai; - ai.Date=tr(__DATE__); - ai.Version = tr("0.1"); - ai.Author = ("Davide Portelli"); - return ai; -} -void EditFitPlugin::StartEdit(QAction *, MeshModel &, GLArea * gla){ +void EditFitPlugin::StartEdit(MeshModel &, GLArea * gla){ //Disabilito lo swap automatico del double buffering //e lo gestisco io direttamente con gla->swapBuffers(). if(toolBox==NULL){ @@ -65,7 +54,7 @@ void EditFitPlugin::StartEdit(QAction *, MeshModel &, GLArea * gla){ gla->update(); glewInit(); } -void EditFitPlugin::EndEdit (QAction *, MeshModel &, GLArea *){ +void EditFitPlugin::EndEdit(MeshModel &, GLArea *){ if(toolBox!=NULL){ delete toolBox; toolBox=NULL; @@ -77,7 +66,7 @@ void EditFitPlugin::EndEdit (QAction *, MeshModel &, GLArea *){ listaPrimitive.clear(); } -void EditFitPlugin::mousePressEvent (QAction *, QMouseEvent *ev, MeshModel &, GLArea *){ +void EditFitPlugin::mousePressEvent(QMouseEvent *ev, MeshModel &, GLArea *){ if(ev->button()==Qt::LeftButton){ startGesture=true; vcg::Point2 tmp(ev->x(),ev->y()); @@ -87,7 +76,7 @@ void EditFitPlugin::mousePressEvent (QAction *, QMouseEvent *ev, MeshModel & listaPrimitive.clear(); } } -void EditFitPlugin::mouseMoveEvent (QAction *, QMouseEvent *ev, MeshModel &, GLArea * gla){ +void EditFitPlugin::mouseMoveEvent(QMouseEvent *ev, MeshModel &, GLArea * gla){ if(startGesture){ vcg::Point2 newPoint(ev->x(),ev->y()); LineRasterDDA(lastPoint.X(),lastPoint.Y(),newPoint.X(),newPoint.Y()); @@ -95,7 +84,7 @@ void EditFitPlugin::mouseMoveEvent (QAction *, QMouseEvent *ev, MeshModel &, } gla->update(); } -void EditFitPlugin::mouseReleaseEvent (QAction *, QMouseEvent *ev, MeshModel &, GLArea * gla){ +void EditFitPlugin::mouseReleaseEvent(QMouseEvent *ev, MeshModel &, GLArea * gla){ if(ev->button()==Qt::LeftButton){ startGesture=false; pickMode=true; @@ -103,7 +92,7 @@ void EditFitPlugin::mouseReleaseEvent (QAction *, QMouseEvent *ev, MeshModel & //DrawInPickingMode(gla); //ProcessPick(gla); } -void EditFitPlugin::Decorate (QAction *, MeshModel &, GLArea * gla){ +void EditFitPlugin::Decorate(MeshModel &, GLArea * gla){ if(pickMode){ DrawInPickingMode(gla); //ProcessPick(gla); @@ -195,7 +184,7 @@ void EditFitPlugin::DrawInPickingMode(GLArea * gla){ glPointSize(1); glDrawBuffer(GL_BACK); /*Disegno ogni punto con un colore diverso partendo da RGBA==(0,0,0,0) - fino al massimo RGBA==(255,255,255,254) perchè (255,255,255,255) è + fino al massimo RGBA==(255,255,255,254) perch� (255,255,255,255) � lo sfondo.Quindi al massimo posso distingure 4294967295 punti* } */ @@ -203,7 +192,7 @@ void EditFitPlugin::DrawInPickingMode(GLArea * gla){ void EditFitPlugin::DrawInPickingMode(GLArea * gla){ /*Disegno ogni punto con un colore diverso partendo da RGBA==(0,0,0,0) - fino al massimo RGBA==(255,255,255,254) perchè (255,255,255,255) è + fino al massimo RGBA==(255,255,255,254) perch� (255,255,255,255) � lo sfondo.Quindi al massimo posso distingure 4294967295 punti*/ QGLFramebufferObject framebuffer(gla->width(),gla->height(),QGLFramebufferObject::Depth,GL_TEXTURE_RECTANGLE_EXT); @@ -246,7 +235,7 @@ void EditFitPlugin::ProcessPick (const QImage &img,GLArea * gla){ unsigned int z; //Visto che in drawInPickingMode disegno pixel grossi 5, inserirei sempre lo stesso punto3D - //perchè per piu pixel ha sempre lo stesso colore, per questo uso last. + //perch� per piu pixel ha sempre lo stesso colore, per questo uso last. unsigned int last=std::numeric_limits::max(); //sarebbe 4294967295; for(int i=0;i<(int)gesture2D.size();i++){ QRgb k=img.pixel(gesture2D[i].X(),gesture2D[i].Y()); @@ -281,7 +270,7 @@ void EditFitPlugin::ProcessPick (const QImage &img,GLArea * gla){ void EditFitPlugin::ProcessPick (GLArea * gla){ unsigned int k=0; //Visto che in drawInPickingMode disegno pixel grossi 5, inserirei sempre lo stesso punto3D - //perchè per piu pixel ha sempre lo stesso colore, per questo uso last. + //perch� per piu pixel ha sempre lo stesso colore, per questo uso last. unsigned int last=std::numeric_limits::max(); //sarebbe 4294967295; glReadBuffer(GL_BACK); glPixelStorei(GL_PACK_ALIGNMENT, 1); @@ -396,4 +385,3 @@ void EditFitPlugin::change_checkBoxGesture3d(bool b){ void EditFitPlugin::slot_UpdateGlArea(){ //gla->update(); } -Q_EXPORT_PLUGIN(EditFitPlugin) \ No newline at end of file diff --git a/src/meshlabplugins/edit_fit/editfit.h b/src/meshlabplugins/edit_fit/editfit.h index 39d872db1..4cd790bd7 100644 --- a/src/meshlabplugins/edit_fit/editfit.h +++ b/src/meshlabplugins/edit_fit/editfit.h @@ -62,29 +62,25 @@ $Log: editfit.h,v $ #include "box.h" #include "fittoolbox.h" - - class EditFitPlugin : public QObject, public MeshEditInterface { Q_OBJECT - Q_INTERFACES(MeshEditInterface) + Q_INTERFACES(MeshEditInterface) enum { CYLINDER, BOX }; public: EditFitPlugin(); ~EditFitPlugin(); - const QString Info(QAction *); - const PluginInfo &Info(); - QList actions() const ; + static const QString Info(); - void StartEdit(QAction *, MeshModel &, GLArea *); - void EndEdit (QAction *, MeshModel &, GLArea *); - void Decorate (QAction *, MeshModel &, GLArea *); + void StartEdit(MeshModel &, GLArea *); + void EndEdit(MeshModel &, GLArea *); + void Decorate(MeshModel &, GLArea *); - void mousePressEvent (QAction *, QMouseEvent *, MeshModel &, GLArea *); - void mouseMoveEvent (QAction *, QMouseEvent *, MeshModel &, GLArea *); - void mouseReleaseEvent (QAction *, QMouseEvent *, MeshModel &, GLArea *); + void mousePressEvent(QMouseEvent *, MeshModel &, GLArea *); + void mouseMoveEvent(QMouseEvent *, MeshModel &, GLArea *); + void mouseReleaseEvent(QMouseEvent *, MeshModel &, GLArea *); public slots: void change_buttonCylinder(); @@ -103,7 +99,7 @@ private: FitToolBox *toolBox; QFont qFont; vcg::Point2i lastPoint; //L'ultimo punto 2d - QList actionList; + std::vector gesture2D; //La selezione dei punti 2d std::vector gesture3D; //La selezione dei punti 3d std::vector listaPrimitive;