diff --git a/invesalius/constants.py b/invesalius/constants.py index 6d40516..cee3897 100644 --- a/invesalius/constants.py +++ b/invesalius/constants.py @@ -708,6 +708,7 @@ STATIC_REF = 0 DYNAMIC_REF = 1 DEFAULT_REF_MODE = DYNAMIC_REF REF_MODE = [_("Static ref."), _("Dynamic ref.")] +FT_SENSOR_MODE = [_("Sensor 3"), _("Sensor 4")] DEFAULT_COIL = SELECT COIL = [_("Select coil:"), _("Neurosoft Figure-8"), @@ -735,13 +736,11 @@ TIPS_IMG = [_("Select left ear in image"), BTNS_TRK = {TR1: {3: _('LET')}, TR2: {4: _('RET')}, - TR3: {5: _('NAT')}, - SET: {6: _('SET')}} + TR3: {5: _('NAT')}} TIPS_TRK = [_("Select left ear with spatial tracker"), _("Select right ear with spatial tracker"), - _("Select nasion with spatial tracker"), - _("Show set coordinates in image")] + _("Select nasion with spatial tracker")] OBJL = wx.NewId() OBJR = wx.NewId() diff --git a/invesalius/data/coordinates.py b/invesalius/data/coordinates.py index ccbaf67..aef364a 100644 --- a/invesalius/data/coordinates.py +++ b/invesalius/data/coordinates.py @@ -109,7 +109,10 @@ def PolhemusWrapperCoord(trck, trck_id, ref_mode): coord3 = np.array([float(trck.PositionTooltipX3) * scale[0], float(trck.PositionTooltipY3) * scale[1], float(trck.PositionTooltipZ3) * scale[2], float(trck.AngleX3), float(trck.AngleY3), float(trck.AngleZ3)]) - coord = np.vstack([coord, coord3]) + coord4 = np.array([float(trck.PositionTooltipX4) * scale[0], float(trck.PositionTooltipY4) * scale[1], + float(trck.PositionTooltipZ4) * scale[2], + float(trck.AngleX4), float(trck.AngleY4), float(trck.AngleZ4)]) + coord = np.vstack([coord, coord3, coord4]) if trck.StylusButton: Publisher.sendMessage('PLH Stylus Button On') @@ -208,9 +211,12 @@ def DebugCoord(trk_init, trck_id, ref_mode): coord3 = np.array([uniform(1, 200), uniform(1, 200), uniform(1, 200), uniform(-180.0, 180.0), uniform(-180.0, 180.0), uniform(-180.0, 180.0)]) + coord4 = np.array([uniform(1, 200), uniform(1, 200), uniform(1, 200), + uniform(-180.0, 180.0), uniform(-180.0, 180.0), uniform(-180.0, 180.0)]) + Publisher.sendMessage('Sensors ID', probe_id=int(uniform(0, 5)), ref_id=int(uniform(0, 5))) - return np.vstack([coord1, coord2, coord3]) + return np.vstack([coord1, coord2, coord3, coord4]) def dynamic_reference(probe, reference): diff --git a/invesalius/gui/dialogs.py b/invesalius/gui/dialogs.py index ad4d243..d233913 100644 --- a/invesalius/gui/dialogs.py +++ b/invesalius/gui/dialogs.py @@ -3487,8 +3487,19 @@ class ObjectCalibrationDialog(wx.Dialog): choice_ref.SetSelection(self.obj_ref_id) choice_ref.SetToolTip(tooltip) choice_ref.Bind(wx.EVT_COMBOBOX, self.OnChoiceRefMode) - if self.tracker_id != const.MTC: - choice_ref.Enable(0) + choice_ref.Enable(0) + if self.tracker_id == const.MTC or self.tracker_id == const.FASTRAK or self.tracker_id == const.DEBUGTRACK: + choice_ref.Enable(1) + + # ComboBox for sensor selection for FASTRAK + tooltip = wx.ToolTip(_(u"Choose the FASTRAK sensor port")) + choice_sensor = wx.ComboBox(self, -1, "", size=wx.Size(90, 23), + choices=const.FT_SENSOR_MODE, style=wx.CB_DROPDOWN | wx.CB_READONLY) + choice_sensor.SetSelection(0) + choice_sensor.SetToolTip(tooltip) + choice_sensor.Bind(wx.EVT_COMBOBOX, self.OnChoiceFTSensor) + choice_sensor.Show(False) + self.choice_sensor = choice_sensor # Buttons to finish or cancel object registration tooltip = wx.ToolTip(_(u"Registration done")) @@ -3496,9 +3507,10 @@ class ObjectCalibrationDialog(wx.Dialog): btn_ok = wx.Button(self, wx.ID_OK, _(u"Done"), size=wx.Size(90, 30)) btn_ok.SetToolTip(tooltip) - extra_sizer = wx.FlexGridSizer(rows=2, cols=1, hgap=5, vgap=30) + extra_sizer = wx.FlexGridSizer(rows=3, cols=1, hgap=5, vgap=30) extra_sizer.AddMany([choice_ref, - btn_ok]) + btn_ok, + choice_sensor]) # Push buttons for object fiducials btns_obj = const.BTNS_OBJ @@ -3651,7 +3663,7 @@ class ObjectCalibrationDialog(wx.Dialog): if self.trk_init and self.tracker_id: coord_raw = dco.GetCoordinates(self.trk_init, self.tracker_id, self.obj_ref_id) if self.obj_ref_id and btn_id == 4: - coord = coord_raw[2, :] + coord = coord_raw[self.obj_ref_id, :] else: coord = coord_raw[0, :] else: @@ -3680,6 +3692,9 @@ class ObjectCalibrationDialog(wx.Dialog): if evt.GetSelection(): self.obj_ref_id = 2 + if self.tracker_id == const.FASTRAK or self.tracker_id == const.DEBUGTRACK: + self.choice_sensor.Show(True) + self.Layout() else: self.obj_ref_id = 0 for m in range(0, 5): @@ -3688,6 +3703,12 @@ class ObjectCalibrationDialog(wx.Dialog): for n in range(0, 3): self.txt_coord[m][n].SetLabel('-') + def OnChoiceFTSensor(self, evt): + if evt.GetSelection(): + self.obj_ref_id = 3 + else: + self.obj_ref_id = 0 + def GetValue(self): return self.obj_fiducials, self.obj_orients, self.obj_ref_id, self.obj_name diff --git a/invesalius/gui/task_navigator.py b/invesalius/gui/task_navigator.py index e117e85..8670880 100644 --- a/invesalius/gui/task_navigator.py +++ b/invesalius/gui/task_navigator.py @@ -134,13 +134,9 @@ class InnerFoldPanel(wx.Panel): # is not working properly in this panel. It might be on some child or # parent panel. Perhaps we need to insert the item into the sizer also... # Study this. - displaySize = wx.DisplaySize() - if displaySize[1] > 768: - fold_panel = fpb.FoldPanelBar(self, -1, wx.DefaultPosition, - (10, 350), 0, fpb.FPB_SINGLE_FOLD) - else: - fold_panel = fpb.FoldPanelBar(self, -1, wx.DefaultPosition, - (10, 320), 0, fpb.FPB_SINGLE_FOLD) + + fold_panel = fpb.FoldPanelBar(self, -1, wx.DefaultPosition, + (10, 290), 0, fpb.FPB_SINGLE_FOLD) # Fold panel style style = fpb.CaptionBarStyle() style.SetCaptionStyle(fpb.CAPTIONBAR_GRADIENT_V) @@ -305,8 +301,8 @@ class NeuronavigationPanel(wx.Panel): self.ref_mode_id = const.DEFAULT_REF_MODE # Initialize list of buttons and numctrls for wx objects - self.btns_coord = [None] * 7 - self.numctrls_coord = [list(), list(), list(), list(), list(), list(), list()] + self.btns_coord = [None, None, None, None, None, None] + self.numctrls_coord = [[], [], [], [], [], []] # ComboBox for spatial tracker device selection tooltip = wx.ToolTip(_("Choose the tracking device")) @@ -345,11 +341,7 @@ class NeuronavigationPanel(wx.Panel): lab = list(btns_trk[k].values())[0] self.btns_coord[n] = wx.Button(self, k, label=lab, size=wx.Size(45, 23)) self.btns_coord[n].SetToolTip(wx.ToolTip(tips_trk[n-3])) - # Exception for event of button that set image coordinates - if n == 6: - self.btns_coord[n].Bind(wx.EVT_BUTTON, self.OnSetImageCoordinates) - else: - self.btns_coord[n].Bind(wx.EVT_BUTTON, self.OnTrackerFiducials) + self.btns_coord[n].Bind(wx.EVT_BUTTON, self.OnTrackerFiducials) # TODO: Find a better allignment between FRE, text and navigate button txt_fre = wx.StaticText(self, -1, _('FRE:')) @@ -370,8 +362,8 @@ class NeuronavigationPanel(wx.Panel): btn_nav.Bind(wx.EVT_TOGGLEBUTTON, partial(self.OnNavigate, btn=(btn_nav, choice_trck, choice_ref))) # Image and tracker coordinates number controls - for m in range(0, 7): - for n in range(0, 3): + for m in range(len(self.btns_coord)): + for n in range(3): self.numctrls_coord[m].append( wx.lib.masked.numctrl.NumCtrl(parent=self, integerWidth=4, fractionWidth=1)) @@ -382,9 +374,9 @@ class NeuronavigationPanel(wx.Panel): coord_sizer = wx.GridBagSizer(hgap=5, vgap=5) - for m in range(0, 7): + for m in range(len(self.btns_coord)): coord_sizer.Add(self.btns_coord[m], pos=wx.GBPosition(m, 0)) - for n in range(0, 3): + for n in range(3): coord_sizer.Add(self.numctrls_coord[m][n], pos=wx.GBPosition(m, n+1)) if m in range(1, 6): self.numctrls_coord[m][n].SetEditable(False) @@ -432,13 +424,8 @@ class NeuronavigationPanel(wx.Panel): def UpdateImageCoordinates(self, position): # TODO: Change from world coordinates to matrix coordinates. They are better for multi software communication. self.current_coord = position - for m in [0, 1, 2, 6]: - if m == 6 and self.btns_coord[m].IsEnabled(): - for n in [0, 1, 2]: - self.numctrls_coord[m][n].SetValue(float(self.current_coord[n])) - elif m != 6 and not self.btns_coord[m].GetValue(): - # btn_state = self.btns_coord[m].GetValue() - # if not btn_state: + for m in [0, 1, 2]: + if not self.btns_coord[m].GetValue(): for n in [0, 1, 2]: self.numctrls_coord[m][n].SetValue(float(self.current_coord[n])) @@ -544,19 +531,6 @@ class NeuronavigationPanel(wx.Panel): nav_prop=(self.tracker_id, self.trk_init, self.ref_mode_id)) print("Reference mode changed!") - def OnSetImageCoordinates(self, evt): - # FIXME: Cross does not update in last clicked slice, only on the other two - btn_id = list(const.BTNS_TRK[evt.GetId()].keys())[0] - - ux, uy, uz = self.numctrls_coord[btn_id][0].GetValue(),\ - self.numctrls_coord[btn_id][1].GetValue(),\ - self.numctrls_coord[btn_id][2].GetValue() - - Publisher.sendMessage('Set ball reference position', position=(ux, uy, uz)) - # Publisher.sendMessage('Set camera in volume', (ux, uy, uz)) - Publisher.sendMessage('Co-registered points', arg=(ux, uy, uz), position=(0., 0., 0.)) - Publisher.sendMessage('Update cross position', position=(ux, uy, uz)) - def OnImageFiducials(self, evt): btn_id = list(const.BTNS_IMG_MKS[evt.GetId()].keys())[0] marker_id = list(const.BTNS_IMG_MKS[evt.GetId()].values())[0] @@ -714,9 +688,6 @@ class NeuronavigationPanel(wx.Panel): for n in range(0, 3): self.numctrls_coord[m][n].SetValue(0.0) - for n in range(0, 3): - self.numctrls_coord[6][n].SetValue(0.0) - def ResetTrackerFiducials(self): for m in range(3, 6): self.fiducials[m, :] = [np.nan, np.nan, np.nan] -- libgit2 0.21.2