mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-08 07:27:29 -06:00
CURA-5427 Force the material models to update when the machine changes and so
when the extruder stack changes. - What happen was that when the extruder model needed to update, the material model was not updated correctly and so when changing a material, the node was incorrect.
This commit is contained in:
parent
bb313c45a9
commit
a4b46be2c5
2 changed files with 6 additions and 3 deletions
|
@ -39,6 +39,8 @@ class BaseMaterialsModel(ListModel):
|
||||||
|
|
||||||
self._extruder_position = 0
|
self._extruder_position = 0
|
||||||
self._extruder_stack = None
|
self._extruder_stack = None
|
||||||
|
# Update the stack and the model data when the machine changes
|
||||||
|
self._machine_manager.globalContainerChanged.connect(self._updateExtruderStack)
|
||||||
|
|
||||||
def _updateExtruderStack(self):
|
def _updateExtruderStack(self):
|
||||||
global_stack = self._machine_manager.activeMachine
|
global_stack = self._machine_manager.activeMachine
|
||||||
|
@ -50,9 +52,11 @@ class BaseMaterialsModel(ListModel):
|
||||||
self._extruder_stack = global_stack.extruders.get(str(self._extruder_position))
|
self._extruder_stack = global_stack.extruders.get(str(self._extruder_position))
|
||||||
if self._extruder_stack is not None:
|
if self._extruder_stack is not None:
|
||||||
self._extruder_stack.pyqtContainersChanged.connect(self._update)
|
self._extruder_stack.pyqtContainersChanged.connect(self._update)
|
||||||
|
# Force update the model when the extruder stack changes
|
||||||
|
self._update()
|
||||||
|
|
||||||
def setExtruderPosition(self, position: int):
|
def setExtruderPosition(self, position: int):
|
||||||
if self._extruder_position != position:
|
if self._extruder_stack is None or self._extruder_position != position:
|
||||||
self._extruder_position = position
|
self._extruder_position = position
|
||||||
self._updateExtruderStack()
|
self._updateExtruderStack()
|
||||||
self.extruderPositionChanged.emit()
|
self.extruderPositionChanged.emit()
|
||||||
|
|
|
@ -63,8 +63,7 @@ Menu
|
||||||
exclusiveGroup: group
|
exclusiveGroup: group
|
||||||
onTriggered:
|
onTriggered:
|
||||||
{
|
{
|
||||||
var activeExtruderIndex = Cura.ExtruderManager.activeExtruderIndex;
|
Cura.MachineManager.setMaterial(extruderIndex, model.container_node);
|
||||||
Cura.MachineManager.setMaterial(activeExtruderIndex, model.container_node);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
onObjectAdded: brandMaterialsMenu.insertItem(index, object)
|
onObjectAdded: brandMaterialsMenu.insertItem(index, object)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue