mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-25 07:33:57 -06:00
Only update ExtrudersModel when material changes
CURA-3780
This commit is contained in:
parent
42fc703516
commit
801c282c97
1 changed files with 7 additions and 7 deletions
|
@ -116,10 +116,10 @@ class ExtrudersModel(UM.Qt.ListModel.ListModel):
|
||||||
active_extruder_stack.containersChanged.connect(self._onExtruderStackContainersChanged)
|
active_extruder_stack.containersChanged.connect(self._onExtruderStackContainersChanged)
|
||||||
self._active_extruder_stack = active_extruder_stack
|
self._active_extruder_stack = active_extruder_stack
|
||||||
|
|
||||||
|
|
||||||
def _onExtruderStackContainersChanged(self, container):
|
def _onExtruderStackContainersChanged(self, container):
|
||||||
# The ExtrudersModel needs to be updated when the material-name or -color changes, because the user identifies extruders by material-name
|
if container.getMetaDataEntry("type") == "material":
|
||||||
self._updateExtruders()
|
# The ExtrudersModel needs to be updated when the material-name or -color changes, because the user identifies extruders by material-name
|
||||||
|
self._updateExtruders()
|
||||||
|
|
||||||
modelChanged = pyqtSignal()
|
modelChanged = pyqtSignal()
|
||||||
|
|
||||||
|
@ -141,7 +141,7 @@ class ExtrudersModel(UM.Qt.ListModel.ListModel):
|
||||||
global_container_stack = Application.getInstance().getGlobalContainerStack()
|
global_container_stack = Application.getInstance().getGlobalContainerStack()
|
||||||
if global_container_stack:
|
if global_container_stack:
|
||||||
if self._add_global:
|
if self._add_global:
|
||||||
material = global_container_stack.findContainer({ "type": "material" })
|
material = global_container_stack.material
|
||||||
color = material.getMetaDataEntry("color_code", default = self.defaultColors[0]) if material else self.defaultColors[0]
|
color = material.getMetaDataEntry("color_code", default = self.defaultColors[0]) if material else self.defaultColors[0]
|
||||||
item = {
|
item = {
|
||||||
"id": global_container_stack.getId(),
|
"id": global_container_stack.getId(),
|
||||||
|
@ -156,9 +156,6 @@ class ExtrudersModel(UM.Qt.ListModel.ListModel):
|
||||||
machine_extruder_count = global_container_stack.getProperty("machine_extruder_count", "value")
|
machine_extruder_count = global_container_stack.getProperty("machine_extruder_count", "value")
|
||||||
manager = ExtruderManager.getInstance()
|
manager = ExtruderManager.getInstance()
|
||||||
for extruder in manager.getMachineExtruders(global_container_stack.getId()):
|
for extruder in manager.getMachineExtruders(global_container_stack.getId()):
|
||||||
extruder_name = extruder.getName()
|
|
||||||
material = extruder.findContainer({ "type": "material" })
|
|
||||||
variant = extruder.findContainer({"type": "variant"})
|
|
||||||
position = extruder.getMetaDataEntry("position", default = "0") # Get the position
|
position = extruder.getMetaDataEntry("position", default = "0") # Get the position
|
||||||
try:
|
try:
|
||||||
position = int(position)
|
position = int(position)
|
||||||
|
@ -166,6 +163,9 @@ class ExtrudersModel(UM.Qt.ListModel.ListModel):
|
||||||
position = -1
|
position = -1
|
||||||
if position >= machine_extruder_count:
|
if position >= machine_extruder_count:
|
||||||
continue
|
continue
|
||||||
|
extruder_name = extruder.getName()
|
||||||
|
material = extruder.material
|
||||||
|
variant = extruder.variant
|
||||||
|
|
||||||
default_color = self.defaultColors[position] if position >= 0 and position < len(self.defaultColors) else self.defaultColors[0]
|
default_color = self.defaultColors[position] if position >= 0 and position < len(self.defaultColors) else self.defaultColors[0]
|
||||||
color = material.getMetaDataEntry("color_code", default = default_color) if material else default_color
|
color = material.getMetaDataEntry("color_code", default = default_color) if material else default_color
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue