Created
June 20, 2016 12:11
-
-
Save comet0/6251ab4c29d066390cf04a0350d69a00 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/gns3/items/node_item.py b/gns3/items/node_item.py | |
index 128f6fc..a7a64b6 100644 | |
--- a/gns3/items/node_item.py | |
+++ b/gns3/items/node_item.py | |
@@ -380,7 +380,9 @@ class NodeItem(): | |
# was causing infinite recursion loops when placed within the below if statements | |
if change == QtWidgets.QGraphicsItem.ItemPositionHasChanged and self._main_window.uiSnapToGridAction.isChecked(): | |
GRID_SIZE = 75 | |
- self.setPos(float(GRID_SIZE * round(self.x() / GRID_SIZE)), float(GRID_SIZE * round(self.y() / GRID_SIZE))) | |
+ tmp_x = (GRID_SIZE * round(self.x() / GRID_SIZE)) - ((self.boundingRect().width() / 2) % GRID_SIZE) | |
+ tmp_y = (GRID_SIZE * round(self.y() / GRID_SIZE)) - ((self.boundingRect().height() / 2) % GRID_SIZE) | |
+ self.setPos(tmp_x, tmp_y) | |
# dynamically change the renderer when this node item is selected/unselected. | |
if change == QtWidgets.QGraphicsItem.ItemSelectedChange: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment