Commit 244981372332711cc3b0e370b3247d73f7fdb549
1 parent
b017bf00
Exists in
master
and in
6 other branches
ADD: Window and level other option
Showing
3 changed files
with
31 additions
and
8 deletions
Show diff stats
invesalius/constants.py
... | ... | @@ -155,6 +155,7 @@ WINDOW_LEVEL = {"Abdomen":(350,50), |
155 | 155 | "Lung - Soft":(1600,-600), |
156 | 156 | "Lung - Hard":(1000,-600), |
157 | 157 | "Mediastinum":(350,25), |
158 | + "Other":(None, None), #Case the user change window and level | |
158 | 159 | "Pelvis": (450,50), |
159 | 160 | "Sinus":(4000, 400), |
160 | 161 | "Vasculature - Hard":(240,80), | ... | ... |
invesalius/control.py
... | ... | @@ -92,6 +92,7 @@ class Controller(): |
92 | 92 | proj.window = window = float(window) |
93 | 93 | proj.level = level = float(level) |
94 | 94 | const.WINDOW_LEVEL['Default'] = (window, level) |
95 | + const.WINDOW_LEVEL['Other'] = (window, level) | |
95 | 96 | |
96 | 97 | threshold_range = proj.imagedata.GetScalarRange() |
97 | 98 | const.THRESHOLD_OUTVALUE = threshold_range[0] |
... | ... | @@ -106,7 +107,7 @@ class Controller(): |
106 | 107 | #Initial Window and Level |
107 | 108 | ps.Publisher().sendMessage('Bright and contrast adjustment image',\ |
108 | 109 | (proj.window, proj.level)) |
109 | - | |
110 | + | |
110 | 111 | ps.Publisher().sendMessage('Update window level value',\ |
111 | 112 | (proj.window, proj.level)) |
112 | 113 | ... | ... |
invesalius/gui/widgets/slice_menu.py
... | ... | @@ -32,18 +32,28 @@ class SliceMenu(wx.Menu): |
32 | 32 | |
33 | 33 | #------------ Sub menu of the window and level ---------- |
34 | 34 | submenu_wl = wx.Menu() |
35 | + | |
36 | + #Window and level from DICOM | |
35 | 37 | new_id = wx.NewId() |
36 | 38 | wl_item = wx.MenuItem(submenu_wl, new_id,\ |
37 | 39 | 'Default', kind=wx.ITEM_RADIO) |
38 | 40 | submenu_wl.AppendItem(wl_item) |
39 | - self.ID_TO_TOOL_ITEM[new_id] = 'Default' | |
41 | + self.ID_TO_TOOL_ITEM[new_id] = wl_item | |
42 | + | |
43 | + #Case the user change window and level | |
44 | + new_id = self.other_wl_id = wx.NewId() | |
45 | + wl_item = wx.MenuItem(submenu_wl, new_id,\ | |
46 | + 'Other', kind=wx.ITEM_RADIO) | |
47 | + submenu_wl.AppendItem(wl_item) | |
48 | + self.ID_TO_TOOL_ITEM[new_id] = wl_item | |
49 | + | |
40 | 50 | for name in sorted(const.WINDOW_LEVEL): |
41 | - if not(name == 'Default'): | |
51 | + if not(name == 'Default' or name == 'Other'): | |
42 | 52 | new_id = wx.NewId() |
43 | 53 | wl_item = wx.MenuItem(submenu_wl, new_id,\ |
44 | 54 | name, kind=wx.ITEM_RADIO) |
45 | 55 | submenu_wl.AppendItem(wl_item) |
46 | - self.ID_TO_TOOL_ITEM[new_id] = name | |
56 | + self.ID_TO_TOOL_ITEM[new_id] = wl_item | |
47 | 57 | |
48 | 58 | #------------ Sub menu of the pseudo colors ------------- |
49 | 59 | submenu_pseudo_colours = wx.Menu() |
... | ... | @@ -51,14 +61,15 @@ class SliceMenu(wx.Menu): |
51 | 61 | color_item = wx.MenuItem(submenu_pseudo_colours, new_id,\ |
52 | 62 | 'Default ', kind=wx.ITEM_RADIO) |
53 | 63 | submenu_pseudo_colours.AppendItem(color_item) |
54 | - self.ID_TO_TOOL_ITEM[new_id] = 'Default ' | |
64 | + self.ID_TO_TOOL_ITEM[new_id] = color_item | |
65 | + | |
55 | 66 | for name in sorted(const.SLICE_COLOR_TABLE): |
56 | 67 | if not(name == 'Default '): |
57 | 68 | new_id = wx.NewId() |
58 | 69 | color_item = wx.MenuItem(submenu_wl, new_id,\ |
59 | 70 | name, kind=wx.ITEM_RADIO) |
60 | 71 | submenu_pseudo_colours.AppendItem(color_item) |
61 | - self.ID_TO_TOOL_ITEM[new_id] = name | |
72 | + self.ID_TO_TOOL_ITEM[new_id] = color_item | |
62 | 73 | |
63 | 74 | #------------ Sub menu of the image tiling --------------- |
64 | 75 | submenu_image_tiling = wx.Menu() |
... | ... | @@ -67,7 +78,7 @@ class SliceMenu(wx.Menu): |
67 | 78 | image_tiling_item = wx.MenuItem(submenu_image_tiling, new_id,\ |
68 | 79 | name, kind=wx.ITEM_RADIO) |
69 | 80 | submenu_image_tiling.AppendItem(image_tiling_item) |
70 | - self.ID_TO_TOOL_ITEM[new_id] = name | |
81 | + self.ID_TO_TOOL_ITEM[new_id] = image_tiling_item | |
71 | 82 | |
72 | 83 | # Add sub itens in the menu |
73 | 84 | self.AppendMenu(-1, "Window Width and Level", submenu_wl) |
... | ... | @@ -82,10 +93,20 @@ class SliceMenu(wx.Menu): |
82 | 93 | submenu_pseudo_colours.Bind(wx.EVT_MENU, self.OnPopup) |
83 | 94 | submenu_image_tiling.Bind(wx.EVT_MENU, self.OnPopup) |
84 | 95 | |
96 | + self.__bind_events() | |
97 | + | |
98 | + def __bind_events(self): | |
99 | + ps.Publisher().subscribe(self.CheckWindowLevelOther, 'Check window and level other') | |
100 | + | |
101 | + def CheckWindowLevelOther(self, pubsub_evt): | |
102 | + item = self.ID_TO_TOOL_ITEM[self.other_wl_id] | |
103 | + item.Check() | |
104 | + | |
85 | 105 | def OnPopup(self, evt): |
86 | 106 | |
87 | 107 | id = evt.GetId() |
88 | - key = self.ID_TO_TOOL_ITEM[evt.GetId()] | |
108 | + item = self.ID_TO_TOOL_ITEM[evt.GetId()] | |
109 | + key = item.GetLabel() | |
89 | 110 | |
90 | 111 | if(key in const.WINDOW_LEVEL.keys()): |
91 | 112 | window, level = const.WINDOW_LEVEL[key] | ... | ... |