mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-11-28 21:31:15 -07:00
Small refactor in MachineManager and add more loggings
CURA-4606 - Added more info loggings - Changed some variant names - Use some shortcut variables instead of getInstance()s
This commit is contained in:
parent
cb7677347d
commit
fb798ab7e5
1 changed files with 17 additions and 10 deletions
|
|
@ -917,30 +917,38 @@ class MachineManager(QObject):
|
||||||
|
|
||||||
## Update current quality type and machine after setting material
|
## Update current quality type and machine after setting material
|
||||||
def _updateQualityWithMaterial(self):
|
def _updateQualityWithMaterial(self):
|
||||||
current_quality = None
|
Logger.log("i", "Updating quality/quality_changes due to material change")
|
||||||
|
current_quality_type = None
|
||||||
if self._current_quality_group:
|
if self._current_quality_group:
|
||||||
current_quality = self._current_quality_group.quality_type
|
current_quality_type = self._current_quality_group.quality_type
|
||||||
quality_manager = Application.getInstance()._quality_manager
|
candidate_quality_groups = self._quality_manager.getQualityGroups(self._global_container_stack)
|
||||||
candidate_quality_groups = quality_manager.getQualityGroups(self._global_container_stack)
|
|
||||||
available_quality_types = {qt for qt, g in candidate_quality_groups.items() if g.is_available}
|
available_quality_types = {qt for qt, g in candidate_quality_groups.items() if g.is_available}
|
||||||
|
|
||||||
|
Logger.log("d", "Current quality type = [%s]", current_quality_type)
|
||||||
if not self.activeMaterialsCompatible():
|
if not self.activeMaterialsCompatible():
|
||||||
|
Logger.log("i", "Active materials are not compatible, setting all qualities to empty (Not Supported).")
|
||||||
self._setEmptyQuality()
|
self._setEmptyQuality()
|
||||||
return
|
return
|
||||||
|
|
||||||
if not available_quality_types:
|
if not available_quality_types:
|
||||||
|
Logger.log("i", "No available quality types found, setting all qualities to empty (Not Supported).")
|
||||||
self._setEmptyQuality()
|
self._setEmptyQuality()
|
||||||
return
|
return
|
||||||
|
|
||||||
if current_quality in available_quality_types:
|
if current_quality_type in available_quality_types:
|
||||||
self._setQualityGroup(candidate_quality_groups[current_quality], empty_quality_changes = False)
|
Logger.log("i", "Current available quality type [%s] is available, applying changes.", current_quality_type)
|
||||||
|
self._setQualityGroup(candidate_quality_groups[current_quality_type], empty_quality_changes = False)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
# The current quality type is not available so we use the preferred quality type if it's available,
|
||||||
|
# otherwise use one of the available quality types.
|
||||||
quality_type = sorted(list(available_quality_types))[0]
|
quality_type = sorted(list(available_quality_types))[0]
|
||||||
preferred_quality_type = self._global_container_stack.getMetaDataEntry("preferred_quality_type")
|
preferred_quality_type = self._global_container_stack.getMetaDataEntry("preferred_quality_type")
|
||||||
if preferred_quality_type in available_quality_types:
|
if preferred_quality_type in available_quality_types:
|
||||||
quality_type = preferred_quality_type
|
quality_type = preferred_quality_type
|
||||||
|
|
||||||
|
Logger.log("i", "The current quality type [%s] is not available, switching to [%s] instead",
|
||||||
|
current_quality_type, quality_type)
|
||||||
self._setQualityGroup(candidate_quality_groups[quality_type], empty_quality_changes = True)
|
self._setQualityGroup(candidate_quality_groups[quality_type], empty_quality_changes = True)
|
||||||
|
|
||||||
def _updateMaterialWithVariant(self, position: Optional[str]):
|
def _updateMaterialWithVariant(self, position: Optional[str]):
|
||||||
|
|
@ -955,9 +963,8 @@ class MachineManager(QObject):
|
||||||
current_material_base_name = extruder.material.getMetaDataEntry("base_file")
|
current_material_base_name = extruder.material.getMetaDataEntry("base_file")
|
||||||
current_variant_name = extruder.variant.getMetaDataEntry("name")
|
current_variant_name = extruder.variant.getMetaDataEntry("name")
|
||||||
|
|
||||||
material_manager = Application.getInstance()._material_manager
|
|
||||||
material_diameter = self._global_container_stack.getProperty("material_diameter", "value")
|
material_diameter = self._global_container_stack.getProperty("material_diameter", "value")
|
||||||
candidate_materials = material_manager.getAvailableMaterials(
|
candidate_materials = self._material_manager.getAvailableMaterials(
|
||||||
self._global_container_stack.definition.getId(),
|
self._global_container_stack.definition.getId(),
|
||||||
current_variant_name,
|
current_variant_name,
|
||||||
material_diameter)
|
material_diameter)
|
||||||
|
|
@ -1004,7 +1011,7 @@ class MachineManager(QObject):
|
||||||
|
|
||||||
# See if we need to show the Discard or Keep changes screen
|
# See if we need to show the Discard or Keep changes screen
|
||||||
if self.hasUserSettings and Preferences.getInstance().getValue("cura/active_mode") == 1:
|
if self.hasUserSettings and Preferences.getInstance().getValue("cura/active_mode") == 1:
|
||||||
Application.getInstance().discardOrKeepProfileChanges()
|
self._application.discardOrKeepProfileChanges()
|
||||||
|
|
||||||
@pyqtProperty(QObject, fset = setQualityGroup, notify = activeQualityGroupChanged)
|
@pyqtProperty(QObject, fset = setQualityGroup, notify = activeQualityGroupChanged)
|
||||||
def activeQualityGroup(self):
|
def activeQualityGroup(self):
|
||||||
|
|
@ -1018,7 +1025,7 @@ class MachineManager(QObject):
|
||||||
|
|
||||||
# See if we need to show the Discard or Keep changes screen
|
# See if we need to show the Discard or Keep changes screen
|
||||||
if self.hasUserSettings and Preferences.getInstance().getValue("cura/active_mode") == 1:
|
if self.hasUserSettings and Preferences.getInstance().getValue("cura/active_mode") == 1:
|
||||||
Application.getInstance().discardOrKeepProfileChanges()
|
self._application.discardOrKeepProfileChanges()
|
||||||
|
|
||||||
@pyqtProperty(QObject, fset = setQualityChangesGroup, notify = activeQualityChangesGroupChanged)
|
@pyqtProperty(QObject, fset = setQualityChangesGroup, notify = activeQualityChangesGroupChanged)
|
||||||
def activeQualityChangesGroup(self):
|
def activeQualityChangesGroup(self):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue