From 5cf9294dc7afbdd21b910eca5e6a3fd456b9ade3 Mon Sep 17 00:00:00 2001 From: Tats Date: Sun, 28 Dec 2014 16:16:21 -0500 Subject: [PATCH] Only update vertex coordinates when control point is actually moved (as opposed to on any event). --- Mapper.cpp | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/Mapper.cpp b/Mapper.cpp index 0d0715d..32a0d5f 100644 --- a/Mapper.cpp +++ b/Mapper.cpp @@ -21,24 +21,25 @@ #include "Mapper.h" #include "MainWindow.h" + bool ShapeGraphicsItem::sceneEventFilter(QGraphicsItem * watched, QEvent * event) { - if (watched == this) + VertexGraphicsItem* child = static_cast(watched); + Q_ASSERT(child); + + // Change vertex in model according to moved item. + if (event->type() == QEvent::GraphicsSceneMouseMove) { - _syncShape(); - } - else { - VertexGraphicsItem* child = static_cast(watched); - Q_ASSERT(child); - qreal offset = MM::VERTEX_SELECT_RADIUS / 2.0; int idx = childItems().indexOf(watched); Q_ASSERT(idx != -1); QPointF pos = child->pos(); - qDebug() << "child(" << idx << ") position = " << watched->pos() << " map from " << mapFromItem(watched, watched->pos()) << endl; _shape->setVertex(idx, pos); -// child->setRect(pos.x()-offset, pos.y()-offset, MM::VERTEX_SELECT_RADIUS, MM::VERTEX_SELECT_RADIUS); - this->update(); } + + // Refresh this shape. + update(); + + // Returns false to allow the child item to process its event. return false; }