From f66f67c6543e919e57cea2f3161b486f9454d434 Mon Sep 17 00:00:00 2001 From: Tats Date: Tue, 10 Dec 2013 22:27:39 -0500 Subject: [PATCH] Better managing of vertex selection --- MapperGLCanvas.cpp | 12 ++++++++++-- MapperGLCanvas.h | 4 ++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/MapperGLCanvas.cpp b/MapperGLCanvas.cpp index a7bb431..ad0df8b 100644 --- a/MapperGLCanvas.cpp +++ b/MapperGLCanvas.cpp @@ -22,7 +22,7 @@ #include "MainWindow.h" MapperGLCanvas::MapperGLCanvas(QWidget* parent, const QGLWidget * shareWidget) - : QGLWidget(parent, shareWidget), _mousepressed(false), _active_vertex(0) + : QGLWidget(parent, shareWidget), _mousepressed(false), _active_vertex(NO_VERTEX) { } @@ -149,7 +149,7 @@ void MapperGLCanvas::mouseMoveEvent(QMouseEvent* event) { // std::cout << "Move event " << std::endl; Shape* shape = getCurrentShape(); - if (shape) + if (shape && _active_vertex != NO_VERTEX) { Point p = shape->getVertex(_active_vertex); p.x = event->x(); @@ -287,3 +287,11 @@ void MapperGLCanvas::glueVertex(Shape *orig, Point *p) } } } + +void MapperGLCanvas::deselectAll() +{ + _active_vertex = NO_VERTEX; + _shapegrabbed = false; + _shapefirstgrab = false; + _mousepressed = false; +} diff --git a/MapperGLCanvas.h b/MapperGLCanvas.h index 0cbf551..9d497f3 100644 --- a/MapperGLCanvas.h +++ b/MapperGLCanvas.h @@ -77,6 +77,10 @@ signals: public slots: void updateCanvas(); + void deselectAll(); + +public: + static const int NO_VERTEX = -1; }; #endif /* MAPPERGLCANVAS_H_ */