From 7b09bb0c9e9d0235403548594f1e5dc5b8699d7e Mon Sep 17 00:00:00 2001 From: fieldOfView Date: Tue, 8 Dec 2015 16:44:21 +0100 Subject: [PATCH 1/3] Deley center_on_selection cameraAnimation until mouse release --- cura/CuraApplication.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/cura/CuraApplication.py b/cura/CuraApplication.py index 7c9f993e21..15726cbb65 100644 --- a/cura/CuraApplication.py +++ b/cura/CuraApplication.py @@ -22,6 +22,7 @@ from UM.Message import Message from UM.PluginRegistry import PluginRegistry from UM.JobQueue import JobQueue from UM.Math.Polygon import Polygon +from UM.Event import MouseEvent from UM.Scene.BoxRenderer import BoxRenderer from UM.Scene.Selection import Selection @@ -231,9 +232,9 @@ class CuraApplication(QtApplication): else: self.getController().setActiveTool("TranslateTool") if Preferences.getInstance().getValue("view/center_on_select"): - self._camera_animation.setStart(self.getController().getTool("CameraTool").getOrigin()) - self._camera_animation.setTarget(Selection.getSelectedObject(0).getWorldPosition()) - self._camera_animation.start() + print("connect") + print(self.getController().getInputDevice("qt_mouse").event) + self.getController().getInputDevice("qt_mouse").event.connect(self.onMouseEventAfterSelectionChanged) else: if self.getController().getActiveTool(): self._previous_active_tool = self.getController().getActiveTool().getPluginId() @@ -241,6 +242,15 @@ class CuraApplication(QtApplication): else: self._previous_active_tool = None + def onMouseEventAfterSelectionChanged(self, event): + print("event") + if event.type == MouseEvent.MouseReleaseEvent: + print("disconnect") + self.getController().getInputDevice("qt_mouse").event.disconnect(self.onMouseEventAfterSelectionChanged) + self._camera_animation.setStart(self.getController().getTool("CameraTool").getOrigin()) + self._camera_animation.setTarget(Selection.getSelectedObject(0).getWorldPosition()) + self._camera_animation.start() + requestAddPrinter = pyqtSignal() activityChanged = pyqtSignal() sceneBoundingBoxChanged = pyqtSignal() From 3a64bc58b7c9fb3d1ff5496dd7df01e4f7b53fb3 Mon Sep 17 00:00:00 2001 From: fieldOfView Date: Sat, 23 Jan 2016 16:58:52 +0100 Subject: [PATCH 2/3] Reimplement fix without connecting/disconnecting events repeatedly --- cura/CuraApplication.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/cura/CuraApplication.py b/cura/CuraApplication.py index 15726cbb65..e66c2afcbe 100644 --- a/cura/CuraApplication.py +++ b/cura/CuraApplication.py @@ -101,10 +101,12 @@ class CuraApplication(QtApplication): self._platform_activity = False self._scene_boundingbox = AxisAlignedBox() self._job_name = None + self._center_after_select = False self.getMachineManager().activeMachineInstanceChanged.connect(self._onActiveMachineChanged) self.getMachineManager().addMachineRequested.connect(self._onAddMachineRequested) self.getController().getScene().sceneChanged.connect(self.updatePlatformActivity) + self.getController().toolOperationStopped.connect(self._onToolOperationStopped) Resources.addType(self.ResourceTypes.QmlFiles, "qml") Resources.addType(self.ResourceTypes.Firmware, "firmware") @@ -232,9 +234,7 @@ class CuraApplication(QtApplication): else: self.getController().setActiveTool("TranslateTool") if Preferences.getInstance().getValue("view/center_on_select"): - print("connect") - print(self.getController().getInputDevice("qt_mouse").event) - self.getController().getInputDevice("qt_mouse").event.connect(self.onMouseEventAfterSelectionChanged) + self._center_after_select = True else: if self.getController().getActiveTool(): self._previous_active_tool = self.getController().getActiveTool().getPluginId() @@ -242,11 +242,9 @@ class CuraApplication(QtApplication): else: self._previous_active_tool = None - def onMouseEventAfterSelectionChanged(self, event): - print("event") - if event.type == MouseEvent.MouseReleaseEvent: - print("disconnect") - self.getController().getInputDevice("qt_mouse").event.disconnect(self.onMouseEventAfterSelectionChanged) + def _onToolOperationStopped(self, event): + if self._center_after_select: + self._center_after_select = False self._camera_animation.setStart(self.getController().getTool("CameraTool").getOrigin()) self._camera_animation.setTarget(Selection.getSelectedObject(0).getWorldPosition()) self._camera_animation.start() From e723b78f09c25729ac74fa78b0b74bd03e4b2f67 Mon Sep 17 00:00:00 2001 From: fieldOfView Date: Sat, 23 Jan 2016 17:15:42 +0100 Subject: [PATCH 3/3] Remove vestigial import --- cura/CuraApplication.py | 1 - 1 file changed, 1 deletion(-) diff --git a/cura/CuraApplication.py b/cura/CuraApplication.py index e66c2afcbe..437323dc2e 100644 --- a/cura/CuraApplication.py +++ b/cura/CuraApplication.py @@ -22,7 +22,6 @@ from UM.Message import Message from UM.PluginRegistry import PluginRegistry from UM.JobQueue import JobQueue from UM.Math.Polygon import Polygon -from UM.Event import MouseEvent from UM.Scene.BoxRenderer import BoxRenderer from UM.Scene.Selection import Selection