From 87b12fec5e2c9d84558e637a81569c936b0689ed Mon Sep 17 00:00:00 2001 From: Renan Date: Fri, 31 Mar 2017 09:35:10 -0300 Subject: [PATCH] Navigation update (#73) --- invesalius/constants.py | 4 ++++ invesalius/gui/dialogs.py | 5 +++-- invesalius/gui/frame.py | 11 +++++++++-- invesalius/gui/task_navigator.py | 26 ++++++++++++++------------ 4 files changed, 30 insertions(+), 16 deletions(-) diff --git a/invesalius/constants.py b/invesalius/constants.py index f348dca..ee41059 100644 --- a/invesalius/constants.py +++ b/invesalius/constants.py @@ -672,6 +672,10 @@ BTNS_IMG = {IR1: {0: _('LEI')}, IR2: {1: _('REI')}, IR3: {2: _('NAI')}} +BTNS_IMG_MKS = {IR1: {0: 'LEI'}, + IR2: {1: 'REI'}, + IR3: {2: 'NAI'}} + TIPS_IMG = [wx.ToolTip(_("Select left ear in image")), wx.ToolTip(_("Select right ear in image")), wx.ToolTip(_("Select nasion in image"))] diff --git a/invesalius/gui/dialogs.py b/invesalius/gui/dialogs.py index 3017e40..bc77dce 100644 --- a/invesalius/gui/dialogs.py +++ b/invesalius/gui/dialogs.py @@ -453,7 +453,7 @@ def ShowSaveMarkersDialog(default_filename=None): _("Save markers as..."), # title "", # last used directory default_filename, - _("Markers (*.txt)|*.txt"), + _("Markers files (*.mks)|*.mks"), wx.SAVE | wx.OVERWRITE_PROMPT) # dlg.SetFilterIndex(0) # default is VTI @@ -469,7 +469,7 @@ def ShowSaveMarkersDialog(default_filename=None): ok = 1 if (ok): - extension = "txt" + extension = "mks" if sys.platform != 'win32': if filename.split(".")[-1] != extension: filename = filename + "." + extension @@ -484,6 +484,7 @@ def ShowLoadMarkersDialog(): dlg = wx.FileDialog(None, message=_("Load markers"), defaultDir="", defaultFile="", + wildcard=_("Markers files (*.mks)|*.mks"), style=wx.OPEN|wx.CHANGE_DIR) # inv3 filter is default diff --git a/invesalius/gui/frame.py b/invesalius/gui/frame.py index fc410a8..8cefc59 100644 --- a/invesalius/gui/frame.py +++ b/invesalius/gui/frame.py @@ -1539,6 +1539,7 @@ class SliceToolBar(AuiToolBar): sub = Publisher.subscribe sub(self._EnableState, "Enable state project") sub(self._UntoggleAllItems, 'Untoggle slice toolbar items') + sub(self.OnToggle, 'Toggle Cross') def __bind_events_wx(self): """ @@ -1577,8 +1578,14 @@ class SliceToolBar(AuiToolBar): Update status of other items on toolbar (only one item should be toggle each time). """ - id = evt.GetId() - evt.Skip() + if hasattr(evt, 'data'): + id = evt.data + if not self.GetToolToggled(id): + self.ToggleTool(id, True) + self.Refresh() + else: + id = evt.GetId() + evt.Skip() state = self.GetToolToggled(id) diff --git a/invesalius/gui/task_navigator.py b/invesalius/gui/task_navigator.py index b02b935..d84c151 100644 --- a/invesalius/gui/task_navigator.py +++ b/invesalius/gui/task_navigator.py @@ -36,7 +36,6 @@ import invesalius.gui.dialogs as dlg import invesalius.gui.widgets.foldpanelbar as fpb import invesalius.gui.widgets.colourselect as csel - class TaskPanel(wx.Panel): def __init__(self, parent): wx.Panel.__init__(self, parent) @@ -317,9 +316,9 @@ class NeuronavigationPanel(wx.Panel): def LoadImageFiducials(self, pubsub_evt): marker_id = pubsub_evt.data[0] coord = pubsub_evt.data[1] - for n in const.BTNS_IMG: - btn_id = const.BTNS_IMG[n].keys()[0] - fid_id = const.BTNS_IMG[n].values()[0] + for n in const.BTNS_IMG_MKS: + btn_id = const.BTNS_IMG_MKS[n].keys()[0] + fid_id = const.BTNS_IMG_MKS[n].values()[0] if marker_id == fid_id and not self.btns_coord[btn_id].GetValue(): self.btns_coord[btn_id].SetValue(True) self.fiducials[btn_id, :] = coord[0:3] @@ -343,6 +342,7 @@ class NeuronavigationPanel(wx.Panel): self.trigger_state = pubsub_evt.data def OnChoiceTracker(self, evt, ctrl): + Publisher.sendMessage('Update status text in GUI', _("Configuring tracker ...")) if evt: choice = evt.GetSelection() else: @@ -390,6 +390,7 @@ class NeuronavigationPanel(wx.Panel): 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 OnChoiceRefMode(self, evt, ctrl): # When ref mode is changed the tracker coords are set to zero @@ -414,8 +415,8 @@ class NeuronavigationPanel(wx.Panel): Publisher.sendMessage('Update cross position', (wx, wy, wz)) def OnImageFiducials(self, evt): - btn_id = const.BTNS_IMG[evt.GetId()].keys()[0] - marker_id = const.BTNS_IMG[evt.GetId()].values()[0] + btn_id = const.BTNS_IMG_MKS[evt.GetId()].keys()[0] + marker_id = const.BTNS_IMG_MKS[evt.GetId()].values()[0] if self.btns_coord[btn_id].GetValue(): coord = self.numctrls_coord[btn_id][0].GetValue(),\ @@ -486,6 +487,8 @@ class NeuronavigationPanel(wx.Panel): self.trigger = trig.Trigger(nav_id) Publisher.sendMessage("Navigation Status", True) + Publisher.sendMessage("Toggle Cross", const.SLICE_STATE_CROSS) + Publisher.sendMessage("Hide current mask") self.correg = dcr.Coregistration((minv, n, q1, q2), nav_id, tracker_mode) @@ -637,10 +640,9 @@ class MarkersPanel(wx.Panel): for id_n in range(self.lc.GetItemCount()): item = self.lc.GetItem(id_n, 4) if item.GetText() == marker_id: - for i in const.BTNS_IMG: - if marker_id in const.BTNS_IMG[i].values()[0]: + for i in const.BTNS_IMG_MKS: + if marker_id in const.BTNS_IMG_MKS[i].values()[0]: self.lc.Focus(item.GetId()) - break self.DeleteMarker() else: if self.lc.GetFocusedItem() is not -1: @@ -683,8 +685,8 @@ class MarkersPanel(wx.Panel): size = float(line[6]) if len(line) == 8: - for i in const.BTNS_IMG: - if line[7] in const.BTNS_IMG[i].values()[0]: + for i in const.BTNS_IMG_MKS: + if line[7] in const.BTNS_IMG_MKS[i].values()[0]: Publisher.sendMessage('Load image fiducials', (line[7], coord)) else: line.append("") @@ -702,7 +704,7 @@ class MarkersPanel(wx.Panel): ctrl.SetLabel('Hide') def OnSaveMarkers(self, evt): - filename = dlg.ShowSaveMarkersDialog("markers.txt") + filename = dlg.ShowSaveMarkersDialog("markers.mks") if filename: if self.list_coord: text_file = open(filename, "w") -- libgit2 0.21.2