Commit 338470d1b2bb38b1e901b053d0a96808ae0842c5
1 parent
d996d582
Exists in
master
and in
68 other branches
ADD: Pseudo colors
Showing
1 changed file
with
36 additions
and
9 deletions
Show diff stats
invesalius/gui/widgets/slice_menu.py
... | ... | @@ -29,24 +29,51 @@ class SliceMenu(wx.Menu): |
29 | 29 | def __init__(self): |
30 | 30 | wx.Menu.__init__(self) |
31 | 31 | self.ID_TO_TOOL_ITEM = {} |
32 | + new_id = 0 | |
33 | + | |
32 | 34 | submenu_wl = wx.Menu() |
33 | 35 | for name in sorted(const.WINDOW_LEVEL): |
34 | - new_id = wx.NewId() | |
35 | 36 | wl_item = wx.MenuItem(submenu_wl, new_id,\ |
36 | 37 | name, kind=wx.ITEM_RADIO) |
37 | 38 | submenu_wl.AppendItem(wl_item) |
38 | 39 | self.ID_TO_TOOL_ITEM[new_id] = name |
40 | + new_id += 1 | |
41 | + | |
42 | + submenu_pseudo_colors = wx.Menu() | |
43 | + for name in sorted(const.SLICE_COLOR_TABLE): | |
44 | + new_id += 1 | |
45 | + color_item = wx.MenuItem(submenu_wl, new_id,\ | |
46 | + name, kind=wx.ITEM_RADIO) | |
47 | + submenu_pseudo_colors.AppendItem(color_item) | |
48 | + self.ID_TO_TOOL_ITEM[new_id] = name | |
49 | + | |
39 | 50 | self.AppendMenu(-1, "Window Width & Level", submenu_wl) |
51 | + self.AppendMenu(-1, "Pseudo Colors", submenu_pseudo_colors) | |
52 | + | |
40 | 53 | # It doesn't work in Linux |
41 | - self.Bind(wx.EVT_MENU, self.OnPopupWindowLevel) | |
54 | + self.Bind(wx.EVT_MENU, self.OnPopup) | |
42 | 55 | # In Linux the bind must be putted in the submenu |
43 | 56 | if sys.platform == 'linux2': |
44 | - submenu_wl.Bind(wx.EVT_MENU, self.OnPopupWindowLevel) | |
45 | - | |
46 | - def OnPopupWindowLevel(self, evt): | |
57 | + submenu_wl.Bind(wx.EVT_MENU, self.OnPopup) | |
58 | + submenu_pseudo_colors.Bind(wx.EVT_MENU, self.OnPopup) | |
59 | + | |
60 | + def OnPopup(self, evt): | |
61 | + | |
62 | + id = evt.GetId() | |
47 | 63 | key = self.ID_TO_TOOL_ITEM[evt.GetId()] |
48 | - window, level = const.WINDOW_LEVEL[key] | |
49 | - ps.Publisher().sendMessage('Bright and contrast adjustment image', | |
50 | - (window, level)) | |
51 | - ps.Publisher().sendMessage('Update slice viewer') | |
64 | + | |
65 | + if (id <= len(const.WINDOW_LEVEL)): | |
66 | + window, level = const.WINDOW_LEVEL[key] | |
67 | + ps.Publisher().sendMessage('Bright and contrast adjustment image', | |
68 | + (window, level)) | |
69 | + ps.Publisher().sendMessage('Update slice viewer') | |
70 | + | |
71 | + elif(id > len(const.WINDOW_LEVEL) and\ | |
72 | + (id <= len(const.SLICE_COLOR_TABLE) + len(const.WINDOW_LEVEL))): | |
73 | + values = const.SLICE_COLOR_TABLE[key] | |
74 | + | |
75 | + ps.Publisher().sendMessage('Change color table from background image', values) | |
76 | + ps.Publisher().sendMessage('Update slice viewer') | |
77 | + | |
52 | 78 | evt.Skip() |
79 | + | ... | ... |