Commit 723af25db2bb44fcf28a95c21a824207e9633afc
Committed by
Thiago Franco de Moraes
1 parent
b8381c75
Exists in
master
and in
10 other branches
Remove tracker when InVesalius is closed (#75)
* remove tracker when invesalius is closed * Fix polhemus connection warning -added msg for statusbar when try to disconnect tracker * Standardization
Showing
4 changed files
with
15 additions
and
1 deletions
Show diff stats
invesalius/data/coordinates.py
... | ... | @@ -51,7 +51,7 @@ def GetCoordinates(trck_init, trck_id, ref_mode): |
51 | 51 | |
52 | 52 | def ClaronCoord(trck_init, trck_id, ref_mode): |
53 | 53 | trck = trck_init[0] |
54 | - scale = 10. * np.array([1., 1.0, -1.0]) | |
54 | + scale = np.array([1.0, 1.0, -1.0]) | |
55 | 55 | coord = None |
56 | 56 | k = 0 |
57 | 57 | # TODO: try to replace while and use some Claron internal computation | ... | ... |
invesalius/data/trackers.py
... | ... | @@ -123,6 +123,8 @@ def PlhWrapperConnection(): |
123 | 123 | if trck_check: |
124 | 124 | # First run is necessary to discard the first coord collection |
125 | 125 | trck_init.Run() |
126 | + else: | |
127 | + trck_init = trck_check | |
126 | 128 | except: |
127 | 129 | print 'Could not connect to Polhemus via wrapper.' |
128 | 130 | |
... | ... | @@ -195,6 +197,8 @@ def DisconnectTracker(tracker_id): |
195 | 197 | |
196 | 198 | :param tracker_id: ID of tracking device. |
197 | 199 | """ |
200 | + from wx.lib.pubsub import pub as Publisher | |
201 | + Publisher.sendMessage('Update status text in GUI', _("Disconnecting tracker ...")) | |
198 | 202 | trck_init = None |
199 | 203 | # TODO: create individual functions to disconnect each other device, e.g. Polhemus. |
200 | 204 | if tracker_id == 1: |
... | ... | @@ -202,6 +206,7 @@ def DisconnectTracker(tracker_id): |
202 | 206 | import pyclaron |
203 | 207 | pyclaron.pyclaron().Close() |
204 | 208 | lib_mode = 'wrapper' |
209 | + print 'Claron tracker disconnected.' | |
205 | 210 | except ImportError: |
206 | 211 | lib_mode = 'error' |
207 | 212 | print 'The ClaronTracker library is not installed.' |
... | ... | @@ -211,6 +216,7 @@ def DisconnectTracker(tracker_id): |
211 | 216 | import polhemus |
212 | 217 | polhemus.polhemus().Close() |
213 | 218 | lib_mode = 'wrapper' |
219 | + print 'Polhemus tracker disconnected.' | |
214 | 220 | except ImportError: |
215 | 221 | lib_mode = 'error' |
216 | 222 | print 'The polhemus library is not installed.' |
... | ... | @@ -219,4 +225,6 @@ def DisconnectTracker(tracker_id): |
219 | 225 | print 'Debug tracker disconnected.' |
220 | 226 | lib_mode = 'debug' |
221 | 227 | |
228 | + Publisher.sendMessage('Update status text in GUI', _("Ready")) | |
229 | + | |
222 | 230 | return trck_init, lib_mode |
223 | 231 | \ No newline at end of file | ... | ... |
invesalius/gui/frame.py
... | ... | @@ -382,6 +382,7 @@ class Frame(wx.Frame): |
382 | 382 | Close all project data. |
383 | 383 | """ |
384 | 384 | Publisher.sendMessage('Close Project') |
385 | + Publisher.sendMessage('Disconnect tracker') | |
385 | 386 | s = ses.Session() |
386 | 387 | if not s.IsOpen() or not s.project_path: |
387 | 388 | Publisher.sendMessage('Exit') | ... | ... |
invesalius/gui/task_navigator.py
... | ... | @@ -312,6 +312,7 @@ class NeuronavigationPanel(wx.Panel): |
312 | 312 | Publisher.subscribe(self.LoadImageFiducials, 'Load image fiducials') |
313 | 313 | Publisher.subscribe(self.UpdateTriggerState, 'Update trigger state') |
314 | 314 | Publisher.subscribe(self.UpdateImageCoordinates, 'Set ball reference position') |
315 | + Publisher.subscribe(self.OnDisconnectTracker, 'Disconnect tracker') | |
315 | 316 | |
316 | 317 | def LoadImageFiducials(self, pubsub_evt): |
317 | 318 | marker_id = pubsub_evt.data[0] |
... | ... | @@ -341,6 +342,10 @@ class NeuronavigationPanel(wx.Panel): |
341 | 342 | def UpdateTriggerState (self, pubsub_evt): |
342 | 343 | self.trigger_state = pubsub_evt.data |
343 | 344 | |
345 | + def OnDisconnectTracker(self, pubsub_evt): | |
346 | + if self.tracker_id: | |
347 | + dt.TrackerConnection(self.tracker_id, 'disconnect') | |
348 | + | |
344 | 349 | def OnChoiceTracker(self, evt, ctrl): |
345 | 350 | Publisher.sendMessage('Update status text in GUI', _("Configuring tracker ...")) |
346 | 351 | if evt: | ... | ... |