From 036a69c9cdeff6fc1b2ce2b21b58b60530f84e8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patryk=20Skowro=C5=84ski?= Date: Tue, 29 Oct 2024 11:35:34 +0100 Subject: [PATCH] Clean-up & requirements update --- cura/NavlibClient.py | 13 +++++++------ cura/Scene/OverlayNode.py | 4 ++-- requirements.txt | 2 ++ 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/cura/NavlibClient.py b/cura/NavlibClient.py index 7490377586f..e5634879cdc 100644 --- a/cura/NavlibClient.py +++ b/cura/NavlibClient.py @@ -5,6 +5,7 @@ from cura.PickingPass import PickingPass from UM.Scene.Iterator.DepthFirstIterator import DepthFirstIterator from cura.Scene.OverlayNode import OverlayNode, SceneNode +from UM.Resources import Resources class NavlibClient(pynav.NavlibNavigationModel): @@ -16,7 +17,7 @@ def __init__(self, scene, renderer) -> None: self._was_pick = False self._hit_selection_only = False self._picking_pass = None - self._pivot_node = OverlayNode(node=SceneNode(), image_path="resources/images/3dx_pivot.png", size=3.) + self._pivot_node = OverlayNode(node=SceneNode(), image_path=Resources.getPath(Resources.Images, "3dx_pivot.png"), size=3.) def pick(self, x, y, check_selection = False, radius = 0.): @@ -224,13 +225,13 @@ def set_camera_matrix(self, matrix : pynav.NavlibMatrix): if active_camera.isPerspective(): camera_position = active_camera.getWorldPosition() dist = (camera_position - self._pivot_node.getWorldPosition()).length() - scale = dist/400 - if scale < 1.0: + scale = dist / 400. + if scale < 1.: scale = scale * scale else: view_width = active_camera.getViewportWidth() - current_size = view_width + (2 * active_camera.getZoomFactor() * view_width) - scale = current_size / view_width * 5 + current_size = view_width + (2. * active_camera.getZoomFactor() * view_width) + scale = current_size / view_width * 5. self._pivot_node.scale(scale) @@ -253,7 +254,7 @@ def set_motion_flag(self, motion : bool): self._renderer.removeRenderPass(self._picking_pass) def set_pivot_position(self, position): - self._pivot_node._target_node.setPosition(position=Vector(position._x, position._y, position._z), transform_space = 3) + self._pivot_node._target_node.setPosition(position=Vector(position._x, position._y, position._z), transform_space = SceneNode.TransformSpace.World) def set_pivot_visible(self, visible): if visible: diff --git a/cura/Scene/OverlayNode.py b/cura/Scene/OverlayNode.py index c3be2d78afd..c3fb25f1495 100644 --- a/cura/Scene/OverlayNode.py +++ b/cura/Scene/OverlayNode.py @@ -14,7 +14,7 @@ from PyQt5.QtGui import QImage class OverlayNode(SceneNode): - def __init__(self, node, image_path, parent=None, size=1.): + def __init__(self, node, image_path, size, parent=None): super().__init__(parent) self._target_node = node self.setCalculateBoundingBox(False) @@ -63,6 +63,6 @@ def render(self, renderer): position_matrix.setByTranslation(node_position) camera_orientation = self._scene.getActiveCamera().getOrientation().toMatrix() - renderer.queueNode(self._scene.getRoot(), shader=self._shader, mesh=self._drawed_mesh.getTransformed(position_matrix.multiply(camera_orientation)), type=3) + renderer.queueNode(self._scene.getRoot(), shader=self._shader, mesh=self._drawed_mesh.getTransformed(position_matrix.multiply(camera_orientation)), overlay=True) return True # This node does it's own rendering. diff --git a/requirements.txt b/requirements.txt index 344a0156d8d..0728d177762 100644 --- a/requirements.txt +++ b/requirements.txt @@ -406,3 +406,5 @@ pywin32-ctypes==0.2.0; \ charset-normalizer==2.1.0; \ --hash=sha256:5189b6f22b01957427f35b6a08d9a0bc45b46d3788ef5a92e978433c7a35f8a5 + +pynavlib==0.9.1; \ No newline at end of file