Require MaterialGroup to always have a base material

The material group is loaded lazily whenever the base material is not yet in the dictionary.

Contributes to issue CURA-4606.
This commit is contained in:
Ghostkeeper 2018-03-12 15:43:25 +01:00
parent c54679ba2d
commit 1512a8096b
No known key found for this signature in database
GPG key ID: 5252B696FB5E7C7A
2 changed files with 13 additions and 14 deletions

View file

@ -1,9 +1,10 @@
# Copyright (c) 2018 Ultimaker B.V.
# Cura is released under the terms of the LGPLv3 or higher.
from typing import List
from cura.Machines.MaterialNode import MaterialNode #For type checking.
#
# A MaterialGroup represents a group of material InstanceContainers that are derived from a single material profile.
## A MaterialGroup represents a group of material InstanceContainers that are derived from a single material profile.
# The main InstanceContainer which has the ID of the material profile file name is called the "root_material". For
# example: "generic_abs" is the root material (ID) of "generic_abs_ultimaker3" and "generic_abs_ultimaker3_AA_0.4",
# and "generic_abs_ultimaker3" and "generic_abs_ultimaker3_AA_0.4" are derived materials of "generic_abs".
@ -17,10 +18,10 @@
class MaterialGroup:
__slots__ = ("name", "root_material_node", "derived_material_node_list")
def __init__(self, name: str):
def __init__(self, name: str, root_material_node: MaterialNode):
self.name = name
self.root_material_node = None
self.derived_material_node_list = []
self.root_material_node = root_material_node
self.derived_material_node_list = [] #type: List[MaterialNode]
def __str__(self) -> str:
return "%s[%s]" % (self.__class__.__name__, self.name)