From a0203905b6e90a46eed183c491f97a6463408688 Mon Sep 17 00:00:00 2001 From: fieldOfView Date: Wed, 10 Aug 2016 14:08:58 +0200 Subject: [PATCH] Show the right material color for single-extrusion machines CURA-1992 --- plugins/SolidView/SolidView.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/plugins/SolidView/SolidView.py b/plugins/SolidView/SolidView.py index 9a4604193e..7896892808 100644 --- a/plugins/SolidView/SolidView.py +++ b/plugins/SolidView/SolidView.py @@ -41,26 +41,28 @@ class SolidView(View): self._disabled_shader.setUniformValue("u_diffuseColor2", [0.68, 0.68, 0.68, 1.0]) self._disabled_shader.setUniformValue("u_width", 50.0) - if Application.getInstance().getGlobalContainerStack(): + multi_extrusion = False + + global_container_stack = Application.getInstance().getGlobalContainerStack() + if global_container_stack: if Preferences.getInstance().getValue("view/show_overhang"): - angle = Application.getInstance().getGlobalContainerStack().getProperty("support_angle", "value") - if angle is not None and Application.getInstance().getGlobalContainerStack().getProperty("support_angle", "validationState") == ValidatorState.Valid: + angle = global_container_stack.getProperty("support_angle", "value") + if angle is not None and global_container_stack.getProperty("support_angle", "validationState") == ValidatorState.Valid: self._enabled_shader.setUniformValue("u_overhangAngle", math.cos(math.radians(90 - angle))) else: self._enabled_shader.setUniformValue("u_overhangAngle", math.cos(math.radians(0))) #Overhang angle of 0 causes no area at all to be marked as overhang. else: self._enabled_shader.setUniformValue("u_overhangAngle", math.cos(math.radians(0))) + multi_extrusion = global_container_stack.getProperty("machine_extruder_count", "value") > 1 + for node in DepthFirstIterator(scene.getRoot()): if not node.render(renderer): if node.getMeshData() and node.isVisible(): - # TODO: Find a better way to handle this - #if node.getBoundingBoxMesh(): - # renderer.queueNode(scene.getRoot(), mesh = node.getBoundingBoxMesh(),mode = Renderer.RenderLines) uniforms = {} - if self._extruders_model.rowCount() == 0: - material = Application.getInstance().getGlobalContainerStack().findContainer({ "type": "material" }) + if not multi_extrusion: + material = global_container_stack.findContainer({ "type": "material" }) material_color = material.getMetaDataEntry("color_code", default = self._extruders_model.defaultColors[0]) if material else self._extruders_model.defaultColors[0] else: # Get color to render this mesh in from ExtrudersModel