Fix render color for single-extrusion printers

CURA-1992
This commit is contained in:
fieldOfView 2016-07-29 17:36:07 +02:00
parent 228f5be35a
commit 1182a3c87e

View File

@ -57,25 +57,28 @@ class SolidView(View):
# renderer.queueNode(scene.getRoot(), mesh = node.getBoundingBoxMesh(),mode = Renderer.RenderLines) # renderer.queueNode(scene.getRoot(), mesh = node.getBoundingBoxMesh(),mode = Renderer.RenderLines)
uniforms = {} uniforms = {}
if self._extruders_model.rowCount() > 0: if self._extruders_model.rowCount() == 0:
material = Application.getInstance().getGlobalContainerStack().findContainer({ "type": "material" })
material_color = material.getMetaDataEntry("color_code", default = self._extruders_model.defaultColours[0]) if material else self._extruders_model.defaultColours[0]
else:
# Get color to render this mesh in from ExtrudersModel # Get color to render this mesh in from ExtrudersModel
extruder_index = 0 extruder_index = 0
extruder_id = node.callDecoration("getActiveExtruder") extruder_id = node.callDecoration("getActiveExtruder")
if extruder_id: if extruder_id:
extruder_index = max(0, self._extruders_model.find("id", extruder_id)) extruder_index = max(0, self._extruders_model.find("id", extruder_id))
extruder_color = self._extruders_model.getItem(extruder_index)["colour"] material_color = self._extruders_model.getItem(extruder_index)["colour"]
try: try:
# Colors are passed as rgb hex strings (eg "#ffffff"), and the shader needs # Colors are passed as rgb hex strings (eg "#ffffff"), and the shader needs
# an rgba list of floats (eg [1.0, 1.0, 1.0, 1.0]) # an rgba list of floats (eg [1.0, 1.0, 1.0, 1.0])
uniforms["diffuse_color"] = [ uniforms["diffuse_color"] = [
int(extruder_color[1:3], 16) / 255, int(material_color[1:3], 16) / 255,
int(extruder_color[3:5], 16) / 255, int(material_color[3:5], 16) / 255,
int(extruder_color[5:7], 16) / 255, int(material_color[5:7], 16) / 255,
1.0 1.0
] ]
except ValueError: except ValueError:
pass pass
if hasattr(node, "_outside_buildarea"): if hasattr(node, "_outside_buildarea"):
if node._outside_buildarea: if node._outside_buildarea: