diff options
author | Tim Kuipers <t.kuipers@ultimaker.com> | 2020-02-26 19:56:22 +0300 |
---|---|---|
committer | Tim Kuipers <t.kuipers@ultimaker.com> | 2020-02-27 18:41:20 +0300 |
commit | b4c3703dc44c923ae05ee9236e0a3d0c1fd7219c (patch) | |
tree | 19c8f85c6e4cddede314c8f62926f89333830b60 /plugins/SolidView | |
parent | 01643f5feef430f04b6867e5633c0ad484a4fa0a (diff) |
Check xray overlay for badness in model every 1.0 second
Diffstat (limited to 'plugins/SolidView')
-rw-r--r-- | plugins/SolidView/SolidView.py | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/plugins/SolidView/SolidView.py b/plugins/SolidView/SolidView.py index 3770939cc7..ec8167aeeb 100644 --- a/plugins/SolidView/SolidView.py +++ b/plugins/SolidView/SolidView.py @@ -8,6 +8,9 @@ from UM.Scene.Selection import Selection from UM.Resources import Resources from PyQt5.QtGui import QOpenGLContext, QImage +import numpy as np +import time + from UM.Application import Application from UM.Logger import Logger from UM.Math.Color import Color @@ -54,6 +57,9 @@ class SolidView(View): self._old_composite_shader = None self._old_layer_bindings = None + self._last_xray_checking_time = time.time() + self._xray_checking_update_time = 1.0 # seconds + Application.getInstance().engineCreatedSignal.connect(self._onGlobalContainerChanged) def _onGlobalContainerChanged(self) -> None: @@ -228,9 +234,21 @@ class SolidView(View): if node.callDecoration("isGroup") and Selection.isSelected(node): renderer.queueNode(scene.getRoot(), mesh = node.getBoundingBoxMesh(), mode = RenderBatch.RenderMode.LineLoop) - def endRendering(self): - pass + # 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() + 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)) + + if bad_pixel_count > 0: + Logger.log("d", "Super bad xray, man! : %d" % bad_pixel_count) def event(self, event): if event.type == Event.ViewActivateEvent: |