mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-12 03:29:00 +08:00
Merge branch 'master' of github.com:Ultimaker/Cura
This commit is contained in:
commit
2c364f4699
@ -4,6 +4,7 @@
|
|||||||
from UM.Application import Application
|
from UM.Application import Application
|
||||||
from UM.Logger import Logger
|
from UM.Logger import Logger
|
||||||
from UM.Settings.ContainerRegistry import ContainerRegistry
|
from UM.Settings.ContainerRegistry import ContainerRegistry
|
||||||
|
from cura.CuraApplication import CuraApplication
|
||||||
|
|
||||||
from cura.PrinterOutputDevice import PrinterOutputDevice, ConnectionState
|
from cura.PrinterOutputDevice import PrinterOutputDevice, ConnectionState
|
||||||
|
|
||||||
@ -255,20 +256,8 @@ class NetworkedPrinterOutputDevice(PrinterOutputDevice):
|
|||||||
self._last_manager_create_time = time()
|
self._last_manager_create_time = time()
|
||||||
self._manager.authenticationRequired.connect(self._onAuthenticationRequired)
|
self._manager.authenticationRequired.connect(self._onAuthenticationRequired)
|
||||||
|
|
||||||
self._checkCorrectGroupName()
|
machine_manager = CuraApplication.getInstance().getMachineManager()
|
||||||
|
machine_manager.checkCorrectGroupName(self.getId(), self.name)
|
||||||
## This method checks if the name of the group stored in the definition container is correct.
|
|
||||||
# After updating from 3.2 to 3.3 some group names may be temporary. If there is a mismatch in the name of the group
|
|
||||||
# then all the container stacks are updated, both the current and the hidden ones.
|
|
||||||
def _checkCorrectGroupName(self):
|
|
||||||
global_container_stack = Application.getInstance().getGlobalContainerStack()
|
|
||||||
if global_container_stack and self.getId() == global_container_stack.getMetaDataEntry("um_network_key"):
|
|
||||||
# Check if the connect_group_name is correct. If not, update all the containers connected to the same printer
|
|
||||||
if global_container_stack.getMetaDataEntry("connect_group_name") != self.name:
|
|
||||||
metadata_filter = {"um_network_key": global_container_stack.getMetaDataEntry("um_network_key")}
|
|
||||||
hidden_containers = ContainerRegistry.getInstance().findContainerStacks(type = "machine", **metadata_filter)
|
|
||||||
for container in hidden_containers:
|
|
||||||
container.setMetaDataEntry("connect_group_name", self.name)
|
|
||||||
|
|
||||||
def _registerOnFinishedCallback(self, reply: QNetworkReply, onFinished: Optional[Callable[[Any, QNetworkReply], None]]) -> None:
|
def _registerOnFinishedCallback(self, reply: QNetworkReply, onFinished: Optional[Callable[[Any, QNetworkReply], None]]) -> None:
|
||||||
if onFinished is not None:
|
if onFinished is not None:
|
||||||
|
@ -173,12 +173,13 @@ class CuraContainerRegistry(ContainerRegistry):
|
|||||||
plugin_registry = PluginRegistry.getInstance()
|
plugin_registry = PluginRegistry.getInstance()
|
||||||
extension = file_name.split(".")[-1]
|
extension = file_name.split(".")[-1]
|
||||||
|
|
||||||
global_container_stack = Application.getInstance().getGlobalContainerStack()
|
global_stack = Application.getInstance().getGlobalContainerStack()
|
||||||
if not global_container_stack:
|
if not global_stack:
|
||||||
return
|
return
|
||||||
|
|
||||||
machine_extruders = list(ExtruderManager.getInstance().getMachineExtruders(global_container_stack.getId()))
|
machine_extruders = []
|
||||||
machine_extruders.sort(key = lambda k: k.getMetaDataEntry("position"))
|
for position in sorted(global_stack.extruders):
|
||||||
|
machine_extruders.append(global_stack.extruders[position])
|
||||||
|
|
||||||
for plugin_id, meta_data in self._getIOPlugins("profile_reader"):
|
for plugin_id, meta_data in self._getIOPlugins("profile_reader"):
|
||||||
if meta_data["profile_reader"][0]["extension"] != extension:
|
if meta_data["profile_reader"][0]["extension"] != extension:
|
||||||
@ -200,13 +201,18 @@ class CuraContainerRegistry(ContainerRegistry):
|
|||||||
|
|
||||||
# First check if this profile is suitable for this machine
|
# First check if this profile is suitable for this machine
|
||||||
global_profile = None
|
global_profile = None
|
||||||
|
extruder_profiles = []
|
||||||
if len(profile_or_list) == 1:
|
if len(profile_or_list) == 1:
|
||||||
global_profile = profile_or_list[0]
|
global_profile = profile_or_list[0]
|
||||||
else:
|
else:
|
||||||
for profile in profile_or_list:
|
for profile in profile_or_list:
|
||||||
if not profile.getMetaDataEntry("position"):
|
if not profile.getMetaDataEntry("position"):
|
||||||
global_profile = profile
|
global_profile = profile
|
||||||
break
|
else:
|
||||||
|
extruder_profiles.append(profile)
|
||||||
|
extruder_profiles = sorted(extruder_profiles, key = lambda x: int(x.getMetaDataEntry("position")))
|
||||||
|
profile_or_list = [global_profile] + extruder_profiles
|
||||||
|
|
||||||
if not global_profile:
|
if not global_profile:
|
||||||
Logger.log("e", "Incorrect profile [%s]. Could not find global profile", file_name)
|
Logger.log("e", "Incorrect profile [%s]. Could not find global profile", file_name)
|
||||||
return { "status": "error",
|
return { "status": "error",
|
||||||
@ -227,7 +233,7 @@ class CuraContainerRegistry(ContainerRegistry):
|
|||||||
# Get the expected machine definition.
|
# Get the expected machine definition.
|
||||||
# i.e.: We expect gcode for a UM2 Extended to be defined as normal UM2 gcode...
|
# i.e.: We expect gcode for a UM2 Extended to be defined as normal UM2 gcode...
|
||||||
profile_definition = getMachineDefinitionIDForQualitySearch(machine_definition)
|
profile_definition = getMachineDefinitionIDForQualitySearch(machine_definition)
|
||||||
expected_machine_definition = getMachineDefinitionIDForQualitySearch(global_container_stack.definition)
|
expected_machine_definition = getMachineDefinitionIDForQualitySearch(global_stack.definition)
|
||||||
|
|
||||||
# And check if the profile_definition matches either one (showing error if not):
|
# And check if the profile_definition matches either one (showing error if not):
|
||||||
if profile_definition != expected_machine_definition:
|
if profile_definition != expected_machine_definition:
|
||||||
@ -251,8 +257,8 @@ class CuraContainerRegistry(ContainerRegistry):
|
|||||||
if len(profile_or_list) == 1:
|
if len(profile_or_list) == 1:
|
||||||
global_profile = profile_or_list[0]
|
global_profile = profile_or_list[0]
|
||||||
extruder_profiles = []
|
extruder_profiles = []
|
||||||
for idx, extruder in enumerate(global_container_stack.extruders.values()):
|
for idx, extruder in enumerate(global_stack.extruders.values()):
|
||||||
profile_id = ContainerRegistry.getInstance().uniqueName(global_container_stack.getId() + "_extruder_" + str(idx + 1))
|
profile_id = ContainerRegistry.getInstance().uniqueName(global_stack.getId() + "_extruder_" + str(idx + 1))
|
||||||
profile = InstanceContainer(profile_id)
|
profile = InstanceContainer(profile_id)
|
||||||
profile.setName(quality_name)
|
profile.setName(quality_name)
|
||||||
profile.addMetaDataEntry("setting_version", CuraApplication.SettingVersion)
|
profile.addMetaDataEntry("setting_version", CuraApplication.SettingVersion)
|
||||||
@ -264,12 +270,12 @@ class CuraContainerRegistry(ContainerRegistry):
|
|||||||
if idx == 0:
|
if idx == 0:
|
||||||
# move all per-extruder settings to the first extruder's quality_changes
|
# move all per-extruder settings to the first extruder's quality_changes
|
||||||
for qc_setting_key in global_profile.getAllKeys():
|
for qc_setting_key in global_profile.getAllKeys():
|
||||||
settable_per_extruder = global_container_stack.getProperty(qc_setting_key,
|
settable_per_extruder = global_stack.getProperty(qc_setting_key,
|
||||||
"settable_per_extruder")
|
"settable_per_extruder")
|
||||||
if settable_per_extruder:
|
if settable_per_extruder:
|
||||||
setting_value = global_profile.getProperty(qc_setting_key, "value")
|
setting_value = global_profile.getProperty(qc_setting_key, "value")
|
||||||
|
|
||||||
setting_definition = global_container_stack.getSettingDefinition(qc_setting_key)
|
setting_definition = global_stack.getSettingDefinition(qc_setting_key)
|
||||||
new_instance = SettingInstance(setting_definition, profile)
|
new_instance = SettingInstance(setting_definition, profile)
|
||||||
new_instance.setProperty("value", setting_value)
|
new_instance.setProperty("value", setting_value)
|
||||||
new_instance.resetState() # Ensure that the state is not seen as a user state.
|
new_instance.resetState() # Ensure that the state is not seen as a user state.
|
||||||
@ -286,7 +292,7 @@ class CuraContainerRegistry(ContainerRegistry):
|
|||||||
for profile_index, profile in enumerate(profile_or_list):
|
for profile_index, profile in enumerate(profile_or_list):
|
||||||
if profile_index == 0:
|
if profile_index == 0:
|
||||||
# This is assumed to be the global profile
|
# This is assumed to be the global profile
|
||||||
profile_id = (global_container_stack.getBottom().getId() + "_" + name_seed).lower().replace(" ", "_")
|
profile_id = (global_stack.getBottom().getId() + "_" + name_seed).lower().replace(" ", "_")
|
||||||
|
|
||||||
elif profile_index < len(machine_extruders) + 1:
|
elif profile_index < len(machine_extruders) + 1:
|
||||||
# This is assumed to be an extruder profile
|
# This is assumed to be an extruder profile
|
||||||
|
@ -1201,6 +1201,18 @@ class MachineManager(QObject):
|
|||||||
if machine.getMetaDataEntry(key) == value:
|
if machine.getMetaDataEntry(key) == value:
|
||||||
machine.setMetaDataEntry(key, new_value)
|
machine.setMetaDataEntry(key, new_value)
|
||||||
|
|
||||||
|
## This method checks if the name of the group stored in the definition container is correct.
|
||||||
|
# After updating from 3.2 to 3.3 some group names may be temporary. If there is a mismatch in the name of the group
|
||||||
|
# then all the container stacks are updated, both the current and the hidden ones.
|
||||||
|
def checkCorrectGroupName(self, device_id: str, group_name: str):
|
||||||
|
if self._global_container_stack and device_id == self.activeMachineNetworkKey:
|
||||||
|
# Check if the connect_group_name is correct. If not, update all the containers connected to the same printer
|
||||||
|
if self.activeMachineNetworkGroupName != group_name:
|
||||||
|
metadata_filter = {"um_network_key": self.activeMachineNetworkKey}
|
||||||
|
hidden_containers = ContainerRegistry.getInstance().findContainerStacks(type = "machine", **metadata_filter)
|
||||||
|
for container in hidden_containers:
|
||||||
|
container.setMetaDataEntry("connect_group_name", group_name)
|
||||||
|
|
||||||
@pyqtSlot("QVariant")
|
@pyqtSlot("QVariant")
|
||||||
def setGlobalVariant(self, container_node):
|
def setGlobalVariant(self, container_node):
|
||||||
self.blurSettings.emit()
|
self.blurSettings.emit()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user