From fe7f3be7f0be7f4aa425e78fe1b6d68a3c64dbcd Mon Sep 17 00:00:00 2001 From: Paolo Cignoni cignoni Date: Sun, 25 Apr 2010 23:58:35 +0000 Subject: [PATCH] minor: rendering of laser beam is done in image space now and initial beam is propotional to screen size rather than model diagonal --- src/meshlabplugins/edit_scan/edit_scan.cpp | 80 ++++++++----------- src/meshlabplugins/edit_scan/edit_scan.h | 6 +- .../edit_scan/edit_scan.pro.user | 18 ++--- 3 files changed, 45 insertions(+), 59 deletions(-) diff --git a/src/meshlabplugins/edit_scan/edit_scan.cpp b/src/meshlabplugins/edit_scan/edit_scan.cpp index fa88848d0..2de1bacbd 100644 --- a/src/meshlabplugins/edit_scan/edit_scan.cpp +++ b/src/meshlabplugins/edit_scan/edit_scan.cpp @@ -84,6 +84,9 @@ bool VirtualScan::StartEdit(MeshDocument& md, GLArea* gla){ connect(widget, SIGNAL(scan_requested()), this, SLOT(scan_requested())); + //--- Compute initial beam + laser_parameter_updated(); + return true; } // We need to refresh the laser scan completely! @@ -91,13 +94,18 @@ void VirtualScan::laser_parameter_updated(){ //--- Retrieve values from GUI int period = 1000 / widget->getSampfreq(); int numsamp = widget->getNumsample(); - float width = widget->getScanwidth()*md->mm()->cm.bbox.Diag()/100.0; - qDebug("period: %d, samples: %d, width: %f", period, numsamp, width); + // Compute start and stop coordinates in image space + Point2f delta( widget->getScanwidth()*gla->height()/(3.0*100.0), 0 ); + Point2f str( gla->width()/2, gla->height()/2 ); str-=delta; + Point2f sto( gla->width()/2, gla->height()/2 ); sto+=delta; + // float width = *md->mm()->cm.bbox.MaxDim()/100.0; + qDebug("period: %d, samples: %d", period, numsamp); + qDebug() << toString(str) << " " << toString(sto); //--- Create the geometry of the scanline gla->update(); // since we use gluproject - sline = ScanLine( numsamp, width ); + sline = ScanLine( numsamp, str, sto); // sline = ScanLineGeom( 10, .1 ); // hardcoded parameters (GUI independent) //--- Create a timer which enables scanning periodically @@ -173,26 +181,16 @@ void VirtualScan::Decorate(MeshModel& mm, GLArea* gla){ sline.render(gla); } -ScanLine::ScanLine(int N, float width){ - // Compute start and stop coordinates in image space - Point2f srt = myGluProject(Point3f(-width/2,0,0)); - Point2f sto = myGluProject(Point3f(+width/2,0,0)); - float delta = width/N; - // qDebug() << "Scanpoint list: "; - for( float i=0; i<=1; i+=delta ){ - if( N==1 ) - i = .5; - Point2f curr = srt*(1-i) + sto*i; +ScanLine::ScanLine(int N, Point2f& srt, Point2f& end ){ + float delta = 1.0 / (N-1); + qDebug() << "Scanpoint list: "; + float alpha=0; + for( int i=0; iwidth(), gla->height(), 0, -1, 1); + glOrtho(0, gla->width(), 0, gla->height(), -1, 1); + glMatrixMode(GL_MODELVIEW); + glPushMatrix(); + glLoadIdentity(); + glColor3f(1.0,0.0,0.0); + glBegin(GL_POINTS); + for(int i=0; iwidth()/2, gla->height()/2 ); + glEnd(); + // glRectf(100,100, 200, 200); + glPopMatrix(); // restore modelview + // The pop must be done in the projection mode + glMatrixMode(GL_PROJECTION); glPopMatrix(); - glMatrixMode(GL_MODELVIEW); - glPushMatrix(); - glLoadIdentity(); - glRectf(100,100, 200, 200); - glPopMatrix(); -#endif } // Must be at the end of everything in CPP file or get segfault at plugin load diff --git a/src/meshlabplugins/edit_scan/edit_scan.h b/src/meshlabplugins/edit_scan/edit_scan.h index f32b2e7d2..00282359d 100644 --- a/src/meshlabplugins/edit_scan/edit_scan.h +++ b/src/meshlabplugins/edit_scan/edit_scan.h @@ -9,19 +9,17 @@ using namespace vcg; using namespace std; -#define SCANPOINTSIZE 5 +#define SCANPOINTSIZE 2 class ScanLine{ public: // Screen offsets of scan points vector soff; - // Object space locations (for rendering) - vector soff_obj; Box2i bbox; bool isScanning; ScanLine(){} - ScanLine(int N, float aperture); + ScanLine(int N, Point2f&, Point2f& ); void render(GLArea* gla); }; diff --git a/src/meshlabplugins/edit_scan/edit_scan.pro.user b/src/meshlabplugins/edit_scan/edit_scan.pro.user index f8a94fe43..aecd47737 100644 --- a/src/meshlabplugins/edit_scan/edit_scan.pro.user +++ b/src/meshlabplugins/edit_scan/edit_scan.pro.user @@ -72,15 +72,15 @@ Debug - Apple_PubSub_Socket_Render=/tmp/launch-qYm1RP/Render + Apple_PubSub_Socket_Render=/tmp/launch-HB6srV/Render COMMAND_MODE=unix2003 - DISPLAY=/tmp/launch-nJGktF/:0 + DISPLAY=/tmp/launch-6Z6Ywn/:0 HOME=/Users/ata2 LOGNAME=ata2 PATH=/Developer/Tools/Qt:/usr/bin:/bin:/usr/sbin:/sbin QTDIR=/usr/local/Qt4.6 SHELL=/bin/bash - SSH_AUTH_SOCK=/tmp/launch-riNXRq/Listeners + SSH_AUTH_SOCK=/tmp/launch-JDaVUl/Listeners TMPDIR=/var/folders/nT/nTstT998GAStacv9t5mUAk+++TQ/-Tmp-/ USER=ata2 __CF_USER_TEXT_ENCODING=0x1F7:0:0 @@ -101,15 +101,15 @@ Debug - Apple_PubSub_Socket_Render=/tmp/launch-qYm1RP/Render + Apple_PubSub_Socket_Render=/tmp/launch-HB6srV/Render COMMAND_MODE=unix2003 - DISPLAY=/tmp/launch-nJGktF/:0 + DISPLAY=/tmp/launch-6Z6Ywn/:0 HOME=/Users/ata2 LOGNAME=ata2 PATH=/Developer/Tools/Qt:/usr/bin:/bin:/usr/sbin:/sbin QTDIR=/usr/local/Qt4.6 SHELL=/bin/bash - SSH_AUTH_SOCK=/tmp/launch-riNXRq/Listeners + SSH_AUTH_SOCK=/tmp/launch-JDaVUl/Listeners TMPDIR=/var/folders/nT/nTstT998GAStacv9t5mUAk+++TQ/-Tmp-/ USER=ata2 __CF_USER_TEXT_ENCODING=0x1F7:0:0 @@ -128,15 +128,15 @@ Debug - Apple_PubSub_Socket_Render=/tmp/launch-qYm1RP/Render + Apple_PubSub_Socket_Render=/tmp/launch-HB6srV/Render COMMAND_MODE=unix2003 - DISPLAY=/tmp/launch-nJGktF/:0 + DISPLAY=/tmp/launch-6Z6Ywn/:0 HOME=/Users/ata2 LOGNAME=ata2 PATH=/Developer/Tools/Qt:/usr/bin:/bin:/usr/sbin:/sbin QTDIR=/usr/local/Qt4.6 SHELL=/bin/bash - SSH_AUTH_SOCK=/tmp/launch-riNXRq/Listeners + SSH_AUTH_SOCK=/tmp/launch-JDaVUl/Listeners TMPDIR=/var/folders/nT/nTstT998GAStacv9t5mUAk+++TQ/-Tmp-/ USER=ata2 __CF_USER_TEXT_ENCODING=0x1F7:0:0