mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-22 06:03:57 -06:00
WIP: Cleanup
This commit is contained in:
parent
7e84e7570f
commit
0c3ac090c9
3 changed files with 8 additions and 40 deletions
|
@ -28,6 +28,7 @@ from . import GlobalStack
|
||||||
from .ExtruderManager import ExtruderManager
|
from .ExtruderManager import ExtruderManager
|
||||||
|
|
||||||
from cura.CuraApplication import CuraApplication
|
from cura.CuraApplication import CuraApplication
|
||||||
|
from cura.Machines.MachineTools import getMachineDefinitionIDForQualitySearch
|
||||||
|
|
||||||
from UM.i18n import i18nCatalog
|
from UM.i18n import i18nCatalog
|
||||||
catalog = i18nCatalog("cura")
|
catalog = i18nCatalog("cura")
|
||||||
|
@ -296,7 +297,7 @@ class CuraContainerRegistry(ContainerRegistry):
|
||||||
|
|
||||||
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
|
||||||
extruder_id = Application.getInstance().getMachineManager().getQualityDefinitionId(machine_extruders[profile_index - 1].getBottom())
|
extruder_id = machine_extruders[profile_index - 1].definition.getId()
|
||||||
if not profile.getMetaDataEntry("extruder"):
|
if not profile.getMetaDataEntry("extruder"):
|
||||||
profile.addMetaDataEntry("extruder", extruder_id)
|
profile.addMetaDataEntry("extruder", extruder_id)
|
||||||
else:
|
else:
|
||||||
|
@ -356,7 +357,9 @@ class CuraContainerRegistry(ContainerRegistry):
|
||||||
|
|
||||||
quality_type_criteria = {"quality_type": quality_type}
|
quality_type_criteria = {"quality_type": quality_type}
|
||||||
if self._machineHasOwnQualities():
|
if self._machineHasOwnQualities():
|
||||||
profile.setDefinition(self._activeQualityDefinition().getId())
|
global_container_stack = Application.getInstance().getGlobalContainerStack()
|
||||||
|
definition_id = getMachineDefinitionIDForQualitySearch(global_container_stack)
|
||||||
|
profile.setDefinition(definition_id)
|
||||||
if self._machineHasOwnMaterials():
|
if self._machineHasOwnMaterials():
|
||||||
active_material_id = self._activeMaterialId()
|
active_material_id = self._activeMaterialId()
|
||||||
if active_material_id and active_material_id != "empty": # only update if there is an active material
|
if active_material_id and active_material_id != "empty": # only update if there is an active material
|
||||||
|
@ -407,18 +410,6 @@ class CuraContainerRegistry(ContainerRegistry):
|
||||||
result.append( (plugin_id, meta_data) )
|
result.append( (plugin_id, meta_data) )
|
||||||
return result
|
return result
|
||||||
|
|
||||||
## Get the definition to use to select quality profiles for the active machine
|
|
||||||
# \return the active quality definition object or None if there is no quality definition
|
|
||||||
def _activeQualityDefinition(self):
|
|
||||||
global_container_stack = Application.getInstance().getGlobalContainerStack()
|
|
||||||
if global_container_stack:
|
|
||||||
definition_id = Application.getInstance().getMachineManager().getQualityDefinitionId(global_container_stack.getBottom())
|
|
||||||
definition = self.findDefinitionContainers(id = definition_id)[0]
|
|
||||||
|
|
||||||
if definition:
|
|
||||||
return definition
|
|
||||||
return None
|
|
||||||
|
|
||||||
## Returns true if the current machine requires its own materials
|
## Returns true if the current machine requires its own materials
|
||||||
# \return True if the current machine requires its own materials
|
# \return True if the current machine requires its own materials
|
||||||
def _machineHasOwnMaterials(self):
|
def _machineHasOwnMaterials(self):
|
||||||
|
|
|
@ -24,6 +24,7 @@ from UM.Settings.InstanceContainer import InstanceContainer
|
||||||
from UM.Settings.SettingFunction import SettingFunction
|
from UM.Settings.SettingFunction import SettingFunction
|
||||||
from UM.Signal import postponeSignals, CompressTechnique
|
from UM.Signal import postponeSignals, CompressTechnique
|
||||||
|
|
||||||
|
from cura.Machines.MachineTools import getMachineDefinitionIDForQualitySearch
|
||||||
|
|
||||||
from cura.QualityManager import QualityManager
|
from cura.QualityManager import QualityManager
|
||||||
from cura.PrinterOutputDevice import PrinterOutputDevice
|
from cura.PrinterOutputDevice import PrinterOutputDevice
|
||||||
|
@ -698,35 +699,12 @@ class MachineManager(QObject):
|
||||||
|
|
||||||
## Get the Definition ID to use to select quality profiles for the currently active machine
|
## Get the Definition ID to use to select quality profiles for the currently active machine
|
||||||
# \returns DefinitionID (string) if found, empty string otherwise
|
# \returns DefinitionID (string) if found, empty string otherwise
|
||||||
# \sa getQualityDefinitionId
|
|
||||||
@pyqtProperty(str, notify = globalContainerChanged)
|
@pyqtProperty(str, notify = globalContainerChanged)
|
||||||
def activeQualityDefinitionId(self) -> str:
|
def activeQualityDefinitionId(self) -> str:
|
||||||
if self._global_container_stack:
|
if self._global_container_stack:
|
||||||
return self.getQualityDefinitionId(self._global_container_stack.definition)
|
return getMachineDefinitionIDForQualitySearch(self._global_container_stack)
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
## Get the Definition ID to use to select quality profiles for machines of the specified definition
|
|
||||||
# This is normally the id of the definition itself, but machines can specify a different definition to inherit qualities from
|
|
||||||
# \param definition (DefinitionContainer) machine definition
|
|
||||||
# \returns DefinitionID (string) if found, empty string otherwise
|
|
||||||
def getQualityDefinitionId(self, definition: "DefinitionContainer") -> str:
|
|
||||||
return QualityManager.getInstance().getParentMachineDefinition(definition).getId()
|
|
||||||
|
|
||||||
## Get the Variant ID to use to select quality profiles for variants of the specified definitions
|
|
||||||
# This is normally the id of the variant itself, but machines can specify a different definition
|
|
||||||
# to inherit qualities from, which has consequences for the variant to use as well
|
|
||||||
# \param definition (DefinitionContainer) machine definition
|
|
||||||
# \param variant (InstanceContainer) variant definition
|
|
||||||
# \returns VariantID (string) if found, empty string otherwise
|
|
||||||
def getQualityVariantId(self, definition: "DefinitionContainer", variant: "InstanceContainer") -> str:
|
|
||||||
variant_id = variant.getId()
|
|
||||||
definition_id = definition.getId()
|
|
||||||
quality_definition_id = self.getQualityDefinitionId(definition)
|
|
||||||
|
|
||||||
if definition_id != quality_definition_id:
|
|
||||||
variant_id = variant_id.replace(definition_id, quality_definition_id, 1)
|
|
||||||
return variant_id
|
|
||||||
|
|
||||||
## Gets how the active definition calls variants
|
## Gets how the active definition calls variants
|
||||||
# Caveat: per-definition-variant-title is currently not translated (though the fallback is)
|
# Caveat: per-definition-variant-title is currently not translated (though the fallback is)
|
||||||
@pyqtProperty(str, notify = globalContainerChanged)
|
@pyqtProperty(str, notify = globalContainerChanged)
|
||||||
|
|
|
@ -147,8 +147,7 @@ Item
|
||||||
{
|
{
|
||||||
text: catalog.i18nc("@action:button", "Export")
|
text: catalog.i18nc("@action:button", "Export")
|
||||||
iconName: "document-export"
|
iconName: "document-export"
|
||||||
//enabled: currentItem != null && !base.currentItem.readOnly
|
enabled: base.hasCurrentItem && !base.currentItem.is_read_only
|
||||||
enabled: true // TODO
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue