Commit 9bbd13653e18798d01156585746925c6cb4f5928
1 parent
d72423d8
Exists in
master
and in
68 other branches
ENH: Redesigned way to store the values of window and level
Showing
2 changed files
with
19 additions
and
13 deletions
Show diff stats
invesalius/control.py
@@ -79,6 +79,9 @@ class Controller(): | @@ -79,6 +79,9 @@ class Controller(): | ||
79 | proj.window = window = const.WINDOW_LEVEL['Bone'][0] | 79 | proj.window = window = const.WINDOW_LEVEL['Bone'][0] |
80 | proj.level = level = const.WINDOW_LEVEL['Bone'][1] | 80 | proj.level = level = const.WINDOW_LEVEL['Bone'][1] |
81 | 81 | ||
82 | + ps.Publisher().sendMessage('Update window level value',\ | ||
83 | + (proj.window, proj.level)) | ||
84 | + | ||
82 | if not imagedata: | 85 | if not imagedata: |
83 | print "Sorry, but there are no medical images supported on this dir." | 86 | print "Sorry, but there are no medical images supported on this dir." |
84 | else: | 87 | else: |
@@ -86,9 +89,9 @@ class Controller(): | @@ -86,9 +89,9 @@ class Controller(): | ||
86 | proj.SetAcquisitionModality(acquisition_modality) | 89 | proj.SetAcquisitionModality(acquisition_modality) |
87 | proj.imagedata = imagedata | 90 | proj.imagedata = imagedata |
88 | proj.original_orientation = orientation | 91 | proj.original_orientation = orientation |
89 | - proj.window = float(window) | ||
90 | - proj.level = float(level) | ||
91 | - | 92 | + proj.window = window = float(window) |
93 | + proj.level = level = float(level) | ||
94 | + | ||
92 | 95 | ||
93 | threshold_range = proj.imagedata.GetScalarRange() | 96 | threshold_range = proj.imagedata.GetScalarRange() |
94 | const.THRESHOLD_OUTVALUE = threshold_range[0] | 97 | const.THRESHOLD_OUTVALUE = threshold_range[0] |
@@ -103,6 +106,9 @@ class Controller(): | @@ -103,6 +106,9 @@ class Controller(): | ||
103 | #Initial Window and Level | 106 | #Initial Window and Level |
104 | ps.Publisher().sendMessage('Bright and contrast adjustment image',\ | 107 | ps.Publisher().sendMessage('Bright and contrast adjustment image',\ |
105 | (proj.window, proj.level)) | 108 | (proj.window, proj.level)) |
109 | + | ||
110 | + ps.Publisher().sendMessage('Update window level value',\ | ||
111 | + (proj.window, proj.level)) | ||
106 | 112 | ||
107 | # Call frame so it shows slice and volume related panels | 113 | # Call frame so it shows slice and volume related panels |
108 | ps.Publisher().sendMessage('Show content panel') | 114 | ps.Publisher().sendMessage('Show content panel') |
invesalius/data/viewer_slice.py
@@ -226,24 +226,24 @@ class Viewer(wx.Panel): | @@ -226,24 +226,24 @@ class Viewer(wx.Panel): | ||
226 | self.acum_achange_level += mouse_y - self.last_y | 226 | self.acum_achange_level += mouse_y - self.last_y |
227 | self.last_x, self.last_y = mouse_x, mouse_y | 227 | self.last_x, self.last_y = mouse_x, mouse_y |
228 | 228 | ||
229 | - proj = project.Project() | ||
230 | - proj.window = self.acum_achange_window | ||
231 | - proj.level = self.acum_achange_level | ||
232 | - | ||
233 | ps.Publisher().sendMessage('Bright and contrast adjustment image', | 229 | ps.Publisher().sendMessage('Bright and contrast adjustment image', |
234 | - (proj.window, proj.level)) | 230 | + (self.acum_achange_window, self.acum_achange_level)) |
235 | 231 | ||
236 | ps.Publisher().sendMessage('Update window and level text',\ | 232 | ps.Publisher().sendMessage('Update window and level text',\ |
237 | - "WL: %d WW: %d"%(proj.level, proj.window)) | 233 | + "WL: %d WW: %d"%(self.acum_achange_window,\ |
234 | + self.acum_achange_level)) | ||
238 | self.interactor.Render() | 235 | self.interactor.Render() |
239 | 236 | ||
240 | 237 | ||
241 | def OnWindowLevelClick(self, evt, obj): | 238 | def OnWindowLevelClick(self, evt, obj): |
242 | - proj = project.Project() | ||
243 | - self.acum_achange_window, self.acum_achange_level = (proj.window, proj.level) | ||
244 | self.last_x, self.last_y = self.interactor.GetLastEventPosition() | 239 | self.last_x, self.last_y = self.interactor.GetLastEventPosition() |
245 | self.mouse_pressed = 1 | 240 | self.mouse_pressed = 1 |
246 | 241 | ||
242 | + def UpdateWindowLevelValue(self, pubsub_evt): | ||
243 | + window, level = pubsub_evt.data | ||
244 | + self.acum_achange_window, self.acum_achange_level = (window, level) | ||
245 | + | ||
246 | + | ||
247 | def OnChangeSliceMove(self, evt, obj): | 247 | def OnChangeSliceMove(self, evt, obj): |
248 | 248 | ||
249 | min = 0 | 249 | min = 0 |
@@ -656,8 +656,8 @@ class Viewer(wx.Panel): | @@ -656,8 +656,8 @@ class Viewer(wx.Panel): | ||
656 | #### | 656 | #### |
657 | ps.Publisher().subscribe(self.UpdateText,\ | 657 | ps.Publisher().subscribe(self.UpdateText,\ |
658 | 'Update window and level text') | 658 | 'Update window and level text') |
659 | - #ps.Publisher().subscribe(self.UpdateCkeckPopUpMenu,\ | ||
660 | - # 'Update ckeck popup menu') | 659 | + ps.Publisher().subscribe(self.UpdateWindowLevelValue,\ |
660 | + 'Update window level value') | ||
661 | 661 | ||
662 | def ChangeBrushOperation(self, pubsub_evt): | 662 | def ChangeBrushOperation(self, pubsub_evt): |
663 | print pubsub_evt.data | 663 | print pubsub_evt.data |