Fix NozzleMenu active nozzle bullet

This commit is contained in:
Lipu Fei 2018-02-21 16:28:11 +01:00
parent 244b109403
commit 7a3ebe1a42
3 changed files with 10 additions and 20 deletions

View File

@ -30,10 +30,11 @@ class ExtruderManager(QObject):
def __init__(self, parent = None):
super().__init__(parent)
self._application = Application.getInstance()
self._extruder_trains = {} # Per machine, a dictionary of extruder container stack IDs. Only for separately defined extruders.
self._active_extruder_index = -1 # Indicates the index of the active extruder stack. -1 means no active extruder stack
self._selected_object_extruders = []
self._global_container_stack_definition_id = None
self._addCurrentMachineExtruders()
#Application.getInstance().globalContainerStackChanged.connect(self._globalContainerStackChanged)
@ -365,10 +366,6 @@ class ExtruderManager(QObject):
return result[:machine_extruder_count]
def _globalContainerStackChanged(self) -> None:
global_container_stack = Application.getInstance().getGlobalContainerStack()
if global_container_stack and global_container_stack.getBottom() and global_container_stack.getBottom().getId() != self._global_container_stack_definition_id:
self._global_container_stack_definition_id = global_container_stack.getBottom().getId()
# If the global container changed, the machine changed and might have extruders that were not registered yet
self._addCurrentMachineExtruders()
@ -376,7 +373,7 @@ class ExtruderManager(QObject):
## Adds the extruders of the currently active machine.
def _addCurrentMachineExtruders(self) -> None:
global_stack = Application.getInstance().getGlobalContainerStack()
global_stack = self._application.getGlobalContainerStack()
extruders_changed = False
if global_stack:

View File

@ -311,10 +311,11 @@ class MachineManager(QObject):
ExtruderManager.getInstance().setActiveExtruderIndex(0) # Switch to first extruder
Application.getInstance().setGlobalContainerStack(global_stack)
self._global_container_stack = global_stack
self.globalContainerChanged.emit()
self._onGlobalContainerChanged()
Application.getInstance().setGlobalContainerStack(global_stack)
ExtruderManager.getInstance()._globalContainerStackChanged()
self._initMachineState(containers[0])
self.globalContainerChanged.emit()
self._onGlobalContainerChanged()
self.__emitChangedSignals()

View File

@ -13,22 +13,12 @@ Menu
title: "Nozzle"
property int extruderIndex: 0
property QtObject extruderStack: Cura.MachineManager.getExtruder(menu.extruderIndex)
property bool hasExtruderStack: extruderStack != null
Cura.NozzleModel
{
id: nozzleModel
}
Connections
{
target: Cura.MachineManager
onGlobalContainerChanged: {
menu.extruderStack = Cura.MachineManager.getExtruder(menu.extruderIndex);
}
}
Instantiator
{
model: nozzleModel
@ -37,10 +27,12 @@ Menu
{
text: model.hotend_name
checkable: true
checked: menu.hasExtruderStack && extruderStack.variant.name == model.hotend_name
checked: {
return Cura.MachineManager.activeVariantNames[extruderIndex] == model.hotend_name
}
exclusiveGroup: group
onTriggered: {
Cura.MachineManager.setVariantGroup(extruderIndex, model.container_node);
Cura.MachineManager.setVariantGroup(menu.extruderIndex, model.container_node);
}
}