Commit 298539e5125a90407f2f4b550efe619e2e0bf294
Committed by
Thiago Franco de Moraes
1 parent
9aa5db75
Exists in
master
and in
10 other branches
Menu enable navigation (#72)
Created a mode menu, whose is possible to actived navigation mode. -This menu was based on view menu. -Once the navigation fold_panel is created the navigation mode button just show/hide the fold_panel. -If mode config file is set 0 the navigation mode item is unchecked, if is set 1 the navigation mode item is checked. -If navigation is ON the navigation mode button is disable. -Navigation mode restricted to windows platform
Showing
4 changed files
with
87 additions
and
2 deletions
Show diff stats
invesalius/constants.py
... | ... | @@ -488,8 +488,8 @@ VTK_WARNING = 0 |
488 | 488 | [ID_DICOM_IMPORT, ID_PROJECT_OPEN, ID_PROJECT_SAVE_AS, ID_PROJECT_SAVE, |
489 | 489 | ID_PROJECT_CLOSE, ID_PROJECT_INFO, ID_SAVE_SCREENSHOT, ID_DICOM_LOAD_NET, |
490 | 490 | ID_PRINT_SCREENSHOT, ID_IMPORT_OTHERS_FILES, ID_PREFERENCES, ID_DICOM_NETWORK, |
491 | -ID_TIFF_JPG_PNG, ID_VIEW_INTERPOLATED, ID_ANALYZE_IMPORT, ID_NIFTI_IMPORT, | |
492 | -ID_PARREC_IMPORT] = [wx.NewId() for number in range(17)] | |
491 | +ID_TIFF_JPG_PNG, ID_VIEW_INTERPOLATED, ID_MODE_NAVIGATION, ID_ANALYZE_IMPORT, | |
492 | +ID_NIFTI_IMPORT, ID_PARREC_IMPORT] = [wx.NewId() for number in range(18)] | |
493 | 493 | ID_EXIT = wx.ID_EXIT |
494 | 494 | ID_ABOUT = wx.ID_ABOUT |
495 | 495 | ... | ... |
invesalius/gui/default_tasks.py
... | ... | @@ -284,9 +284,11 @@ class UpperTaskPanel(wx.Panel): |
284 | 284 | |
285 | 285 | fold_panel.Expand(fold_panel.GetFoldPanel(0)) |
286 | 286 | self.fold_panel = fold_panel |
287 | + self.image_list = image_list | |
287 | 288 | |
288 | 289 | sizer = wx.BoxSizer(wx.VERTICAL) |
289 | 290 | sizer.Add(fold_panel, 1, wx.GROW|wx.EXPAND) |
291 | + self.sizer = sizer | |
290 | 292 | self.SetSizerAndFit(sizer) |
291 | 293 | |
292 | 294 | self.SetStateProjectClose() |
... | ... | @@ -298,6 +300,7 @@ class UpperTaskPanel(wx.Panel): |
298 | 300 | Publisher.subscribe(self.OnOverwrite, 'Create surface from index') |
299 | 301 | Publisher.subscribe(self.OnFoldSurface, 'Fold surface task') |
300 | 302 | Publisher.subscribe(self.OnFoldExport, 'Fold export task') |
303 | + Publisher.subscribe(self.SetNavigationMode, "Set navigation mode") | |
301 | 304 | |
302 | 305 | def OnOverwrite(self, pubsub_evt): |
303 | 306 | self.overwrite = pubsub_evt.data['options']['overwrite'] |
... | ... | @@ -316,6 +319,37 @@ class UpperTaskPanel(wx.Panel): |
316 | 319 | else: |
317 | 320 | self.SetStateProjectClose() |
318 | 321 | |
322 | + def SetNavigationMode(self, pubsub_evt): | |
323 | + self.navigation_mode_status = status = pubsub_evt.data | |
324 | + name = _("Navigation system") | |
325 | + panel = navigator.TaskPanel | |
326 | + if status and (self.fold_panel.GetCount()<=4): | |
327 | + # Create panel | |
328 | + item = self.fold_panel.AddFoldPanel("%d. %s"%(5, name), | |
329 | + collapsed=True, | |
330 | + foldIcons=self.image_list) | |
331 | + style = self.fold_panel.GetCaptionStyle(item) | |
332 | + col = style.GetFirstColour() | |
333 | + | |
334 | + # Add panel to FoldPanel | |
335 | + self.fold_panel.AddFoldPanelWindow(item, | |
336 | + panel(item), | |
337 | + #Spacing=0, | |
338 | + leftSpacing=0, | |
339 | + rightSpacing=0) | |
340 | + self.enable_items.append(item) | |
341 | + if not self.fold_panel.GetFoldPanel(2).IsEnabled(): | |
342 | + item.Disable() | |
343 | + | |
344 | + elif status and (self.fold_panel.GetCount()>4): | |
345 | + self.fold_panel.GetFoldPanel(4).Show() | |
346 | + | |
347 | + else: | |
348 | + self.fold_panel.GetFoldPanel(4).Hide() | |
349 | + self.sizer.Layout() | |
350 | + | |
351 | + | |
352 | + | |
319 | 353 | def SetStateProjectClose(self): |
320 | 354 | self.fold_panel.Expand(self.fold_panel.GetFoldPanel(0)) |
321 | 355 | for item in self.enable_items: | ... | ... |
invesalius/gui/frame.py
... | ... | @@ -94,11 +94,13 @@ class Frame(wx.Frame): |
94 | 94 | self.SetSize(self.GetSize()) |
95 | 95 | #self.SetSize(wx.Size(1024, 748)) |
96 | 96 | |
97 | + self._show_navigator_message = True | |
97 | 98 | |
98 | 99 | #to control check and unckeck of menu view -> interpolated_slices |
99 | 100 | main_menu = MenuBar(self) |
100 | 101 | |
101 | 102 | self.actived_interpolated_slices = main_menu.view_menu |
103 | + self.actived_navigation_mode = main_menu.mode_menu | |
102 | 104 | |
103 | 105 | # Set menus, status and task bar |
104 | 106 | self.SetMenuBar(main_menu) |
... | ... | @@ -467,12 +469,22 @@ class Frame(wx.Frame): |
467 | 469 | self.OnInterpolatedSlices(True) |
468 | 470 | else: |
469 | 471 | self.OnInterpolatedSlices(False) |
472 | + | |
473 | + elif id == const.ID_MODE_NAVIGATION: | |
474 | + st = self.actived_navigation_mode.IsChecked(const.ID_MODE_NAVIGATION) | |
475 | + self.OnNavigationMode(st) | |
476 | + | |
470 | 477 | elif id == const.ID_CROP_MASK: |
471 | 478 | self.OnCropMask() |
472 | 479 | |
473 | 480 | def OnInterpolatedSlices(self, status): |
474 | 481 | Publisher.sendMessage('Set interpolated slices', status) |
475 | 482 | |
483 | + def OnNavigationMode(self, status): | |
484 | + if status and self._show_navigator_message and sys.platform != 'win32': | |
485 | + wx.MessageBox(_('Currently the Navigation mode is only working on Windows'), 'Info', wx.OK | wx.ICON_INFORMATION) | |
486 | + self._show_navigator_message = False | |
487 | + Publisher.sendMessage('Set navigation mode', status) | |
476 | 488 | |
477 | 489 | def OnSize(self, evt): |
478 | 490 | """ |
... | ... | @@ -513,6 +525,7 @@ class Frame(wx.Frame): |
513 | 525 | Publisher.sendMessage('Reset Reaycasting') |
514 | 526 | Publisher.sendMessage('Update Slice Interpolation') |
515 | 527 | Publisher.sendMessage('Update Slice Interpolation MenuBar') |
528 | + Publisher.sendMessage('Update Navigation Mode MenuBar') | |
516 | 529 | Publisher.sendMessage('Update Surface Interpolation') |
517 | 530 | |
518 | 531 | def ShowAbout(self): |
... | ... | @@ -660,11 +673,13 @@ class MenuBar(wx.MenuBar): |
660 | 673 | sub(self.OnEnableState, "Enable state project") |
661 | 674 | sub(self.OnEnableUndo, "Enable undo") |
662 | 675 | sub(self.OnEnableRedo, "Enable redo") |
676 | + sub(self.OnEnableNavigation, "Navigation Status") | |
663 | 677 | |
664 | 678 | sub(self.OnAddMask, "Add mask") |
665 | 679 | sub(self.OnRemoveMasks, "Remove masks") |
666 | 680 | sub(self.OnShowMask, "Show mask") |
667 | 681 | sub(self.OnUpdateSliceInterpolation, "Update Slice Interpolation MenuBar") |
682 | + sub(self.OnUpdateNavigationMode, "Update Navigation Mode MenuBar") | |
668 | 683 | |
669 | 684 | self.num_masks = 0 |
670 | 685 | |
... | ... | @@ -835,6 +850,15 @@ class MenuBar(wx.MenuBar): |
835 | 850 | options_menu = wx.Menu() |
836 | 851 | options_menu.Append(const.ID_PREFERENCES, _("Preferences...")) |
837 | 852 | |
853 | + #Mode | |
854 | + self.mode_menu = mode_menu = wx.Menu() | |
855 | + mode_menu.Append(const.ID_MODE_NAVIGATION, _(u'Navigation mode'), "", wx.ITEM_CHECK) | |
856 | + | |
857 | + v = self.NavigationModeStatus() | |
858 | + self.mode_menu.Check(const.ID_MODE_NAVIGATION, v) | |
859 | + | |
860 | + self.actived_navigation_mode = self.mode_menu | |
861 | + | |
838 | 862 | # HELP |
839 | 863 | help_menu = wx.Menu() |
840 | 864 | help_menu.Append(const.ID_START, _("Getting started...")) |
... | ... | @@ -854,6 +878,7 @@ class MenuBar(wx.MenuBar): |
854 | 878 | self.Append(tools_menu, _(u"Tools")) |
855 | 879 | #self.Append(tools_menu, "Tools") |
856 | 880 | self.Append(options_menu, _("Options")) |
881 | + self.Append(mode_menu, _("Mode")) | |
857 | 882 | self.Append(help_menu, _("Help")) |
858 | 883 | |
859 | 884 | |
... | ... | @@ -868,10 +893,21 @@ class MenuBar(wx.MenuBar): |
868 | 893 | |
869 | 894 | return v |
870 | 895 | |
896 | + def NavigationModeStatus(self): | |
897 | + status = int(ses.Session().mode) | |
898 | + | |
899 | + if status == 1: | |
900 | + return True | |
901 | + else: | |
902 | + return False | |
903 | + | |
871 | 904 | def OnUpdateSliceInterpolation(self, pubsub_evt): |
872 | 905 | v = self.SliceInterpolationStatus() |
873 | 906 | self.view_menu.Check(const.ID_VIEW_INTERPOLATED, v) |
874 | 907 | |
908 | + def OnUpdateNavigationMode(self, pubsub_evt): | |
909 | + v = self.NavigationModeStatus() | |
910 | + self.mode_menu.Check(const.ID_MODE_NAVIGATION, v) | |
875 | 911 | |
876 | 912 | def OnEnableState(self, pubsub_evt): |
877 | 913 | """ |
... | ... | @@ -912,6 +948,17 @@ class MenuBar(wx.MenuBar): |
912 | 948 | else: |
913 | 949 | self.FindItemById(wx.ID_REDO).Enable(False) |
914 | 950 | |
951 | + def OnEnableNavigation(self, pubsub_evt): | |
952 | + """ | |
953 | + Disable mode menu when navigation is on. | |
954 | + :param pubsub_evt: Navigation status | |
955 | + """ | |
956 | + value = pubsub_evt.data | |
957 | + if value: | |
958 | + self.FindItemById(const.ID_MODE_NAVIGATION).Enable(False) | |
959 | + else: | |
960 | + self.FindItemById(const.ID_MODE_NAVIGATION).Enable(True) | |
961 | + | |
915 | 962 | def OnAddMask(self, pubsub_evt): |
916 | 963 | self.num_masks += 1 |
917 | 964 | self.bool_op_menu.Enable(self.num_masks >= 2) | ... | ... |
invesalius/gui/task_navigator.py
... | ... | @@ -485,6 +485,8 @@ class NeuronavigationPanel(wx.Panel): |
485 | 485 | if self.trigger_state: |
486 | 486 | self.trigger = trig.Trigger(nav_id) |
487 | 487 | |
488 | + Publisher.sendMessage("Navigation Status", True) | |
489 | + | |
488 | 490 | self.correg = dcr.Coregistration((minv, n, q1, q2), nav_id, tracker_mode) |
489 | 491 | |
490 | 492 | else: |
... | ... | @@ -502,6 +504,8 @@ class NeuronavigationPanel(wx.Panel): |
502 | 504 | |
503 | 505 | self.correg.stop() |
504 | 506 | |
507 | + Publisher.sendMessage("Navigation Status", False) | |
508 | + | |
505 | 509 | def ResetTrackerFiducials(self): |
506 | 510 | for m in range(3, 6): |
507 | 511 | for n in range(0, 3): | ... | ... |