mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-15 02:37:49 -06:00
Fixes for selecting active variant, material and quality - CURA-4482
This commit is contained in:
parent
4701518404
commit
bc6984a0ed
4 changed files with 58 additions and 42 deletions
|
@ -405,6 +405,7 @@ class CuraContainerRegistry(ContainerRegistry):
|
||||||
def _addExtruderStackForSingleExtrusionMachine(self, machine, extruder_id):
|
def _addExtruderStackForSingleExtrusionMachine(self, machine, extruder_id):
|
||||||
new_extruder_id = extruder_id
|
new_extruder_id = extruder_id
|
||||||
|
|
||||||
|
# if extruders are defined in the machine definition use those instead
|
||||||
if machine.extruders and len(machine.extruders) > 0:
|
if machine.extruders and len(machine.extruders) > 0:
|
||||||
new_extruder_id = machine.extruders["0"].getId()
|
new_extruder_id = machine.extruders["0"].getId()
|
||||||
|
|
||||||
|
@ -415,13 +416,12 @@ class CuraContainerRegistry(ContainerRegistry):
|
||||||
return
|
return
|
||||||
|
|
||||||
extruder_definition = extruder_definitions[0]
|
extruder_definition = extruder_definitions[0]
|
||||||
unique_name = self.uniqueName(machine.getId() + " " + new_extruder_id)
|
unique_name = self.uniqueName(machine.getName() + " " + new_extruder_id)
|
||||||
|
|
||||||
extruder_stack = ExtruderStack.ExtruderStack(unique_name)
|
extruder_stack = ExtruderStack.ExtruderStack(unique_name)
|
||||||
extruder_stack.setName(extruder_definition.getName())
|
extruder_stack.setName(extruder_definition.getName())
|
||||||
extruder_stack.setDefinition(extruder_definition)
|
extruder_stack.setDefinition(extruder_definition)
|
||||||
extruder_stack.addMetaDataEntry("machine", machine.getId())
|
extruder_stack.addMetaDataEntry("position", extruder_definition.getMetaDataEntry("position"))
|
||||||
extruder_stack.addMetaDataEntry("position", "0")
|
|
||||||
extruder_stack.setNextStack(machine)
|
extruder_stack.setNextStack(machine)
|
||||||
|
|
||||||
if machine.userChanges:
|
if machine.userChanges:
|
||||||
|
@ -429,7 +429,7 @@ class CuraContainerRegistry(ContainerRegistry):
|
||||||
extruder_stack.setUserChanges(machine.userChanges)
|
extruder_stack.setUserChanges(machine.userChanges)
|
||||||
else:
|
else:
|
||||||
# create empty user changes container otherwise
|
# create empty user changes container otherwise
|
||||||
user_container = InstanceContainer(extruder_stack.getId() + "_user")
|
user_container = InstanceContainer(extruder_stack.id + "_user")
|
||||||
user_container.addMetaDataEntry("type", "user")
|
user_container.addMetaDataEntry("type", "user")
|
||||||
user_container.addMetaDataEntry("machine", extruder_stack.getId())
|
user_container.addMetaDataEntry("machine", extruder_stack.getId())
|
||||||
from cura.CuraApplication import CuraApplication
|
from cura.CuraApplication import CuraApplication
|
||||||
|
@ -438,7 +438,7 @@ class CuraContainerRegistry(ContainerRegistry):
|
||||||
extruder_stack.setUserChanges(user_container)
|
extruder_stack.setUserChanges(user_container)
|
||||||
self.addContainer(user_container)
|
self.addContainer(user_container)
|
||||||
|
|
||||||
# extruder_stack.setVariantById("default")
|
extruder_stack.setVariantById("default")
|
||||||
extruder_stack.setMaterialById("default")
|
extruder_stack.setMaterialById("default")
|
||||||
extruder_stack.setQualityById("default")
|
extruder_stack.setQualityById("default")
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,7 @@ class CuraStackBuilder:
|
||||||
if not extruder_definition:
|
if not extruder_definition:
|
||||||
# create extruder stack for single extrusion machines that have no separate extruder definition files
|
# create extruder stack for single extrusion machines that have no separate extruder definition files
|
||||||
extruder_definition = registry.findDefinitionContainers(id = "fdmextruder")[0]
|
extruder_definition = registry.findDefinitionContainers(id = "fdmextruder")[0]
|
||||||
new_extruder_id = registry.uniqueName(machine_definition.getId() + " " + "fdmextruder")
|
new_extruder_id = registry.uniqueName(machine_definition.getName() + " " + extruder_definition.id)
|
||||||
new_extruder = cls.createExtruderStack(
|
new_extruder = cls.createExtruderStack(
|
||||||
new_extruder_id,
|
new_extruder_id,
|
||||||
definition=extruder_definition,
|
definition=extruder_definition,
|
||||||
|
|
|
@ -543,9 +543,8 @@ class ExtruderManager(QObject):
|
||||||
self._global_container_stack_definition_id = global_container_stack.getBottom().getId()
|
self._global_container_stack_definition_id = global_container_stack.getBottom().getId()
|
||||||
self.globalContainerStackDefinitionChanged.emit()
|
self.globalContainerStackDefinitionChanged.emit()
|
||||||
|
|
||||||
# If the global container changed, the number of extruders could be changed and so the active_extruder_index is updated
|
# If the global container changed, the machine changed and might have extruders that were not registered yet
|
||||||
if self._active_extruder_index == -1:
|
self._addCurrentMachineExtruders()
|
||||||
self.setActiveExtruderIndex(0)
|
|
||||||
|
|
||||||
self.resetSelectedObjectExtruders()
|
self.resetSelectedObjectExtruders()
|
||||||
|
|
||||||
|
@ -554,21 +553,29 @@ class ExtruderManager(QObject):
|
||||||
global_stack = Application.getInstance().getGlobalContainerStack()
|
global_stack = Application.getInstance().getGlobalContainerStack()
|
||||||
extruders_changed = False
|
extruders_changed = False
|
||||||
|
|
||||||
if global_stack and global_stack.getBottom():
|
if global_stack:
|
||||||
container_registry = ContainerRegistry.getInstance()
|
container_registry = ContainerRegistry.getInstance()
|
||||||
machine_id = global_stack.getBottom().getId()
|
global_stack_id = global_stack.getId()
|
||||||
|
|
||||||
# Gets the extruder trains that we just created as well as any that still existed.
|
# Gets the extruder trains that we just created as well as any that still existed.
|
||||||
extruder_trains = container_registry.findContainerStacks(type = "extruder_train", machine = machine_id)
|
extruder_trains = container_registry.findContainerStacks(type = "extruder_train", machine = global_stack_id)
|
||||||
|
|
||||||
|
# Make sure the extruder trains for the new machine can be placed in the set of sets
|
||||||
|
if global_stack_id not in self._extruder_trains:
|
||||||
|
self._extruder_trains[global_stack_id] = {}
|
||||||
|
extruders_changed = True
|
||||||
|
|
||||||
|
# Register the extruder trains by position
|
||||||
for extruder_train in extruder_trains:
|
for extruder_train in extruder_trains:
|
||||||
self._extruder_trains[machine_id][extruder_train.getMetaDataEntry("position")] = extruder_train
|
self._extruder_trains[global_stack_id][extruder_train.getMetaDataEntry("position")] = extruder_train
|
||||||
|
|
||||||
# regardless of what the next stack is, we have to set it again, because of signal routing. ???
|
# regardless of what the next stack is, we have to set it again, because of signal routing. ???
|
||||||
extruder_train.setNextStack(global_stack)
|
extruder_train.setNextStack(global_stack)
|
||||||
extruders_changed = True
|
extruders_changed = True
|
||||||
|
|
||||||
if extruders_changed:
|
if extruders_changed:
|
||||||
self.extrudersChanged.emit(machine_id)
|
self.extrudersChanged.emit(global_stack_id)
|
||||||
|
self.setActiveExtruderIndex(0)
|
||||||
|
|
||||||
## Get all extruder values for a certain setting.
|
## Get all extruder values for a certain setting.
|
||||||
#
|
#
|
||||||
|
|
|
@ -161,7 +161,7 @@ class MachineManager(QObject):
|
||||||
|
|
||||||
@pyqtProperty(int, constant=True)
|
@pyqtProperty(int, constant=True)
|
||||||
def totalNumberOfSettings(self) -> int:
|
def totalNumberOfSettings(self) -> int:
|
||||||
return len(ContainerRegistry.getInstance().findDefinitionContainers(id="fdmprinter")[0].getAllKeys())
|
return len(ContainerRegistry.getInstance().findDefinitionContainers(id = "fdmprinter")[0].getAllKeys())
|
||||||
|
|
||||||
def _onHotendIdChanged(self, index: Union[str, int], hotend_id: str) -> None:
|
def _onHotendIdChanged(self, index: Union[str, int], hotend_id: str) -> None:
|
||||||
if not self._global_container_stack:
|
if not self._global_container_stack:
|
||||||
|
@ -386,15 +386,6 @@ class MachineManager(QObject):
|
||||||
else:
|
else:
|
||||||
Logger.log("w", "Failed creating a new machine!")
|
Logger.log("w", "Failed creating a new machine!")
|
||||||
|
|
||||||
## Create a name that is not empty and unique
|
|
||||||
# \param container_type \type{string} Type of the container (machine, quality, ...)
|
|
||||||
# \param current_name \type{} Current name of the container, which may be an acceptable option
|
|
||||||
# \param new_name \type{string} Base name, which may not be unique
|
|
||||||
# \param fallback_name \type{string} Name to use when (stripped) new_name is empty
|
|
||||||
# \return \type{string} Name that is unique for the specified type and name/id
|
|
||||||
def _createUniqueName(self, container_type: str, current_name: str, new_name: str, fallback_name: str) -> str:
|
|
||||||
return ContainerRegistry.getInstance().createUniqueName(container_type, current_name, new_name, fallback_name)
|
|
||||||
|
|
||||||
def _checkStacksHaveErrors(self) -> bool:
|
def _checkStacksHaveErrors(self) -> bool:
|
||||||
if self._global_container_stack is None: #No active machine.
|
if self._global_container_stack is None: #No active machine.
|
||||||
return False
|
return False
|
||||||
|
@ -950,15 +941,12 @@ class MachineManager(QObject):
|
||||||
global_container_stack = self._global_container_stack
|
global_container_stack = self._global_container_stack
|
||||||
if not global_container_stack:
|
if not global_container_stack:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
global_machine_definition = quality_manager.getParentMachineDefinition(global_container_stack.getBottom())
|
global_machine_definition = quality_manager.getParentMachineDefinition(global_container_stack.getBottom())
|
||||||
|
|
||||||
extruder_stacks = ExtruderManager.getInstance().getActiveExtruderStacks()
|
extruder_stacks = ExtruderManager.getInstance().getActiveExtruderStacks()
|
||||||
if extruder_stacks:
|
|
||||||
stacks = extruder_stacks
|
|
||||||
else:
|
|
||||||
stacks = [global_container_stack]
|
|
||||||
|
|
||||||
for stack in stacks:
|
# find qualities for extruders
|
||||||
|
for stack in extruder_stacks:
|
||||||
material = stack.material
|
material = stack.material
|
||||||
|
|
||||||
# TODO: fix this
|
# TODO: fix this
|
||||||
|
@ -966,19 +954,33 @@ class MachineManager(QObject):
|
||||||
material = self._new_material_container
|
material = self._new_material_container
|
||||||
|
|
||||||
quality = quality_manager.findQualityByQualityType(quality_type, global_machine_definition, [material])
|
quality = quality_manager.findQualityByQualityType(quality_type, global_machine_definition, [material])
|
||||||
|
|
||||||
if not quality:
|
if not quality:
|
||||||
# No quality profile is found for this quality type.
|
# No quality profile is found for this quality type.
|
||||||
quality = self._empty_quality_container
|
quality = self._empty_quality_container
|
||||||
result.append({"stack": stack, "quality": quality, "quality_changes": empty_quality_changes})
|
|
||||||
|
|
||||||
if extruder_stacks:
|
result.append({
|
||||||
# Add an extra entry for the global stack.
|
"stack": stack,
|
||||||
global_quality = quality_manager.findQualityByQualityType(quality_type, global_machine_definition, [], global_quality = "True")
|
"quality": quality,
|
||||||
|
"quality_changes": empty_quality_changes
|
||||||
|
})
|
||||||
|
|
||||||
if not global_quality:
|
# also find a global quality for the machine
|
||||||
global_quality = self._empty_quality_container
|
global_quality = quality_manager.findQualityByQualityType(quality_type, global_machine_definition, [], global_quality = True)
|
||||||
|
|
||||||
result.append({"stack": global_container_stack, "quality": global_quality, "quality_changes": empty_quality_changes})
|
# if there is not global quality but we're using a single extrusion machine, copy the quality of the first extruder - CURA-4482
|
||||||
|
if not global_quality and len(extruder_stacks) == 1:
|
||||||
|
global_quality = result[0]["quality"]
|
||||||
|
|
||||||
|
# if there is still no global quality, set it to empty (not supported)
|
||||||
|
if not global_quality:
|
||||||
|
global_quality = self._empty_quality_container
|
||||||
|
|
||||||
|
result.append({
|
||||||
|
"stack": global_container_stack,
|
||||||
|
"quality": global_quality,
|
||||||
|
"quality_changes": empty_quality_changes
|
||||||
|
})
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
@ -1030,7 +1032,7 @@ class MachineManager(QObject):
|
||||||
|
|
||||||
material = extruder_stack.material
|
material = extruder_stack.material
|
||||||
|
|
||||||
if self._new_material_container and self._active_container_stack.getId() == stack.getId():
|
if self._new_material_container and self._active_container_stack.getId() == extruder_stack.getId():
|
||||||
material = self._new_material_container
|
material = self._new_material_container
|
||||||
|
|
||||||
quality = quality_manager.findQualityByQualityType(quality_type, global_machine_definition, [material])
|
quality = quality_manager.findQualityByQualityType(quality_type, global_machine_definition, [material])
|
||||||
|
@ -1047,6 +1049,12 @@ class MachineManager(QObject):
|
||||||
|
|
||||||
# append the global quality changes
|
# append the global quality changes
|
||||||
global_quality = quality_manager.findQualityByQualityType(quality_type, global_machine_definition, [material], global_quality = True)
|
global_quality = quality_manager.findQualityByQualityType(quality_type, global_machine_definition, [material], global_quality = True)
|
||||||
|
|
||||||
|
# if there is not global quality but we're using a single extrusion machine, copy the quality of the first extruder - CURA-4482
|
||||||
|
if not global_quality and len(extruder_stacks) == 1:
|
||||||
|
global_quality = result[0]["quality_changes"]
|
||||||
|
|
||||||
|
# if still no global quality changes are found we set it to empty (not supported)
|
||||||
if not global_quality:
|
if not global_quality:
|
||||||
global_quality = self._empty_quality_container
|
global_quality = self._empty_quality_container
|
||||||
|
|
||||||
|
@ -1163,10 +1171,11 @@ class MachineManager(QObject):
|
||||||
|
|
||||||
@pyqtSlot(str, str)
|
@pyqtSlot(str, str)
|
||||||
def renameMachine(self, machine_id: str, new_name: str):
|
def renameMachine(self, machine_id: str, new_name: str):
|
||||||
containers = ContainerRegistry.getInstance().findContainerStacks(id = machine_id)
|
container_registry = ContainerRegistry.getInstance()
|
||||||
if containers:
|
machine_stack = container_registry.findContainerStacks(id = machine_id)
|
||||||
new_name = self._createUniqueName("machine", containers[0].getName(), new_name, containers[0].getBottom().getName())
|
if machine_stack:
|
||||||
containers[0].setName(new_name)
|
new_name = container_registry.createUniqueName("machine", machine_stack[0].getName(), new_name, machine_stack[0].getBottom().getName())
|
||||||
|
machine_stack[0].setName(new_name)
|
||||||
self.globalContainerChanged.emit()
|
self.globalContainerChanged.emit()
|
||||||
|
|
||||||
@pyqtSlot(str)
|
@pyqtSlot(str)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue