Set translate tool as active/inactive on selection change in Printer

This commit is contained in:
Arjen Hiemstra 2014-12-19 11:59:12 +01:00
parent 3786ced279
commit e68e761598

View file

@ -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)