mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-07 23:17:32 -06:00
More profiles model refactoring - CURA-4482
This commit is contained in:
parent
de34464e47
commit
152f6f8405
3 changed files with 32 additions and 27 deletions
|
@ -53,6 +53,7 @@ class CrashHandler:
|
||||||
self.exception_type = exception_type
|
self.exception_type = exception_type
|
||||||
self.value = value
|
self.value = value
|
||||||
self.traceback = tb
|
self.traceback = tb
|
||||||
|
self.dialog = QDialog()
|
||||||
|
|
||||||
# While we create the GUI, the information will be stored for sending afterwards
|
# While we create the GUI, the information will be stored for sending afterwards
|
||||||
self.data = dict()
|
self.data = dict()
|
||||||
|
|
|
@ -32,11 +32,9 @@ class ProfilesModel(InstanceContainersModel):
|
||||||
self.addRoleName(self.AvailableRole, "available")
|
self.addRoleName(self.AvailableRole, "available")
|
||||||
|
|
||||||
Application.getInstance().globalContainerStackChanged.connect(self._update)
|
Application.getInstance().globalContainerStackChanged.connect(self._update)
|
||||||
|
Application.getInstance().getMachineManager().activeVariantChanged.connect(self._update)
|
||||||
self._machine_manager = Application.getInstance().getMachineManager()
|
Application.getInstance().getMachineManager().activeStackChanged.connect(self._update)
|
||||||
self._machine_manager.activeVariantChanged.connect(self._update)
|
Application.getInstance().getMachineManager().activeMaterialChanged.connect(self._update)
|
||||||
self._machine_manager.activeStackChanged.connect(self._update)
|
|
||||||
self._machine_manager.activeMaterialChanged.connect(self._update)
|
|
||||||
|
|
||||||
# Factory function, used by QML
|
# Factory function, used by QML
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
@ -153,17 +151,21 @@ class ProfilesModel(InstanceContainersModel):
|
||||||
yield item
|
yield item
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
machine_manager = Application.getInstance().getMachineManager()
|
||||||
|
|
||||||
# Quality-changes profile that has no value for layer height. Get the corresponding quality profile and ask that profile.
|
# Quality-changes profile that has no value for layer height. Get the corresponding quality profile and ask that profile.
|
||||||
quality_type = profile.getMetaDataEntry("quality_type", None)
|
quality_type = profile.getMetaDataEntry("quality_type", None)
|
||||||
if quality_type:
|
if quality_type:
|
||||||
quality_results = self._machine_manager.determineQualityAndQualityChangesForQualityType(quality_type)
|
quality_results = machine_manager.determineQualityAndQualityChangesForQualityType(quality_type)
|
||||||
for quality_result in quality_results:
|
for quality_result in quality_results:
|
||||||
if quality_result["stack"] is global_container_stack:
|
if quality_result["stack"] is global_container_stack:
|
||||||
quality = quality_result["quality"]
|
quality = quality_result["quality"]
|
||||||
break
|
break
|
||||||
else: #No global container stack in the results:
|
else:
|
||||||
|
# No global container stack in the results:
|
||||||
if quality_results:
|
if quality_results:
|
||||||
quality = quality_results[0]["quality"] #Take any of the extruders.
|
# Take any of the extruders.
|
||||||
|
quality = quality_results[0]["quality"]
|
||||||
else:
|
else:
|
||||||
quality = None
|
quality = None
|
||||||
if quality and quality.hasProperty("layer_height", "value"):
|
if quality and quality.hasProperty("layer_height", "value"):
|
||||||
|
@ -171,11 +173,11 @@ class ProfilesModel(InstanceContainersModel):
|
||||||
yield item
|
yield item
|
||||||
continue
|
continue
|
||||||
|
|
||||||
#Quality has no value for layer height either. Get the layer height from somewhere lower in the stack.
|
# Quality has no value for layer height either. Get the layer height from somewhere lower in the stack.
|
||||||
skip_until_container = global_container_stack.material
|
skip_until_container = global_container_stack.material
|
||||||
if not skip_until_container or skip_until_container == ContainerRegistry.getInstance().getEmptyInstanceContainer(): #No material in stack.
|
if not skip_until_container or skip_until_container == ContainerRegistry.getInstance().getEmptyInstanceContainer(): # No material in stack.
|
||||||
skip_until_container = global_container_stack.variant
|
skip_until_container = global_container_stack.variant
|
||||||
if not skip_until_container or skip_until_container == ContainerRegistry.getInstance().getEmptyInstanceContainer(): #No variant in stack.
|
if not skip_until_container or skip_until_container == ContainerRegistry.getInstance().getEmptyInstanceContainer(): # No variant in stack.
|
||||||
skip_until_container = global_container_stack.getBottom()
|
skip_until_container = global_container_stack.getBottom()
|
||||||
self._setItemLayerHeight(item, global_container_stack.getRawProperty("layer_height", "value", skip_until_container = skip_until_container.getId()), unit) # Fall through to the currently loaded material.
|
self._setItemLayerHeight(item, global_container_stack.getRawProperty("layer_height", "value", skip_until_container = skip_until_container.getId()), unit) # Fall through to the currently loaded material.
|
||||||
yield item
|
yield item
|
||||||
|
|
|
@ -176,17 +176,19 @@ class MachineSettingsAction(MachineAction):
|
||||||
extruder_manager.setActiveExtruderIndex(0)
|
extruder_manager.setActiveExtruderIndex(0)
|
||||||
|
|
||||||
# Move settable_per_extruder values out of the global container
|
# Move settable_per_extruder values out of the global container
|
||||||
extruder_stacks = ExtruderManager.getInstance().getActiveExtruderStack()
|
# extruder_stacks = ExtruderManager.getInstance().getActiveExtruderStack()
|
||||||
global_user_container = self._global_container_stack.getTop()
|
global_user_container = self._global_container_stack.getTop()
|
||||||
|
|
||||||
for setting_instance in global_user_container.findInstances():
|
if extruder_count > 1:
|
||||||
setting_key = setting_instance.definition.key
|
# Multi extrusion
|
||||||
|
# Make sure one of the extruder stacks is active
|
||||||
|
if extruder_manager.activeExtruderIndex == -1:
|
||||||
|
extruder_manager.setActiveExtruderIndex(0)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Move settable_per_extruder values out of the global container
|
||||||
|
if previous_extruder_count == 1:
|
||||||
|
extruder_stacks = ExtruderManager.getInstance().getActiveExtruderStacks()
|
||||||
|
global_user_container = self._global_container_stack.getTop()
|
||||||
for setting_instance in global_user_container.findInstances():
|
for setting_instance in global_user_container.findInstances():
|
||||||
setting_key = setting_instance.definition.key
|
setting_key = setting_instance.definition.key
|
||||||
settable_per_extruder = self._global_container_stack.getProperty(setting_key, "settable_per_extruder")
|
settable_per_extruder = self._global_container_stack.getProperty(setting_key, "settable_per_extruder")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue