Commit 8f2dbda6d199d2dd04218bb9e7a0aca96d2ad966
1 parent
14a26332
Exists in
master
and in
68 other branches
ADD: added part of the code to change window and level image
Showing
1 changed file
with
23 additions
and
5 deletions
Show diff stats
invesalius/data/viewer_slice.py
| ... | ... | @@ -102,7 +102,7 @@ class Viewer(wx.Panel): |
| 102 | 102 | def append_mode(self, mode): |
| 103 | 103 | |
| 104 | 104 | #TODO: Temporary |
| 105 | - #self.modes = [] | |
| 105 | + self.modes = [] | |
| 106 | 106 | |
| 107 | 107 | # Retrieve currently set modes |
| 108 | 108 | self.modes.append(mode) |
| ... | ... | @@ -195,8 +195,8 @@ class Viewer(wx.Panel): |
| 195 | 195 | |
| 196 | 196 | def WindowLevelMode(self, pubsub_evt): |
| 197 | 197 | self.append_mode('WINDOWLEVEL') |
| 198 | - proj = project.Project() | |
| 199 | - self.interactor.Render() | |
| 198 | + self.mouse_pressed = 0 | |
| 199 | + self.interactor.SetCursor(wx.StockCursor(wx.CURSOR_SIZING)) | |
| 200 | 200 | |
| 201 | 201 | def ChangeSliceMode(self, pubsub_evt): |
| 202 | 202 | self.append_mode('CHANGESLICE') |
| ... | ... | @@ -204,10 +204,28 @@ class Viewer(wx.Panel): |
| 204 | 204 | self.interactor.SetCursor(wx.StockCursor(wx.CURSOR_SIZENS)) |
| 205 | 205 | |
| 206 | 206 | def OnWindowLevelMove(self, evt, obj): |
| 207 | - print 'Move...' | |
| 207 | + if self.mouse_pressed: | |
| 208 | + position = self.interactor.GetLastEventPosition() | |
| 209 | + mouse_x, mouse_y = self.interactor.GetEventPosition() | |
| 210 | + self.acum_achange_window += mouse_x - self.last_x | |
| 211 | + self.acum_achange_level += mouse_y - self.last_y | |
| 212 | + self.last_x, self.last_y = mouse_x, mouse_y | |
| 213 | + | |
| 214 | + proj = project.Project() | |
| 215 | + proj.window = self.acum_achange_window | |
| 216 | + proj.level = self.acum_achange_level | |
| 217 | + | |
| 218 | + ps.Publisher().sendMessage('Bright and contrast adjustment image', | |
| 219 | + (proj.window, proj.level)) | |
| 220 | + self.interactor.Render() | |
| 221 | + #ps.Publisher().sendMessage('Update slice viewer') | |
| 222 | + | |
| 208 | 223 | |
| 209 | 224 | def OnWindowLevelClick(self, evt, obj): |
| 210 | - print 'Click' | |
| 225 | + proj = project.Project() | |
| 226 | + self.acum_achange_window, self.acum_achange_level = (proj.window, proj.level) | |
| 227 | + self.last_x, self.last_y = self.interactor.GetLastEventPosition() | |
| 228 | + self.mouse_pressed = 1 | |
| 211 | 229 | |
| 212 | 230 | def OnChangeSliceMove(self, evt, obj): |
| 213 | 231 | ... | ... |