mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-07 23:17:32 -06:00
Create extruder stack for single extruder machines on start - CURA-4482
This commit is contained in:
parent
b91824aab1
commit
d718e6e36c
20 changed files with 268 additions and 224 deletions
|
@ -12,6 +12,7 @@ from PyQt5.QtWidgets import QMessageBox
|
|||
from UM.Decorators import override
|
||||
from UM.Settings.ContainerRegistry import ContainerRegistry
|
||||
from UM.Settings.ContainerStack import ContainerStack
|
||||
from UM.Settings.DefinitionContainer import DefinitionContainer
|
||||
from UM.Settings.InstanceContainer import InstanceContainer
|
||||
from UM.Application import Application
|
||||
from UM.Logger import Logger
|
||||
|
@ -42,12 +43,13 @@ class CuraContainerRegistry(ContainerRegistry):
|
|||
# Global stack based on metadata information.
|
||||
@override(ContainerRegistry)
|
||||
def addContainer(self, container):
|
||||
|
||||
# Note: Intentional check with type() because we want to ignore subclasses
|
||||
if type(container) == ContainerStack:
|
||||
container = self._convertContainerStack(container)
|
||||
|
||||
if isinstance(container, InstanceContainer) and type(container) != type(self.getEmptyInstanceContainer()):
|
||||
#Check against setting version of the definition.
|
||||
# Check against setting version of the definition.
|
||||
required_setting_version = CuraApplication.SettingVersion
|
||||
actual_setting_version = int(container.getMetaDataEntry("setting_version", default = 0))
|
||||
if required_setting_version != actual_setting_version:
|
||||
|
@ -256,7 +258,8 @@ class CuraContainerRegistry(ContainerRegistry):
|
|||
@override(ContainerRegistry)
|
||||
def load(self):
|
||||
super().load()
|
||||
self._fixupExtruders()
|
||||
self._registerSingleExtrusionMachinesExtruderStacks()
|
||||
self._connectUpgradedExtruderStacksToMachines()
|
||||
|
||||
## Update an imported profile to match the current machine configuration.
|
||||
#
|
||||
|
@ -357,8 +360,8 @@ class CuraContainerRegistry(ContainerRegistry):
|
|||
return global_container_stack.material.getId()
|
||||
return ""
|
||||
|
||||
## Returns true if the current machien requires its own quality profiles
|
||||
# \return true if the current machien requires its own quality profiles
|
||||
## Returns true if the current machine requires its own quality profiles
|
||||
# \return true if the current machine requires its own quality profiles
|
||||
def _machineHasOwnQualities(self):
|
||||
global_container_stack = Application.getInstance().getGlobalContainerStack()
|
||||
if global_container_stack:
|
||||
|
@ -391,12 +394,59 @@ class CuraContainerRegistry(ContainerRegistry):
|
|||
|
||||
return new_stack
|
||||
|
||||
def _registerSingleExtrusionMachinesExtruderStacks(self):
|
||||
machines = ContainerRegistry.getInstance().findContainerStacks(machine_extruder_trains = {"0": "fdmextruder"})
|
||||
for machine in machines:
|
||||
self._addExtruderStackForSingleExtrusionMachine(machine, "fdmextruder")
|
||||
|
||||
def _addExtruderStackForSingleExtrusionMachine(self, machine, extruder_id):
|
||||
new_extruder_id = extruder_id
|
||||
|
||||
if machine.extruders and len(machine.extruders) > 0:
|
||||
new_extruder_id = machine.extruders["0"].getId()
|
||||
|
||||
extruder_definitions = self.findDefinitionContainers(id = new_extruder_id)
|
||||
|
||||
if not extruder_definitions:
|
||||
Logger.log("w", "Could not find definition containers for extruder %s", new_extruder_id)
|
||||
return
|
||||
|
||||
extruder_definition = extruder_definitions[0]
|
||||
unique_name = self.uniqueName(machine.getId() + " " + new_extruder_id)
|
||||
|
||||
extruder_stack = ExtruderStack.ExtruderStack(unique_name)
|
||||
extruder_stack.setName(extruder_definition.getName())
|
||||
extruder_stack.setDefinition(extruder_definition)
|
||||
extruder_stack.addMetaDataEntry("machine", machine.getId())
|
||||
extruder_stack.addMetaDataEntry("position", "0")
|
||||
extruder_stack.setNextStack(machine)
|
||||
|
||||
# if machine.userChanges:
|
||||
# # set existing user changes if found
|
||||
# extruder_stack.setUserChanges(machine.userChanges)
|
||||
# else:
|
||||
# # create empty user changes container otherwise
|
||||
# user_container = InstanceContainer(extruder_stack.getId() + "_user")
|
||||
# user_container.addMetaDataEntry("type", "user")
|
||||
# user_container.addMetaDataEntry("machine", extruder_stack.getId())
|
||||
# from cura.CuraApplication import CuraApplication
|
||||
# user_container.addMetaDataEntry("setting_version", CuraApplication.SettingVersion)
|
||||
# user_container.setDefinition(extruder_definition)
|
||||
# extruder_stack.setUserChanges(user_container)
|
||||
# self.addContainer(user_container)
|
||||
|
||||
# extruder_stack.setVariantById("default")
|
||||
# extruder_stack.setMaterialById("default")
|
||||
# extruder_stack.setQualityById("default")
|
||||
|
||||
self.addContainer(extruder_stack)
|
||||
|
||||
# Fix the extruders that were upgraded to ExtruderStack instances during addContainer.
|
||||
# The stacks are now responsible for setting the next stack on deserialize. However,
|
||||
# due to problems with loading order, some stacks may not have the proper next stack
|
||||
# set after upgrading, because the proper global stack was not yet loaded. This method
|
||||
# makes sure those extruders also get the right stack set.
|
||||
def _fixupExtruders(self):
|
||||
def _connectUpgradedExtruderStacksToMachines(self):
|
||||
extruder_stacks = self.findContainers(ExtruderStack.ExtruderStack)
|
||||
for extruder_stack in extruder_stacks:
|
||||
if extruder_stack.getNextStack():
|
||||
|
|
|
@ -62,7 +62,7 @@ class CuraStackBuilder:
|
|||
variant = "default",
|
||||
next_stack = new_global_stack
|
||||
)
|
||||
new_global_stack.addExtruder(new_extruder)
|
||||
# new_global_stack.addExtruder(new_extruder)
|
||||
|
||||
return new_global_stack
|
||||
|
||||
|
|
|
@ -1,21 +1,18 @@
|
|||
# Copyright (c) 2017 Ultimaker B.V.
|
||||
# Cura is released under the terms of the LGPLv3 or higher.
|
||||
|
||||
from PyQt5.QtCore import pyqtSignal, pyqtProperty, QObject, QVariant #For communicating data and events to Qt.
|
||||
from PyQt5.QtCore import pyqtSignal, pyqtProperty, QObject, QVariant # For communicating data and events to Qt.
|
||||
from UM.FlameProfiler import pyqtSlot
|
||||
|
||||
from UM.Application import Application #To get the global container stack to find the current machine.
|
||||
from UM.Application import Application # To get the global container stack to find the current machine.
|
||||
from UM.Logger import Logger
|
||||
from UM.Decorators import deprecated
|
||||
from UM.Scene.Iterator.DepthFirstIterator import DepthFirstIterator
|
||||
from UM.Scene.SceneNode import SceneNode
|
||||
from UM.Scene.Selection import Selection
|
||||
from UM.Scene.Iterator.BreadthFirstIterator import BreadthFirstIterator
|
||||
from UM.Settings.ContainerRegistry import ContainerRegistry #Finding containers by ID.
|
||||
from UM.Settings.InstanceContainer import InstanceContainer
|
||||
from UM.Settings.ContainerRegistry import ContainerRegistry # Finding containers by ID.
|
||||
from UM.Settings.SettingFunction import SettingFunction
|
||||
from UM.Settings.ContainerStack import ContainerStack
|
||||
from UM.Settings.Interfaces import DefinitionContainerInterface
|
||||
from UM.Settings.PropertyEvaluationContext import PropertyEvaluationContext
|
||||
from typing import Optional, List, TYPE_CHECKING, Union
|
||||
|
||||
|
@ -214,39 +211,39 @@ class ExtruderManager(QObject):
|
|||
result.append(self.getExtruderStack(i))
|
||||
return result
|
||||
|
||||
## Adds all extruders of a specific machine definition to the extruder
|
||||
# manager.
|
||||
# ## Adds all extruders of a specific machine definition to the extruder
|
||||
# # manager.
|
||||
# #
|
||||
# # \param machine_definition The machine definition to add the extruders for.
|
||||
# # \param machine_id The machine_id to add the extruders for.
|
||||
# @deprecated("Use CuraStackBuilder", "2.6")
|
||||
# def addMachineExtruders(self, machine_definition: DefinitionContainerInterface, machine_id: str) -> None:
|
||||
# changed = False
|
||||
# machine_definition_id = machine_definition.getId()
|
||||
# if machine_id not in self._extruder_trains:
|
||||
# self._extruder_trains[machine_id] = { }
|
||||
# changed = True
|
||||
# container_registry = ContainerRegistry.getInstance()
|
||||
# if container_registry:
|
||||
# # Add the extruder trains that don't exist yet.
|
||||
# for extruder_definition in container_registry.findDefinitionContainers(machine = machine_definition_id):
|
||||
# position = extruder_definition.getMetaDataEntry("position", None)
|
||||
# if not position:
|
||||
# Logger.log("w", "Extruder definition %s specifies no position metadata entry.", extruder_definition.getId())
|
||||
# if not container_registry.findContainerStacks(machine = machine_id, position = position): # Doesn't exist yet.
|
||||
# self.createExtruderTrain(extruder_definition, machine_definition, position, machine_id)
|
||||
# changed = True
|
||||
#
|
||||
# \param machine_definition The machine definition to add the extruders for.
|
||||
# \param machine_id The machine_id to add the extruders for.
|
||||
@deprecated("Use CuraStackBuilder", "2.6")
|
||||
def addMachineExtruders(self, machine_definition: DefinitionContainerInterface, machine_id: str) -> None:
|
||||
changed = False
|
||||
machine_definition_id = machine_definition.getId()
|
||||
if machine_id not in self._extruder_trains:
|
||||
self._extruder_trains[machine_id] = { }
|
||||
changed = True
|
||||
container_registry = ContainerRegistry.getInstance()
|
||||
if container_registry:
|
||||
# Add the extruder trains that don't exist yet.
|
||||
for extruder_definition in container_registry.findDefinitionContainers(machine = machine_definition_id):
|
||||
position = extruder_definition.getMetaDataEntry("position", None)
|
||||
if not position:
|
||||
Logger.log("w", "Extruder definition %s specifies no position metadata entry.", extruder_definition.getId())
|
||||
if not container_registry.findContainerStacks(machine = machine_id, position = position): # Doesn't exist yet.
|
||||
self.createExtruderTrain(extruder_definition, machine_definition, position, machine_id)
|
||||
changed = True
|
||||
|
||||
# Gets the extruder trains that we just created as well as any that still existed.
|
||||
extruder_trains = container_registry.findContainerStacks(type = "extruder_train", machine = machine_id)
|
||||
for extruder_train in extruder_trains:
|
||||
self._extruder_trains[machine_id][extruder_train.getMetaDataEntry("position")] = extruder_train
|
||||
|
||||
# regardless of what the next stack is, we have to set it again, because of signal routing.
|
||||
extruder_train.setNextStack(Application.getInstance().getGlobalContainerStack())
|
||||
changed = True
|
||||
if changed:
|
||||
self.extrudersChanged.emit(machine_id)
|
||||
# # Gets the extruder trains that we just created as well as any that still existed.
|
||||
# extruder_trains = container_registry.findContainerStacks(type = "extruder_train", machine = machine_id)
|
||||
# for extruder_train in extruder_trains:
|
||||
# self._extruder_trains[machine_id][extruder_train.getMetaDataEntry("position")] = extruder_train
|
||||
#
|
||||
# # regardless of what the next stack is, we have to set it again, because of signal routing.
|
||||
# extruder_train.setNextStack(Application.getInstance().getGlobalContainerStack())
|
||||
# changed = True
|
||||
# if changed:
|
||||
# self.extrudersChanged.emit(machine_id)
|
||||
|
||||
def registerExtruder(self, extruder_train, machine_id):
|
||||
changed = False
|
||||
|
@ -267,137 +264,137 @@ class ExtruderManager(QObject):
|
|||
if changed:
|
||||
self.extrudersChanged.emit(machine_id)
|
||||
|
||||
## Creates a container stack for an extruder train.
|
||||
# ## Creates a container stack for an extruder train.
|
||||
# #
|
||||
# # The container stack has an extruder definition at the bottom, which is
|
||||
# # linked to a machine definition. Then it has a variant profile, a material
|
||||
# # profile, a quality profile and a user profile, in that order.
|
||||
# #
|
||||
# # The resulting container stack is added to the registry.
|
||||
# #
|
||||
# # \param extruder_definition The extruder to create the extruder train for.
|
||||
# # \param machine_definition The machine that the extruder train belongs to.
|
||||
# # \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.
|
||||
# @deprecated("Use CuraStackBuilder::createExtruderStack", "2.6")
|
||||
# def createExtruderTrain(self, extruder_definition: DefinitionContainerInterface, machine_definition: DefinitionContainerInterface,
|
||||
# position, machine_id: str) -> None:
|
||||
# # Cache some things.
|
||||
# container_registry = ContainerRegistry.getInstance()
|
||||
# machine_definition_id = Application.getInstance().getMachineManager().getQualityDefinitionId(machine_definition)
|
||||
#
|
||||
# The container stack has an extruder definition at the bottom, which is
|
||||
# linked to a machine definition. Then it has a variant profile, a material
|
||||
# profile, a quality profile and a user profile, in that order.
|
||||
# # Create a container stack for this extruder.
|
||||
# extruder_stack_id = container_registry.uniqueName(extruder_definition.getId())
|
||||
# container_stack = ContainerStack(extruder_stack_id)
|
||||
# container_stack.setName(extruder_definition.getName()) # Take over the display name to display the stack with.
|
||||
# container_stack.addMetaDataEntry("type", "extruder_train")
|
||||
# container_stack.addMetaDataEntry("machine", machine_id)
|
||||
# container_stack.addMetaDataEntry("position", position)
|
||||
# container_stack.addContainer(extruder_definition)
|
||||
#
|
||||
# The resulting container stack is added to the registry.
|
||||
# # Find the variant to use for this extruder.
|
||||
# variant = container_registry.findInstanceContainers(id = "empty_variant")[0]
|
||||
# if machine_definition.getMetaDataEntry("has_variants"):
|
||||
# # First add any variant. Later, overwrite with preference if the preference is valid.
|
||||
# variants = container_registry.findInstanceContainers(definition = machine_definition_id, type = "variant")
|
||||
# if len(variants) >= 1:
|
||||
# variant = variants[0]
|
||||
# preferred_variant_id = machine_definition.getMetaDataEntry("preferred_variant")
|
||||
# if preferred_variant_id:
|
||||
# preferred_variants = container_registry.findInstanceContainers(id = preferred_variant_id, definition = machine_definition_id, type = "variant")
|
||||
# if len(preferred_variants) >= 1:
|
||||
# variant = preferred_variants[0]
|
||||
# else:
|
||||
# Logger.log("w", "The preferred variant \"%s\" of machine %s doesn't exist or is not a variant profile.", preferred_variant_id, machine_id)
|
||||
# # And leave it at the default variant.
|
||||
# container_stack.addContainer(variant)
|
||||
#
|
||||
# \param extruder_definition The extruder to create the extruder train for.
|
||||
# \param machine_definition The machine that the extruder train belongs to.
|
||||
# \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.
|
||||
@deprecated("Use CuraStackBuilder::createExtruderStack", "2.6")
|
||||
def createExtruderTrain(self, extruder_definition: DefinitionContainerInterface, machine_definition: DefinitionContainerInterface,
|
||||
position, machine_id: str) -> None:
|
||||
# Cache some things.
|
||||
container_registry = ContainerRegistry.getInstance()
|
||||
machine_definition_id = Application.getInstance().getMachineManager().getQualityDefinitionId(machine_definition)
|
||||
|
||||
# Create a container stack for this extruder.
|
||||
extruder_stack_id = container_registry.uniqueName(extruder_definition.getId())
|
||||
container_stack = ContainerStack(extruder_stack_id)
|
||||
container_stack.setName(extruder_definition.getName()) # Take over the display name to display the stack with.
|
||||
container_stack.addMetaDataEntry("type", "extruder_train")
|
||||
container_stack.addMetaDataEntry("machine", machine_id)
|
||||
container_stack.addMetaDataEntry("position", position)
|
||||
container_stack.addContainer(extruder_definition)
|
||||
|
||||
# Find the variant to use for this extruder.
|
||||
variant = container_registry.findInstanceContainers(id = "empty_variant")[0]
|
||||
if machine_definition.getMetaDataEntry("has_variants"):
|
||||
# First add any variant. Later, overwrite with preference if the preference is valid.
|
||||
variants = container_registry.findInstanceContainers(definition = machine_definition_id, type = "variant")
|
||||
if len(variants) >= 1:
|
||||
variant = variants[0]
|
||||
preferred_variant_id = machine_definition.getMetaDataEntry("preferred_variant")
|
||||
if preferred_variant_id:
|
||||
preferred_variants = container_registry.findInstanceContainers(id = preferred_variant_id, definition = machine_definition_id, type = "variant")
|
||||
if len(preferred_variants) >= 1:
|
||||
variant = preferred_variants[0]
|
||||
else:
|
||||
Logger.log("w", "The preferred variant \"%s\" of machine %s doesn't exist or is not a variant profile.", preferred_variant_id, machine_id)
|
||||
# And leave it at the default variant.
|
||||
container_stack.addContainer(variant)
|
||||
|
||||
# Find a material to use for this variant.
|
||||
material = container_registry.findInstanceContainers(id = "empty_material")[0]
|
||||
if machine_definition.getMetaDataEntry("has_materials"):
|
||||
# First add any material. Later, overwrite with preference if the preference is valid.
|
||||
machine_has_variant_materials = machine_definition.getMetaDataEntry("has_variant_materials", default = False)
|
||||
if machine_has_variant_materials or machine_has_variant_materials == "True":
|
||||
materials = container_registry.findInstanceContainers(type = "material", definition = machine_definition_id, variant = variant.getId())
|
||||
else:
|
||||
materials = container_registry.findInstanceContainers(type = "material", definition = machine_definition_id)
|
||||
if len(materials) >= 1:
|
||||
material = materials[0]
|
||||
preferred_material_id = machine_definition.getMetaDataEntry("preferred_material")
|
||||
if preferred_material_id:
|
||||
global_stack = ContainerRegistry.getInstance().findContainerStacks(id = machine_id)
|
||||
if global_stack:
|
||||
approximate_material_diameter = str(round(global_stack[0].getProperty("material_diameter", "value")))
|
||||
else:
|
||||
approximate_material_diameter = str(round(machine_definition.getProperty("material_diameter", "value")))
|
||||
|
||||
search_criteria = { "type": "material", "id": preferred_material_id, "approximate_diameter": approximate_material_diameter}
|
||||
if machine_definition.getMetaDataEntry("has_machine_materials"):
|
||||
search_criteria["definition"] = machine_definition_id
|
||||
|
||||
if machine_definition.getMetaDataEntry("has_variants") and variant:
|
||||
search_criteria["variant"] = variant.id
|
||||
else:
|
||||
search_criteria["definition"] = "fdmprinter"
|
||||
|
||||
preferred_materials = container_registry.findInstanceContainers(**search_criteria)
|
||||
if len(preferred_materials) >= 1:
|
||||
# In some cases we get multiple materials. In that case, prefer materials that are marked as read only.
|
||||
read_only_preferred_materials = [preferred_material for preferred_material in preferred_materials if preferred_material.isReadOnly()]
|
||||
if len(read_only_preferred_materials) >= 1:
|
||||
material = read_only_preferred_materials[0]
|
||||
else:
|
||||
material = preferred_materials[0]
|
||||
else:
|
||||
Logger.log("w", "The preferred material \"%s\" of machine %s doesn't exist or is not a material profile.", preferred_material_id, machine_id)
|
||||
# And leave it at the default material.
|
||||
container_stack.addContainer(material)
|
||||
|
||||
# Find a quality to use for this extruder.
|
||||
quality = container_registry.getEmptyInstanceContainer()
|
||||
|
||||
search_criteria = { "type": "quality" }
|
||||
if machine_definition.getMetaDataEntry("has_machine_quality"):
|
||||
search_criteria["definition"] = machine_definition_id
|
||||
if machine_definition.getMetaDataEntry("has_materials") and material:
|
||||
search_criteria["material"] = material.id
|
||||
else:
|
||||
search_criteria["definition"] = "fdmprinter"
|
||||
|
||||
preferred_quality = machine_definition.getMetaDataEntry("preferred_quality")
|
||||
if preferred_quality:
|
||||
search_criteria["id"] = preferred_quality
|
||||
|
||||
containers = ContainerRegistry.getInstance().findInstanceContainers(**search_criteria)
|
||||
if not containers and preferred_quality:
|
||||
Logger.log("w", "The preferred quality \"%s\" of machine %s doesn't exist or is not a quality profile.", preferred_quality, machine_id)
|
||||
search_criteria.pop("id", None)
|
||||
containers = ContainerRegistry.getInstance().findInstanceContainers(**search_criteria)
|
||||
if containers:
|
||||
quality = containers[0]
|
||||
|
||||
container_stack.addContainer(quality)
|
||||
|
||||
empty_quality_changes = container_registry.findInstanceContainers(id = "empty_quality_changes")[0]
|
||||
container_stack.addContainer(empty_quality_changes)
|
||||
|
||||
user_profile = container_registry.findInstanceContainers(type = "user", extruder = extruder_stack_id)
|
||||
if user_profile: # There was already a user profile, loaded from settings.
|
||||
user_profile = user_profile[0]
|
||||
else:
|
||||
user_profile = InstanceContainer(extruder_stack_id + "_current_settings") # Add an empty user profile.
|
||||
user_profile.addMetaDataEntry("type", "user")
|
||||
user_profile.addMetaDataEntry("extruder", extruder_stack_id)
|
||||
from cura.CuraApplication import CuraApplication
|
||||
user_profile.addMetaDataEntry("setting_version", CuraApplication.SettingVersion)
|
||||
user_profile.setDefinition(machine_definition)
|
||||
container_registry.addContainer(user_profile)
|
||||
container_stack.addContainer(user_profile)
|
||||
|
||||
# regardless of what the next stack is, we have to set it again, because of signal routing.
|
||||
container_stack.setNextStack(Application.getInstance().getGlobalContainerStack())
|
||||
|
||||
container_registry.addContainer(container_stack)
|
||||
# # Find a material to use for this variant.
|
||||
# material = container_registry.findInstanceContainers(id = "empty_material")[0]
|
||||
# if machine_definition.getMetaDataEntry("has_materials"):
|
||||
# # First add any material. Later, overwrite with preference if the preference is valid.
|
||||
# machine_has_variant_materials = machine_definition.getMetaDataEntry("has_variant_materials", default = False)
|
||||
# if machine_has_variant_materials or machine_has_variant_materials == "True":
|
||||
# materials = container_registry.findInstanceContainers(type = "material", definition = machine_definition_id, variant = variant.getId())
|
||||
# else:
|
||||
# materials = container_registry.findInstanceContainers(type = "material", definition = machine_definition_id)
|
||||
# if len(materials) >= 1:
|
||||
# material = materials[0]
|
||||
# preferred_material_id = machine_definition.getMetaDataEntry("preferred_material")
|
||||
# if preferred_material_id:
|
||||
# global_stack = ContainerRegistry.getInstance().findContainerStacks(id = machine_id)
|
||||
# if global_stack:
|
||||
# approximate_material_diameter = str(round(global_stack[0].getProperty("material_diameter", "value")))
|
||||
# else:
|
||||
# approximate_material_diameter = str(round(machine_definition.getProperty("material_diameter", "value")))
|
||||
#
|
||||
# search_criteria = { "type": "material", "id": preferred_material_id, "approximate_diameter": approximate_material_diameter}
|
||||
# if machine_definition.getMetaDataEntry("has_machine_materials"):
|
||||
# search_criteria["definition"] = machine_definition_id
|
||||
#
|
||||
# if machine_definition.getMetaDataEntry("has_variants") and variant:
|
||||
# search_criteria["variant"] = variant.id
|
||||
# else:
|
||||
# search_criteria["definition"] = "fdmprinter"
|
||||
#
|
||||
# preferred_materials = container_registry.findInstanceContainers(**search_criteria)
|
||||
# if len(preferred_materials) >= 1:
|
||||
# # In some cases we get multiple materials. In that case, prefer materials that are marked as read only.
|
||||
# read_only_preferred_materials = [preferred_material for preferred_material in preferred_materials if preferred_material.isReadOnly()]
|
||||
# if len(read_only_preferred_materials) >= 1:
|
||||
# material = read_only_preferred_materials[0]
|
||||
# else:
|
||||
# material = preferred_materials[0]
|
||||
# else:
|
||||
# Logger.log("w", "The preferred material \"%s\" of machine %s doesn't exist or is not a material profile.", preferred_material_id, machine_id)
|
||||
# # And leave it at the default material.
|
||||
# container_stack.addContainer(material)
|
||||
#
|
||||
# # Find a quality to use for this extruder.
|
||||
# quality = container_registry.getEmptyInstanceContainer()
|
||||
#
|
||||
# search_criteria = { "type": "quality" }
|
||||
# if machine_definition.getMetaDataEntry("has_machine_quality"):
|
||||
# search_criteria["definition"] = machine_definition_id
|
||||
# if machine_definition.getMetaDataEntry("has_materials") and material:
|
||||
# search_criteria["material"] = material.id
|
||||
# else:
|
||||
# search_criteria["definition"] = "fdmprinter"
|
||||
#
|
||||
# preferred_quality = machine_definition.getMetaDataEntry("preferred_quality")
|
||||
# if preferred_quality:
|
||||
# search_criteria["id"] = preferred_quality
|
||||
#
|
||||
# containers = ContainerRegistry.getInstance().findInstanceContainers(**search_criteria)
|
||||
# if not containers and preferred_quality:
|
||||
# Logger.log("w", "The preferred quality \"%s\" of machine %s doesn't exist or is not a quality profile.", preferred_quality, machine_id)
|
||||
# search_criteria.pop("id", None)
|
||||
# containers = ContainerRegistry.getInstance().findInstanceContainers(**search_criteria)
|
||||
# if containers:
|
||||
# quality = containers[0]
|
||||
#
|
||||
# container_stack.addContainer(quality)
|
||||
#
|
||||
# empty_quality_changes = container_registry.findInstanceContainers(id = "empty_quality_changes")[0]
|
||||
# container_stack.addContainer(empty_quality_changes)
|
||||
#
|
||||
# user_profile = container_registry.findInstanceContainers(type = "user", extruder = extruder_stack_id)
|
||||
# if user_profile: # There was already a user profile, loaded from settings.
|
||||
# user_profile = user_profile[0]
|
||||
# else:
|
||||
# user_profile = InstanceContainer(extruder_stack_id + "_current_settings") # Add an empty user profile.
|
||||
# user_profile.addMetaDataEntry("type", "user")
|
||||
# user_profile.addMetaDataEntry("extruder", extruder_stack_id)
|
||||
# from cura.CuraApplication import CuraApplication
|
||||
# user_profile.addMetaDataEntry("setting_version", CuraApplication.SettingVersion)
|
||||
# user_profile.setDefinition(machine_definition)
|
||||
# container_registry.addContainer(user_profile)
|
||||
# container_stack.addContainer(user_profile)
|
||||
#
|
||||
# # regardless of what the next stack is, we have to set it again, because of signal routing.
|
||||
# container_stack.setNextStack(Application.getInstance().getGlobalContainerStack())
|
||||
#
|
||||
# container_registry.addContainer(container_stack)
|
||||
|
||||
def getAllExtruderValues(self, setting_key):
|
||||
return self.getAllExtruderSettings(setting_key, "value")
|
||||
|
@ -545,7 +542,6 @@ class ExtruderManager(QObject):
|
|||
if self._active_extruder_index == -1:
|
||||
self.setActiveExtruderIndex(0)
|
||||
|
||||
self.activeExtruderChanged.emit()
|
||||
self.resetSelectedObjectExtruders()
|
||||
|
||||
## Adds the extruders of the currently active machine.
|
||||
|
@ -562,7 +558,7 @@ class ExtruderManager(QObject):
|
|||
for extruder_train in extruder_trains:
|
||||
self._extruder_trains[machine_id][extruder_train.getMetaDataEntry("position")] = extruder_train
|
||||
|
||||
# regardless of what the next stack is, we have to set it again, because of signal routing.
|
||||
# regardless of what the next stack is, we have to set it again, because of signal routing. ???
|
||||
extruder_train.setNextStack(global_stack)
|
||||
extruders_changed = True
|
||||
|
||||
|
@ -582,7 +578,7 @@ class ExtruderManager(QObject):
|
|||
global_stack = Application.getInstance().getGlobalContainerStack()
|
||||
|
||||
result = []
|
||||
for extruder in ExtruderManager.getMachineExtruders(global_stack.getId()):
|
||||
for extruder in ExtruderManager.getInstance().getMachineExtruders(global_stack.getId()):
|
||||
# only include values from extruders that are "active" for the current machine instance
|
||||
if int(extruder.getMetaDataEntry("position")) >= global_stack.getProperty("machine_extruder_count", "value"):
|
||||
continue
|
||||
|
|
|
@ -201,7 +201,7 @@ class ExtrudersModel(UM.Qt.ListModel.ListModel):
|
|||
continue
|
||||
|
||||
default_color = self.defaultColors[position] if 0 <= position < len(self.defaultColors) else self.defaultColors[0]
|
||||
color = extruder.material.getMetaDataEntry("color_code", default = default_color) if material else default_color
|
||||
color = extruder.material.getMetaDataEntry("color_code", default = default_color) if extruder.material else default_color
|
||||
|
||||
# construct an item with only the relevant information
|
||||
item = {
|
||||
|
@ -210,7 +210,7 @@ class ExtrudersModel(UM.Qt.ListModel.ListModel):
|
|||
"color": color,
|
||||
"index": position,
|
||||
"definition": extruder.getBottom().getId(),
|
||||
"material": extruder.material.getName() if material else "",
|
||||
"material": extruder.material.getName() if extruder.material else "",
|
||||
"variant": extruder.variant.getName() if extruder.variant else "", # e.g. print core
|
||||
}
|
||||
|
||||
|
|
|
@ -300,6 +300,17 @@ class MachineManager(QObject):
|
|||
if global_material != self._empty_material_container:
|
||||
self._global_container_stack.setMaterial(self._empty_material_container)
|
||||
|
||||
# TODO: update stack builder since this is not always a user created stack
|
||||
# if len(self._global_container_stack.extruders) == 0:
|
||||
# extruder_stack = CuraStackBuilder.createExtruderStack(
|
||||
# self._global_container_stack.getId(),
|
||||
# definition = self._global_container_stack.definition,
|
||||
# machine_definition = self._global_container_stack.definition,
|
||||
# )
|
||||
# extruder_stack.setNextStack(self._global_container_stack)
|
||||
# extruder_stack.propertyChanged.connect(self._onPropertyChanged)
|
||||
# extruder_stack.containersChanged.connect(self._onInstanceContainersChanged)
|
||||
|
||||
# Listen for changes on all extruder stacks
|
||||
for extruder_stack in ExtruderManager.getInstance().getActiveExtruderStacks():
|
||||
extruder_stack.propertyChanged.connect(self._onPropertyChanged)
|
||||
|
@ -320,8 +331,8 @@ class MachineManager(QObject):
|
|||
old_active_container_stack = self._active_container_stack
|
||||
|
||||
self._active_container_stack = ExtruderManager.getInstance().getActiveExtruderStack()
|
||||
if not self._active_container_stack:
|
||||
self._active_container_stack = self._global_container_stack
|
||||
# if not self._active_container_stack:
|
||||
# self._active_container_stack = self._global_container_stack
|
||||
|
||||
self._error_check_timer.start()
|
||||
|
||||
|
|
|
@ -77,8 +77,8 @@ class SettingInheritanceManager(QObject):
|
|||
|
||||
def _onActiveExtruderChanged(self):
|
||||
new_active_stack = ExtruderManager.getInstance().getActiveExtruderStack()
|
||||
if not new_active_stack:
|
||||
new_active_stack = self._global_container_stack
|
||||
# if not new_active_stack:
|
||||
# new_active_stack = self._global_container_stack
|
||||
|
||||
if new_active_stack != self._active_container_stack: # Check if changed
|
||||
if self._active_container_stack: # Disconnect signal from old container (if any)
|
||||
|
|
|
@ -27,11 +27,7 @@ class SettingOverrideDecorator(SceneNodeDecorator):
|
|||
self._stack = PerObjectContainerStack(stack_id = id(self))
|
||||
self._stack.setDirty(False) # This stack does not need to be saved.
|
||||
self._stack.addContainer(InstanceContainer(container_id = "SettingOverrideInstanceContainer"))
|
||||
|
||||
if ExtruderManager.getInstance().extruderCount > 1:
|
||||
self._extruder_stack = ExtruderManager.getInstance().getExtruderStack(0).getId()
|
||||
else:
|
||||
self._extruder_stack = None
|
||||
self._extruder_stack = ExtruderManager.getInstance().getExtruderStack(0).getId()
|
||||
|
||||
self._stack.propertyChanged.connect(self._onSettingChanged)
|
||||
|
||||
|
|
|
@ -7,10 +7,6 @@
|
|||
"visible": true,
|
||||
"author": "rikky",
|
||||
"manufacturer": "101Hero",
|
||||
"machine_extruder_trains":
|
||||
{
|
||||
"0": "fdmextruder"
|
||||
},
|
||||
"file_formats": "text/x-gcode",
|
||||
"platform": "101hero-platform.stl",
|
||||
"supports_usb_connection": true
|
||||
|
|
|
@ -10,11 +10,7 @@
|
|||
"file_formats": "text/x-gcode",
|
||||
"icon": "icon_ultimaker2",
|
||||
"supports_usb_connection": true,
|
||||
"platform": "3dator_platform.stl",
|
||||
"machine_extruder_trains":
|
||||
{
|
||||
"0": "fdmextruder"
|
||||
}
|
||||
"platform": "3dator_platform.stl"
|
||||
},
|
||||
|
||||
"overrides": {
|
||||
|
@ -29,7 +25,6 @@
|
|||
"layer_height": { "default_value": 0.2 },
|
||||
"speed_print": { "default_value": 50 },
|
||||
"speed_infill": { "default_value": 60 },
|
||||
"machine_extruder_count": { "default_value": 1 },
|
||||
"machine_heated_bed": { "default_value": true },
|
||||
"machine_center_is_zero": { "default_value": false },
|
||||
"machine_height": { "default_value": 260 },
|
||||
|
|
|
@ -177,7 +177,7 @@ UM.MainWindow
|
|||
|
||||
MenuSeparator { }
|
||||
|
||||
MenuItem { text: catalog.i18nc("@action:inmenu", "Set as Active Extruder"); onTriggered: ExtruderManager.setActiveExtruderIndex(model.index) }
|
||||
MenuItem { text: catalog.i18nc("@action:inmenu", "Set as Active Extruder"); onTriggered: Cura.ExtruderManager.setActiveExtruderIndex(model.index) }
|
||||
}
|
||||
onObjectAdded: settingsMenu.insertItem(index, object)
|
||||
onObjectRemoved: settingsMenu.removeItem(object)
|
||||
|
|
|
@ -18,7 +18,7 @@ Button
|
|||
style: UM.Theme.styles.tool_button;
|
||||
iconSource: UM.Theme.getIcon("extruder_button")
|
||||
|
||||
checked: ExtruderManager.selectedObjectExtruders.indexOf(extruder.id) != -1
|
||||
checked: Cura.ExtruderManager.selectedObjectExtruders.indexOf(extruder.id) != -1
|
||||
enabled: UM.Selection.hasSelection
|
||||
|
||||
property color customColor: base.hovered ? UM.Theme.getColor("button_hover") : UM.Theme.getColor("button");
|
||||
|
|
|
@ -31,7 +31,7 @@ Menu
|
|||
visible: base.shouldShowExtruders
|
||||
enabled: UM.Selection.hasSelection
|
||||
checkable: true
|
||||
checked: ExtruderManager.selectedObjectExtruders.indexOf(model.id) != -1
|
||||
checked: Cura.ExtruderManager.selectedObjectExtruders.indexOf(model.id) != -1
|
||||
onTriggered: CuraActions.setExtruderForSelection(model.id)
|
||||
shortcut: "Ctrl+" + (model.index + 1)
|
||||
}
|
||||
|
|
|
@ -72,16 +72,16 @@ Menu
|
|||
{
|
||||
text: model.name
|
||||
checkable: true
|
||||
checked: model.id == Cura.MachineManager.allActiveMaterialIds[ExtruderManager.extruderIds[extruderIndex]]
|
||||
checked: model.id == Cura.MachineManager.allActiveMaterialIds[Cura.ExtruderManager.extruderIds[extruderIndex]]
|
||||
exclusiveGroup: group
|
||||
onTriggered:
|
||||
{
|
||||
// This workaround is done because of the application menus for materials and variants for multiextrusion printers.
|
||||
// The extruder menu would always act on the correspoding extruder only, instead of acting on the extruder selected in the UI.
|
||||
var activeExtruderIndex = ExtruderManager.activeExtruderIndex;
|
||||
ExtruderManager.setActiveExtruderIndex(extruderIndex);
|
||||
var activeExtruderIndex = Cura.ExtruderManager.activeExtruderIndex;
|
||||
Cura.ExtruderManager.setActiveExtruderIndex(extruderIndex);
|
||||
Cura.MachineManager.setActiveMaterial(model.id);
|
||||
ExtruderManager.setActiveExtruderIndex(activeExtruderIndex);
|
||||
Cura.ExtruderManager.setActiveExtruderIndex(activeExtruderIndex);
|
||||
}
|
||||
}
|
||||
onObjectAdded: menu.insertItem(index, object)
|
||||
|
@ -115,16 +115,16 @@ Menu
|
|||
{
|
||||
text: model.name
|
||||
checkable: true
|
||||
checked: model.id == Cura.MachineManager.allActiveMaterialIds[ExtruderManager.extruderIds[extruderIndex]]
|
||||
checked: model.id == Cura.MachineManager.allActiveMaterialIds[Cura.ExtruderManager.extruderIds[extruderIndex]]
|
||||
exclusiveGroup: group
|
||||
onTriggered:
|
||||
{
|
||||
// This workaround is done because of the application menus for materials and variants for multiextrusion printers.
|
||||
// The extruder menu would always act on the correspoding extruder only, instead of acting on the extruder selected in the UI.
|
||||
var activeExtruderIndex = ExtruderManager.activeExtruderIndex;
|
||||
ExtruderManager.setActiveExtruderIndex(extruderIndex);
|
||||
var activeExtruderIndex = Cura.ExtruderManager.activeExtruderIndex;
|
||||
Cura.ExtruderManager.setActiveExtruderIndex(extruderIndex);
|
||||
Cura.MachineManager.setActiveMaterial(model.id);
|
||||
ExtruderManager.setActiveExtruderIndex(activeExtruderIndex);
|
||||
Cura.ExtruderManager.setActiveExtruderIndex(activeExtruderIndex);
|
||||
}
|
||||
}
|
||||
onObjectAdded: brandMaterialsMenu.insertItem(index, object)
|
||||
|
|
|
@ -38,15 +38,15 @@ Menu
|
|||
visible: printerConnected && Cura.MachineManager.printerOutputDevices[0].hotendIds.length > extruderIndex && !isClusterPrinter
|
||||
onTriggered:
|
||||
{
|
||||
var activeExtruderIndex = ExtruderManager.activeExtruderIndex;
|
||||
ExtruderManager.setActiveExtruderIndex(extruderIndex);
|
||||
var activeExtruderIndex = Cura.ExtruderManager.activeExtruderIndex;
|
||||
Cura.ExtruderManager.setActiveExtruderIndex(extruderIndex);
|
||||
var hotendId = Cura.MachineManager.printerOutputDevices[0].hotendIds[extruderIndex];
|
||||
var itemIndex = nozzleInstantiator.model.find("name", hotendId);
|
||||
if(itemIndex > -1)
|
||||
{
|
||||
Cura.MachineManager.setActiveVariant(nozzleInstantiator.model.getItem(itemIndex).id);
|
||||
}
|
||||
ExtruderManager.setActiveExtruderIndex(activeExtruderIndex);
|
||||
Cura.ExtruderManager.setActiveExtruderIndex(activeExtruderIndex);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -69,14 +69,14 @@ Menu
|
|||
MenuItem {
|
||||
text: model.name
|
||||
checkable: true
|
||||
checked: model.id == Cura.MachineManager.allActiveVariantIds[ExtruderManager.extruderIds[extruderIndex]]
|
||||
checked: model.id == Cura.MachineManager.allActiveVariantIds[Cura.ExtruderManager.extruderIds[extruderIndex]]
|
||||
exclusiveGroup: group
|
||||
onTriggered:
|
||||
{
|
||||
var activeExtruderIndex = ExtruderManager.activeExtruderIndex;
|
||||
ExtruderManager.setActiveExtruderIndex(extruderIndex);
|
||||
var activeExtruderIndex = Cura.ExtruderManager.activeExtruderIndex;
|
||||
Cura.ExtruderManager.setActiveExtruderIndex(extruderIndex);
|
||||
Cura.MachineManager.setActiveVariant(model.id);
|
||||
ExtruderManager.setActiveExtruderIndex(activeExtruderIndex);
|
||||
Cura.ExtruderManager.setActiveExtruderIndex(activeExtruderIndex);
|
||||
}
|
||||
}
|
||||
onObjectAdded: menu.insertItem(index, object)
|
||||
|
|
|
@ -208,7 +208,7 @@ UM.ManagementPage
|
|||
anchors.right: parent.right
|
||||
anchors.bottom: parent.bottom
|
||||
|
||||
currentIndex: ExtruderManager.extruderCount > 0 ? ExtruderManager.activeExtruderIndex + 1 : 0
|
||||
currentIndex: Cura.ExtruderManager.extruderCount > 0 ? Cura.ExtruderManager.activeExtruderIndex + 1 : 0
|
||||
|
||||
ProfileTab
|
||||
{
|
||||
|
|
|
@ -87,7 +87,7 @@ Column
|
|||
|
||||
Label //Extruder name.
|
||||
{
|
||||
text: ExtruderManager.getExtruderName(index) != "" ? ExtruderManager.getExtruderName(index) : catalog.i18nc("@label", "Extruder")
|
||||
text: Cura.ExtruderManager.getExtruderName(index) != "" ? Cura.ExtruderManager.getExtruderName(index) : catalog.i18nc("@label", "Extruder")
|
||||
color: UM.Theme.getColor("text")
|
||||
font: UM.Theme.getFont("default")
|
||||
anchors.left: parent.left
|
||||
|
|
|
@ -157,7 +157,7 @@ Item {
|
|||
var tooltipText = catalog.i18nc("@label", "This setting is always shared between all extruders. Changing it here will change the value for all extruders") + ".";
|
||||
if ((resolve != "None") && (stackLevel != 0)) {
|
||||
// We come here if a setting has a resolve and the setting is not manually edited.
|
||||
tooltipText += " " + catalog.i18nc("@label", "The value is resolved from per-extruder values ") + "[" + ExtruderManager.getInstanceExtruderValues(definition.key) + "].";
|
||||
tooltipText += " " + catalog.i18nc("@label", "The value is resolved from per-extruder values ") + "[" + Cura.ExtruderManager.getInstanceExtruderValues(definition.key) + "].";
|
||||
}
|
||||
base.showTooltip(tooltipText);
|
||||
}
|
||||
|
|
|
@ -268,7 +268,7 @@ Item
|
|||
Behavior on opacity { NumberAnimation { duration: 100 } }
|
||||
enabled:
|
||||
{
|
||||
if(!ExtruderManager.activeExtruderStackId && machineExtruderCount.properties.value > 1)
|
||||
if (!Cura.ExtruderManager.activeExtruderStackId && machineExtruderCount.properties.value > 1)
|
||||
{
|
||||
// disable all controls on the global tab, except categories
|
||||
return model.type == "category"
|
||||
|
@ -338,12 +338,12 @@ Item
|
|||
if(inheritStackProvider.properties.limit_to_extruder != null && inheritStackProvider.properties.limit_to_extruder >= 0)
|
||||
{
|
||||
//We have limit_to_extruder, so pick that stack.
|
||||
return ExtruderManager.extruderIds[String(inheritStackProvider.properties.limit_to_extruder)];
|
||||
return Cura.ExtruderManager.extruderIds[String(inheritStackProvider.properties.limit_to_extruder)];
|
||||
}
|
||||
if(ExtruderManager.activeExtruderStackId)
|
||||
if(Cura.ExtruderManager.activeExtruderStackId)
|
||||
{
|
||||
//We're on an extruder tab. Pick the current extruder.
|
||||
return ExtruderManager.activeExtruderStackId;
|
||||
return Cura.ExtruderManager.activeExtruderStackId;
|
||||
}
|
||||
//No extruder tab is selected. Pick the global stack. Shouldn't happen any more since we removed the global tab.
|
||||
return activeMachineId;
|
||||
|
|
|
@ -14,7 +14,7 @@ Column
|
|||
{
|
||||
id: base;
|
||||
|
||||
property int currentExtruderIndex: ExtruderManager.activeExtruderIndex;
|
||||
property int currentExtruderIndex: Cura.ExtruderManager.activeExtruderIndex;
|
||||
property bool currentExtruderVisible: extrudersList.visible;
|
||||
|
||||
spacing: Math.floor(UM.Theme.getSize("sidebar_margin").width * 0.9)
|
||||
|
@ -93,7 +93,7 @@ Column
|
|||
onClicked:
|
||||
{
|
||||
forceActiveFocus() // Changing focus applies the currently-being-typed values so it can change the displayed setting values.
|
||||
ExtruderManager.setActiveExtruderIndex(index);
|
||||
Cura.ExtruderManager.setActiveExtruderIndex(index);
|
||||
}
|
||||
|
||||
style: ButtonStyle
|
||||
|
|
|
@ -19,7 +19,7 @@ Item
|
|||
property Action configureSettings;
|
||||
property variant minimumPrintTime: PrintInformation.minimumPrintTime;
|
||||
property variant maximumPrintTime: PrintInformation.maximumPrintTime;
|
||||
property bool settingsEnabled: ExtruderManager.activeExtruderStackId || machineExtruderCount.properties.value == 1
|
||||
property bool settingsEnabled: Cura.ExtruderManager.activeExtruderStackId || machineExtruderCount.properties.value == 1
|
||||
|
||||
Component.onCompleted: PrintInformation.enabled = true
|
||||
Component.onDestruction: PrintInformation.enabled = false
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue