Define dummy 3DConnexion interface in case module is not available

CURA-12404
This commit is contained in:
Erwan MATHIEU 2025-02-07 14:50:23 +01:00
parent f23e881478
commit 5cf52a5d85

View file

@ -1,4 +1,3 @@
import pynavlib.pynavlib_interface as pynav
from UM.Math.Matrix import Matrix from UM.Math.Matrix import Matrix
from UM.Math.Vector import Vector from UM.Math.Vector import Vector
from UM.Math.AxisAlignedBox import AxisAlignedBox from UM.Math.AxisAlignedBox import AxisAlignedBox
@ -6,8 +5,12 @@ 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 from UM.Resources import Resources
from UM.Logger import Logger
class NavlibClient(pynav.NavlibNavigationModel): try:
import pynavlib.pynavlib_interface as pynav
class NavlibClient(pynav.NavlibNavigationModel):
def __init__(self, scene, renderer) -> None: def __init__(self, scene, renderer) -> None:
super().__init__(False, pynav.NavlibOptions.RowMajorOrder) super().__init__(False, pynav.NavlibOptions.RowMajorOrder)
@ -262,3 +265,16 @@ class NavlibClient(pynav.NavlibNavigationModel):
else: else:
self._scene.getRoot().removeChild(self._pivot_node) self._scene.getRoot().removeChild(self._pivot_node)
except BaseException as exception:
Logger.warning(f"Unable to load 3DConnexion library: {exception}")
# Define dummy class instead so that integration is transparent from outside
class NavlibClient:
def __init__(self, scene, renderer) -> None:
pass
def put_profile_hint(self, hint) -> None:
pass
def enable_navigation(self, enabled) -> None:
pass