Commit bfb7466961ff928209afe4641c56f002373d6c06
Committed by
Thiago Franco de Moraes
1 parent
a76ce758
Exists in
master
Update GUI defaults in navigation and improved functionalities (#196)
* ENH:Update GUI navigation defaults for better workflow * ENH: Improved visualization in navigation - Larger distance text in target interface - Better colors for coil objects and aim - Update defaults in navigation tab * ENH: Save last used NDI markers filenames to config.json
Showing
5 changed files
with
129 additions
and
50 deletions
Show diff stats
invesalius/constants.py
@@ -62,6 +62,7 @@ TEXT_SIZE_SMALL = 11 | @@ -62,6 +62,7 @@ TEXT_SIZE_SMALL = 11 | ||
62 | TEXT_SIZE = 12 | 62 | TEXT_SIZE = 12 |
63 | TEXT_SIZE_LARGE = 16 | 63 | TEXT_SIZE_LARGE = 16 |
64 | TEXT_SIZE_EXTRA_LARGE = 20 | 64 | TEXT_SIZE_EXTRA_LARGE = 20 |
65 | +TEXT_SIZE_DIST_NAV = 32 | ||
65 | TEXT_COLOUR = (1,1,1) | 66 | TEXT_COLOUR = (1,1,1) |
66 | 67 | ||
67 | (X,Y) = (0.03, 0.97) | 68 | (X,Y) = (0.03, 0.97) |
invesalius/data/viewer_volume.py
@@ -165,6 +165,7 @@ class Viewer(wx.Panel): | @@ -165,6 +165,7 @@ class Viewer(wx.Panel): | ||
165 | self.obj_state = None | 165 | self.obj_state = None |
166 | self.obj_actor_list = None | 166 | self.obj_actor_list = None |
167 | self.arrow_actor_list = None | 167 | self.arrow_actor_list = None |
168 | + #self.pTarget = [0., 0., 0.] | ||
168 | 169 | ||
169 | # self.obj_axes = None | 170 | # self.obj_axes = None |
170 | 171 | ||
@@ -623,6 +624,7 @@ class Viewer(wx.Panel): | @@ -623,6 +624,7 @@ class Viewer(wx.Panel): | ||
623 | self.distthreshold = dist_threshold | 624 | self.distthreshold = dist_threshold |
624 | 625 | ||
625 | def ActivateTargetMode(self, evt=None, target_mode=None): | 626 | def ActivateTargetMode(self, evt=None, target_mode=None): |
627 | + vtk_colors = vtk.vtkNamedColors() | ||
626 | self.target_mode = target_mode | 628 | self.target_mode = target_mode |
627 | if self.target_coord and self.target_mode: | 629 | if self.target_coord and self.target_mode: |
628 | self.CreateTargetAim() | 630 | self.CreateTargetAim() |
@@ -646,21 +648,33 @@ class Viewer(wx.Panel): | @@ -646,21 +648,33 @@ class Viewer(wx.Panel): | ||
646 | mapper = vtk.vtkPolyDataMapper() | 648 | mapper = vtk.vtkPolyDataMapper() |
647 | mapper.SetInputData(normals.GetOutput()) | 649 | mapper.SetInputData(normals.GetOutput()) |
648 | mapper.ScalarVisibilityOff() | 650 | mapper.ScalarVisibilityOff() |
649 | - mapper.ImmediateModeRenderingOn() # improve performance | 651 | + #mapper.ImmediateModeRenderingOn() # improve performance |
650 | 652 | ||
651 | obj_roll = vtk.vtkActor() | 653 | obj_roll = vtk.vtkActor() |
652 | obj_roll.SetMapper(mapper) | 654 | obj_roll.SetMapper(mapper) |
655 | + obj_roll.GetProperty().SetColor(1, 1, 1) | ||
656 | + # obj_roll.GetProperty().SetDiffuseColor(vtk_colors.GetColor3d('GhostWhite')) | ||
657 | + # obj_roll.GetProperty().SetSpecular(30) | ||
658 | + # obj_roll.GetProperty().SetSpecularPower(80) | ||
653 | obj_roll.SetPosition(0, 25, -30) | 659 | obj_roll.SetPosition(0, 25, -30) |
654 | obj_roll.RotateX(-60) | 660 | obj_roll.RotateX(-60) |
655 | obj_roll.RotateZ(180) | 661 | obj_roll.RotateZ(180) |
656 | 662 | ||
657 | obj_yaw = vtk.vtkActor() | 663 | obj_yaw = vtk.vtkActor() |
658 | obj_yaw.SetMapper(mapper) | 664 | obj_yaw.SetMapper(mapper) |
665 | + obj_yaw.GetProperty().SetColor(1, 1, 1) | ||
666 | + # obj_yaw.GetProperty().SetDiffuseColor(vtk_colors.GetColor3d('GhostWhite')) | ||
667 | + # obj_yaw.GetProperty().SetSpecular(30) | ||
668 | + # obj_yaw.GetProperty().SetSpecularPower(80) | ||
659 | obj_yaw.SetPosition(0, -115, 5) | 669 | obj_yaw.SetPosition(0, -115, 5) |
660 | obj_yaw.RotateZ(180) | 670 | obj_yaw.RotateZ(180) |
661 | 671 | ||
662 | obj_pitch = vtk.vtkActor() | 672 | obj_pitch = vtk.vtkActor() |
663 | obj_pitch.SetMapper(mapper) | 673 | obj_pitch.SetMapper(mapper) |
674 | + obj_pitch.GetProperty().SetColor(1, 1, 1) | ||
675 | + # obj_pitch.GetProperty().SetDiffuseColor(vtk_colors.GetColor3d('GhostWhite')) | ||
676 | + # obj_pitch.GetProperty().SetSpecular(30) | ||
677 | + # obj_pitch.GetProperty().SetSpecularPower(80) | ||
664 | obj_pitch.SetPosition(5, -265, 5) | 678 | obj_pitch.SetPosition(5, -265, 5) |
665 | obj_pitch.RotateY(90) | 679 | obj_pitch.RotateY(90) |
666 | obj_pitch.RotateZ(180) | 680 | obj_pitch.RotateZ(180) |
@@ -717,6 +731,9 @@ class Viewer(wx.Panel): | @@ -717,6 +731,9 @@ class Viewer(wx.Panel): | ||
717 | self.DisableCoilTracker() | 731 | self.DisableCoilTracker() |
718 | 732 | ||
719 | def OnUpdateObjectTargetGuide(self, m_img, coord): | 733 | def OnUpdateObjectTargetGuide(self, m_img, coord): |
734 | + | ||
735 | + vtk_colors = vtk.vtkNamedColors() | ||
736 | + | ||
720 | if self.target_coord and self.target_mode: | 737 | if self.target_coord and self.target_mode: |
721 | 738 | ||
722 | target_dist = distance.euclidean(coord[0:3], | 739 | target_dist = distance.euclidean(coord[0:3], |
@@ -734,10 +751,10 @@ class Viewer(wx.Panel): | @@ -734,10 +751,10 @@ class Viewer(wx.Panel): | ||
734 | 751 | ||
735 | if target_dist <= self.distthreshold: | 752 | if target_dist <= self.distthreshold: |
736 | thrdist = True | 753 | thrdist = True |
737 | - self.aim_actor.GetProperty().SetColor(0, 1, 0) | 754 | + self.aim_actor.GetProperty().SetDiffuseColor(vtk_colors.GetColor3d('Green')) |
738 | else: | 755 | else: |
739 | thrdist = False | 756 | thrdist = False |
740 | - self.aim_actor.GetProperty().SetColor(1, 1, 1) | 757 | + self.aim_actor.GetProperty().SetDiffuseColor(vtk_colors.GetColor3d('Yellow')) |
741 | 758 | ||
742 | coordx = self.target_coord[3] - coord[3] | 759 | coordx = self.target_coord[3] - coord[3] |
743 | if coordx > const.ARROW_UPPER_LIMIT: | 760 | if coordx > const.ARROW_UPPER_LIMIT: |
@@ -765,9 +782,11 @@ class Viewer(wx.Panel): | @@ -765,9 +782,11 @@ class Viewer(wx.Panel): | ||
765 | 782 | ||
766 | if self.anglethreshold * const.ARROW_SCALE > coordx > -self.anglethreshold * const.ARROW_SCALE: | 783 | if self.anglethreshold * const.ARROW_SCALE > coordx > -self.anglethreshold * const.ARROW_SCALE: |
767 | thrcoordx = True | 784 | thrcoordx = True |
785 | + # self.obj_actor_list[0].GetProperty().SetDiffuseColor(vtk_colors.GetColor3d('Green')) | ||
768 | self.obj_actor_list[0].GetProperty().SetColor(0, 1, 0) | 786 | self.obj_actor_list[0].GetProperty().SetColor(0, 1, 0) |
769 | else: | 787 | else: |
770 | thrcoordx = False | 788 | thrcoordx = False |
789 | + # self.obj_actor_list[0].GetProperty().SetDiffuseColor(vtk_colors.GetColor3d('GhostWhite')) | ||
771 | self.obj_actor_list[0].GetProperty().SetColor(1, 1, 1) | 790 | self.obj_actor_list[0].GetProperty().SetColor(1, 1, 1) |
772 | 791 | ||
773 | offset = 5 | 792 | offset = 5 |
@@ -784,9 +803,11 @@ class Viewer(wx.Panel): | @@ -784,9 +803,11 @@ class Viewer(wx.Panel): | ||
784 | 803 | ||
785 | if self.anglethreshold * const.ARROW_SCALE > coordz > -self.anglethreshold * const.ARROW_SCALE: | 804 | if self.anglethreshold * const.ARROW_SCALE > coordz > -self.anglethreshold * const.ARROW_SCALE: |
786 | thrcoordz = True | 805 | thrcoordz = True |
806 | + # self.obj_actor_list[1].GetProperty().SetDiffuseColor(vtk_colors.GetColor3d('Green')) | ||
787 | self.obj_actor_list[1].GetProperty().SetColor(0, 1, 0) | 807 | self.obj_actor_list[1].GetProperty().SetColor(0, 1, 0) |
788 | else: | 808 | else: |
789 | thrcoordz = False | 809 | thrcoordz = False |
810 | + # self.obj_actor_list[1].GetProperty().SetDiffuseColor(vtk_colors.GetColor3d('GhostWhite')) | ||
790 | self.obj_actor_list[1].GetProperty().SetColor(1, 1, 1) | 811 | self.obj_actor_list[1].GetProperty().SetColor(1, 1, 1) |
791 | 812 | ||
792 | offset = -35 | 813 | offset = -35 |
@@ -803,9 +824,11 @@ class Viewer(wx.Panel): | @@ -803,9 +824,11 @@ class Viewer(wx.Panel): | ||
803 | 824 | ||
804 | if self.anglethreshold * const.ARROW_SCALE > coordy > -self.anglethreshold * const.ARROW_SCALE: | 825 | if self.anglethreshold * const.ARROW_SCALE > coordy > -self.anglethreshold * const.ARROW_SCALE: |
805 | thrcoordy = True | 826 | thrcoordy = True |
827 | + #self.obj_actor_list[2].GetProperty().SetDiffuseColor(vtk_colors.GetColor3d('Green')) | ||
806 | self.obj_actor_list[2].GetProperty().SetColor(0, 1, 0) | 828 | self.obj_actor_list[2].GetProperty().SetColor(0, 1, 0) |
807 | else: | 829 | else: |
808 | thrcoordy = False | 830 | thrcoordy = False |
831 | + #self.obj_actor_list[2].GetProperty().SetDiffuseColor(vtk_colors.GetColor3d('GhostWhite')) | ||
809 | self.obj_actor_list[2].GetProperty().SetColor(1, 1, 1) | 832 | self.obj_actor_list[2].GetProperty().SetColor(1, 1, 1) |
810 | 833 | ||
811 | offset = 38 | 834 | offset = 38 |
@@ -823,9 +846,9 @@ class Viewer(wx.Panel): | @@ -823,9 +846,9 @@ class Viewer(wx.Panel): | ||
823 | arrow_pitch_y2.GetProperty().SetColor(1, 0, 0) | 846 | arrow_pitch_y2.GetProperty().SetColor(1, 0, 0) |
824 | 847 | ||
825 | if thrdist and thrcoordx and thrcoordy and thrcoordz: | 848 | if thrdist and thrcoordx and thrcoordy and thrcoordz: |
826 | - self.dummy_coil_actor.GetProperty().SetColor(0, 1, 0) | 849 | + self.dummy_coil_actor.GetProperty().SetDiffuseColor(vtk_colors.GetColor3d('Green')) |
827 | else: | 850 | else: |
828 | - self.dummy_coil_actor.GetProperty().SetColor(1, 1, 1) | 851 | + self.dummy_coil_actor.GetProperty().SetDiffuseColor(vtk_colors.GetColor3d('DarkOrange')) |
829 | 852 | ||
830 | self.arrow_actor_list = arrow_roll_x1, arrow_roll_x2, arrow_yaw_z1, arrow_yaw_z2, \ | 853 | self.arrow_actor_list = arrow_roll_x1, arrow_roll_x2, arrow_yaw_z1, arrow_yaw_z2, \ |
831 | arrow_pitch_y1, arrow_pitch_y2 | 854 | arrow_pitch_y1, arrow_pitch_y2 |
@@ -833,7 +856,6 @@ class Viewer(wx.Panel): | @@ -833,7 +856,6 @@ class Viewer(wx.Panel): | ||
833 | for ind in self.arrow_actor_list: | 856 | for ind in self.arrow_actor_list: |
834 | self.ren2.AddActor(ind) | 857 | self.ren2.AddActor(ind) |
835 | 858 | ||
836 | - | ||
837 | self.Refresh() | 859 | self.Refresh() |
838 | 860 | ||
839 | def OnUpdateTargetCoordinates(self, coord): | 861 | def OnUpdateTargetCoordinates(self, coord): |
@@ -853,6 +875,8 @@ class Viewer(wx.Panel): | @@ -853,6 +875,8 @@ class Viewer(wx.Panel): | ||
853 | self.RemoveTargetAim() | 875 | self.RemoveTargetAim() |
854 | self.aim_actor = None | 876 | self.aim_actor = None |
855 | 877 | ||
878 | + vtk_colors = vtk.vtkNamedColors() | ||
879 | + | ||
856 | a, b, g = np.radians(self.target_coord[3:]) | 880 | a, b, g = np.radians(self.target_coord[3:]) |
857 | r_ref = tr.euler_matrix(a, b, g, 'sxyz') | 881 | r_ref = tr.euler_matrix(a, b, g, 'sxyz') |
858 | t_ref = tr.translation_matrix(self.target_coord[:3]) | 882 | t_ref = tr.translation_matrix(self.target_coord[:3]) |
@@ -885,8 +909,10 @@ class Viewer(wx.Panel): | @@ -885,8 +909,10 @@ class Viewer(wx.Panel): | ||
885 | 909 | ||
886 | aim_actor = vtk.vtkActor() | 910 | aim_actor = vtk.vtkActor() |
887 | aim_actor.SetMapper(mapper) | 911 | aim_actor.SetMapper(mapper) |
888 | - aim_actor.GetProperty().SetColor(1, 1, 1) | ||
889 | - aim_actor.GetProperty().SetOpacity(0.6) | 912 | + aim_actor.GetProperty().SetDiffuseColor(vtk_colors.GetColor3d('Yellow')) |
913 | + aim_actor.GetProperty().SetSpecular(.2) | ||
914 | + aim_actor.GetProperty().SetSpecularPower(100) | ||
915 | + aim_actor.GetProperty().SetOpacity(1.) | ||
890 | self.aim_actor = aim_actor | 916 | self.aim_actor = aim_actor |
891 | self.ren.AddActor(aim_actor) | 917 | self.ren.AddActor(aim_actor) |
892 | 918 | ||
@@ -909,11 +935,14 @@ class Viewer(wx.Panel): | @@ -909,11 +935,14 @@ class Viewer(wx.Panel): | ||
909 | obj_mapper = vtk.vtkPolyDataMapper() | 935 | obj_mapper = vtk.vtkPolyDataMapper() |
910 | obj_mapper.SetInputData(normals.GetOutput()) | 936 | obj_mapper.SetInputData(normals.GetOutput()) |
911 | obj_mapper.ScalarVisibilityOff() | 937 | obj_mapper.ScalarVisibilityOff() |
912 | - obj_mapper.ImmediateModeRenderingOn() # improve performance | 938 | + #obj_mapper.ImmediateModeRenderingOn() # improve performance |
913 | 939 | ||
914 | self.dummy_coil_actor = vtk.vtkActor() | 940 | self.dummy_coil_actor = vtk.vtkActor() |
915 | self.dummy_coil_actor.SetMapper(obj_mapper) | 941 | self.dummy_coil_actor.SetMapper(obj_mapper) |
916 | - self.dummy_coil_actor.GetProperty().SetOpacity(0.15) | 942 | + self.dummy_coil_actor.GetProperty().SetDiffuseColor(vtk_colors.GetColor3d('DarkOrange')) |
943 | + self.dummy_coil_actor.GetProperty().SetSpecular(0.5) | ||
944 | + self.dummy_coil_actor.GetProperty().SetSpecularPower(10) | ||
945 | + self.dummy_coil_actor.GetProperty().SetOpacity(.3) | ||
917 | self.dummy_coil_actor.SetVisibility(1) | 946 | self.dummy_coil_actor.SetVisibility(1) |
918 | self.dummy_coil_actor.SetUserMatrix(m_img_vtk) | 947 | self.dummy_coil_actor.SetUserMatrix(m_img_vtk) |
919 | 948 | ||
@@ -928,9 +957,9 @@ class Viewer(wx.Panel): | @@ -928,9 +957,9 @@ class Viewer(wx.Panel): | ||
928 | 957 | ||
929 | def CreateTextDistance(self): | 958 | def CreateTextDistance(self): |
930 | tdist = vtku.Text() | 959 | tdist = vtku.Text() |
931 | - tdist.SetSize(const.TEXT_SIZE_LARGE) | 960 | + tdist.SetSize(const.TEXT_SIZE_DIST_NAV) |
932 | tdist.SetPosition((const.X, 1.03-const.Y)) | 961 | tdist.SetPosition((const.X, 1.03-const.Y)) |
933 | - tdist.ShadowOff() | 962 | + #tdist.ShadowOff() |
934 | tdist.BoldOn() | 963 | tdist.BoldOn() |
935 | 964 | ||
936 | self.ren.AddActor(tdist.actor) | 965 | self.ren.AddActor(tdist.actor) |
@@ -1162,7 +1191,7 @@ class Viewer(wx.Panel): | @@ -1162,7 +1191,7 @@ class Viewer(wx.Panel): | ||
1162 | """ | 1191 | """ |
1163 | Coil for navigation rendered in volume viewer. | 1192 | Coil for navigation rendered in volume viewer. |
1164 | """ | 1193 | """ |
1165 | - | 1194 | + vtk_colors = vtk.vtkNamedColors() |
1166 | obj_polydata = self.CreateObjectPolyData(obj_name) | 1195 | obj_polydata = self.CreateObjectPolyData(obj_name) |
1167 | 1196 | ||
1168 | transform = vtk.vtkTransform() | 1197 | transform = vtk.vtkTransform() |
@@ -1182,11 +1211,14 @@ class Viewer(wx.Panel): | @@ -1182,11 +1211,14 @@ class Viewer(wx.Panel): | ||
1182 | obj_mapper = vtk.vtkPolyDataMapper() | 1211 | obj_mapper = vtk.vtkPolyDataMapper() |
1183 | obj_mapper.SetInputData(normals.GetOutput()) | 1212 | obj_mapper.SetInputData(normals.GetOutput()) |
1184 | obj_mapper.ScalarVisibilityOff() | 1213 | obj_mapper.ScalarVisibilityOff() |
1185 | - obj_mapper.ImmediateModeRenderingOn() # improve performance | 1214 | + #obj_mapper.ImmediateModeRenderingOn() # improve performance |
1186 | 1215 | ||
1187 | self.obj_actor = vtk.vtkActor() | 1216 | self.obj_actor = vtk.vtkActor() |
1188 | self.obj_actor.SetMapper(obj_mapper) | 1217 | self.obj_actor.SetMapper(obj_mapper) |
1189 | - self.obj_actor.GetProperty().SetOpacity(0.9) | 1218 | + self.obj_actor.GetProperty().SetAmbientColor(vtk_colors.GetColor3d('GhostWhite')) |
1219 | + self.obj_actor.GetProperty().SetSpecular(30) | ||
1220 | + self.obj_actor.GetProperty().SetSpecularPower(80) | ||
1221 | + self.obj_actor.GetProperty().SetOpacity(.4) | ||
1190 | self.obj_actor.SetVisibility(0) | 1222 | self.obj_actor.SetVisibility(0) |
1191 | 1223 | ||
1192 | self.ren.AddActor(self.obj_actor) | 1224 | self.ren.AddActor(self.obj_actor) |
invesalius/gui/default_viewers.py
@@ -488,9 +488,11 @@ class VolumeToolPanel(wx.Panel): | @@ -488,9 +488,11 @@ class VolumeToolPanel(wx.Panel): | ||
488 | if not self.button_target.IsPressed() and evt is not False: | 488 | if not self.button_target.IsPressed() and evt is not False: |
489 | self.button_target._pressed = True | 489 | self.button_target._pressed = True |
490 | Publisher.sendMessage('Target navigation mode', target_mode=self.button_target._pressed) | 490 | Publisher.sendMessage('Target navigation mode', target_mode=self.button_target._pressed) |
491 | + Publisher.sendMessage('Change camera checkbox', status=self.button_target._pressed) | ||
491 | elif self.button_target.IsPressed() or evt is False: | 492 | elif self.button_target.IsPressed() or evt is False: |
492 | self.button_target._pressed = False | 493 | self.button_target._pressed = False |
493 | Publisher.sendMessage('Target navigation mode', target_mode=self.button_target._pressed) | 494 | Publisher.sendMessage('Target navigation mode', target_mode=self.button_target._pressed) |
495 | + Publisher.sendMessage('Change camera checkbox', status=self.button_target._pressed) | ||
494 | 496 | ||
495 | def OnSavePreset(self, evt): | 497 | def OnSavePreset(self, evt): |
496 | d = wx.TextEntryDialog(self, _("Preset name")) | 498 | d = wx.TextEntryDialog(self, _("Preset name")) |
invesalius/gui/dialogs.py
@@ -3326,7 +3326,7 @@ class ObjectCalibrationDialog(wx.Dialog): | @@ -3326,7 +3326,7 @@ class ObjectCalibrationDialog(wx.Dialog): | ||
3326 | 3326 | ||
3327 | self.tracker_id = nav_prop[0] | 3327 | self.tracker_id = nav_prop[0] |
3328 | self.trk_init = nav_prop[1] | 3328 | self.trk_init = nav_prop[1] |
3329 | - self.obj_ref_id = 0 | 3329 | + self.obj_ref_id = 2 |
3330 | self.obj_name = None | 3330 | self.obj_name = None |
3331 | 3331 | ||
3332 | self.obj_fiducials = np.full([5, 3], np.nan) | 3332 | self.obj_fiducials = np.full([5, 3], np.nan) |
@@ -3354,7 +3354,7 @@ class ObjectCalibrationDialog(wx.Dialog): | @@ -3354,7 +3354,7 @@ class ObjectCalibrationDialog(wx.Dialog): | ||
3354 | tooltip = wx.ToolTip(_(u"Choose the object reference mode")) | 3354 | tooltip = wx.ToolTip(_(u"Choose the object reference mode")) |
3355 | choice_ref = wx.ComboBox(self, -1, "", size=wx.Size(90, 23), | 3355 | choice_ref = wx.ComboBox(self, -1, "", size=wx.Size(90, 23), |
3356 | choices=const.REF_MODE, style=wx.CB_DROPDOWN | wx.CB_READONLY) | 3356 | choices=const.REF_MODE, style=wx.CB_DROPDOWN | wx.CB_READONLY) |
3357 | - choice_ref.SetSelection(self.obj_ref_id) | 3357 | + choice_ref.SetSelection(1) |
3358 | choice_ref.SetToolTip(tooltip) | 3358 | choice_ref.SetToolTip(tooltip) |
3359 | choice_ref.Bind(wx.EVT_COMBOBOX, self.OnChoiceRefMode) | 3359 | choice_ref.Bind(wx.EVT_COMBOBOX, self.OnChoiceRefMode) |
3360 | choice_ref.Enable(0) | 3360 | choice_ref.Enable(0) |
@@ -3368,7 +3368,10 @@ class ObjectCalibrationDialog(wx.Dialog): | @@ -3368,7 +3368,10 @@ class ObjectCalibrationDialog(wx.Dialog): | ||
3368 | choice_sensor.SetSelection(0) | 3368 | choice_sensor.SetSelection(0) |
3369 | choice_sensor.SetToolTip(tooltip) | 3369 | choice_sensor.SetToolTip(tooltip) |
3370 | choice_sensor.Bind(wx.EVT_COMBOBOX, self.OnChoiceFTSensor) | 3370 | choice_sensor.Bind(wx.EVT_COMBOBOX, self.OnChoiceFTSensor) |
3371 | - choice_sensor.Show(False) | 3371 | + if self.tracker_id == const.FASTRAK or self.tracker_id == const.DEBUGTRACK: |
3372 | + choice_sensor.Show(True) | ||
3373 | + else: | ||
3374 | + choice_sensor.Show(False) | ||
3372 | self.choice_sensor = choice_sensor | 3375 | self.choice_sensor = choice_sensor |
3373 | 3376 | ||
3374 | # Buttons to finish or cancel object registration | 3377 | # Buttons to finish or cancel object registration |
@@ -3487,7 +3490,7 @@ class ObjectCalibrationDialog(wx.Dialog): | @@ -3487,7 +3490,7 @@ class ObjectCalibrationDialog(wx.Dialog): | ||
3487 | mapper = vtk.vtkPolyDataMapper() | 3490 | mapper = vtk.vtkPolyDataMapper() |
3488 | mapper.SetInputData(normals.GetOutput()) | 3491 | mapper.SetInputData(normals.GetOutput()) |
3489 | mapper.ScalarVisibilityOff() | 3492 | mapper.ScalarVisibilityOff() |
3490 | - mapper.ImmediateModeRenderingOn() | 3493 | + #mapper.ImmediateModeRenderingOn() |
3491 | 3494 | ||
3492 | obj_actor = vtk.vtkActor() | 3495 | obj_actor = vtk.vtkActor() |
3493 | obj_actor.SetMapper(mapper) | 3496 | obj_actor.SetMapper(mapper) |
@@ -3563,16 +3566,19 @@ class ObjectCalibrationDialog(wx.Dialog): | @@ -3563,16 +3566,19 @@ class ObjectCalibrationDialog(wx.Dialog): | ||
3563 | if evt.GetSelection(): | 3566 | if evt.GetSelection(): |
3564 | self.obj_ref_id = 2 | 3567 | self.obj_ref_id = 2 |
3565 | if self.tracker_id == const.FASTRAK or self.tracker_id == const.DEBUGTRACK: | 3568 | if self.tracker_id == const.FASTRAK or self.tracker_id == const.DEBUGTRACK: |
3566 | - self.choice_sensor.Show(True) | ||
3567 | - self.Layout() | 3569 | + self.choice_sensor.Show(self.obj_ref_id) |
3568 | else: | 3570 | else: |
3569 | self.obj_ref_id = 0 | 3571 | self.obj_ref_id = 0 |
3572 | + self.choice_sensor.Show(self.obj_ref_id) | ||
3570 | for m in range(0, 5): | 3573 | for m in range(0, 5): |
3571 | self.obj_fiducials[m, :] = np.full([1, 3], np.nan) | 3574 | self.obj_fiducials[m, :] = np.full([1, 3], np.nan) |
3572 | self.obj_orients[m, :] = np.full([1, 3], np.nan) | 3575 | self.obj_orients[m, :] = np.full([1, 3], np.nan) |
3573 | for n in range(0, 3): | 3576 | for n in range(0, 3): |
3574 | self.txt_coord[m][n].SetLabel('-') | 3577 | self.txt_coord[m][n].SetLabel('-') |
3575 | 3578 | ||
3579 | + # Used to update choice sensor controls | ||
3580 | + self.Layout() | ||
3581 | + | ||
3576 | def OnChoiceFTSensor(self, evt): | 3582 | def OnChoiceFTSensor(self, evt): |
3577 | if evt.GetSelection(): | 3583 | if evt.GetSelection(): |
3578 | self.obj_ref_id = 3 | 3584 | self.obj_ref_id = 3 |
@@ -3786,20 +3792,33 @@ class GoToDialogScannerCoord(wx.Dialog): | @@ -3786,20 +3792,33 @@ class GoToDialogScannerCoord(wx.Dialog): | ||
3786 | wx.Dialog.Close(self) | 3792 | wx.Dialog.Close(self) |
3787 | self.Destroy() | 3793 | self.Destroy() |
3788 | 3794 | ||
3795 | + | ||
3789 | class SetNDIconfigs(wx.Dialog): | 3796 | class SetNDIconfigs(wx.Dialog): |
3790 | def __init__(self, title=_("Setting NDI polaris configs:")): | 3797 | def __init__(self, title=_("Setting NDI polaris configs:")): |
3791 | - wx.Dialog.__init__(self, wx.GetApp().GetTopWindow(), -1, title, style=wx.DEFAULT_DIALOG_STYLE|wx.FRAME_FLOAT_ON_PARENT|wx.STAY_ON_TOP) | 3798 | + wx.Dialog.__init__(self, wx.GetApp().GetTopWindow(), -1, title, size=wx.Size(1000, 200), |
3799 | + style=wx.DEFAULT_DIALOG_STYLE|wx.FRAME_FLOAT_ON_PARENT|wx.STAY_ON_TOP|wx.RESIZE_BORDER) | ||
3792 | self._init_gui() | 3800 | self._init_gui() |
3793 | 3801 | ||
3794 | def serial_ports(self): | 3802 | def serial_ports(self): |
3795 | - """ Lists serial port names | 3803 | + """ Lists serial port names and pre-select the description containing NDI |
3796 | """ | 3804 | """ |
3797 | import serial.tools.list_ports | 3805 | import serial.tools.list_ports |
3806 | + | ||
3807 | + ports = serial.tools.list_ports.comports() | ||
3798 | if sys.platform.startswith('win'): | 3808 | if sys.platform.startswith('win'): |
3799 | - ports = ([comport.device for comport in serial.tools.list_ports.comports()]) | 3809 | + port_list = [] |
3810 | + count = 0 | ||
3811 | + for port, desc, hwid in sorted(ports): | ||
3812 | + port_list.append(port) | ||
3813 | + if 'NDI' in desc: | ||
3814 | + port_selec = port, count | ||
3815 | + count += 1 | ||
3800 | else: | 3816 | else: |
3801 | raise EnvironmentError('Unsupported platform') | 3817 | raise EnvironmentError('Unsupported platform') |
3802 | - return ports | 3818 | + |
3819 | + #print("Here is the chosen port: {} with id {}".format(port_selec[0], port_selec[1])) | ||
3820 | + | ||
3821 | + return port_list, port_selec | ||
3803 | 3822 | ||
3804 | def _init_gui(self): | 3823 | def _init_gui(self): |
3805 | self.com_ports = wx.ComboBox(self, -1, style=wx.CB_DROPDOWN|wx.CB_READONLY) | 3824 | self.com_ports = wx.ComboBox(self, -1, style=wx.CB_DROPDOWN|wx.CB_READONLY) |
@@ -3807,30 +3826,42 @@ class SetNDIconfigs(wx.Dialog): | @@ -3807,30 +3826,42 @@ class SetNDIconfigs(wx.Dialog): | ||
3807 | row_com.Add(wx.StaticText(self, wx.ID_ANY, "Select the COM port"), 0, wx.TOP|wx.RIGHT,5) | 3826 | row_com.Add(wx.StaticText(self, wx.ID_ANY, "Select the COM port"), 0, wx.TOP|wx.RIGHT,5) |
3808 | row_com.Add(self.com_ports, 0, wx.EXPAND) | 3827 | row_com.Add(self.com_ports, 0, wx.EXPAND) |
3809 | 3828 | ||
3810 | - ports = self.serial_ports() | ||
3811 | - self.com_ports.Append(ports) | 3829 | + port_list, port_selec = self.serial_ports() |
3812 | 3830 | ||
3813 | - self.dir_probe = wx.FilePickerCtrl(self, path=inv_paths.NDI_MAR_DIR_REF, style=wx.FLP_USE_TEXTCTRL|wx.FLP_SMALL, | 3831 | + self.com_ports.Append(port_list) |
3832 | + self.com_ports.SetSelection(port_selec[1]) | ||
3833 | + | ||
3834 | + session = ses.Session() | ||
3835 | + last_ndi_probe_marker = session.get('paths', 'last_ndi_probe_marker', '') | ||
3836 | + last_ndi_ref_marker = session.get('paths', 'last_ndi_ref_marker', '') | ||
3837 | + last_ndi_obj_marker = session.get('paths', 'last_ndi_obj_marker', '') | ||
3838 | + | ||
3839 | + if not last_ndi_probe_marker: | ||
3840 | + last_ndi_probe_marker = inv_paths.NDI_MAR_DIR_PROBE | ||
3841 | + if not last_ndi_ref_marker: | ||
3842 | + last_ndi_ref_marker = inv_paths.NDI_MAR_DIR_REF | ||
3843 | + if not last_ndi_obj_marker: | ||
3844 | + last_ndi_obj_marker = inv_paths.NDI_MAR_DIR_OBJ | ||
3845 | + | ||
3846 | + self.dir_probe = wx.FilePickerCtrl(self, path=last_ndi_probe_marker, style=wx.FLP_USE_TEXTCTRL|wx.FLP_SMALL, | ||
3814 | wildcard="Rom files (*.rom)|*.rom", message="Select probe's rom file") | 3847 | wildcard="Rom files (*.rom)|*.rom", message="Select probe's rom file") |
3815 | row_probe = wx.BoxSizer(wx.VERTICAL) | 3848 | row_probe = wx.BoxSizer(wx.VERTICAL) |
3816 | row_probe.Add(wx.StaticText(self, wx.ID_ANY, "Set probe's rom file"), 0, wx.TOP|wx.RIGHT, 5) | 3849 | row_probe.Add(wx.StaticText(self, wx.ID_ANY, "Set probe's rom file"), 0, wx.TOP|wx.RIGHT, 5) |
3817 | row_probe.Add(self.dir_probe, 0, wx.EXPAND|wx.ALIGN_CENTER) | 3850 | row_probe.Add(self.dir_probe, 0, wx.EXPAND|wx.ALIGN_CENTER) |
3818 | 3851 | ||
3819 | - self.dir_ref = wx.FilePickerCtrl(self, path=inv_paths.NDI_MAR_DIR_REF, style=wx.FLP_USE_TEXTCTRL|wx.FLP_SMALL, | ||
3820 | - wildcard="Rom files (*.rom)|*.rom", message="Select reference's rom file") | 3852 | + self.dir_ref = wx.FilePickerCtrl(self, path=last_ndi_ref_marker, style=wx.FLP_USE_TEXTCTRL|wx.FLP_SMALL, |
3853 | + wildcard="Rom files (*.rom)|*.rom", message="Select reference's rom file") | ||
3821 | row_ref = wx.BoxSizer(wx.VERTICAL) | 3854 | row_ref = wx.BoxSizer(wx.VERTICAL) |
3822 | row_ref.Add(wx.StaticText(self, wx.ID_ANY, "Set reference's rom file"), 0, wx.TOP | wx.RIGHT, 5) | 3855 | row_ref.Add(wx.StaticText(self, wx.ID_ANY, "Set reference's rom file"), 0, wx.TOP | wx.RIGHT, 5) |
3823 | row_ref.Add(self.dir_ref, 0, wx.EXPAND|wx.ALIGN_CENTER) | 3856 | row_ref.Add(self.dir_ref, 0, wx.EXPAND|wx.ALIGN_CENTER) |
3824 | 3857 | ||
3825 | - self.dir_obj = wx.FilePickerCtrl(self, path=inv_paths.NDI_MAR_DIR_OBJ, style=wx.FLP_USE_TEXTCTRL|wx.FLP_SMALL, | ||
3826 | - wildcard="Rom files (*.rom)|*.rom", message="Select object's rom file") | 3858 | + self.dir_obj = wx.FilePickerCtrl(self, path=last_ndi_obj_marker, style=wx.FLP_USE_TEXTCTRL|wx.FLP_SMALL, |
3859 | + wildcard="Rom files (*.rom)|*.rom", message="Select object's rom file") | ||
3827 | #self.dir_probe.Bind(wx.EVT_FILEPICKER_CHANGED, self.Selected) | 3860 | #self.dir_probe.Bind(wx.EVT_FILEPICKER_CHANGED, self.Selected) |
3828 | row_obj = wx.BoxSizer(wx.VERTICAL) | 3861 | row_obj = wx.BoxSizer(wx.VERTICAL) |
3829 | row_obj.Add(wx.StaticText(self, wx.ID_ANY, "Set object's rom file"), 0, wx.TOP|wx.RIGHT, 5) | 3862 | row_obj.Add(wx.StaticText(self, wx.ID_ANY, "Set object's rom file"), 0, wx.TOP|wx.RIGHT, 5) |
3830 | row_obj.Add(self.dir_obj, 0, wx.EXPAND|wx.ALIGN_CENTER) | 3863 | row_obj.Add(self.dir_obj, 0, wx.EXPAND|wx.ALIGN_CENTER) |
3831 | 3864 | ||
3832 | - # self.goto_orientation.SetSelection(cb_init) | ||
3833 | - | ||
3834 | btn_ok = wx.Button(self, wx.ID_OK) | 3865 | btn_ok = wx.Button(self, wx.ID_OK) |
3835 | btn_ok.SetHelpText("") | 3866 | btn_ok.SetHelpText("") |
3836 | btn_ok.SetDefault() | 3867 | btn_ok.SetDefault() |
@@ -3863,10 +3894,19 @@ class SetNDIconfigs(wx.Dialog): | @@ -3863,10 +3894,19 @@ class SetNDIconfigs(wx.Dialog): | ||
3863 | self.CenterOnParent() | 3894 | self.CenterOnParent() |
3864 | 3895 | ||
3865 | def GetValue(self): | 3896 | def GetValue(self): |
3866 | - return self.com_ports.GetString(self.com_ports.GetSelection()).encode(const.FS_ENCODE), \ | ||
3867 | - self.dir_probe.GetPath().encode(const.FS_ENCODE),\ | ||
3868 | - self.dir_ref.GetPath().encode(const.FS_ENCODE), \ | ||
3869 | - self.dir_obj.GetPath().encode(const.FS_ENCODE) | 3897 | + fn_probe = self.dir_probe.GetPath().encode(const.FS_ENCODE) |
3898 | + fn_ref = self.dir_ref.GetPath().encode(const.FS_ENCODE) | ||
3899 | + fn_obj = self.dir_obj.GetPath().encode(const.FS_ENCODE) | ||
3900 | + | ||
3901 | + if fn_probe and fn_ref and fn_obj: | ||
3902 | + session = ses.Session() | ||
3903 | + session['paths']['last_ndi_probe_marker'] = self.dir_probe.GetPath() | ||
3904 | + session['paths']['last_ndi_ref_marker'] = self.dir_ref.GetPath() | ||
3905 | + session['paths']['last_ndi_obj_marker'] = self.dir_obj.GetPath() | ||
3906 | + session.WriteSessionFile() | ||
3907 | + | ||
3908 | + return self.com_ports.GetString(self.com_ports.GetSelection()).encode(const.FS_ENCODE), fn_probe, fn_ref, fn_obj | ||
3909 | + | ||
3870 | 3910 | ||
3871 | class SetCOMport(wx.Dialog): | 3911 | class SetCOMport(wx.Dialog): |
3872 | def __init__(self, title=_("Select COM port")): | 3912 | def __init__(self, title=_("Select COM port")): |
invesalius/gui/task_navigator.py
@@ -229,18 +229,16 @@ class InnerFoldPanel(wx.Panel): | @@ -229,18 +229,16 @@ class InnerFoldPanel(wx.Panel): | ||
229 | def __bind_events(self): | 229 | def __bind_events(self): |
230 | Publisher.subscribe(self.OnCheckStatus, 'Navigation status') | 230 | Publisher.subscribe(self.OnCheckStatus, 'Navigation status') |
231 | Publisher.subscribe(self.OnShowObject, 'Update track object state') | 231 | Publisher.subscribe(self.OnShowObject, 'Update track object state') |
232 | - Publisher.subscribe(self.OnVolumeCamera, 'Target navigation mode') | 232 | + Publisher.subscribe(self.OnVolumeCamera, 'Change camera checkbox') |
233 | Publisher.subscribe(self.OnShowDbs, "Active dbs folder") | 233 | Publisher.subscribe(self.OnShowDbs, "Active dbs folder") |
234 | Publisher.subscribe(self.OnHideDbs, "Deactive dbs folder") | 234 | Publisher.subscribe(self.OnHideDbs, "Deactive dbs folder") |
235 | 235 | ||
236 | def OnShowDbs(self): | 236 | def OnShowDbs(self): |
237 | self.dbs_item.Show() | 237 | self.dbs_item.Show() |
238 | 238 | ||
239 | - | ||
240 | def OnHideDbs(self): | 239 | def OnHideDbs(self): |
241 | self.dbs_item.Hide() | 240 | self.dbs_item.Hide() |
242 | 241 | ||
243 | - | ||
244 | def OnCheckStatus(self, status): | 242 | def OnCheckStatus(self, status): |
245 | if status: | 243 | if status: |
246 | self.checktrigger.Enable(False) | 244 | self.checktrigger.Enable(False) |
@@ -257,6 +255,7 @@ class InnerFoldPanel(wx.Panel): | @@ -257,6 +255,7 @@ class InnerFoldPanel(wx.Panel): | ||
257 | if not evt: | 255 | if not evt: |
258 | if flag: | 256 | if flag: |
259 | self.checkobj.Enable(True) | 257 | self.checkobj.Enable(True) |
258 | + self.checkobj.SetValue(True) | ||
260 | self.track_obj = True | 259 | self.track_obj = True |
261 | Publisher.sendMessage('Status target button', status=True) | 260 | Publisher.sendMessage('Status target button', status=True) |
262 | else: | 261 | else: |
@@ -267,12 +266,12 @@ class InnerFoldPanel(wx.Panel): | @@ -267,12 +266,12 @@ class InnerFoldPanel(wx.Panel): | ||
267 | 266 | ||
268 | Publisher.sendMessage('Update show object state', state=self.checkobj.GetValue()) | 267 | Publisher.sendMessage('Update show object state', state=self.checkobj.GetValue()) |
269 | 268 | ||
270 | - def OnVolumeCamera(self, evt=None, target_mode=None): | 269 | + def OnVolumeCamera(self, evt=None, status=None): |
271 | if not evt: | 270 | if not evt: |
272 | - if target_mode is True: | ||
273 | - self.checkcamera.SetValue(0) | 271 | + self.checkcamera.SetValue(status) |
274 | Publisher.sendMessage('Update volume camera state', camera_state=self.checkcamera.GetValue()) | 272 | Publisher.sendMessage('Update volume camera state', camera_state=self.checkcamera.GetValue()) |
275 | 273 | ||
274 | + | ||
276 | class NeuronavigationPanel(wx.Panel): | 275 | class NeuronavigationPanel(wx.Panel): |
277 | def __init__(self, parent): | 276 | def __init__(self, parent): |
278 | wx.Panel.__init__(self, parent) | 277 | wx.Panel.__init__(self, parent) |
@@ -890,6 +889,10 @@ class ObjectRegistrationPanel(wx.Panel): | @@ -890,6 +889,10 @@ class ObjectRegistrationPanel(wx.Panel): | ||
890 | data=(self.obj_fiducials, self.obj_orients, self.obj_ref_mode, self.obj_name)) | 889 | data=(self.obj_fiducials, self.obj_orients, self.obj_ref_mode, self.obj_name)) |
891 | Publisher.sendMessage('Update status text in GUI', | 890 | Publisher.sendMessage('Update status text in GUI', |
892 | label=_("Ready")) | 891 | label=_("Ready")) |
892 | + # Enable automatically Track object, Show coil and disable Vol. Camera | ||
893 | + self.checktrack.SetValue(True) | ||
894 | + Publisher.sendMessage('Update track object state', flag=True, obj_name=self.obj_name) | ||
895 | + Publisher.sendMessage('Change camera checkbox', status=False) | ||
893 | 896 | ||
894 | except wx._core.PyAssertionError: # TODO FIX: win64 | 897 | except wx._core.PyAssertionError: # TODO FIX: win64 |
895 | pass | 898 | pass |
@@ -916,6 +919,9 @@ class ObjectRegistrationPanel(wx.Panel): | @@ -916,6 +919,9 @@ class ObjectRegistrationPanel(wx.Panel): | ||
916 | Publisher.sendMessage('Update object registration', | 919 | Publisher.sendMessage('Update object registration', |
917 | data=(self.obj_fiducials, self.obj_orients, self.obj_ref_mode, self.obj_name)) | 920 | data=(self.obj_fiducials, self.obj_orients, self.obj_ref_mode, self.obj_name)) |
918 | Publisher.sendMessage('Update status text in GUI', label=_("Ready")) | 921 | Publisher.sendMessage('Update status text in GUI', label=_("Ready")) |
922 | + self.checktrack.SetValue(True) | ||
923 | + Publisher.sendMessage('Update track object state', flag=True, obj_name=self.obj_name) | ||
924 | + Publisher.sendMessage('Change camera checkbox', status=False) | ||
919 | wx.MessageBox(_("Object file successfully loaded"), _("Load")) | 925 | wx.MessageBox(_("Object file successfully loaded"), _("Load")) |
920 | 926 | ||
921 | def ShowSaveObjectDialog(self, evt): | 927 | def ShowSaveObjectDialog(self, evt): |
@@ -963,8 +969,8 @@ class MarkersPanel(wx.Panel): | @@ -963,8 +969,8 @@ class MarkersPanel(wx.Panel): | ||
963 | self.tgt_flag = self.tgt_index = None | 969 | self.tgt_flag = self.tgt_index = None |
964 | self.nav_status = False | 970 | self.nav_status = False |
965 | 971 | ||
966 | - self.marker_colour = (0.0, 0.0, 1.) | ||
967 | - self.marker_size = 4 | 972 | + self.marker_colour = (1.0, 1.0, 0.) |
973 | + self.marker_size = 3 | ||
968 | 974 | ||
969 | # Change marker size | 975 | # Change marker size |
970 | spin_size = wx.SpinCtrl(self, -1, "", size=wx.Size(40, 23)) | 976 | spin_size = wx.SpinCtrl(self, -1, "", size=wx.Size(40, 23)) |
@@ -1058,9 +1064,7 @@ class MarkersPanel(wx.Panel): | @@ -1058,9 +1064,7 @@ class MarkersPanel(wx.Panel): | ||
1058 | self.nav_status = True | 1064 | self.nav_status = True |
1059 | 1065 | ||
1060 | def OnMouseRightDown(self, evt): | 1066 | def OnMouseRightDown(self, evt): |
1061 | - self.OnListEditMarkerId(self.nav_status) | ||
1062 | - | ||
1063 | - def OnListEditMarkerId(self, status): | 1067 | + # TODO: Enable the "Set as target" only when target is created with registered object |
1064 | menu_id = wx.Menu() | 1068 | menu_id = wx.Menu() |
1065 | edit_id = menu_id.Append(0, _('Edit ID')) | 1069 | edit_id = menu_id.Append(0, _('Edit ID')) |
1066 | menu_id.Bind(wx.EVT_MENU, self.OnMenuEditMarkerId, edit_id) | 1070 | menu_id.Bind(wx.EVT_MENU, self.OnMenuEditMarkerId, edit_id) |
@@ -1070,7 +1074,7 @@ class MarkersPanel(wx.Panel): | @@ -1070,7 +1074,7 @@ class MarkersPanel(wx.Panel): | ||
1070 | target_menu = menu_id.Append(1, _('Set as target')) | 1074 | target_menu = menu_id.Append(1, _('Set as target')) |
1071 | menu_id.Bind(wx.EVT_MENU, self.OnMenuSetTarget, target_menu) | 1075 | menu_id.Bind(wx.EVT_MENU, self.OnMenuSetTarget, target_menu) |
1072 | 1076 | ||
1073 | - target_menu.Enable(status) | 1077 | + target_menu.Enable(True) |
1074 | self.PopupMenu(menu_id) | 1078 | self.PopupMenu(menu_id) |
1075 | menu_id.Destroy() | 1079 | menu_id.Destroy() |
1076 | 1080 |