mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-19 12:47:49 -06:00
Update the _available_materials in the actual _update function
It's confusing that this would be updated in the _canUpdate function. Just cleanliness. Contributes to issue CURA-6600.
This commit is contained in:
parent
ea1c99b708
commit
8ef410e826
4 changed files with 13 additions and 12 deletions
|
@ -115,6 +115,16 @@ class BaseMaterialsModel(ListModel):
|
||||||
def _update(self):
|
def _update(self):
|
||||||
self._favorite_ids = set(Preferences.getInstance().getValue("cura/favorite_materials").split(";"))
|
self._favorite_ids = set(Preferences.getInstance().getValue("cura/favorite_materials").split(";"))
|
||||||
|
|
||||||
|
# Update the available materials (ContainerNode) for the current active machine and extruder setup.
|
||||||
|
global_stack = cura.CuraApplication.CuraApplication.getInstance().getGlobalContainerStack()
|
||||||
|
extruder_stack = global_stack.extruders[str(self._extruder_position)]
|
||||||
|
nozzle_name = None
|
||||||
|
if extruder_stack.variant.getId() != "empty_variant":
|
||||||
|
nozzle_name = extruder_stack.variant.getName()
|
||||||
|
materials = ContainerTree.getInstance().machines[global_stack.definition.getId()].variants[nozzle_name].materials
|
||||||
|
compatible_material_diameter = str(round(extruder_stack.getCompatibleMaterialDiameter()))
|
||||||
|
self._available_materials = {key: material for key, material in materials.items() if material.container.getMetaDataEntry("approximate_diameter") == compatible_material_diameter}
|
||||||
|
|
||||||
## This method is used by all material models in the beginning of the
|
## This method is used by all material models in the beginning of the
|
||||||
# _update() method in order to prevent errors. It's the same in all models
|
# _update() method in order to prevent errors. It's the same in all models
|
||||||
# so it's placed here for easy access.
|
# so it's placed here for easy access.
|
||||||
|
@ -126,16 +136,7 @@ class BaseMaterialsModel(ListModel):
|
||||||
extruder_position = str(self._extruder_position)
|
extruder_position = str(self._extruder_position)
|
||||||
if extruder_position not in global_stack.extruders:
|
if extruder_position not in global_stack.extruders:
|
||||||
return False
|
return False
|
||||||
extruder_stack = global_stack.extruders[extruder_position]
|
|
||||||
|
|
||||||
nozzle_name = None
|
|
||||||
if extruder_stack.variant.getId() != "empty_variant":
|
|
||||||
nozzle_name = extruder_stack.variant.getName()
|
|
||||||
|
|
||||||
# Update the available materials (ContainerNode) for the current active machine and extruder setup.
|
|
||||||
materials = ContainerTree.getInstance().machines[global_stack.definition.getId()].variants[nozzle_name].materials
|
|
||||||
compatible_material_diameter = str(round(extruder_stack.getCompatibleMaterialDiameter()))
|
|
||||||
self._available_materials = {key: material for key, material in materials.items() if material.container.getMetaDataEntry("approximate_diameter") == compatible_material_diameter}
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
## This is another convenience function which is shared by all material
|
## This is another convenience function which is shared by all material
|
||||||
|
|
|
@ -19,9 +19,9 @@ class FavoriteMaterialsModel(BaseMaterialsModel):
|
||||||
self._update()
|
self._update()
|
||||||
|
|
||||||
def _update(self):
|
def _update(self):
|
||||||
super()._update()
|
|
||||||
if not self._canUpdate():
|
if not self._canUpdate():
|
||||||
return
|
return
|
||||||
|
super()._update()
|
||||||
|
|
||||||
item_list = []
|
item_list = []
|
||||||
|
|
||||||
|
|
|
@ -10,9 +10,9 @@ class GenericMaterialsModel(BaseMaterialsModel):
|
||||||
self._update()
|
self._update()
|
||||||
|
|
||||||
def _update(self):
|
def _update(self):
|
||||||
super()._update()
|
|
||||||
if not self._canUpdate():
|
if not self._canUpdate():
|
||||||
return
|
return
|
||||||
|
super()._update()
|
||||||
|
|
||||||
item_list = []
|
item_list = []
|
||||||
|
|
||||||
|
|
|
@ -27,9 +27,9 @@ class MaterialBrandsModel(BaseMaterialsModel):
|
||||||
self._update()
|
self._update()
|
||||||
|
|
||||||
def _update(self):
|
def _update(self):
|
||||||
super()._update()
|
|
||||||
if not self._canUpdate():
|
if not self._canUpdate():
|
||||||
return
|
return
|
||||||
|
super()._update()
|
||||||
|
|
||||||
brand_item_list = []
|
brand_item_list = []
|
||||||
brand_group_dict = {}
|
brand_group_dict = {}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue