mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-07 06:57:28 -06:00
Clean-up & requirements update
This commit is contained in:
parent
6be979c670
commit
036a69c9cd
3 changed files with 11 additions and 8 deletions
|
@ -5,6 +5,7 @@ from UM.Math.AxisAlignedBox import AxisAlignedBox
|
||||||
from cura.PickingPass import PickingPass
|
from cura.PickingPass import PickingPass
|
||||||
from UM.Scene.Iterator.DepthFirstIterator import DepthFirstIterator
|
from UM.Scene.Iterator.DepthFirstIterator import DepthFirstIterator
|
||||||
from cura.Scene.OverlayNode import OverlayNode, SceneNode
|
from cura.Scene.OverlayNode import OverlayNode, SceneNode
|
||||||
|
from UM.Resources import Resources
|
||||||
|
|
||||||
class NavlibClient(pynav.NavlibNavigationModel):
|
class NavlibClient(pynav.NavlibNavigationModel):
|
||||||
|
|
||||||
|
@ -16,7 +17,7 @@ class NavlibClient(pynav.NavlibNavigationModel):
|
||||||
self._was_pick = False
|
self._was_pick = False
|
||||||
self._hit_selection_only = False
|
self._hit_selection_only = False
|
||||||
self._picking_pass = None
|
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.):
|
def pick(self, x, y, check_selection = False, radius = 0.):
|
||||||
|
|
||||||
|
@ -224,13 +225,13 @@ class NavlibClient(pynav.NavlibNavigationModel):
|
||||||
if active_camera.isPerspective():
|
if active_camera.isPerspective():
|
||||||
camera_position = active_camera.getWorldPosition()
|
camera_position = active_camera.getWorldPosition()
|
||||||
dist = (camera_position - self._pivot_node.getWorldPosition()).length()
|
dist = (camera_position - self._pivot_node.getWorldPosition()).length()
|
||||||
scale = dist/400
|
scale = dist / 400.
|
||||||
if scale < 1.0:
|
if scale < 1.:
|
||||||
scale = scale * scale
|
scale = scale * scale
|
||||||
else:
|
else:
|
||||||
view_width = active_camera.getViewportWidth()
|
view_width = active_camera.getViewportWidth()
|
||||||
current_size = view_width + (2 * active_camera.getZoomFactor() * view_width)
|
current_size = view_width + (2. * active_camera.getZoomFactor() * view_width)
|
||||||
scale = current_size / view_width * 5
|
scale = current_size / view_width * 5.
|
||||||
|
|
||||||
self._pivot_node.scale(scale)
|
self._pivot_node.scale(scale)
|
||||||
|
|
||||||
|
@ -253,7 +254,7 @@ class NavlibClient(pynav.NavlibNavigationModel):
|
||||||
self._renderer.removeRenderPass(self._picking_pass)
|
self._renderer.removeRenderPass(self._picking_pass)
|
||||||
|
|
||||||
def set_pivot_position(self, position):
|
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):
|
def set_pivot_visible(self, visible):
|
||||||
if visible:
|
if visible:
|
||||||
|
|
|
@ -14,7 +14,7 @@ except:
|
||||||
from PyQt5.QtGui import QImage
|
from PyQt5.QtGui import QImage
|
||||||
|
|
||||||
class OverlayNode(SceneNode):
|
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)
|
super().__init__(parent)
|
||||||
self._target_node = node
|
self._target_node = node
|
||||||
self.setCalculateBoundingBox(False)
|
self.setCalculateBoundingBox(False)
|
||||||
|
@ -63,6 +63,6 @@ class OverlayNode(SceneNode):
|
||||||
position_matrix.setByTranslation(node_position)
|
position_matrix.setByTranslation(node_position)
|
||||||
camera_orientation = self._scene.getActiveCamera().getOrientation().toMatrix()
|
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.
|
return True # This node does it's own rendering.
|
||||||
|
|
|
@ -406,3 +406,5 @@ pywin32-ctypes==0.2.0; \
|
||||||
|
|
||||||
charset-normalizer==2.1.0; \
|
charset-normalizer==2.1.0; \
|
||||||
--hash=sha256:5189b6f22b01957427f35b6a08d9a0bc45b46d3788ef5a92e978433c7a35f8a5
|
--hash=sha256:5189b6f22b01957427f35b6a08d9a0bc45b46d3788ef5a92e978433c7a35f8a5
|
||||||
|
|
||||||
|
pynavlib==0.9.1;
|
Loading…
Add table
Add a link
Reference in a new issue