diff options
author | Tim Kuipers <t.kuipers@ultimaker.com> | 2019-10-21 18:34:23 +0300 |
---|---|---|
committer | Tim Kuipers <t.kuipers@ultimaker.com> | 2020-02-27 18:41:13 +0300 |
commit | fc4c66b62a7173d1260e40c121bc6133fbca6a88 (patch) | |
tree | 5b34b01c2e51fb1412e919d1c89c2add12a9ddb6 /plugins/XRayView | |
parent | b3761c454bba281517f1cd21d3fa4d669c7e39ba (diff) |
show xray errors in solid view
Diffstat (limited to 'plugins/XRayView')
-rw-r--r-- | plugins/XRayView/XRayPass.py | 39 | ||||
-rw-r--r-- | plugins/XRayView/XRayView.py | 6 | ||||
-rw-r--r-- | plugins/XRayView/xray.shader | 55 |
3 files changed, 4 insertions, 96 deletions
diff --git a/plugins/XRayView/XRayPass.py b/plugins/XRayView/XRayPass.py deleted file mode 100644 index a75d393b35..0000000000 --- a/plugins/XRayView/XRayPass.py +++ /dev/null @@ -1,39 +0,0 @@ -# Copyright (c) 2018 Ultimaker B.V. -# Cura is released under the terms of the LGPLv3 or higher. - -import os.path - -from UM.Application import Application -from UM.PluginRegistry import PluginRegistry - -from UM.View.RenderPass import RenderPass -from UM.View.RenderBatch import RenderBatch -from UM.View.GL.OpenGL import OpenGL - -from cura.Scene.CuraSceneNode import CuraSceneNode -from UM.Scene.Iterator.DepthFirstIterator import DepthFirstIterator - -class XRayPass(RenderPass): - def __init__(self, width, height): - super().__init__("xray", width, height) - - self._shader = None - self._gl = OpenGL.getInstance().getBindingsObject() - self._scene = Application.getInstance().getController().getScene() - - def render(self): - if not self._shader: - self._shader = OpenGL.getInstance().createShaderProgram(os.path.join(PluginRegistry.getInstance().getPluginPath("XRayView"), "xray.shader")) - - batch = RenderBatch(self._shader, type = RenderBatch.RenderType.NoType, backface_cull = False, blend_mode = RenderBatch.BlendMode.Additive) - for node in DepthFirstIterator(self._scene.getRoot()): - if isinstance(node, CuraSceneNode) and node.getMeshData() and node.isVisible(): - batch.addItem(node.getWorldTransformation(), node.getMeshData()) - - self.bind() - - self._gl.glDisable(self._gl.GL_DEPTH_TEST) - batch.render(self._scene.getActiveCamera()) - self._gl.glEnable(self._gl.GL_DEPTH_TEST) - - self.release() diff --git a/plugins/XRayView/XRayView.py b/plugins/XRayView/XRayView.py index 88a5a441b8..d94835c65e 100644 --- a/plugins/XRayView/XRayView.py +++ b/plugins/XRayView/XRayView.py @@ -8,6 +8,7 @@ from UM.Application import Application from UM.Logger import Logger from UM.Math.Color import Color from UM.PluginRegistry import PluginRegistry +from UM.Resources import Resources from UM.Platform import Platform from UM.Event import Event from UM.Scene.Iterator.BreadthFirstIterator import BreadthFirstIterator @@ -19,7 +20,8 @@ from cura.CuraApplication import CuraApplication from cura.CuraView import CuraView from cura.Scene.ConvexHullNode import ConvexHullNode -from . import XRayPass +from cura import XRayPass + ## View used to display a see-through version of objects with errors highlighted. class XRayView(CuraView): @@ -38,7 +40,7 @@ class XRayView(CuraView): renderer = self.getRenderer() if not self._xray_shader: - self._xray_shader = OpenGL.getInstance().createShaderProgram(os.path.join(PluginRegistry.getInstance().getPluginPath("XRayView"), "xray.shader")) + self._xray_shader = OpenGL.getInstance().createShaderProgram(Resources.getPath(Resources.Shaders, "xray.shader")) self._xray_shader.setUniformValue("u_color", Color(*Application.getInstance().getTheme().getColor("xray").getRgb())) for node in BreadthFirstIterator(scene.getRoot()): diff --git a/plugins/XRayView/xray.shader b/plugins/XRayView/xray.shader deleted file mode 100644 index 45cb16c44c..0000000000 --- a/plugins/XRayView/xray.shader +++ /dev/null @@ -1,55 +0,0 @@ -[shaders] -vertex = - uniform highp mat4 u_modelMatrix; - uniform highp mat4 u_viewMatrix; - uniform highp mat4 u_projectionMatrix; - - attribute highp vec4 a_vertex; - - void main() - { - gl_Position = u_projectionMatrix * u_viewMatrix * u_modelMatrix * a_vertex; - } - -fragment = - uniform lowp vec4 u_color; - - void main() - { - gl_FragColor = u_color; - } - -vertex41core = - #version 410 - uniform highp mat4 u_modelMatrix; - uniform highp mat4 u_viewMatrix; - uniform highp mat4 u_projectionMatrix; - - in highp vec4 a_vertex; - - void main() - { - gl_Position = u_projectionMatrix * u_viewMatrix * u_modelMatrix * a_vertex; - } - -fragment41core = - #version 410 - uniform lowp vec4 u_color; - - out vec4 frag_color; - - void main() - { - frag_color = u_color; - } - -[defaults] -u_color = [0.02, 0.02, 0.02, 1.0] - -[bindings] -u_modelMatrix = model_matrix -u_viewMatrix = view_matrix -u_projectionMatrix = projection_matrix - -[attributes] -a_vertex = vertex |