Remove the checkbox option to set the preference to hide the messagebox

This commit is contained in:
fieldOfView 2020-03-31 11:50:16 +02:00
parent b7898b5a97
commit ccc0589495
2 changed files with 70 additions and 42 deletions

View file

@ -67,11 +67,11 @@ class SolidView(View):
self._next_xray_checking_time = time.time()
self._xray_checking_update_time = 1.0 # seconds
self._xray_warning_cooldown = 60 * 10 # reshow Model error message every 10 minutes
self._xray_warning_message = Message(catalog.i18nc("@info:status", "Your model is not manifold. The highlighted areas indicate either missing or extraneous surfaces.")
, lifetime = 60 * 5 # leave message for 5 minutes
, title = catalog.i18nc("@info:title", "Model errors"),
option_text = catalog.i18nc("@info:option_text", "Do not show this message again"), option_state = False)
self._xray_warning_message.optionToggled.connect(self._onDontAskMeAgain)
self._xray_warning_message = Message(
catalog.i18nc("@info:status", "Your model is not manifold. The highlighted areas indicate either missing or extraneous surfaces."),
lifetime = 60 * 5, # leave message for 5 minutes
title = catalog.i18nc("@info:title", "Model errors"),
)
application.getPreferences().addPreference(self._show_xray_warning_preference, True)
application.engineCreatedSignal.connect(self._onGlobalContainerChanged)
@ -133,44 +133,55 @@ class SolidView(View):
self._support_mesh_shader.setUniformValue("u_vertical_stripes", True)
self._support_mesh_shader.setUniformValue("u_width", 5.0)
if not self._xray_error_image:
self._xray_error_image = OpenGL.getInstance().createTexture()
texture_file = "xray_error.png"
try:
texture_image = QImage(Resources.getPath(Resources.Images, texture_file)).mirrored()
self._xray_error_image.setImage(texture_image)
self._xray_error_image_size = texture_image.size()
except FileNotFoundError:
Logger.log("w", "Unable to find xray error texture image [%s]", texture_file)
if not Application.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"
try:
texture_image = QImage(Resources.getPath(Resources.Images, texture_file)).mirrored()
self._xray_error_image.setImage(texture_image)
self._xray_error_image_size = texture_image.size()
except FileNotFoundError:
Logger.log("w", "Unable to find xray error texture image [%s]", texture_file)
if not self._xray_shader:
self._xray_shader = OpenGL.getInstance().createShaderProgram(Resources.getPath(Resources.Shaders, "xray.shader"))
if not self._xray_shader:
self._xray_shader = OpenGL.getInstance().createShaderProgram(Resources.getPath(Resources.Shaders, "xray.shader"))
if not self._xray_composite_shader:
self._xray_composite_shader = OpenGL.getInstance().createShaderProgram(Resources.getPath(Resources.Shaders, "xray_composite.shader"))
theme = Application.getInstance().getTheme()
self._xray_composite_shader.setUniformValue("u_background_color", Color(*theme.getColor("viewport_background").getRgb()))
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._xray_composite_shader:
self._xray_composite_shader = OpenGL.getInstance().createShaderProgram(Resources.getPath(Resources.Shaders, "xray_composite.shader"))
theme = Application.getInstance().getTheme()
self._xray_composite_shader.setUniformValue("u_background_color", Color(*theme.getColor("viewport_background").getRgb()))
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)
renderer = self.getRenderer()
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)
renderer = self.getRenderer()
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)
renderer.addRenderPass(self._xray_pass)
renderer.addRenderPass(self._xray_pass)
if not self._composite_pass:
self._composite_pass = self.getRenderer().getRenderPass("composite")
if not self._composite_pass:
self._composite_pass = self.getRenderer().getRenderPass("composite")
self._old_layer_bindings = self._composite_pass.getLayerBindings()
self._composite_pass.setLayerBindings(["default", "selection", "xray"])
self._old_composite_shader = self._composite_pass.getCompositeShader()
self._composite_pass.setCompositeShader(self._xray_composite_shader)
self._old_layer_bindings = self._composite_pass.getLayerBindings()
self._composite_pass.setLayerBindings(["default", "selection", "xray"])
self._old_composite_shader = self._composite_pass.getCompositeShader()
self._composite_pass.setCompositeShader(self._xray_composite_shader)
error_image_scale = [renderer.getViewportWidth() / self._xray_error_image_size.width(), renderer.getViewportHeight() / self._xray_error_image_size.height()]
self._xray_composite_shader.setUniformValue("u_xray_error_scale", error_image_scale)
error_image_scale = [renderer.getViewportWidth() / self._xray_error_image_size.width(), renderer.getViewportHeight() / self._xray_error_image_size.height()]
self._xray_composite_shader.setUniformValue("u_xray_error_scale", error_image_scale)
def beginRendering(self):
scene = self.getController().getScene()
@ -291,9 +302,6 @@ class SolidView(View):
self._xray_warning_message.show()
Logger.log("i", "X-Ray overlay found non-manifold pixels.")
def _onDontAskMeAgain(self, checked: bool) -> None:
Application.getInstance().getPreferences().setValue(self._show_xray_warning_preference, not checked)
def event(self, event):
if event.type == Event.ViewActivateEvent:
# FIX: on Max OS X, somehow QOpenGLContext.currentContext() can become None during View switching.

View file

@ -87,7 +87,9 @@ UM.PreferencesPage
UM.Preferences.resetPreference("view/show_overhang");
showOverhangCheckbox.checked = boolCheck(UM.Preferences.getValue("view/show_overhang"))
UM.Preferences.resetPreference("view/show_xray_warning");
showXrayErrorCheckbox.checked = boolCheck(UM.Preferences.getValue("view/show_xray_warning"))
showXrayErrorCheckbox.checked = boolCheck(UM.Preferences.getValue("view/show_warning"))
UM.Preferences.resetPreference("view/show_xray_warning_message");
showXrayErrorMessageCheckbox.checked = boolCheck(UM.Preferences.getValue("view/show_warning_message"))
UM.Preferences.resetPreference("view/center_on_select");
centerOnSelectCheckbox.checked = boolCheck(UM.Preferences.getValue("view/center_on_select"))
UM.Preferences.resetPreference("view/invert_zoom");
@ -345,7 +347,7 @@ UM.PreferencesPage
width: childrenRect.width;
height: childrenRect.height;
text: catalog.i18nc("@info:tooltip", "Show a message if missing or extraneous surfaces are detected. The toolpaths will often be missing parts of the intended geometry.")
text: catalog.i18nc("@info:tooltip", "Highlight missing or extraneous surfaces of the model using warning signs. The toolpaths will often be missing parts of the intended geometry.")
CheckBox
{
@ -354,7 +356,25 @@ UM.PreferencesPage
checked: boolCheck(UM.Preferences.getValue("view/show_xray_warning"))
onClicked: UM.Preferences.setValue("view/show_xray_warning", checked)
text: catalog.i18nc("@option:check", "Display message if model errors are detected");
text: catalog.i18nc("@option:check", "Display model errors");
}
}
UM.TooltipArea
{
width: childrenRect.width;
height: childrenRect.height;
text: catalog.i18nc("@info:tooltip", "Highlight missing or extraneous surfaces of the model using warning signs. The toolpaths will often be missing parts of the intended geometry.")
CheckBox
{
id: showXrayErrorMessageCheckbox
checked: boolCheck(UM.Preferences.getValue("view/show_xray_warning_message"))
onClicked: UM.Preferences.setValue("view/show_xray_warning_message", checked)
text: catalog.i18nc("@option:check", "Display model errors");
}
}