mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-06 14:37:29 -06:00
Check xray overlay for badness in model every 1.0 second
This commit is contained in:
parent
01643f5fee
commit
b4c3703dc4
1 changed files with 20 additions and 2 deletions
|
@ -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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue