Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/Ultimaker/Cura.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Kuipers <t.kuipers@ultimaker.com>2020-02-26 21:21:43 +0300
committerTim Kuipers <t.kuipers@ultimaker.com>2020-02-27 18:41:20 +0300
commit643b27e1606d80f5246233d34d27c64970d57d54 (patch)
tree9a706a0b7e574ff08dd7e146c4e1c0326789fb97 /plugins/SolidView
parentb4c3703dc44c923ae05ee9236e0a3d0c1fd7219c (diff)
add xray error warning message
Diffstat (limited to 'plugins/SolidView')
-rw-r--r--plugins/SolidView/SolidView.py34
1 files changed, 27 insertions, 7 deletions
diff --git a/plugins/SolidView/SolidView.py b/plugins/SolidView/SolidView.py
index ec8167aeeb..40877bf477 100644
--- a/plugins/SolidView/SolidView.py
+++ b/plugins/SolidView/SolidView.py
@@ -13,6 +13,7 @@ import time
from UM.Application import Application
from UM.Logger import Logger
+from UM.Message import Message
from UM.Math.Color import Color
from UM.PluginRegistry import PluginRegistry
from UM.Platform import Platform
@@ -21,6 +22,8 @@ from UM.Event import Event
from UM.View.RenderBatch import RenderBatch
from UM.View.GL.OpenGL import OpenGL
+from UM.i18n import i18nCatalog
+
from cura.CuraApplication import CuraApplication
from cura.Settings.ExtruderManager import ExtruderManager
@@ -29,9 +32,13 @@ from cura import XRayPass
import math
+catalog = i18nCatalog("cura")
+
## Standard view for mesh models.
class SolidView(View):
+ _show_xray_warning_preference = "view/show_xray_warning"
+
def __init__(self):
super().__init__()
application = Application.getInstance()
@@ -57,8 +64,15 @@ class SolidView(View):
self._old_composite_shader = None
self._old_layer_bindings = None
- self._last_xray_checking_time = time.time()
+ self._next_xray_checking_time = time.time()
self._xray_checking_update_time = 1.0 # seconds
+ self._xray_warning_cooldown = 1 # 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)
+ CuraApplication.getInstance().getPreferences().addPreference(self._show_xray_warning_preference, True)
Application.getInstance().engineCreatedSignal.connect(self._onGlobalContainerChanged)
@@ -236,19 +250,24 @@ class SolidView(View):
def endRendering(self):
# check whether the xray overlay is showing badness
- if time.time() > self._last_xray_checking_time + self._xray_checking_update_time:
- self._last_xray_checking_time = time.time()
+ if time.time() > self._next_xray_checking_time\
+ and CuraApplication.getInstance().getPreferences().getValue(self._show_xray_warning_preference):
+ self._next_xray_checking_time = time.time() + self._xray_checking_update_time
+
xray_img = self._xray_pass.getOutput()
xray_img = xray_img.convertToFormat(QImage.Format.Format_RGB888)
-
ptr = xray_img.bits()
ptr.setsize(xray_img.byteCount())
reds = np.array(ptr).reshape(xray_img.height(), xray_img.width(), 3)[:,:,0] # Copies the data
+ bad_pixel_count = np.sum(np.mod(reds, 2)) # check number of pixels with an odd intersection count
- bad_pixel_count = np.sum(np.mod(reds, 2))
+ if bad_pixel_count > 10: # allow for 10 pixels to be erroneously marked as problematic
+ self._next_xray_checking_time = time.time() + self._xray_warning_cooldown
+ self._xray_warning_message.show()
+ Logger.log("i", "Xray overlay found %d non-manifold pixels." % bad_pixel_count)
- if bad_pixel_count > 0:
- Logger.log("d", "Super bad xray, man! : %d" % bad_pixel_count)
+ def _onDontAskMeAgain(self, checked: bool) -> None:
+ CuraApplication.getInstance().getPreferences().setValue(self._show_xray_warning_preference, not checked)
def event(self, event):
if event.type == Event.ViewActivateEvent:
@@ -274,3 +293,4 @@ class SolidView(View):
self.getRenderer().removeRenderPass(self._xray_pass)
self._composite_pass.setLayerBindings(self._old_layer_bindings)
self._composite_pass.setCompositeShader(self._old_composite_shader)
+ self._xray_warning_message.hide()