Replaced hack for setting extruders with more robust setter

CURA-1263
This commit is contained in:
Jaime van Kessel 2016-11-16 14:54:48 +01:00
parent b175e6876f
commit 053f0ca031
3 changed files with 17 additions and 5 deletions

View file

@ -150,6 +150,18 @@ class ExtruderManager(QObject):
if changed:
self.extrudersChanged.emit(machine_id)
def registerExtruder(self, extruder_train, machine_id):
changed = False
if machine_id not in self._extruder_trains:
self._extruder_trains[machine_id] = {}
changed = True
if extruder_train:
self._extruder_trains[machine_id][extruder_train.getMetaDataEntry("position")] = extruder_train
changed = True
if changed:
self.extrudersChanged.emit(machine_id)
## Creates a container stack for an extruder train.
#
# The container stack has an extruder definition at the bottom, which is

View file

@ -301,11 +301,11 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
quality_changes_index = stack.getContainerIndex(old_container)
stack.replaceContainer(quality_changes_index, container)
# TODO: This is nasty hack; this should be made way more robust (setter?)
if global_stack.getId() not in ExtruderManager.getInstance()._extruder_trains:
ExtruderManager.getInstance()._extruder_trains[global_stack.getId()] = {}
for stack in extruder_stacks:
ExtruderManager.getInstance()._extruder_trains[global_stack.getId()][stack.getMetaDataEntry("position")] = stack
ExtruderManager.getInstance().registerExtruder(stack, global_stack.getId())
else:
# Machine has no extruders, but it needs to be registered with the extruder manager.
ExtruderManager.getInstance().registerExtruder(None, global_stack.getId())
Logger.log("d", "Workspace loading is notifying rest of the code of changes...")
# Notify everything/one that is to notify about changes.

View file

@ -128,7 +128,7 @@ UM.Dialog
width: parent.width
height: visible ? 25 : 0
text: catalog.i18nc("@info:tooltip", "How should the conflict in the material(s) be resolved?")
visible: false #manager.materialConflict
visible: false //manager.materialConflict
Row
{
width: parent.width