Merge branch 'master' of github.com:Ultimaker/Cura

This commit is contained in:
Jaime van Kessel 2017-05-22 14:10:27 +02:00
commit 92192ff411
5 changed files with 54 additions and 41 deletions

View file

@ -15,7 +15,7 @@ from UM.Settings.ContainerRegistry import ContainerRegistry #Finding containers
from UM.Settings.InstanceContainer import InstanceContainer from UM.Settings.InstanceContainer import InstanceContainer
from UM.Settings.SettingFunction import SettingFunction from UM.Settings.SettingFunction import SettingFunction
from UM.Settings.ContainerStack import ContainerStack from UM.Settings.ContainerStack import ContainerStack
from UM.Settings.DefinitionContainer import DefinitionContainer from UM.Settings.Interfaces import DefinitionContainerInterface
from typing import Optional, List, TYPE_CHECKING, Union from typing import Optional, List, TYPE_CHECKING, Union
if TYPE_CHECKING: if TYPE_CHECKING:
@ -74,7 +74,7 @@ class ExtruderManager(QObject):
except KeyError: except KeyError:
return 0 return 0
@pyqtProperty("QVariantMap", notify=extrudersChanged) @pyqtProperty("QVariantMap", notify = extrudersChanged)
def extruderIds(self): def extruderIds(self):
map = {} map = {}
global_stack_id = Application.getInstance().getGlobalContainerStack().getId() global_stack_id = Application.getInstance().getGlobalContainerStack().getId()
@ -203,7 +203,7 @@ class ExtruderManager(QObject):
# \param machine_definition The machine definition to add the extruders for. # \param machine_definition The machine definition to add the extruders for.
# \param machine_id The machine_id to add the extruders for. # \param machine_id The machine_id to add the extruders for.
@deprecated("Use CuraStackBuilder", "2.6") @deprecated("Use CuraStackBuilder", "2.6")
def addMachineExtruders(self, machine_definition: DefinitionContainer, machine_id: str) -> None: def addMachineExtruders(self, machine_definition: DefinitionContainerInterface, machine_id: str) -> None:
changed = False changed = False
machine_definition_id = machine_definition.getId() machine_definition_id = machine_definition.getId()
if machine_id not in self._extruder_trains: if machine_id not in self._extruder_trains:
@ -263,7 +263,7 @@ class ExtruderManager(QObject):
# \param position The position of this extruder train in the extruder slots of the machine. # \param position The position of this extruder train in the extruder slots of the machine.
# \param machine_id The id of the "global" stack this extruder is linked to. # \param machine_id The id of the "global" stack this extruder is linked to.
@deprecated("Use CuraStackBuilder::createExtruderStack", "2.6") @deprecated("Use CuraStackBuilder::createExtruderStack", "2.6")
def createExtruderTrain(self, extruder_definition: DefinitionContainer, machine_definition: DefinitionContainer, def createExtruderTrain(self, extruder_definition: DefinitionContainerInterface, machine_definition: DefinitionContainerInterface,
position, machine_id: str) -> None: position, machine_id: str) -> None:
# Cache some things. # Cache some things.
container_registry = ContainerRegistry.getInstance() container_registry = ContainerRegistry.getInstance()
@ -525,7 +525,7 @@ class ExtruderManager(QObject):
# #
# This is exposed to SettingFunction so it can be used in value functions. # This is exposed to SettingFunction so it can be used in value functions.
# #
# \param key The key of the setting to retieve values for. # \param key The key of the setting to retrieve values for.
# #
# \return A list of values for all extruders. If an extruder does not have a value, it will not be in the list. # \return A list of values for all extruders. If an extruder does not have a value, it will not be in the list.
# If no extruder has the value, the list will contain the global value. # If no extruder has the value, the list will contain the global value.

View file

@ -1,12 +1,15 @@
# Copyright (c) 2016 Ultimaker B.V. # Copyright (c) 2017 Ultimaker B.V.
# Cura is released under the terms of the AGPLv3 or higher. # Cura is released under the terms of the AGPLv3 or higher.
from PyQt5.QtCore import Qt, pyqtSignal, pyqtProperty, QTimer from PyQt5.QtCore import Qt, pyqtSignal, pyqtProperty, QTimer
from typing import Iterable
import UM.Qt.ListModel import UM.Qt.ListModel
from UM.Application import Application from UM.Application import Application
import UM.FlameProfiler import UM.FlameProfiler
from cura.Settings.ExtruderManager import ExtruderManager from cura.Settings.ExtruderManager import ExtruderManager
from cura.Settings.ExtruderStack import ExtruderStack #To listen to changes on the extruders.
from cura.Settings.MachineManager import MachineManager #To listen to changes on the extruders of the currently active machine.
## Model that holds extruders. ## Model that holds extruders.
# #
@ -66,17 +69,13 @@ class ExtrudersModel(UM.Qt.ListModel.ListModel):
self._add_global = False self._add_global = False
self._simple_names = False self._simple_names = False
self._active_extruder_stack = None self._active_machine_extruders = [] # type: Iterable[ExtruderStack]
self._add_optional_extruder = False self._add_optional_extruder = False
#Listen to changes. #Listen to changes.
Application.getInstance().globalContainerStackChanged.connect(self._updateExtruders) Application.getInstance().globalContainerStackChanged.connect(self._extrudersChanged) #When the machine is swapped we must update the active machine extruders.
manager = ExtruderManager.getInstance() ExtruderManager.getInstance().extrudersChanged.connect(self._extrudersChanged) #When the extruders change we must link to the stack-changed signal of the new extruder.
self._extrudersChanged() #Also calls _updateExtruders.
self._updateExtruders()
manager.activeExtruderChanged.connect(self._onActiveExtruderChanged)
self._onActiveExtruderChanged()
def setAddGlobal(self, add): def setAddGlobal(self, add):
if add != self._add_global: if add != self._add_global:
@ -117,17 +116,31 @@ class ExtrudersModel(UM.Qt.ListModel.ListModel):
def simpleNames(self): def simpleNames(self):
return self._simple_names return self._simple_names
def _onActiveExtruderChanged(self): ## Links to the stack-changed signal of the new extruders when an extruder
manager = ExtruderManager.getInstance() # is swapped out or added in the current machine.
active_extruder_stack = manager.getActiveExtruderStack() #
if self._active_extruder_stack != active_extruder_stack: # \param machine_id The machine for which the extruders changed. This is
if self._active_extruder_stack: # filled by the ExtruderManager.extrudersChanged signal when coming from
self._active_extruder_stack.containersChanged.disconnect(self._onExtruderStackContainersChanged) # that signal. Application.globalContainerStackChanged doesn't fill this
# signal; it's assumed to be the current printer in that case.
def _extrudersChanged(self, machine_id = None):
if machine_id is not None:
if Application.getInstance().getGlobalContainerStack() is None:
return #No machine, don't need to update the current machine's extruders.
if machine_id != Application.getInstance().getGlobalContainerStack().getId():
return #Not the current machine.
#Unlink from old extruders.
for extruder in self._active_machine_extruders:
extruder.containersChanged.disconnect(self._onExtruderStackContainersChanged)
if active_extruder_stack: #Link to new extruders.
# Update the model when the material container is changed self._active_machine_extruders = []
active_extruder_stack.containersChanged.connect(self._onExtruderStackContainersChanged) extruder_manager = ExtruderManager.getInstance()
self._active_extruder_stack = active_extruder_stack for extruder in extruder_manager.getExtruderStacks():
extruder.containersChanged.connect(self._onExtruderStackContainersChanged)
self._active_machine_extruders.append(extruder)
self._updateExtruders() #Since the new extruders may have different properties, update our own model.
def _onExtruderStackContainersChanged(self, container): def _onExtruderStackContainersChanged(self, container):
# Update when there is an empty container or material change # Update when there is an empty container or material change

View file

@ -705,7 +705,7 @@ class MachineManager(QObject):
# Depending on from/to material+current variant, a quality profile is chosen and set. # Depending on from/to material+current variant, a quality profile is chosen and set.
@pyqtSlot(str) @pyqtSlot(str)
def setActiveMaterial(self, material_id: str): def setActiveMaterial(self, material_id: str):
with postponeSignals(*self._getContainerChangedSignals(), compress = True): with postponeSignals(*self._getContainerChangedSignals()):
containers = ContainerRegistry.getInstance().findInstanceContainers(id = material_id) containers = ContainerRegistry.getInstance().findInstanceContainers(id = material_id)
if not containers or not self._active_container_stack: if not containers or not self._active_container_stack:
return return
@ -770,7 +770,7 @@ class MachineManager(QObject):
@pyqtSlot(str) @pyqtSlot(str)
def setActiveVariant(self, variant_id: str): def setActiveVariant(self, variant_id: str):
with postponeSignals(*self._getContainerChangedSignals(), compress = True): with postponeSignals(*self._getContainerChangedSignals()):
containers = ContainerRegistry.getInstance().findInstanceContainers(id = variant_id) containers = ContainerRegistry.getInstance().findInstanceContainers(id = variant_id)
if not containers or not self._active_container_stack: if not containers or not self._active_container_stack:
return return

View file

@ -1,4 +1,4 @@
# Copyright (c) 2016 Ultimaker B.V. # Copyright (c) 2017 Ultimaker B.V.
# Cura is released under the terms of the AGPLv3 or higher. # Cura is released under the terms of the AGPLv3 or higher.
from PyQt5.QtCore import QObject, pyqtProperty, pyqtSignal from PyQt5.QtCore import QObject, pyqtProperty, pyqtSignal
@ -35,7 +35,7 @@ class SettingInheritanceManager(QObject):
## Get the keys of all children settings with an override. ## Get the keys of all children settings with an override.
@pyqtSlot(str, result = "QStringList") @pyqtSlot(str, result = "QStringList")
def getChildrenKeysWithOverride(self, key): def getChildrenKeysWithOverride(self, key):
definitions = self._global_container_stack.getBottom().findDefinitions(key=key) definitions = self._global_container_stack.definition.findDefinitions(key=key)
if not definitions: if not definitions:
Logger.log("w", "Could not find definition for key [%s]", key) Logger.log("w", "Could not find definition for key [%s]", key)
return [] return []
@ -55,7 +55,7 @@ class SettingInheritanceManager(QObject):
Logger.log("w", "Unable to find extruder for current machine with index %s", extruder_index) Logger.log("w", "Unable to find extruder for current machine with index %s", extruder_index)
return [] return []
definitions = self._global_container_stack.getBottom().findDefinitions(key=key) definitions = self._global_container_stack.definition.findDefinitions(key=key)
if not definitions: if not definitions:
Logger.log("w", "Could not find definition for key [%s] (2)", key) Logger.log("w", "Could not find definition for key [%s] (2)", key)
return [] return []
@ -93,7 +93,7 @@ class SettingInheritanceManager(QObject):
def _onPropertyChanged(self, key, property_name): def _onPropertyChanged(self, key, property_name):
if (property_name == "value" or property_name == "enabled") and self._global_container_stack: if (property_name == "value" or property_name == "enabled") and self._global_container_stack:
definitions = self._global_container_stack.getBottom().findDefinitions(key = key) definitions = self._global_container_stack.definition.findDefinitions(key = key)
if not definitions: if not definitions:
return return
@ -209,7 +209,7 @@ class SettingInheritanceManager(QObject):
self._settings_with_inheritance_warning.append(setting_key) self._settings_with_inheritance_warning.append(setting_key)
# Check all the categories if any of their children have their inheritance overwritten. # Check all the categories if any of their children have their inheritance overwritten.
for category in self._global_container_stack.getBottom().findDefinitions(type = "category"): for category in self._global_container_stack.definition.findDefinitions(type = "category"):
if self._recursiveCheck(category): if self._recursiveCheck(category):
self._settings_with_inheritance_warning.append(category.key) self._settings_with_inheritance_warning.append(category.key)

View file

@ -773,7 +773,7 @@
"type": "float", "type": "float",
"enabled": "support_enable and support_roof_enable", "enabled": "support_enable and support_roof_enable",
"limit_to_extruder": "support_roof_extruder_nr", "limit_to_extruder": "support_roof_extruder_nr",
"value": "support_interface_line_width", "value": "extruderValue(support_roof_extruder_nr, 'support_interface_line_width')",
"settable_per_mesh": false, "settable_per_mesh": false,
"settable_per_extruder": true "settable_per_extruder": true
}, },
@ -789,7 +789,7 @@
"type": "float", "type": "float",
"enabled": "support_enable and support_bottom_enable", "enabled": "support_enable and support_bottom_enable",
"limit_to_extruder": "support_bottom_extruder_nr", "limit_to_extruder": "support_bottom_extruder_nr",
"value": "support_interface_line_width", "value": "extruderValue(support_bottom_extruder_nr, 'support_interface_line_width')",
"settable_per_mesh": false, "settable_per_mesh": false,
"settable_per_extruder": true "settable_per_extruder": true
} }
@ -1972,7 +1972,7 @@
"maximum_value_warning": "150", "maximum_value_warning": "150",
"enabled": "support_roof_enable and support_enable", "enabled": "support_roof_enable and support_enable",
"limit_to_extruder": "support_roof_extruder_nr", "limit_to_extruder": "support_roof_extruder_nr",
"value": "speed_support_interface", "value": "extruderValue(support_roof_extruder_nr, 'speed_support_interface')",
"settable_per_mesh": false, "settable_per_mesh": false,
"settable_per_extruder": true "settable_per_extruder": true
}, },
@ -1988,7 +1988,7 @@
"maximum_value_warning": "150", "maximum_value_warning": "150",
"enabled": "support_bottom_enable and support_enable", "enabled": "support_bottom_enable and support_enable",
"limit_to_extruder": "support_bottom_extruder_nr", "limit_to_extruder": "support_bottom_extruder_nr",
"value": "speed_support_interface", "value": "extruderValue(support_bottom_extruder_nr, 'speed_support_interface')",
"settable_per_mesh": false, "settable_per_mesh": false,
"settable_per_extruder": true "settable_per_extruder": true
} }
@ -2288,11 +2288,11 @@
"unit": "mm/s²", "unit": "mm/s²",
"type": "float", "type": "float",
"default_value": 3000, "default_value": 3000,
"value": "acceleration_support_interface", "value": "extruderValue(support_roof_extruder_nr, 'acceleration_support_interface')",
"minimum_value": "0.1", "minimum_value": "0.1",
"minimum_value_warning": "100", "minimum_value_warning": "100",
"maximum_value_warning": "10000", "maximum_value_warning": "10000",
"enabled": "resolveOrValue('acceleration_enabled') and support_roof_enable and support_enable", "enabled": "acceleration_enabled and support_roof_enable and support_enable",
"limit_to_extruder": "support_roof_extruder_nr", "limit_to_extruder": "support_roof_extruder_nr",
"settable_per_mesh": false, "settable_per_mesh": false,
"settable_per_extruder": true "settable_per_extruder": true
@ -2304,11 +2304,11 @@
"unit": "mm/s²", "unit": "mm/s²",
"type": "float", "type": "float",
"default_value": 3000, "default_value": 3000,
"value": "acceleration_support_interface", "value": "extruderValue(support_bottom_extruder_nr, 'acceleration_support_interface')",
"minimum_value": "0.1", "minimum_value": "0.1",
"minimum_value_warning": "100", "minimum_value_warning": "100",
"maximum_value_warning": "10000", "maximum_value_warning": "10000",
"enabled": "resolveOrValue('acceleration_enabled') and support_bottom_enable and support_enable", "enabled": "acceleration_enabled and support_bottom_enable and support_enable",
"limit_to_extruder": "support_bottom_extruder_nr", "limit_to_extruder": "support_bottom_extruder_nr",
"settable_per_mesh": false, "settable_per_mesh": false,
"settable_per_extruder": true "settable_per_extruder": true
@ -2553,7 +2553,7 @@
"unit": "mm/s", "unit": "mm/s",
"type": "float", "type": "float",
"default_value": 20, "default_value": 20,
"value": "jerk_support_interface", "value": "extruderValue(support_roof_extruder_nr, 'jerk_support_interface')",
"minimum_value": "0.1", "minimum_value": "0.1",
"maximum_value_warning": "50", "maximum_value_warning": "50",
"enabled": "resolveOrValue('jerk_enabled') and support_roof_enable and support_enable", "enabled": "resolveOrValue('jerk_enabled') and support_roof_enable and support_enable",
@ -2568,7 +2568,7 @@
"unit": "mm/s", "unit": "mm/s",
"type": "float", "type": "float",
"default_value": 20, "default_value": 20,
"value": "jerk_support_interface", "value": "extruderValue(support_roof_extruder_nr, 'jerk_support_interface')",
"minimum_value": "0.1", "minimum_value": "0.1",
"maximum_value_warning": "50", "maximum_value_warning": "50",
"enabled": "resolveOrValue('jerk_enabled') and support_bottom_enable and support_enable", "enabled": "resolveOrValue('jerk_enabled') and support_bottom_enable and support_enable",