From ed898334474abd00a2cbba040d09c0646b571148 Mon Sep 17 00:00:00 2001 From: Olli-Pekka Kahilakoski Date: Thu, 20 Jan 2022 16:31:57 +0200 Subject: [PATCH] ADD: Send 'Set cross focal point' msgs using NeuronavigationApi (#420) --- invesalius/net/neuronavigation_api.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+), 0 deletions(-) diff --git a/invesalius/net/neuronavigation_api.py b/invesalius/net/neuronavigation_api.py index bcd0849..6e13b4c 100644 --- a/invesalius/net/neuronavigation_api.py +++ b/invesalius/net/neuronavigation_api.py @@ -36,12 +36,28 @@ class NeuronavigationApi(metaclass=Singleton): def __init__(self, connection=None): if connection is not None: assert self._hasmethod(connection, 'update_coil_pose') + self.__bind_events() self.connection = connection def _hasmethod(self, obj, name): return hasattr(obj, name) and callable(getattr(obj, name)) + def __bind_events(self): + Publisher.subscribe(self.update_focus, 'Set cross focal point') + + # TODO: Not the cleanest API; for an example of a better API, see update_coil_pose + # below, for which position and orientation are sent separately. Changing this + # would require changing 'Set cross focal point' publishers and subscribers + # throughout the code. + # + def update_focus(self, position): + if self.connection is not None: + self.connection.update_focus( + position=position[:3], + orientation=position[3:], + ) + def update_coil_pose(self, position, orientation): if self.connection is not None: self.connection.update_coil_pose( -- libgit2 0.21.2