Commit 991392d7b57805ec6faa4309403d0ab251e79f62

Authored by Renan
Committed by Thiago Franco de Moraes
1 parent fc96ee16

Refresh optimization and markers (#67)

Navigation optimization and marker creation improvement
.gitignore
... ... @@ -16,6 +16,8 @@ invesalius/gui/widgets/*.pyc
16 16 invesalius/reader/*.log
17 17 invesalius/reader/*.pyc
18 18  
  19 +.idea
  20 +
19 21 *.pyc
20 22 *.swp
21 23 *.so
... ...
invesalius/data/coordinates.py
... ... @@ -20,6 +20,7 @@
20 20 from math import sin, cos
21 21 import numpy as np
22 22  
  23 +from time import sleep
23 24 from random import uniform
24 25  
25 26  
... ... @@ -211,7 +212,7 @@ def DebugCoord(trk_init, trck_id, ref_mode):
211 212 :param trck_id: id of tracking device
212 213 :return: six coordinates x, y, z, alfa, beta and gama
213 214 """
214   -
  215 + sleep(0.2)
215 216 if ref_mode:
216 217 probe = np.array([uniform(1, 200), uniform(1, 200), uniform(1, 200),
217 218 uniform(1, 200), uniform(1, 200), uniform(1, 200)])
... ...
invesalius/data/coregistration.py
... ... @@ -74,8 +74,8 @@ class Coregistration(threading.Thread):
74 74 # TODO: Optimize the value of sleep for each tracking device.
75 75 # Debug tracker is not working with 0.175 so changed to 0.2
76 76 # However, 0.2 is too low update frequency ~5 Hz. Need optimization URGENTLY.
77   - sleep(.3)
78   - # sleep(0.175)
  77 + #sleep(.3)
  78 + sleep(0.175)
79 79  
80 80 if self._pause_:
81 81 return
... ...
invesalius/data/viewer_volume.py
... ... @@ -674,7 +674,8 @@ class Viewer(wx.Panel):
674 674 # Need to be outside condition for sphere marker position update
675 675 # self.ren.ResetCameraClippingRange()
676 676 # self.ren.ResetCamera()
677   - self.interactor.Render()
  677 + #self.interactor.Render()
  678 + self.Refresh()
678 679  
679 680 def OnExportSurface(self, pubsub_evt):
680 681 filename, filetype = pubsub_evt.data
... ...
invesalius/gui/task_navigator.py
... ... @@ -141,7 +141,7 @@ class InnerFoldPanel(wx.Panel):
141 141 fold_panel.AddFoldPanelWindow(item, mtw, Spacing= 0,
142 142 leftSpacing=0, rightSpacing=0)
143 143  
144   -
  144 +
145 145 # Check box for camera update in volume rendering during navigation
146 146 tooltip = wx.ToolTip(_("Update camera in volume"))
147 147 checkcamera = wx.CheckBox(self, -1, _('Volume camera'))
... ... @@ -174,7 +174,7 @@ class InnerFoldPanel(wx.Panel):
174 174 self.SetSizer(sizer)
175 175 self.Update()
176 176 self.SetAutoLayout(1)
177   -
  177 +
178 178 def UpdateExternalTrigger(self, evt, ctrl):
179 179 Publisher.sendMessage('Update trigger state', ctrl.GetValue())
180 180  
... ... @@ -633,23 +633,28 @@ class MarkersPanel(wx.Panel):
633 633 for id_n in range(self.lc.GetItemCount()):
634 634 item = self.lc.GetItem(id_n, 4)
635 635 if item.GetText() == marker_id:
636   - if marker_id == "LEI" or marker_id == "REI" or marker_id == "NAI":
637   - self.lc.Focus(item.GetId())
638   - break
  636 + for i in const.BTNS_IMG:
  637 + if marker_id in const.BTNS_IMG[i].values()[0]:
  638 + self.lc.Focus(item.GetId())
  639 + break
  640 + self.DeleteMarker()
639 641 else:
640   - if self.lc.GetFocusedItem() is not -1 and self.lc.GetItemCount():
641   - index = self.lc.GetFocusedItem()
642   - del self.list_coord[index]
643   - self.lc.DeleteItem(index)
644   - for n in range(0, self.lc.GetItemCount()):
645   - self.lc.SetStringItem(n, 0, str(n+1))
646   - self.marker_ind -= 1
647   - Publisher.sendMessage('Remove marker', index)
  642 + if self.lc.GetFocusedItem() is not -1:
  643 + self.DeleteMarker()
648 644 elif not self.lc.GetItemCount():
649 645 pass
650 646 else:
651 647 dlg.NoMarkerSelected()
652 648  
  649 + def DeleteMarker(self):
  650 + index = self.lc.GetFocusedItem()
  651 + del self.list_coord[index]
  652 + self.lc.DeleteItem(index)
  653 + for n in range(0, self.lc.GetItemCount()):
  654 + self.lc.SetStringItem(n, 0, str(n+1))
  655 + self.marker_ind -= 1
  656 + Publisher.sendMessage('Remove marker', index)
  657 +
653 658 def OnCreateMarker(self, evt):
654 659 # OnCreateMarker is used for both pubsub and button click events
655 660 # Pubsub is used for markers created with fiducial buttons, trigger and create marker button
... ... @@ -674,8 +679,9 @@ class MarkersPanel(wx.Panel):
674 679 size = float(line[6])
675 680  
676 681 if len(line) == 8:
677   - if line[7] == "LEI" or line[7] == "REI" or line[7] == "NAI":
678   - Publisher.sendMessage('Load image fiducials', (line[7], coord))
  682 + for i in const.BTNS_IMG:
  683 + if line[7] in const.BTNS_IMG[i].values()[0]:
  684 + Publisher.sendMessage('Load image fiducials', (line[7], coord))
679 685 else:
680 686 line.append("")
681 687 self.CreateMarker(coord, colour, size, line[7])
... ... @@ -690,7 +696,7 @@ class MarkersPanel(wx.Panel):
690 696 else:
691 697 Publisher.sendMessage('Show all markers', self.lc.GetItemCount())
692 698 ctrl.SetLabel('Hide')
693   -
  699 +
694 700 def OnSaveMarkers(self, evt):
695 701 filename = dlg.ShowSaveMarkersDialog("markers.txt")
696 702 if filename:
... ... @@ -709,7 +715,7 @@ class MarkersPanel(wx.Panel):
709 715  
710 716 text_file.writelines(line)
711 717 text_file.close()
712   -
  718 +
713 719 def OnSelectColour(self, evt, ctrl):
714 720 self.marker_colour = [colour/255.0 for colour in ctrl.GetValue()]
715 721  
... ...