allow immediate change of preference for showing xray errors in solid view

This commit is contained in:
Tim Kuipers 2020-02-27 08:46:52 +01:00
parent 4b1a426873
commit 0e633a0dfa

View file

@ -139,6 +139,17 @@ class SolidView(View):
self._checkSetup()
if not CuraApplication.getInstance().getPreferences().getValue(self._show_xray_warning_preference):
self._xray_error_image = None
self._xray_shader = None
self._xray_composite_shader = None
if self._composite_pass and 'xray' in self._composite_pass.getLayerBindings():
self._composite_pass.setLayerBindings(self._old_layer_bindings)
self._composite_pass.setCompositeShader(self._old_composite_shader)
self._old_layer_bindings = None
self._old_composite_shader = None
self._xray_warning_message.hide()
else:
if not self._xray_error_image:
self._xray_error_image = OpenGL.getInstance().createTexture()
texture_file = "xray_error.png"
@ -157,7 +168,7 @@ class SolidView(View):
self._xray_composite_shader.setUniformValue("u_outline_color", Color(*theme.getColor("model_selection_outline").getRgb()))
self._xray_composite_shader.setTexture(3, self._xray_error_image)
if not self.getRenderer().getRenderPass("xray"):
if not self._composite_pass or not 'xray' in self._composite_pass.getLayerBindings():
# Currently the RenderPass constructor requires a size > 0
# This should be fixed in RenderPass's constructor.
self._xray_pass = XRayPass.XRayPass(1, 1)
@ -290,6 +301,7 @@ class SolidView(View):
if event.type == Event.ViewDeactivateEvent:
if self._composite_pass and 'xray' in self._composite_pass.getLayerBindings():
self.getRenderer().removeRenderPass(self._xray_pass)
self._composite_pass.setLayerBindings(self._old_layer_bindings)
self._composite_pass.setCompositeShader(self._old_composite_shader)