From edc9a312498693d5ceba12a4ded59a7f97ad741e Mon Sep 17 00:00:00 2001 From: Olli-Pekka Kahilakoski Date: Tue, 12 Apr 2022 21:04:19 +0300 Subject: [PATCH] ADD: Using neuronavigation API to communicate if coil at target (#443) --- invesalius/net/neuronavigation_api.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/invesalius/net/neuronavigation_api.py b/invesalius/net/neuronavigation_api.py index 1d1208137..de2b1a2a7 100644 --- a/invesalius/net/neuronavigation_api.py +++ b/invesalius/net/neuronavigation_api.py @@ -56,11 +56,13 @@ def _hasmethod(self, obj, name): return hasattr(obj, name) and callable(getattr(obj, name)) def assert_valid(self, connection): + assert self._hasmethod(connection, 'update_coil_at_target') assert self._hasmethod(connection, 'update_coil_pose') assert self._hasmethod(connection, 'update_focus') assert self._hasmethod(connection, 'set_callback__set_markers') def __bind_events(self): + Publisher.subscribe(self.update_coil_at_target, 'Coil at target') Publisher.subscribe(self.update_focus, 'Set cross focal point') # Functions for InVesalius to send updates. @@ -110,6 +112,12 @@ def update_coil_mesh(self, polydata): polygons=polygons, ) + def update_coil_at_target(self, state): + if self.connection is not None: + self.connection.update_coil_at_target( + state=state + ) + # Functions for InVesalius to receive updates via callbacks. def __set_callbacks(self, connection):