|
@@ -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 = []
|
|
|
|
|
@@ -157,6 +158,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
|
|
@@ -309,10 +314,11 @@ class MachineManager(QObject):
|
|
|
self._global_container_stack.containersChanged.connect(self._onInstanceContainersChanged)
|
|
|
self._global_container_stack.propertyChanged.connect(self._onPropertyChanged)
|
|
|
|
|
|
- # set the global variant to empty as we now use the extruder stack at all times - CURA-4482
|
|
|
+ # Global stack can have only a variant if it is a buildplate
|
|
|
global_variant = self._global_container_stack.variant
|
|
|
if global_variant != self._empty_variant_container:
|
|
|
- self._global_container_stack.setVariant(self._empty_variant_container)
|
|
|
+ if global_variant.getMetaDataEntry("hardware_type") != "buildplate":
|
|
|
+ self._global_container_stack.setVariant(self._empty_variant_container)
|
|
|
|
|
|
# set the global material to empty as we now use the extruder stack at all times - CURA-4482
|
|
|
global_material = self._global_container_stack.material
|
|
@@ -675,6 +681,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:
|
|
@@ -855,6 +869,24 @@ class MachineManager(QObject):
|
|
|
else:
|
|
|
Logger.log("w", "While trying to set the active variant, no variant was found to replace.")
|
|
|
|
|
|
+ @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)
|
|
|
+ old_buildplate = self._global_container_stack.variant
|
|
|
+ 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()))
|
|
|
+
|
|
|
+ # Force set the active quality as it is so the values are updated
|
|
|
+ self.setActiveMaterial(self._active_container_stack.material.getId())
|
|
|
+ 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
|
|
|
@pyqtSlot(str)
|
|
@@ -939,6 +971,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
|
|
@@ -961,6 +997,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.
|
|
@@ -1125,6 +1162,15 @@ class MachineManager(QObject):
|
|
|
|
|
|
return ""
|
|
|
|
|
|
+ @pyqtProperty(str, notify = activeVariantChanged)
|
|
|
+ def activeVariantBuildplateName(self) -> str:
|
|
|
+ if self._global_container_stack:
|
|
|
+ variant = self._global_container_stack.variant
|
|
|
+ if variant:
|
|
|
+ return variant.getName()
|
|
|
+
|
|
|
+ return ""
|
|
|
+
|
|
|
@pyqtProperty(str, notify = globalContainerChanged)
|
|
|
def activeDefinitionId(self) -> str:
|
|
|
if self._global_container_stack:
|
|
@@ -1222,7 +1268,6 @@ class MachineManager(QObject):
|
|
|
def hasMaterials(self) -> bool:
|
|
|
if self._global_container_stack:
|
|
|
return Util.parseBool(self._global_container_stack.getMetaDataEntry("has_materials", False))
|
|
|
-
|
|
|
return False
|
|
|
|
|
|
@pyqtProperty(bool, notify = globalContainerChanged)
|
|
@@ -1231,6 +1276,53 @@ class MachineManager(QObject):
|
|
|
return Util.parseBool(self._global_container_stack.getMetaDataEntry("has_variants", False))
|
|
|
return False
|
|
|
|
|
|
+ @pyqtProperty(bool, notify = globalContainerChanged)
|
|
|
+ def hasVariantBuildplates(self) -> bool:
|
|
|
+ if self._global_container_stack:
|
|
|
+ return Util.parseBool(self._global_container_stack.getMetaDataEntry("has_variant_buildplates", False))
|
|
|
+ return False
|
|
|
+
|
|
|
+ ## The selected buildplate is compatible if it is compatible with all the materials in all the extruders
|
|
|
+ @pyqtProperty(bool, notify = activeMaterialChanged)
|
|
|
+ def variantBuildplateCompatible(self) -> bool:
|
|
|
+ if not self._global_container_stack:
|
|
|
+ return True
|
|
|
+
|
|
|
+ buildplate_compatible = True # It is compatible by default
|
|
|
+ extruder_stacks = self._global_container_stack.extruders.values()
|
|
|
+ for stack in extruder_stacks:
|
|
|
+ material_container = stack.material
|
|
|
+ if material_container == self._empty_material_container:
|
|
|
+ continue
|
|
|
+ if material_container.getMetaDataEntry("buildplate_compatible"):
|
|
|
+ buildplate_compatible = buildplate_compatible and material_container.getMetaDataEntry("buildplate_compatible")[self.activeVariantBuildplateName]
|
|
|
+
|
|
|
+ return buildplate_compatible
|
|
|
+
|
|
|
+ ## The selected buildplate is usable if it is usable for all materials OR it is compatible for one but not compatible
|
|
|
+ # for the other material but the buildplate is still usable
|
|
|
+ @pyqtProperty(bool, notify = activeMaterialChanged)
|
|
|
+ def variantBuildplateUsable(self) -> bool:
|
|
|
+ if not self._global_container_stack:
|
|
|
+ return True
|
|
|
+
|
|
|
+ # Here the next formula is being calculated:
|
|
|
+ # result = (not (material_left_compatible and material_right_compatible)) and
|
|
|
+ # (material_left_compatible or material_left_usable) and
|
|
|
+ # (material_right_compatible or material_right_usable)
|
|
|
+ result = not self.variantBuildplateCompatible
|
|
|
+ extruder_stacks = self._global_container_stack.extruders.values()
|
|
|
+ for stack in extruder_stacks:
|
|
|
+ material_container = stack.material
|
|
|
+ if material_container == self._empty_material_container:
|
|
|
+ continue
|
|
|
+ buildplate_compatible = material_container.getMetaDataEntry("buildplate_compatible")[self.activeVariantBuildplateName] if material_container.getMetaDataEntry("buildplate_compatible") else True
|
|
|
+ buildplate_usable = material_container.getMetaDataEntry("buildplate_recommended")[self.activeVariantBuildplateName] if material_container.getMetaDataEntry("buildplate_recommended") else True
|
|
|
+
|
|
|
+ result = result and (buildplate_compatible or buildplate_usable)
|
|
|
+
|
|
|
+ return result
|
|
|
+
|
|
|
## Property to indicate if a machine has "specialized" material profiles.
|
|
|
# Some machines have their own material profiles that "override" the default catch all profiles.
|
|
|
@pyqtProperty(bool, notify = globalContainerChanged)
|