Skip to content

Instantly share code, notes, and snippets.

@comet0
Created June 19, 2016 00:39
Show Gist options
  • Save comet0/ca90a77aa2a1c60f7022b32483e958d5 to your computer and use it in GitHub Desktop.
Save comet0/ca90a77aa2a1c60f7022b32483e958d5 to your computer and use it in GitHub Desktop.
diff --git a/gns3/graphics_view.py b/gns3/graphics_view.py
index d027c72..8ce7b9e 100644
--- a/gns3/graphics_view.py
+++ b/gns3/graphics_view.py
@@ -521,6 +521,11 @@ class GraphicsView(QtWidgets.QGraphicsView):
"""
item = self.itemAt(event.pos())
+ if isinstance(item, NodeItem):
+ item.setPos(float(75 * round(item.x() / 75)), float(75 * round(item.y() / 75)))
+ for item in self.scene().selectedItems():
+ if isinstance(item, NodeItem):
+ item.setPos(float(75 * round(item.x() / 75)), float(75 * round(item.y() / 75)))
# If the left mouse button is not still pressed TOGETHER with the SHIFT key and neither is the middle button
# this means the user is no longer trying to drag the view
if self._dragging and not (event.buttons() == QtCore.Qt.LeftButton and event.modifiers() == QtCore.Qt.ShiftModifier) and not event.buttons() & QtCore.Qt.MidButton:
@@ -600,10 +605,14 @@ class GraphicsView(QtWidgets.QGraphicsView):
if item:
# show item coords in the status bar
coords = "X: {} Y: {} Z: {}".format(item.x(), item.y(), item.zValue())
+ if isinstance(item, NodeItem):
+ item.setPos(float(75 * round(item.x()/75)), float(75 * round(item.y()/75)))
self._main_window.uiStatusBar.showMessage(coords, 2000)
# force the children to redraw because of a problem with QGraphicsEffect
for item in self.scene().selectedItems():
+ if isinstance(item, NodeItem):
+ item.setPos(float(75 * round(item.x() / 75)), float(75 * round(item.y() / 75)))
for child in item.childItems():
child.update()
super().mouseMoveEvent(event)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment