Merge branch 'feature_local_container_server' of github.com:Ultimaker/Cura into feature_local_container_server

This commit is contained in:
Jack Ha 2017-12-06 11:03:47 +01:00
commit 20500b5c51
3 changed files with 39 additions and 3 deletions

View file

@ -725,7 +725,7 @@ class CuraApplication(QtApplication):
self.exec_() self.exec_()
def getMachineManager(self, *args): def getMachineManager(self, *args) -> MachineManager:
if self._machine_manager is None: if self._machine_manager is None:
self._machine_manager = MachineManager.createMachineManager() self._machine_manager = MachineManager.createMachineManager()
return self._machine_manager return self._machine_manager

View file

@ -789,7 +789,8 @@ class ContainerManager(QObject):
if container_to_copy.getMetaDataEntry("definition") != "fdmprinter": if container_to_copy.getMetaDataEntry("definition") != "fdmprinter":
new_id += "_" + container_to_copy.getMetaDataEntry("definition") new_id += "_" + container_to_copy.getMetaDataEntry("definition")
if container_to_copy.getMetaDataEntry("variant"): if container_to_copy.getMetaDataEntry("variant"):
new_id += "_" + container_to_copy.getMetaDataEntry("variant") variant = self._container_registry.findContainers(id = container_to_copy.getMetaDataEntry("variant"))[0]
new_id += "_" + variant.getName().replace(" ", "_")
if current_id == material_id: if current_id == material_id:
clone_of_original = new_id clone_of_original = new_id

View file

@ -1,7 +1,7 @@
# Copyright (c) 2017 Ultimaker B.V. # Copyright (c) 2017 Ultimaker B.V.
# Cura is released under the terms of the LGPLv3 or higher. # Cura is released under the terms of the LGPLv3 or higher.
from UM.Application import Application
from UM.Application import Application
from cura.QualityManager import QualityManager from cura.QualityManager import QualityManager
from cura.Settings.ProfilesModel import ProfilesModel from cura.Settings.ProfilesModel import ProfilesModel
from cura.Settings.ExtruderManager import ExtruderManager from cura.Settings.ExtruderManager import ExtruderManager
@ -12,6 +12,16 @@ class UserProfilesModel(ProfilesModel):
def __init__(self, parent = None): def __init__(self, parent = None):
super().__init__(parent) super().__init__(parent)
#Need to connect to the metaDataChanged signal of the active materials.
self.__current_extruders = []
self.__current_materials = []
Application.getInstance().getExtruderManager().extrudersChanged.connect(self.__onExtrudersChanged)
self.__onExtrudersChanged()
self.__current_materials = [extruder.material for extruder in self.__current_extruders]
for material in self.__current_materials:
material.metaDataChanged.connect(self._onContainerChanged)
## Fetch the list of containers to display. ## Fetch the list of containers to display.
# #
# See UM.Settings.Models.InstanceContainersModel._fetchInstanceContainers(). # See UM.Settings.Models.InstanceContainersModel._fetchInstanceContainers().
@ -43,3 +53,28 @@ class UserProfilesModel(ProfilesModel):
qc.getMetaDataEntry("extruder") == active_extruder.definition.getId())} qc.getMetaDataEntry("extruder") == active_extruder.definition.getId())}
return filtered_quality_changes, {} return filtered_quality_changes, {}
## Called when a container changed on an extruder stack.
#
# If it's the material we need to connect to the metaDataChanged signal of
# that.
def __onContainerChanged(self, new_container):
#Careful not to update when a quality or quality changes profile changed!
#If you then update you're going to have an infinite recursion because the update may change the container.
if new_container.getMetaDataEntry("type") == "material":
for material in self.__current_materials:
material.metaDataChanged.disconnect(self._onContainerChanged)
self.__current_materials = [extruder.material for extruder in self.__current_extruders]
for material in self.__current_materials:
material.metaDataChanged.connect(self._onContainerChanged)
## Called when the current set of extruders change.
#
# This makes sure that we are listening to the signal for when the
# materials change.
def __onExtrudersChanged(self):
for extruder in self.__current_extruders:
extruder.containersChanged.disconnect(self.__onContainerChanged)
self.__current_extruders = Application.getInstance().getExtruderManager().getExtruderStacks()
for extruder in self.__current_extruders:
extruder.containersChanged.connect(self.__onContainerChanged)