Commit 87b12fec5e2c9d84558e637a81569c936b0689ed

Authored by Renan
Committed by Thiago Franco de Moraes
1 parent 1005a965

Navigation update (#73)

* Navigation update
-Markers file extension update and transifex conflicts solved
-Disable mask when navigation starts
-Enable cross when navigation starts if cross is disabled
-Shows msg in statusbar when a tracker is connecting

* Code cleaning

* Minor code optimization

* Added wildcard to loadMarkersDialog
invesalius/constants.py
@@ -672,6 +672,10 @@ BTNS_IMG = {IR1: {0: _('LEI')}, @@ -672,6 +672,10 @@ BTNS_IMG = {IR1: {0: _('LEI')},
672 IR2: {1: _('REI')}, 672 IR2: {1: _('REI')},
673 IR3: {2: _('NAI')}} 673 IR3: {2: _('NAI')}}
674 674
  675 +BTNS_IMG_MKS = {IR1: {0: 'LEI'},
  676 + IR2: {1: 'REI'},
  677 + IR3: {2: 'NAI'}}
  678 +
675 TIPS_IMG = [wx.ToolTip(_("Select left ear in image")), 679 TIPS_IMG = [wx.ToolTip(_("Select left ear in image")),
676 wx.ToolTip(_("Select right ear in image")), 680 wx.ToolTip(_("Select right ear in image")),
677 wx.ToolTip(_("Select nasion in image"))] 681 wx.ToolTip(_("Select nasion in image"))]
invesalius/gui/dialogs.py
@@ -453,7 +453,7 @@ def ShowSaveMarkersDialog(default_filename=None): @@ -453,7 +453,7 @@ def ShowSaveMarkersDialog(default_filename=None):
453 _("Save markers as..."), # title 453 _("Save markers as..."), # title
454 "", # last used directory 454 "", # last used directory
455 default_filename, 455 default_filename,
456 - _("Markers (*.txt)|*.txt"), 456 + _("Markers files (*.mks)|*.mks"),
457 wx.SAVE | wx.OVERWRITE_PROMPT) 457 wx.SAVE | wx.OVERWRITE_PROMPT)
458 # dlg.SetFilterIndex(0) # default is VTI 458 # dlg.SetFilterIndex(0) # default is VTI
459 459
@@ -469,7 +469,7 @@ def ShowSaveMarkersDialog(default_filename=None): @@ -469,7 +469,7 @@ def ShowSaveMarkersDialog(default_filename=None):
469 ok = 1 469 ok = 1
470 470
471 if (ok): 471 if (ok):
472 - extension = "txt" 472 + extension = "mks"
473 if sys.platform != 'win32': 473 if sys.platform != 'win32':
474 if filename.split(".")[-1] != extension: 474 if filename.split(".")[-1] != extension:
475 filename = filename + "." + extension 475 filename = filename + "." + extension
@@ -484,6 +484,7 @@ def ShowLoadMarkersDialog(): @@ -484,6 +484,7 @@ def ShowLoadMarkersDialog():
484 dlg = wx.FileDialog(None, message=_("Load markers"), 484 dlg = wx.FileDialog(None, message=_("Load markers"),
485 defaultDir="", 485 defaultDir="",
486 defaultFile="", 486 defaultFile="",
  487 + wildcard=_("Markers files (*.mks)|*.mks"),
487 style=wx.OPEN|wx.CHANGE_DIR) 488 style=wx.OPEN|wx.CHANGE_DIR)
488 489
489 # inv3 filter is default 490 # inv3 filter is default
invesalius/gui/frame.py
@@ -1539,6 +1539,7 @@ class SliceToolBar(AuiToolBar): @@ -1539,6 +1539,7 @@ class SliceToolBar(AuiToolBar):
1539 sub = Publisher.subscribe 1539 sub = Publisher.subscribe
1540 sub(self._EnableState, "Enable state project") 1540 sub(self._EnableState, "Enable state project")
1541 sub(self._UntoggleAllItems, 'Untoggle slice toolbar items') 1541 sub(self._UntoggleAllItems, 'Untoggle slice toolbar items')
  1542 + sub(self.OnToggle, 'Toggle Cross')
1542 1543
1543 def __bind_events_wx(self): 1544 def __bind_events_wx(self):
1544 """ 1545 """
@@ -1577,8 +1578,14 @@ class SliceToolBar(AuiToolBar): @@ -1577,8 +1578,14 @@ class SliceToolBar(AuiToolBar):
1577 Update status of other items on toolbar (only one item 1578 Update status of other items on toolbar (only one item
1578 should be toggle each time). 1579 should be toggle each time).
1579 """ 1580 """
1580 - id = evt.GetId()  
1581 - evt.Skip() 1581 + if hasattr(evt, 'data'):
  1582 + id = evt.data
  1583 + if not self.GetToolToggled(id):
  1584 + self.ToggleTool(id, True)
  1585 + self.Refresh()
  1586 + else:
  1587 + id = evt.GetId()
  1588 + evt.Skip()
1582 1589
1583 state = self.GetToolToggled(id) 1590 state = self.GetToolToggled(id)
1584 1591
invesalius/gui/task_navigator.py
@@ -36,7 +36,6 @@ import invesalius.gui.dialogs as dlg @@ -36,7 +36,6 @@ import invesalius.gui.dialogs as dlg
36 import invesalius.gui.widgets.foldpanelbar as fpb 36 import invesalius.gui.widgets.foldpanelbar as fpb
37 import invesalius.gui.widgets.colourselect as csel 37 import invesalius.gui.widgets.colourselect as csel
38 38
39 -  
40 class TaskPanel(wx.Panel): 39 class TaskPanel(wx.Panel):
41 def __init__(self, parent): 40 def __init__(self, parent):
42 wx.Panel.__init__(self, parent) 41 wx.Panel.__init__(self, parent)
@@ -317,9 +316,9 @@ class NeuronavigationPanel(wx.Panel): @@ -317,9 +316,9 @@ class NeuronavigationPanel(wx.Panel):
317 def LoadImageFiducials(self, pubsub_evt): 316 def LoadImageFiducials(self, pubsub_evt):
318 marker_id = pubsub_evt.data[0] 317 marker_id = pubsub_evt.data[0]
319 coord = pubsub_evt.data[1] 318 coord = pubsub_evt.data[1]
320 - for n in const.BTNS_IMG:  
321 - btn_id = const.BTNS_IMG[n].keys()[0]  
322 - fid_id = const.BTNS_IMG[n].values()[0] 319 + for n in const.BTNS_IMG_MKS:
  320 + btn_id = const.BTNS_IMG_MKS[n].keys()[0]
  321 + fid_id = const.BTNS_IMG_MKS[n].values()[0]
323 if marker_id == fid_id and not self.btns_coord[btn_id].GetValue(): 322 if marker_id == fid_id and not self.btns_coord[btn_id].GetValue():
324 self.btns_coord[btn_id].SetValue(True) 323 self.btns_coord[btn_id].SetValue(True)
325 self.fiducials[btn_id, :] = coord[0:3] 324 self.fiducials[btn_id, :] = coord[0:3]
@@ -343,6 +342,7 @@ class NeuronavigationPanel(wx.Panel): @@ -343,6 +342,7 @@ class NeuronavigationPanel(wx.Panel):
343 self.trigger_state = pubsub_evt.data 342 self.trigger_state = pubsub_evt.data
344 343
345 def OnChoiceTracker(self, evt, ctrl): 344 def OnChoiceTracker(self, evt, ctrl):
  345 + Publisher.sendMessage('Update status text in GUI', _("Configuring tracker ..."))
346 if evt: 346 if evt:
347 choice = evt.GetSelection() 347 choice = evt.GetSelection()
348 else: 348 else:
@@ -390,6 +390,7 @@ class NeuronavigationPanel(wx.Panel): @@ -390,6 +390,7 @@ class NeuronavigationPanel(wx.Panel):
390 dlg.NavigationTrackerWarning(self.tracker_id, self.trk_init[1]) 390 dlg.NavigationTrackerWarning(self.tracker_id, self.trk_init[1])
391 self.tracker_id = 0 391 self.tracker_id = 0
392 ctrl.SetSelection(self.tracker_id) 392 ctrl.SetSelection(self.tracker_id)
  393 + Publisher.sendMessage('Update status text in GUI', _("Ready"))
393 394
394 def OnChoiceRefMode(self, evt, ctrl): 395 def OnChoiceRefMode(self, evt, ctrl):
395 # When ref mode is changed the tracker coords are set to zero 396 # When ref mode is changed the tracker coords are set to zero
@@ -414,8 +415,8 @@ class NeuronavigationPanel(wx.Panel): @@ -414,8 +415,8 @@ class NeuronavigationPanel(wx.Panel):
414 Publisher.sendMessage('Update cross position', (wx, wy, wz)) 415 Publisher.sendMessage('Update cross position', (wx, wy, wz))
415 416
416 def OnImageFiducials(self, evt): 417 def OnImageFiducials(self, evt):
417 - btn_id = const.BTNS_IMG[evt.GetId()].keys()[0]  
418 - marker_id = const.BTNS_IMG[evt.GetId()].values()[0] 418 + btn_id = const.BTNS_IMG_MKS[evt.GetId()].keys()[0]
  419 + marker_id = const.BTNS_IMG_MKS[evt.GetId()].values()[0]
419 420
420 if self.btns_coord[btn_id].GetValue(): 421 if self.btns_coord[btn_id].GetValue():
421 coord = self.numctrls_coord[btn_id][0].GetValue(),\ 422 coord = self.numctrls_coord[btn_id][0].GetValue(),\
@@ -486,6 +487,8 @@ class NeuronavigationPanel(wx.Panel): @@ -486,6 +487,8 @@ class NeuronavigationPanel(wx.Panel):
486 self.trigger = trig.Trigger(nav_id) 487 self.trigger = trig.Trigger(nav_id)
487 488
488 Publisher.sendMessage("Navigation Status", True) 489 Publisher.sendMessage("Navigation Status", True)
  490 + Publisher.sendMessage("Toggle Cross", const.SLICE_STATE_CROSS)
  491 + Publisher.sendMessage("Hide current mask")
489 492
490 self.correg = dcr.Coregistration((minv, n, q1, q2), nav_id, tracker_mode) 493 self.correg = dcr.Coregistration((minv, n, q1, q2), nav_id, tracker_mode)
491 494
@@ -637,10 +640,9 @@ class MarkersPanel(wx.Panel): @@ -637,10 +640,9 @@ class MarkersPanel(wx.Panel):
637 for id_n in range(self.lc.GetItemCount()): 640 for id_n in range(self.lc.GetItemCount()):
638 item = self.lc.GetItem(id_n, 4) 641 item = self.lc.GetItem(id_n, 4)
639 if item.GetText() == marker_id: 642 if item.GetText() == marker_id:
640 - for i in const.BTNS_IMG:  
641 - if marker_id in const.BTNS_IMG[i].values()[0]: 643 + for i in const.BTNS_IMG_MKS:
  644 + if marker_id in const.BTNS_IMG_MKS[i].values()[0]:
642 self.lc.Focus(item.GetId()) 645 self.lc.Focus(item.GetId())
643 - break  
644 self.DeleteMarker() 646 self.DeleteMarker()
645 else: 647 else:
646 if self.lc.GetFocusedItem() is not -1: 648 if self.lc.GetFocusedItem() is not -1:
@@ -683,8 +685,8 @@ class MarkersPanel(wx.Panel): @@ -683,8 +685,8 @@ class MarkersPanel(wx.Panel):
683 size = float(line[6]) 685 size = float(line[6])
684 686
685 if len(line) == 8: 687 if len(line) == 8:
686 - for i in const.BTNS_IMG:  
687 - if line[7] in const.BTNS_IMG[i].values()[0]: 688 + for i in const.BTNS_IMG_MKS:
  689 + if line[7] in const.BTNS_IMG_MKS[i].values()[0]:
688 Publisher.sendMessage('Load image fiducials', (line[7], coord)) 690 Publisher.sendMessage('Load image fiducials', (line[7], coord))
689 else: 691 else:
690 line.append("") 692 line.append("")
@@ -702,7 +704,7 @@ class MarkersPanel(wx.Panel): @@ -702,7 +704,7 @@ class MarkersPanel(wx.Panel):
702 ctrl.SetLabel('Hide') 704 ctrl.SetLabel('Hide')
703 705
704 def OnSaveMarkers(self, evt): 706 def OnSaveMarkers(self, evt):
705 - filename = dlg.ShowSaveMarkersDialog("markers.txt") 707 + filename = dlg.ShowSaveMarkersDialog("markers.mks")
706 if filename: 708 if filename:
707 if self.list_coord: 709 if self.list_coord:
708 text_file = open(filename, "w") 710 text_file = open(filename, "w")