mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-07 06:57:28 -06:00
CURA-4386 CURA-4379 change stack behaviours to fix crashes
This commit is contained in:
parent
e3edc79a3e
commit
1b8766b953
6 changed files with 34 additions and 29 deletions
|
@ -41,7 +41,7 @@ class ExtruderManager(QObject):
|
||||||
def __init__(self, parent = None):
|
def __init__(self, parent = None):
|
||||||
super().__init__(parent)
|
super().__init__(parent)
|
||||||
self._extruder_trains = { } #Per machine, a dictionary of extruder container stack IDs. Only for separately defined extruders.
|
self._extruder_trains = { } #Per machine, a dictionary of extruder container stack IDs. Only for separately defined extruders.
|
||||||
self._active_extruder_index = 0
|
self._active_extruder_index = -1
|
||||||
self._selected_object_extruders = []
|
self._selected_object_extruders = []
|
||||||
Application.getInstance().globalContainerStackChanged.connect(self.__globalContainerStackChanged)
|
Application.getInstance().globalContainerStackChanged.connect(self.__globalContainerStackChanged)
|
||||||
self._global_container_stack_definition_id = None
|
self._global_container_stack_definition_id = None
|
||||||
|
@ -78,6 +78,7 @@ class ExtruderManager(QObject):
|
||||||
def extruderIds(self):
|
def extruderIds(self):
|
||||||
map = {}
|
map = {}
|
||||||
global_stack_id = Application.getInstance().getGlobalContainerStack().getId()
|
global_stack_id = Application.getInstance().getGlobalContainerStack().getId()
|
||||||
|
map["-1"] = global_stack_id
|
||||||
if global_stack_id in self._extruder_trains:
|
if global_stack_id in self._extruder_trains:
|
||||||
for position in self._extruder_trains[global_stack_id]:
|
for position in self._extruder_trains[global_stack_id]:
|
||||||
map[position] = self._extruder_trains[global_stack_id][position].getId()
|
map[position] = self._extruder_trains[global_stack_id][position].getId()
|
||||||
|
@ -513,11 +514,16 @@ class ExtruderManager(QObject):
|
||||||
global_stack = Application.getInstance().getGlobalContainerStack()
|
global_stack = Application.getInstance().getGlobalContainerStack()
|
||||||
|
|
||||||
result = []
|
result = []
|
||||||
|
machine_extruder_count = global_stack.getProperty("machine_extruder_count", "value")
|
||||||
|
|
||||||
|
if machine_extruder_count is 1:
|
||||||
|
return result
|
||||||
|
|
||||||
if global_stack and global_stack.getId() in self._extruder_trains:
|
if global_stack and global_stack.getId() in self._extruder_trains:
|
||||||
for extruder in sorted(self._extruder_trains[global_stack.getId()]):
|
for extruder in sorted(self._extruder_trains[global_stack.getId()]):
|
||||||
result.append(self._extruder_trains[global_stack.getId()][extruder])
|
result.append(self._extruder_trains[global_stack.getId()][extruder])
|
||||||
|
|
||||||
return result[:global_stack.getProperty("machine_extruder_count", "value")]
|
return result[:machine_extruder_count]
|
||||||
|
|
||||||
def __globalContainerStackChanged(self) -> None:
|
def __globalContainerStackChanged(self) -> None:
|
||||||
global_container_stack = Application.getInstance().getGlobalContainerStack()
|
global_container_stack = Application.getInstance().getGlobalContainerStack()
|
||||||
|
|
|
@ -271,7 +271,6 @@ class MachineManager(QObject):
|
||||||
extruder_stack.containersChanged.disconnect(self._onInstanceContainersChanged)
|
extruder_stack.containersChanged.disconnect(self._onInstanceContainersChanged)
|
||||||
|
|
||||||
self._global_container_stack = Application.getInstance().getGlobalContainerStack()
|
self._global_container_stack = Application.getInstance().getGlobalContainerStack()
|
||||||
self._active_container_stack = self._global_container_stack
|
|
||||||
|
|
||||||
self.globalContainerChanged.emit()
|
self.globalContainerChanged.emit()
|
||||||
|
|
||||||
|
@ -303,6 +302,9 @@ class MachineManager(QObject):
|
||||||
|
|
||||||
quality = self._global_container_stack.quality
|
quality = self._global_container_stack.quality
|
||||||
quality.nameChanged.connect(self._onQualityNameChanged)
|
quality.nameChanged.connect(self._onQualityNameChanged)
|
||||||
|
|
||||||
|
self._active_container_stack = self._global_container_stack
|
||||||
|
|
||||||
self._error_check_timer.start()
|
self._error_check_timer.start()
|
||||||
|
|
||||||
## Update self._stacks_valid according to _checkStacksForErrors and emit if change.
|
## Update self._stacks_valid according to _checkStacksForErrors and emit if change.
|
||||||
|
@ -547,12 +549,14 @@ class MachineManager(QObject):
|
||||||
def allActiveMaterialIds(self) -> Dict[str, str]:
|
def allActiveMaterialIds(self) -> Dict[str, str]:
|
||||||
result = {}
|
result = {}
|
||||||
active_stacks = ExtruderManager.getInstance().getActiveExtruderStacks()
|
active_stacks = ExtruderManager.getInstance().getActiveExtruderStacks()
|
||||||
if active_stacks is not None: #If we have a global stack.
|
|
||||||
|
result[self._global_container_stack.getId()] = self._global_container_stack.material.getId()
|
||||||
|
|
||||||
|
if active_stacks is not None: # If we have extruder stacks
|
||||||
for stack in active_stacks:
|
for stack in active_stacks:
|
||||||
material_container = stack.material
|
material_container = stack.material
|
||||||
if not material_container:
|
if not material_container:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
result[stack.getId()] = material_container.getId()
|
result[stack.getId()] = material_container.getId()
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
|
@ -219,6 +219,7 @@ class MachineSettingsAction(MachineAction):
|
||||||
machine_manager.setActiveVariant(extruder_variant_id)
|
machine_manager.setActiveVariant(extruder_variant_id)
|
||||||
|
|
||||||
preferences.setValue("cura/choice_on_profile_override", choice_on_profile_override)
|
preferences.setValue("cura/choice_on_profile_override", choice_on_profile_override)
|
||||||
|
|
||||||
self.forceUpdate()
|
self.forceUpdate()
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -39,11 +39,8 @@ Menu
|
||||||
visible: printerConnected && Cura.MachineManager.printerOutputDevices[0].materialNames.length > extruderIndex
|
visible: printerConnected && Cura.MachineManager.printerOutputDevices[0].materialNames.length > extruderIndex
|
||||||
onTriggered:
|
onTriggered:
|
||||||
{
|
{
|
||||||
var activeExtruderIndex = ExtruderManager.activeExtruderIndex;
|
|
||||||
ExtruderManager.setActiveExtruderIndex(extruderIndex);
|
|
||||||
var materialId = Cura.MachineManager.printerOutputDevices[0].materialIds[extruderIndex];
|
var materialId = Cura.MachineManager.printerOutputDevices[0].materialIds[extruderIndex];
|
||||||
var items = materialsModel.items;
|
var items = materialsModel.items;
|
||||||
// materialsModel.find cannot be used because we need to look inside the metadata property of items
|
|
||||||
for(var i in items)
|
for(var i in items)
|
||||||
{
|
{
|
||||||
if (items[i]["metadata"]["GUID"] == materialId)
|
if (items[i]["metadata"]["GUID"] == materialId)
|
||||||
|
@ -52,7 +49,6 @@ Menu
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ExtruderManager.setActiveExtruderIndex(activeExtruderIndex);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,13 +66,7 @@ Menu
|
||||||
checkable: true
|
checkable: true
|
||||||
checked: model.id == Cura.MachineManager.allActiveMaterialIds[ExtruderManager.extruderIds[extruderIndex]]
|
checked: model.id == Cura.MachineManager.allActiveMaterialIds[ExtruderManager.extruderIds[extruderIndex]]
|
||||||
exclusiveGroup: group
|
exclusiveGroup: group
|
||||||
onTriggered:
|
onTriggered: Cura.MachineManager.setActiveMaterial(model.id)
|
||||||
{
|
|
||||||
var activeExtruderIndex = ExtruderManager.activeExtruderIndex;
|
|
||||||
ExtruderManager.setActiveExtruderIndex(extruderIndex);
|
|
||||||
Cura.MachineManager.setActiveMaterial(model.id);
|
|
||||||
ExtruderManager.setActiveExtruderIndex(activeExtruderIndex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
onObjectAdded: menu.insertItem(index, object)
|
onObjectAdded: menu.insertItem(index, object)
|
||||||
onObjectRemoved: menu.removeItem(object)
|
onObjectRemoved: menu.removeItem(object)
|
||||||
|
@ -111,13 +101,7 @@ Menu
|
||||||
checkable: true
|
checkable: true
|
||||||
checked: model.id == Cura.MachineManager.allActiveMaterialIds[ExtruderManager.extruderIds[extruderIndex]]
|
checked: model.id == Cura.MachineManager.allActiveMaterialIds[ExtruderManager.extruderIds[extruderIndex]]
|
||||||
exclusiveGroup: group
|
exclusiveGroup: group
|
||||||
onTriggered:
|
onTriggered: Cura.MachineManager.setActiveMaterial(model.id)
|
||||||
{
|
|
||||||
var activeExtruderIndex = ExtruderManager.activeExtruderIndex;
|
|
||||||
ExtruderManager.setActiveExtruderIndex(extruderIndex);
|
|
||||||
Cura.MachineManager.setActiveMaterial(model.id);
|
|
||||||
ExtruderManager.setActiveExtruderIndex(activeExtruderIndex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
onObjectAdded: brandMaterialsMenu.insertItem(index, object)
|
onObjectAdded: brandMaterialsMenu.insertItem(index, object)
|
||||||
onObjectRemoved: brandMaterialsMenu.removeItem(object)
|
onObjectRemoved: brandMaterialsMenu.removeItem(object)
|
||||||
|
|
|
@ -91,12 +91,7 @@ Column
|
||||||
Connections
|
Connections
|
||||||
{
|
{
|
||||||
target: Cura.MachineManager
|
target: Cura.MachineManager
|
||||||
onGlobalContainerChanged:
|
onGlobalContainerChanged: forceActiveFocus() // Changing focus applies the currently-being-typed values so it can change the displayed setting values.
|
||||||
{
|
|
||||||
forceActiveFocus() // Changing focus applies the currently-being-typed values so it can change the displayed setting values.
|
|
||||||
// var extruder_index = (machineExtruderCount.properties.value == 1) ? -1 : 0
|
|
||||||
// ExtruderManager.setActiveExtruderIndex(extruder_index);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
delegate: Button
|
delegate: Button
|
||||||
|
@ -294,6 +289,15 @@ Column
|
||||||
|
|
||||||
menu: MaterialMenu { extruderIndex: base.currentExtruderIndex }
|
menu: MaterialMenu { extruderIndex: base.currentExtruderIndex }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Connections
|
||||||
|
{
|
||||||
|
target: Cura.MachineManager
|
||||||
|
onGlobalContainerChanged:
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Print core row
|
// Print core row
|
||||||
|
|
|
@ -68,6 +68,12 @@ Item
|
||||||
onActiveQualityChanged: qualityModel.update()
|
onActiveQualityChanged: qualityModel.update()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Connections
|
||||||
|
{
|
||||||
|
target: Cura.MachineManager
|
||||||
|
onActiveMaterialChanged: qualityModel.update()
|
||||||
|
}
|
||||||
|
|
||||||
ListModel
|
ListModel
|
||||||
{
|
{
|
||||||
id: qualityModel
|
id: qualityModel
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue