Commit 991392d7b57805ec6faa4309403d0ab251e79f62
Committed by
Thiago Franco de Moraes
1 parent
fc96ee16
Exists in
master
and in
12 other branches
Refresh optimization and markers (#67)
Navigation optimization and marker creation improvement
Showing
5 changed files
with
31 additions
and
21 deletions
Show diff stats
.gitignore
invesalius/data/coordinates.py
| @@ -20,6 +20,7 @@ | @@ -20,6 +20,7 @@ | ||
| 20 | from math import sin, cos | 20 | from math import sin, cos |
| 21 | import numpy as np | 21 | import numpy as np |
| 22 | 22 | ||
| 23 | +from time import sleep | ||
| 23 | from random import uniform | 24 | from random import uniform |
| 24 | 25 | ||
| 25 | 26 | ||
| @@ -211,7 +212,7 @@ def DebugCoord(trk_init, trck_id, ref_mode): | @@ -211,7 +212,7 @@ def DebugCoord(trk_init, trck_id, ref_mode): | ||
| 211 | :param trck_id: id of tracking device | 212 | :param trck_id: id of tracking device |
| 212 | :return: six coordinates x, y, z, alfa, beta and gama | 213 | :return: six coordinates x, y, z, alfa, beta and gama |
| 213 | """ | 214 | """ |
| 214 | - | 215 | + sleep(0.2) |
| 215 | if ref_mode: | 216 | if ref_mode: |
| 216 | probe = np.array([uniform(1, 200), uniform(1, 200), uniform(1, 200), | 217 | probe = np.array([uniform(1, 200), uniform(1, 200), uniform(1, 200), |
| 217 | uniform(1, 200), uniform(1, 200), uniform(1, 200)]) | 218 | uniform(1, 200), uniform(1, 200), uniform(1, 200)]) |
invesalius/data/coregistration.py
| @@ -74,8 +74,8 @@ class Coregistration(threading.Thread): | @@ -74,8 +74,8 @@ class Coregistration(threading.Thread): | ||
| 74 | # TODO: Optimize the value of sleep for each tracking device. | 74 | # TODO: Optimize the value of sleep for each tracking device. |
| 75 | # Debug tracker is not working with 0.175 so changed to 0.2 | 75 | # Debug tracker is not working with 0.175 so changed to 0.2 |
| 76 | # However, 0.2 is too low update frequency ~5 Hz. Need optimization URGENTLY. | 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 | if self._pause_: | 80 | if self._pause_: |
| 81 | return | 81 | return |
invesalius/data/viewer_volume.py
| @@ -674,7 +674,8 @@ class Viewer(wx.Panel): | @@ -674,7 +674,8 @@ class Viewer(wx.Panel): | ||
| 674 | # Need to be outside condition for sphere marker position update | 674 | # Need to be outside condition for sphere marker position update |
| 675 | # self.ren.ResetCameraClippingRange() | 675 | # self.ren.ResetCameraClippingRange() |
| 676 | # self.ren.ResetCamera() | 676 | # self.ren.ResetCamera() |
| 677 | - self.interactor.Render() | 677 | + #self.interactor.Render() |
| 678 | + self.Refresh() | ||
| 678 | 679 | ||
| 679 | def OnExportSurface(self, pubsub_evt): | 680 | def OnExportSurface(self, pubsub_evt): |
| 680 | filename, filetype = pubsub_evt.data | 681 | filename, filetype = pubsub_evt.data |
invesalius/gui/task_navigator.py
| @@ -141,7 +141,7 @@ class InnerFoldPanel(wx.Panel): | @@ -141,7 +141,7 @@ class InnerFoldPanel(wx.Panel): | ||
| 141 | fold_panel.AddFoldPanelWindow(item, mtw, Spacing= 0, | 141 | fold_panel.AddFoldPanelWindow(item, mtw, Spacing= 0, |
| 142 | leftSpacing=0, rightSpacing=0) | 142 | leftSpacing=0, rightSpacing=0) |
| 143 | 143 | ||
| 144 | - | 144 | + |
| 145 | # Check box for camera update in volume rendering during navigation | 145 | # Check box for camera update in volume rendering during navigation |
| 146 | tooltip = wx.ToolTip(_("Update camera in volume")) | 146 | tooltip = wx.ToolTip(_("Update camera in volume")) |
| 147 | checkcamera = wx.CheckBox(self, -1, _('Volume camera')) | 147 | checkcamera = wx.CheckBox(self, -1, _('Volume camera')) |
| @@ -174,7 +174,7 @@ class InnerFoldPanel(wx.Panel): | @@ -174,7 +174,7 @@ class InnerFoldPanel(wx.Panel): | ||
| 174 | self.SetSizer(sizer) | 174 | self.SetSizer(sizer) |
| 175 | self.Update() | 175 | self.Update() |
| 176 | self.SetAutoLayout(1) | 176 | self.SetAutoLayout(1) |
| 177 | - | 177 | + |
| 178 | def UpdateExternalTrigger(self, evt, ctrl): | 178 | def UpdateExternalTrigger(self, evt, ctrl): |
| 179 | Publisher.sendMessage('Update trigger state', ctrl.GetValue()) | 179 | Publisher.sendMessage('Update trigger state', ctrl.GetValue()) |
| 180 | 180 | ||
| @@ -633,23 +633,28 @@ class MarkersPanel(wx.Panel): | @@ -633,23 +633,28 @@ class MarkersPanel(wx.Panel): | ||
| 633 | for id_n in range(self.lc.GetItemCount()): | 633 | for id_n in range(self.lc.GetItemCount()): |
| 634 | item = self.lc.GetItem(id_n, 4) | 634 | item = self.lc.GetItem(id_n, 4) |
| 635 | if item.GetText() == marker_id: | 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 | else: | 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 | elif not self.lc.GetItemCount(): | 644 | elif not self.lc.GetItemCount(): |
| 649 | pass | 645 | pass |
| 650 | else: | 646 | else: |
| 651 | dlg.NoMarkerSelected() | 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 | def OnCreateMarker(self, evt): | 658 | def OnCreateMarker(self, evt): |
| 654 | # OnCreateMarker is used for both pubsub and button click events | 659 | # OnCreateMarker is used for both pubsub and button click events |
| 655 | # Pubsub is used for markers created with fiducial buttons, trigger and create marker button | 660 | # Pubsub is used for markers created with fiducial buttons, trigger and create marker button |
| @@ -674,8 +679,9 @@ class MarkersPanel(wx.Panel): | @@ -674,8 +679,9 @@ class MarkersPanel(wx.Panel): | ||
| 674 | size = float(line[6]) | 679 | size = float(line[6]) |
| 675 | 680 | ||
| 676 | if len(line) == 8: | 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 | else: | 685 | else: |
| 680 | line.append("") | 686 | line.append("") |
| 681 | self.CreateMarker(coord, colour, size, line[7]) | 687 | self.CreateMarker(coord, colour, size, line[7]) |
| @@ -690,7 +696,7 @@ class MarkersPanel(wx.Panel): | @@ -690,7 +696,7 @@ class MarkersPanel(wx.Panel): | ||
| 690 | else: | 696 | else: |
| 691 | Publisher.sendMessage('Show all markers', self.lc.GetItemCount()) | 697 | Publisher.sendMessage('Show all markers', self.lc.GetItemCount()) |
| 692 | ctrl.SetLabel('Hide') | 698 | ctrl.SetLabel('Hide') |
| 693 | - | 699 | + |
| 694 | def OnSaveMarkers(self, evt): | 700 | def OnSaveMarkers(self, evt): |
| 695 | filename = dlg.ShowSaveMarkersDialog("markers.txt") | 701 | filename = dlg.ShowSaveMarkersDialog("markers.txt") |
| 696 | if filename: | 702 | if filename: |
| @@ -709,7 +715,7 @@ class MarkersPanel(wx.Panel): | @@ -709,7 +715,7 @@ class MarkersPanel(wx.Panel): | ||
| 709 | 715 | ||
| 710 | text_file.writelines(line) | 716 | text_file.writelines(line) |
| 711 | text_file.close() | 717 | text_file.close() |
| 712 | - | 718 | + |
| 713 | def OnSelectColour(self, evt, ctrl): | 719 | def OnSelectColour(self, evt, ctrl): |
| 714 | self.marker_colour = [colour/255.0 for colour in ctrl.GetValue()] | 720 | self.marker_colour = [colour/255.0 for colour in ctrl.GetValue()] |
| 715 | 721 |