From f37a64b65e7dcbc9c41d37cb07f5ba74c07bdeb5 Mon Sep 17 00:00:00 2001 From: Paolo Cignoni cignoni Date: Tue, 20 May 2008 13:51:12 +0000 Subject: [PATCH] Changed plugin name to the current standard --- .../edit_select/images/iconslice.png | Bin 0 -> 1970 bytes .../edit_select/images/sel_rect.png | Bin 0 -> 294 bytes .../edit_select/images/sel_rect_minus.png | Bin 0 -> 231 bytes .../edit_select/images/sel_rect_plus.png | Bin 0 -> 245 bytes .../edit_select/images/select_face.png | Bin 0 -> 2632 bytes src/meshlabplugins/edit_select/meshedit.cpp | 285 ++++++++++++++++++ src/meshlabplugins/edit_select/meshedit.h | 69 +++++ src/meshlabplugins/edit_select/meshedit.pro | 27 ++ src/meshlabplugins/edit_select/meshlab.qrc | 8 + 9 files changed, 389 insertions(+) create mode 100644 src/meshlabplugins/edit_select/images/iconslice.png create mode 100644 src/meshlabplugins/edit_select/images/sel_rect.png create mode 100644 src/meshlabplugins/edit_select/images/sel_rect_minus.png create mode 100644 src/meshlabplugins/edit_select/images/sel_rect_plus.png create mode 100644 src/meshlabplugins/edit_select/images/select_face.png create mode 100644 src/meshlabplugins/edit_select/meshedit.cpp create mode 100644 src/meshlabplugins/edit_select/meshedit.h create mode 100644 src/meshlabplugins/edit_select/meshedit.pro create mode 100644 src/meshlabplugins/edit_select/meshlab.qrc diff --git a/src/meshlabplugins/edit_select/images/iconslice.png b/src/meshlabplugins/edit_select/images/iconslice.png new file mode 100644 index 0000000000000000000000000000000000000000..be598b0ce6a76089d195a8b833f350979497ea8b GIT binary patch literal 1970 zcmV;j2Tk~iP)jfxJ)yrBrJwB?T#@6=TO% zryxyJY_-xEKiFCo9Y<%BFP-X4JLAjPGIhoo`i45%!RmBW#y6;<)*=X!K!lW_m}VrQ zP}`DbZju{w?>>Im-DG=T&%N2Wb#nhRJLjA|&w2Ja|Li&Y-zR%TRhiAOq7EQxlnIDB zfT%I+39x6vsmT1}P|+BkM^%V_MOAl%=hMZE5CANJebuliBzIp=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6qVxA;4t67dIyX?=4yez zm|h_(0q+!9b{A}X92QoadWsldgZM7kcS7}8G2=1_SSxb#R=D=_7?J*#z&04(4Zk_1 z+FR_{pb(nd1|NAGnpREomj7SD0k*=>UfBJTYJVv{Y=CP-mT!PtABCDK;4JxtP`*BJ zpOGoT%Lw`9#Zy`Y2lycj9e`*1RbMunZYFHcdF23f-5C%-1Vm8Ms|VZJ`TOIL=ve0_J{k~SpYH< zKb;kkFA?7Cef&;~`1Z#XGeW@s6K4G$P$nSi0HVf!0TFSY5i7ubl>h($07*qoM6N<$ Eg68maxc~qF literal 0 HcmV?d00001 diff --git a/src/meshlabplugins/edit_select/images/sel_rect.png b/src/meshlabplugins/edit_select/images/sel_rect.png new file mode 100644 index 0000000000000000000000000000000000000000..a2a28a25f27714687b8fbeafa4f65bb687b355ed GIT binary patch literal 294 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdzwj^(N7l!{JxM1({$v_d#0*}aI z1_o|n5N2eUHAey{$X?><>&kweNm87jwQA{v??9o=o-U3d5r^MSbL4AL;Bk%b6o0@r zXU6MIvv*zWJlUf>YnqzyEP?P(^84$!SFK_RW9n$}U{ESzofyMtr4YB)G;1xxl%Nxq zw*_(*y*J$@D}SwQ3$w!=1}nuYq7T}H>lhX*=skYQdvR*Mf5%gIoBeKKE=PDBLT`S* z@7KHaK_++E#*4{{vPTaG6^O{cJydk<@q=uq>pYj${ZDgRy|F!=xJ1o-?sE2xf7UHy kzTEiI;m!PlYw=gPq;gN5{3Yq`4Rk((r>mdKI;Vst0PECkf&c&j literal 0 HcmV?d00001 diff --git a/src/meshlabplugins/edit_select/images/sel_rect_minus.png b/src/meshlabplugins/edit_select/images/sel_rect_minus.png new file mode 100644 index 0000000000000000000000000000000000000000..bbfb389b960b2bc2aa6738081a78044bf01a59d1 GIT binary patch literal 231 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=ffJb)GJcArY-_r{3mkP~dU4KK%cG zQLW(PROTy|JqtSx9T%oEn@v!$%3^AmC&0h@X5EKY)*seI~tK;X@BCDS>s9gWO&xJSt@ZxK_ zC(sUfK}7!LT3`Ac dS{R?nCLMl!x8jSxJV2K-c)I$ztaD0e0syNMT1Ef> literal 0 HcmV?d00001 diff --git a/src/meshlabplugins/edit_select/images/sel_rect_plus.png b/src/meshlabplugins/edit_select/images/sel_rect_plus.png new file mode 100644 index 0000000000000000000000000000000000000000..26d6ccac4f9f30261841b080b6f8b4c7ec6eb3e1 GIT binary patch literal 245 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=ffJJ)SO(ArY-_r`+aiQQ&d0KKB3r z)0^TdD=r***KxAVv%{6ic5lPPC11ObPRKAemTr`I{Fa45!12nWX(>t8JseFbefzeg zG6=FTFc)lI%D~5RspH>Yz6TCZOqZ?#@_a-pIUYE8JY_o5z`;1L?M5`WX}t<(q4+!o zk9qH^W@X?0w9J07QIm!3vV*sN` z)1=g5oFcT=AALJx>yNfG?U*{rWIEas+h(-2Z88#Tu`^m9u`gP+0c+Z^l|nQcgGL2G z5cC4~^!x6)SFe`~_jN#+;hR~*J@?$R_g>#xd+oLMJ^(`)!eGZ@%H4N*5dDQIlrK?U zw*fW$+etC_c~7hjI;|R6A7QaiW>U#)0~n<*6M?pSfrcdD^nZXfeqR}D2R5rlY5`>3 zCn%3mW>C^74i3;Wn#xWBF6IDdih$a=z!g1kA5eM@aFGD=;q`{7aVI^XSLP@X&{Mh zT3 z9zcEYIm)9PQD%U3TcfdVB%t+eB*1ZlB#+l<+4CuDDQ`qy$U2W()-zotAWl&uSn3n)vH%yquu_@ zE9SKGTA!|eFUR;IEV91f2)h0)8Gh>Tz&yJ9yV*dCRUHL`QO-fd6PhV4K9LvHF(G<~ zvFFH@>r8_q)K8t=`aqLW(C$^AW=yblpjY^Vs_3&jZU@Z6sUOQBTmE zr&dl8KrcwV?wghlhXZf!+-aLLZ=S8h>0J2%@KLL+F9Z`HTx3U!I1oFN@|9P7F4>o$ zGcO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fd<6@y{)F? z<`K#QnEMV2hDTFVQ?G=Kgv697Q{2obxAoTeK=%MaUf>QAd4ZjS-hd4!PvBElaZB`C4vmb z0BwTkjnb4mHE^q-`SxLmGIy1bO%>AM&9UFd=I z4->sX<5Z?7OKO`zK0000 + +#include +#include +#include +#include "meshedit.h" +#include +#include + +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); + +} + +QList ExtraMeshEditPlugin::actions() const { + return actionList; +} + + +const QString ExtraMeshEditPlugin::Info(QAction *action) +{ + 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() +{ + 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 || + event->modifiers() == Qt::ShiftModifier ) + { + CMeshO::FaceIterator fi; + for(fi=m.cm.face.begin();fi!=m.cm.face.end();++fi) + if(!(*fi).IsD() && (*fi).IsS()) + LastSel.push_back(&*fi); + } + + selMode=SMClear; + if(event->modifiers()==Qt::ControlModifier) selMode=SMAdd; + if(event->modifiers()==Qt::ShiftModifier) selMode=SMSub; + + start=event->pos(); + cur=start; + return; + } + + void ExtraMeshEditPlugin::mouseMoveEvent (QAction *,QMouseEvent * event, MeshModel &/*m*/, GLArea * gla) + { + prev=cur; + cur=event->pos(); + isDragging = true; + + // now the management of the update + //static int lastMouse=0; + static int lastRendering=clock(); + int curT = clock(); + qDebug("mouseMoveEvent: curt %i last %i",curT,lastRendering); + if(gla->lastRenderingTime() < 50 || (curT - lastRendering) > 1000 ) + { + lastRendering=curT; + gla->update(); + qDebug("mouseMoveEvent: ----"); + } + else{ + gla->makeCurrent(); + glDrawBuffer(GL_FRONT); + DrawXORRect(gla,true); + glDrawBuffer(GL_BACK); + glFlush(); + } + } + + void ExtraMeshEditPlugin::mouseReleaseEvent (QAction *,QMouseEvent * event, MeshModel &/*m*/, GLArea * gla) + { + gla->update(); + prev=cur; + cur=event->pos(); + } + void ExtraMeshEditPlugin::DrawXORRect(GLArea * gla, bool doubleDraw) + { + glMatrixMode(GL_PROJECTION); + glPushMatrix(); + glLoadIdentity(); + glOrtho(0,gla->curSiz.width(),gla->curSiz.height(),0,-1,1); + glMatrixMode(GL_MODELVIEW); + glPushMatrix(); + glLoadIdentity(); + glPushAttrib(GL_ENABLE_BIT); + glDisable(GL_DEPTH_TEST); + glDisable(GL_LIGHTING); + glDisable(GL_TEXTURE_2D); + glEnable(GL_COLOR_LOGIC_OP); + glLogicOp(GL_XOR); + glColor3f(1,1,1); + if(doubleDraw) + { + glBegin(GL_LINE_LOOP); + glVertex2f(start.x(),start.y()); + glVertex2f(prev.x(),start.y()); + glVertex2f(prev.x(),prev.y()); + glVertex2f(start.x(),prev.y()); + glEnd(); + } + glBegin(GL_LINE_LOOP); + glVertex2f(start.x(),start.y()); + glVertex2f(cur.x(),start.y()); + glVertex2f(cur.x(),cur.y()); + glVertex2f(start.x(),cur.y()); + glEnd(); + glDisable(GL_LOGIC_OP); + + // Closing 2D + glPopAttrib(); + glPopMatrix(); // restore modelview + glMatrixMode(GL_PROJECTION); + glPopMatrix(); + glMatrixMode(GL_MODELVIEW); + + } + void ExtraMeshEditPlugin::Decorate(QAction * ac, MeshModel &m, GLArea * gla) + { + if(isDragging) + { + DrawXORRect(gla,false); + vector::iterator fpi; + // Starting Sel + vector NewSel; + QPoint mid=(start+cur)/2; + mid.setY(gla->curSiz.height()- mid.y()); + QPoint wid=(start-cur); + if(wid.x()<0) wid.setX(-wid.x()); + if(wid.y()<0) wid.setY(-wid.y()); + + /* CMeshO::FaceIterator fi; + for(fi=m.cm.face.begin(),fpi=NewSel.begin();fpi!=NewSel.end();++fi) + if(!(*fi).IsD()) { + if(&(*fi)!=*fpi) (*fpi)->ClearS(); + else { + (*fpi)->SetS(); + ++fpi; + } + } + + for(;fi!=m.cm.face.end();++fi) + if(!(*fi).IsD()) (*fi).ClearS(); + +*/ + + CMeshO::FaceIterator fi; + for(fi=m.cm.face.begin();fi!=m.cm.face.end();++fi) + if(!(*fi).IsD()) (*fi).ClearS(); + + glPushMatrix(); + glMultMatrix(m.cm.Tr); + GLPickTri::PickFace(mid.x(), mid.y(), m.cm, NewSel, wid.x(), wid.y()); + qDebug("Pickface: rect %i %i - %i %i",mid.x(),mid.y(),wid.x(),wid.y()); + qDebug("Pickface: Got %i on %i",NewSel.size(),m.cm.face.size()); + glPopMatrix(); + switch(selMode) + { + case SMSub : + for(fpi=LastSel.begin();fpi!=LastSel.end();++fpi) + (*fpi)->SetS(); + for(fpi=NewSel.begin();fpi!=NewSel.end();++fpi) + (*fpi)->ClearS(); + break; + case SMAdd : + for(fpi=LastSel.begin();fpi!=LastSel.end();++fpi) + (*fpi)->SetS(); + case SMClear : + for(fpi=NewSel.begin();fpi!=NewSel.end();++fpi) + (*fpi)->SetS(); + break; + } + isDragging=false; + } + + } + +void ExtraMeshEditPlugin::StartEdit(QAction * /*mode*/, MeshModel &m, GLArea *gla ) +{ + LastSel.clear(); + CMeshO::FaceIterator fi; + for(fi=m.cm.face.begin();fi!=m.cm.face.end();++fi) + if(!(*fi).IsD() && (*fi).IsS() ) + LastSel.push_back(&*fi); + + gla->setCursor(QCursor(QPixmap(":/images/sel_rect.png"),1,1)); + + connect(this, SIGNAL(setSelectionRendering(bool)),gla,SLOT(setSelectionRendering(bool)) ); + + setSelectionRendering(true); + +} + + + +Q_EXPORT_PLUGIN(ExtraMeshEditPlugin) diff --git a/src/meshlabplugins/edit_select/meshedit.h b/src/meshlabplugins/edit_select/meshedit.h new file mode 100644 index 000000000..82b959d6e --- /dev/null +++ b/src/meshlabplugins/edit_select/meshedit.h @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** Copyright (C) 2005-2005 Trolltech AS. All rights reserved. +** +** This file is part of the example classes of the Qt Toolkit. +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software. +** +** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for +** information about Qt Commercial License Agreements. +** +** Contact info@trolltech.com if any conditions of this licensing are +** not clear to you. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +****************************************************************************/ + +#ifndef EDITPLUGIN_H +#define EDITPLUGIN_H + +#include +#include +#include + +#include +#include + +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(); + + 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); + +private: + typedef enum {SMAdd, SMClear,SMSub} SelMode; + SelMode selMode; + void DrawXORRect(GLArea * gla, bool doubleDraw); +}; + +#endif diff --git a/src/meshlabplugins/edit_select/meshedit.pro b/src/meshlabplugins/edit_select/meshedit.pro new file mode 100644 index 000000000..9063c9e45 --- /dev/null +++ b/src/meshlabplugins/edit_select/meshedit.pro @@ -0,0 +1,27 @@ +TEMPLATE = lib +CONFIG += plugin +INCLUDEPATH += ../.. ../../../../sf ../../../../code/lib/glew/include +HEADERS = meshedit.h +SOURCES = meshedit.cpp ../../../../code/lib/glew/src/glew.c +TARGET = meshedit +DESTDIR = ../../meshlab/plugins +DEFINES += GLEW_STATIC +QT += opengl +RESOURCES = meshlab.qrc + +# the following line is needed to avoid mismatch between +# the awful min/max macros of windows and the limits max +win32:DEFINES += NOMINMAX +CONFIG += debug_and_release + +# mac:CONFIG += x86 ppc + +contains(TEMPLATE,lib) { + CONFIG(debug, debug|release) { + unix:TARGET = $$member(TARGET, 0)_debug + else:TARGET = $$member(TARGET, 0)d + } +} + + + diff --git a/src/meshlabplugins/edit_select/meshlab.qrc b/src/meshlabplugins/edit_select/meshlab.qrc new file mode 100644 index 000000000..b290a9bb3 --- /dev/null +++ b/src/meshlabplugins/edit_select/meshlab.qrc @@ -0,0 +1,8 @@ + + + images/select_face.png + images/sel_rect.png + images/sel_rect_plus.png + images/sel_rect_minus.png + +