mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-08 07:27:29 -06:00
start
This commit is contained in:
parent
ff732720ca
commit
c132300fd5
2 changed files with 33 additions and 33 deletions
|
@ -28,6 +28,20 @@ if TYPE_CHECKING:
|
|||
#
|
||||
# This keeps a list of extruder stacks for each machine.
|
||||
class ExtruderManager(QObject):
|
||||
|
||||
## Registers listeners and such to listen to changes to the extruders.
|
||||
def __init__(self, parent = None):
|
||||
super().__init__(parent)
|
||||
|
||||
self._extruder_trains = {} # Per machine, a dictionary of extruder container stack IDs. Only for separately defined extruders.
|
||||
self._active_extruder_index = -1 # Indicates the index of the active extruder stack. -1 means no active extruder stack
|
||||
self._selected_object_extruders = []
|
||||
self._global_container_stack_definition_id = None
|
||||
self._addCurrentMachineExtruders()
|
||||
|
||||
Application.getInstance().globalContainerStackChanged.connect(self.__globalContainerStackChanged)
|
||||
Selection.selectionChanged.connect(self.resetSelectedObjectExtruders)
|
||||
|
||||
## Signal to notify other components when the list of extruders for a machine definition changes.
|
||||
extrudersChanged = pyqtSignal(QVariant)
|
||||
|
||||
|
@ -38,18 +52,6 @@ class ExtruderManager(QObject):
|
|||
## Notify when the user switches the currently active extruder.
|
||||
activeExtruderChanged = pyqtSignal()
|
||||
|
||||
## Registers listeners and such to listen to changes to the extruders.
|
||||
def __init__(self, parent = None):
|
||||
super().__init__(parent)
|
||||
self._extruder_trains = { } #Per machine, a dictionary of extruder container stack IDs. Only for separately defined extruders.
|
||||
self._active_extruder_index = -1 # Indicates the index of the active extruder stack. -1 means no active extruder stack
|
||||
self._selected_object_extruders = []
|
||||
Application.getInstance().globalContainerStackChanged.connect(self.__globalContainerStackChanged)
|
||||
self._global_container_stack_definition_id = None
|
||||
self._addCurrentMachineExtruders()
|
||||
|
||||
Selection.selectionChanged.connect(self.resetSelectedObjectExtruders)
|
||||
|
||||
## Gets the unique identifier of the currently active extruder stack.
|
||||
#
|
||||
# The currently active extruder stack is the stack that is currently being
|
||||
|
@ -521,8 +523,8 @@ class ExtruderManager(QObject):
|
|||
machine_extruder_count = global_stack.getProperty("machine_extruder_count", "value")
|
||||
|
||||
# In case the printer is using one extruder, shouldn't exist active extruder stacks
|
||||
if machine_extruder_count == 1:
|
||||
return result
|
||||
# if machine_extruder_count == 1:
|
||||
# return result
|
||||
|
||||
if global_stack and global_stack.getId() in self._extruder_trains:
|
||||
for extruder in sorted(self._extruder_trains[global_stack.getId()]):
|
||||
|
@ -537,16 +539,10 @@ class ExtruderManager(QObject):
|
|||
self.globalContainerStackDefinitionChanged.emit()
|
||||
|
||||
# If the global container changed, the number of extruders could be changed and so the active_extruder_index is updated
|
||||
extruder_count = global_container_stack.getProperty("machine_extruder_count", "value")
|
||||
if extruder_count > 1:
|
||||
if self._active_extruder_index == -1:
|
||||
self.setActiveExtruderIndex(0)
|
||||
else:
|
||||
if self._active_extruder_index != -1:
|
||||
self.setActiveExtruderIndex(-1)
|
||||
|
||||
self.activeExtruderChanged.emit()
|
||||
|
||||
self.resetSelectedObjectExtruders()
|
||||
|
||||
## Adds the extruders of the currently active machine.
|
||||
|
|
|
@ -171,18 +171,22 @@ class MachineSettingsAction(MachineAction):
|
|||
|
||||
definition_changes_container.setProperty("machine_extruder_count", "value", extruder_count)
|
||||
|
||||
if extruder_count > 1:
|
||||
# Multiextrusion
|
||||
|
||||
# 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()
|
||||
extruder_stacks = ExtruderManager.getInstance().getActiveExtruderStack()
|
||||
global_user_container = self._global_container_stack.getTop()
|
||||
|
||||
for setting_instance in global_user_container.findInstances():
|
||||
setting_key = setting_instance.definition.key
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
for setting_instance in global_user_container.findInstances():
|
||||
setting_key = setting_instance.definition.key
|
||||
settable_per_extruder = self._global_container_stack.getProperty(setting_key, "settable_per_extruder")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue