mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-23 14:44:13 -06:00
CURA-4461 Set active buildplate in the global container stack when is
changed in the UI. Add a new setting for distinguish between types of build plates.
This commit is contained in:
parent
fd46f6968b
commit
cea9f359cd
3 changed files with 55 additions and 3 deletions
|
@ -50,6 +50,7 @@ class MachineManager(QObject):
|
|||
|
||||
# Used to store the new containers until after confirming the dialog
|
||||
self._new_variant_container = None
|
||||
self._new_buildplate_container = None
|
||||
self._new_material_container = None
|
||||
self._new_quality_containers = []
|
||||
|
||||
|
@ -158,6 +159,10 @@ class MachineManager(QObject):
|
|||
def newVariant(self):
|
||||
return self._new_variant_container
|
||||
|
||||
@property
|
||||
def newBuildplate(self):
|
||||
return self._new_buildplate_container
|
||||
|
||||
@property
|
||||
def newMaterial(self):
|
||||
return self._new_material_container
|
||||
|
@ -664,6 +669,14 @@ class MachineManager(QObject):
|
|||
return quality.getId()
|
||||
return ""
|
||||
|
||||
@pyqtProperty(str, notify=activeVariantChanged)
|
||||
def globalVariantId(self) -> str:
|
||||
if self._global_container_stack:
|
||||
variant = self._global_container_stack.variant
|
||||
if variant and not isinstance(variant, type(self._empty_variant_container)):
|
||||
return variant.getId()
|
||||
return ""
|
||||
|
||||
@pyqtProperty(str, notify = activeQualityChanged)
|
||||
def activeQualityType(self) -> str:
|
||||
if self._active_container_stack:
|
||||
|
@ -846,8 +859,24 @@ class MachineManager(QObject):
|
|||
|
||||
@pyqtSlot(str)
|
||||
def setActiveVariantBuildplate(self, variant_buildplate_id: str):
|
||||
with postponeSignals(*self._getContainerChangedSignals(), compress = CompressTechnique.CompressPerParameterValue):
|
||||
containers = ContainerRegistry.getInstance().findInstanceContainers(id = variant_buildplate_id)
|
||||
if not containers or not self._global_container_stack:
|
||||
return
|
||||
Logger.log("d", "Attempting to change the active buildplate to %s", variant_buildplate_id)
|
||||
pass
|
||||
old_buildplate = self._global_container_stack.variant
|
||||
old_material = self._active_container_stack.material
|
||||
if old_buildplate:
|
||||
self.blurSettings.emit()
|
||||
self._new_buildplate_container = containers[0] # self._active_container_stack will be updated with a delay
|
||||
Logger.log("d", "Active buildplate changed to {active_variant_buildplate_id}".format(active_variant_buildplate_id = containers[0].getId()))
|
||||
preferred_material_name = None
|
||||
if old_material:
|
||||
preferred_material_name = old_material.getName()
|
||||
preferred_material_id = self._updateMaterialContainer(self._global_container_stack.definition, self._global_container_stack, containers[0], preferred_material_name).id
|
||||
self.setActiveMaterial(preferred_material_id)
|
||||
else:
|
||||
Logger.log("w", "While trying to set the active buildplate, no buildplate was found to replace.")
|
||||
|
||||
## set the active quality
|
||||
# \param quality_id The quality_id of either a quality or a quality_changes
|
||||
|
@ -926,6 +955,10 @@ class MachineManager(QObject):
|
|||
self._active_container_stack.variant = self._new_variant_container
|
||||
self._new_variant_container = None
|
||||
|
||||
if self._new_buildplate_container is not None:
|
||||
self._global_container_stack.variant = self._new_buildplate_container
|
||||
self._new_buildplate_container = None
|
||||
|
||||
if self._new_material_container is not None:
|
||||
self._active_container_stack.material = self._new_material_container
|
||||
self._new_material_container = None
|
||||
|
@ -946,6 +979,7 @@ class MachineManager(QObject):
|
|||
# Used for ignoring any changes when switching between printers (setActiveMachine)
|
||||
def _cancelDelayedActiveContainerStackChanges(self):
|
||||
self._new_material_container = None
|
||||
self._new_buildplate_container = None
|
||||
self._new_variant_container = None
|
||||
|
||||
## Determine the quality and quality changes settings for the current machine for a quality name.
|
||||
|
|
|
@ -154,6 +154,21 @@
|
|||
"settable_per_extruder": false,
|
||||
"settable_per_meshgroup": false
|
||||
},
|
||||
"machine_buildplate_type":
|
||||
{
|
||||
"label": "Build Plate Material",
|
||||
"description": "The material of the build plate installed on the printer.",
|
||||
"default_value": "glass",
|
||||
"type": "enum",
|
||||
"options":
|
||||
{
|
||||
"glass": "Glass",
|
||||
"aluminium": "Aluminium"
|
||||
},
|
||||
"settable_per_mesh": false,
|
||||
"settable_per_extruder": false,
|
||||
"settable_per_meshgroup": false
|
||||
},
|
||||
"machine_height":
|
||||
{
|
||||
"label": "Machine Height",
|
||||
|
|
|
@ -12,6 +12,7 @@ Menu
|
|||
id: menu
|
||||
title: "Build plate"
|
||||
|
||||
property int extruderIndex: 0
|
||||
property bool printerConnected: Cura.MachineManager.printerOutputDevices.length != 0
|
||||
property bool isClusterPrinter:
|
||||
{
|
||||
|
@ -72,10 +73,12 @@ Menu
|
|||
MenuItem {
|
||||
text: model.name
|
||||
checkable: true
|
||||
// checked: model.id == Cura.MachineManager.buildplateIds[buildplateIndex]
|
||||
checked: model.id == Cura.MachineManager.globalVariantId
|
||||
exclusiveGroup: group
|
||||
onTriggered:
|
||||
{
|
||||
print("Cura.MachineManager.activeDefinitionId", Cura.MachineManager.activeDefinitionId)
|
||||
print("Cura.MachineManager.allActiveVariantIds[Cura.MachineManager.activeDefinitionId]", JSON.stringify(Cura.MachineManager.globalVariantId))
|
||||
Cura.MachineManager.setActiveVariantBuildplate(model.id);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue