Commit 93044664a95e9cd5c0deaf3c13aef0988735d1ef
1 parent
af3889aa
Exists in
master
and in
68 other branches
ADD: Window and level text in the 2D
Showing
1 changed file
with
24 additions
and
4 deletions
Show diff stats
invesalius/data/viewer_slice.py
@@ -28,6 +28,7 @@ import data.slice_ as sl | @@ -28,6 +28,7 @@ import data.slice_ as sl | ||
28 | import constants as const | 28 | import constants as const |
29 | import project | 29 | import project |
30 | import cursor_actors as ca | 30 | import cursor_actors as ca |
31 | +import data.vtk_utils as vtku | ||
31 | 32 | ||
32 | from slice_data import SliceData | 33 | from slice_data import SliceData |
33 | 34 | ||
@@ -47,7 +48,7 @@ class Viewer(wx.Panel): | @@ -47,7 +48,7 @@ class Viewer(wx.Panel): | ||
47 | self.slice_data_list = [] | 48 | self.slice_data_list = [] |
48 | # The layout from slice_data, the first is number of cols, the second | 49 | # The layout from slice_data, the first is number of cols, the second |
49 | # is the number of rows | 50 | # is the number of rows |
50 | - self.layout = (2, 2) | 51 | + self.layout = (1, 1) |
51 | 52 | ||
52 | self.__init_gui() | 53 | self.__init_gui() |
53 | 54 | ||
@@ -59,6 +60,7 @@ class Viewer(wx.Panel): | @@ -59,6 +60,7 @@ class Viewer(wx.Panel): | ||
59 | self._brush_cursor_colour = const.BRUSH_COLOUR | 60 | self._brush_cursor_colour = const.BRUSH_COLOUR |
60 | self._brush_cursor_type = const.DEFAULT_BRUSH_OP | 61 | self._brush_cursor_type = const.DEFAULT_BRUSH_OP |
61 | self.cursor = None | 62 | self.cursor = None |
63 | + self.text = None | ||
62 | # VTK pipeline and actors | 64 | # VTK pipeline and actors |
63 | #self.__config_interactor() | 65 | #self.__config_interactor() |
64 | self.pick = vtk.vtkCellPicker() | 66 | self.pick = vtk.vtkCellPicker() |
@@ -197,6 +199,7 @@ class Viewer(wx.Panel): | @@ -197,6 +199,7 @@ class Viewer(wx.Panel): | ||
197 | self.append_mode('WINDOWLEVEL') | 199 | self.append_mode('WINDOWLEVEL') |
198 | self.mouse_pressed = 0 | 200 | self.mouse_pressed = 0 |
199 | self.interactor.SetCursor(wx.StockCursor(wx.CURSOR_SIZING)) | 201 | self.interactor.SetCursor(wx.StockCursor(wx.CURSOR_SIZING)) |
202 | + self.interactor.Render() | ||
200 | 203 | ||
201 | def ChangeSliceMode(self, pubsub_evt): | 204 | def ChangeSliceMode(self, pubsub_evt): |
202 | self.append_mode('CHANGESLICE') | 205 | self.append_mode('CHANGESLICE') |
@@ -218,10 +221,11 @@ class Viewer(wx.Panel): | @@ -218,10 +221,11 @@ class Viewer(wx.Panel): | ||
218 | ps.Publisher().sendMessage('Bright and contrast adjustment image', | 221 | ps.Publisher().sendMessage('Bright and contrast adjustment image', |
219 | (proj.window, proj.level)) | 222 | (proj.window, proj.level)) |
220 | 223 | ||
224 | + ps.Publisher().sendMessage('Update window and level text',\ | ||
225 | + "WL: %d WW: %d"%(proj.level, proj.window)) | ||
221 | self.interactor.Render() | 226 | self.interactor.Render() |
222 | 227 | ||
223 | 228 | ||
224 | - | ||
225 | def OnWindowLevelClick(self, evt, obj): | 229 | def OnWindowLevelClick(self, evt, obj): |
226 | proj = project.Project() | 230 | proj = project.Project() |
227 | self.acum_achange_window, self.acum_achange_level = (proj.window, proj.level) | 231 | self.acum_achange_window, self.acum_achange_level = (proj.window, proj.level) |
@@ -303,6 +307,21 @@ class Viewer(wx.Panel): | @@ -303,6 +307,21 @@ class Viewer(wx.Panel): | ||
303 | slice_data.cursor.Show(0) | 307 | slice_data.cursor.Show(0) |
304 | self.interactor.Render() | 308 | self.interactor.Render() |
305 | 309 | ||
310 | + def UpdateText(self, pubsub_evt): | ||
311 | + if (self.text): | ||
312 | + self.text.SetValue(pubsub_evt.data) | ||
313 | + self.interactor.Render() | ||
314 | + | ||
315 | + def EnableText(self): | ||
316 | + if not (self.text): | ||
317 | + text = self.text = vtku.Text() | ||
318 | + self.ren.AddActor(text.actor) | ||
319 | + proj = project.Project() | ||
320 | + | ||
321 | + ps.Publisher().sendMessage('Update window and level text',\ | ||
322 | + "WL: %d WW: %d"%(proj.level, proj.window)) | ||
323 | + | ||
324 | + | ||
306 | def Reposition(self, slice_data): | 325 | def Reposition(self, slice_data): |
307 | """ | 326 | """ |
308 | Based on code of method Zoom in the | 327 | Based on code of method Zoom in the |
@@ -610,12 +629,12 @@ class Viewer(wx.Panel): | @@ -610,12 +629,12 @@ class Viewer(wx.Panel): | ||
610 | 'Set Zoom Select Mode') | 629 | 'Set Zoom Select Mode') |
611 | ps.Publisher().subscribe(self.ZoomSelectMode, | 630 | ps.Publisher().subscribe(self.ZoomSelectMode, |
612 | 'Set Zoom Select Mode') | 631 | 'Set Zoom Select Mode') |
613 | - | ||
614 | ps.Publisher().subscribe(self.ChangeSliceMode, | 632 | ps.Publisher().subscribe(self.ChangeSliceMode, |
615 | 'Set Change Slice Mode') | 633 | 'Set Change Slice Mode') |
616 | - | ||
617 | ps.Publisher().subscribe(self.WindowLevelMode, | 634 | ps.Publisher().subscribe(self.WindowLevelMode, |
618 | 'Bright and contrast adjustment') | 635 | 'Bright and contrast adjustment') |
636 | + ps.Publisher().subscribe(self.UpdateText,\ | ||
637 | + 'Update window and level text') | ||
619 | 638 | ||
620 | def ChangeBrushOperation(self, pubsub_evt): | 639 | def ChangeBrushOperation(self, pubsub_evt): |
621 | print pubsub_evt.data | 640 | print pubsub_evt.data |
@@ -705,6 +724,7 @@ class Viewer(wx.Panel): | @@ -705,6 +724,7 @@ class Viewer(wx.Panel): | ||
705 | 724 | ||
706 | actor_bound = actor.GetBounds() | 725 | actor_bound = actor.GetBounds() |
707 | 726 | ||
727 | + self.EnableText() | ||
708 | # Insert cursor | 728 | # Insert cursor |
709 | self.append_mode('EDITOR') | 729 | self.append_mode('EDITOR') |
710 | 730 |