From e68e7615989bc0fe49921d19824f94c1d9a8478d Mon Sep 17 00:00:00 2001 From: Arjen Hiemstra Date: Fri, 19 Dec 2014 11:59:12 +0100 Subject: [PATCH] Set translate tool as active/inactive on selection change in Printer --- PrinterApplication.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/PrinterApplication.py b/PrinterApplication.py index fefe1d9866..02b6f48ac6 100644 --- a/PrinterApplication.py +++ b/PrinterApplication.py @@ -7,6 +7,7 @@ from UM.Math.Matrix import Matrix from UM.Resources import Resources from UM.Scene.BoxRenderer import BoxRenderer +from UM.Scene.Selection import Selection import os.path @@ -28,6 +29,8 @@ class PrinterApplication(QtApplication): controller.setCameraTool("CameraTool") controller.setSelectionTool("SelectionTool") + Selection.selectionChanged.connect(self.onSelectionChanged) + try: self.getMachineSettings().loadValuesFromFile(Resources.getPath(Resources.SettingsLocation, 'ultimaker2.cfg')) except FileNotFoundError: @@ -82,3 +85,11 @@ class PrinterApplication(QtApplication): def registerObjects(self, engine): pass + + def onSelectionChanged(self): + if Selection.getCount() > 0: + if not self.getController().getActiveTool(): + self.getController().setActiveTool('TranslateTool') + else: + if self.getController().getActiveTool() and self.getController().getActiveTool().getName() == 'TranslateTool': + self.getController().setActiveTool(None)