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 | 79 | proj.window = window = const.WINDOW_LEVEL['Bone'][0] |
| 80 | 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 | 85 | if not imagedata: |
| 83 | 86 | print "Sorry, but there are no medical images supported on this dir." |
| 84 | 87 | else: |
| ... | ... | @@ -86,9 +89,9 @@ class Controller(): |
| 86 | 89 | proj.SetAcquisitionModality(acquisition_modality) |
| 87 | 90 | proj.imagedata = imagedata |
| 88 | 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 | 96 | threshold_range = proj.imagedata.GetScalarRange() |
| 94 | 97 | const.THRESHOLD_OUTVALUE = threshold_range[0] |
| ... | ... | @@ -103,6 +106,9 @@ class Controller(): |
| 103 | 106 | #Initial Window and Level |
| 104 | 107 | ps.Publisher().sendMessage('Bright and contrast adjustment image',\ |
| 105 | 108 | (proj.window, proj.level)) |
| 109 | + | |
| 110 | + ps.Publisher().sendMessage('Update window level value',\ | |
| 111 | + (proj.window, proj.level)) | |
| 106 | 112 | |
| 107 | 113 | # Call frame so it shows slice and volume related panels |
| 108 | 114 | ps.Publisher().sendMessage('Show content panel') | ... | ... |
invesalius/data/viewer_slice.py
| ... | ... | @@ -226,24 +226,24 @@ class Viewer(wx.Panel): |
| 226 | 226 | self.acum_achange_level += mouse_y - self.last_y |
| 227 | 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 | 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 | 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 | 235 | self.interactor.Render() |
| 239 | 236 | |
| 240 | 237 | |
| 241 | 238 | def OnWindowLevelClick(self, evt, obj): |
| 242 | - proj = project.Project() | |
| 243 | - self.acum_achange_window, self.acum_achange_level = (proj.window, proj.level) | |
| 244 | 239 | self.last_x, self.last_y = self.interactor.GetLastEventPosition() |
| 245 | 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 | 247 | def OnChangeSliceMove(self, evt, obj): |
| 248 | 248 | |
| 249 | 249 | min = 0 |
| ... | ... | @@ -656,8 +656,8 @@ class Viewer(wx.Panel): |
| 656 | 656 | #### |
| 657 | 657 | ps.Publisher().subscribe(self.UpdateText,\ |
| 658 | 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 | 662 | def ChangeBrushOperation(self, pubsub_evt): |
| 663 | 663 | print pubsub_evt.data | ... | ... |