def OnChoiceTracker(self, evt, ctrl): Publisher.sendMessage('Update status text in GUI', _("Configuring tracker ...")) if evt: choice = evt.GetSelection() else: choice = self.tracker_id if self.trk_init: trck = self.trk_init[0] else: trck = None # Conditions check if click was on current selection and if any other tracker # has been initialized before if trck and choice != 6: self.ResetTrackerFiducials() self.trk_init = dt.TrackerConnection(self.tracker_id, 'disconnect') self.tracker_id = choice if not self.trk_init[0]: self.trk_init = dt.TrackerConnection(self.tracker_id, 'connect') if not self.trk_init[0]: dlg.NavigationTrackerWarning(self.tracker_id, self.trk_init[1]) ctrl.SetSelection(0) print "Tracker not connected!" else: ctrl.SetSelection(self.tracker_id) print "Tracker connected!" elif choice == 6: if trck: self.trk_init = dt.TrackerConnection(self.tracker_id, 'disconnect') if not self.trk_init[0]: dlg.NavigationTrackerWarning(self.tracker_id, 'disconnect') self.tracker_id = 0 ctrl.SetSelection(self.tracker_id) print "Tracker disconnected!" else: print "Tracker still connected!" else: ctrl.SetSelection(self.tracker_id) else: # If trk_init is None try to connect. If doesn't succeed show dialog. if choice: self.tracker_id = choice self.trk_init = dt.TrackerConnection(self.tracker_id, 'connect') if not self.trk_init[0]: dlg.NavigationTrackerWarning(self.tracker_id, self.trk_init[1]) self.tracker_id = 0 ctrl.SetSelection(self.tracker_id) Publisher.sendMessage('Update status text in GUI', _("Ready"))
def OnTrackerFiducials(self, evt): btn_id = const.BTNS_TRK[evt.GetId()].keys()[0] coord = None if self.trk_init and self.tracker_id: coord = dco.GetCoordinates(self.trk_init, self.tracker_id, self.ref_mode_id) else: dlg.NavigationTrackerWarning(0, 'choose') # Update number controls with tracker coordinates if coord is not None: self.fiducials[btn_id, :] = coord[0:3] for n in [0, 1, 2]: self.numctrls_coord[btn_id][n].SetValue(float(coord[n]))