Skip to content

Commit

Permalink
Clean-up & requirements update
Browse files Browse the repository at this point in the history
  • Loading branch information
Patryk Skowroński committed Oct 29, 2024
1 parent 6be979c commit 036a69c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
13 changes: 7 additions & 6 deletions cura/NavlibClient.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):

Expand All @@ -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.):

Expand Down Expand Up @@ -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)

Expand All @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions cura/Scene/OverlayNode.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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.
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -406,3 +406,5 @@ pywin32-ctypes==0.2.0; \

charset-normalizer==2.1.0; \
--hash=sha256:5189b6f22b01957427f35b6a08d9a0bc45b46d3788ef5a92e978433c7a35f8a5

pynavlib==0.9.1;

0 comments on commit 036a69c

Please sign in to comment.