Commit 93044664a95e9cd5c0deaf3c13aef0988735d1ef

Authored by Paulo Henrique Junqueira Amorim
1 parent af3889aa

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 28 import constants as const
29 29 import project
30 30 import cursor_actors as ca
  31 +import data.vtk_utils as vtku
31 32  
32 33 from slice_data import SliceData
33 34  
... ... @@ -47,7 +48,7 @@ class Viewer(wx.Panel):
47 48 self.slice_data_list = []
48 49 # The layout from slice_data, the first is number of cols, the second
49 50 # is the number of rows
50   - self.layout = (2, 2)
  51 + self.layout = (1, 1)
51 52  
52 53 self.__init_gui()
53 54  
... ... @@ -59,6 +60,7 @@ class Viewer(wx.Panel):
59 60 self._brush_cursor_colour = const.BRUSH_COLOUR
60 61 self._brush_cursor_type = const.DEFAULT_BRUSH_OP
61 62 self.cursor = None
  63 + self.text = None
62 64 # VTK pipeline and actors
63 65 #self.__config_interactor()
64 66 self.pick = vtk.vtkCellPicker()
... ... @@ -197,6 +199,7 @@ class Viewer(wx.Panel):
197 199 self.append_mode('WINDOWLEVEL')
198 200 self.mouse_pressed = 0
199 201 self.interactor.SetCursor(wx.StockCursor(wx.CURSOR_SIZING))
  202 + self.interactor.Render()
200 203  
201 204 def ChangeSliceMode(self, pubsub_evt):
202 205 self.append_mode('CHANGESLICE')
... ... @@ -218,10 +221,11 @@ class Viewer(wx.Panel):
218 221 ps.Publisher().sendMessage('Bright and contrast adjustment image',
219 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 226 self.interactor.Render()
222 227  
223 228  
224   -
225 229 def OnWindowLevelClick(self, evt, obj):
226 230 proj = project.Project()
227 231 self.acum_achange_window, self.acum_achange_level = (proj.window, proj.level)
... ... @@ -303,6 +307,21 @@ class Viewer(wx.Panel):
303 307 slice_data.cursor.Show(0)
304 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 325 def Reposition(self, slice_data):
307 326 """
308 327 Based on code of method Zoom in the
... ... @@ -610,12 +629,12 @@ class Viewer(wx.Panel):
610 629 'Set Zoom Select Mode')
611 630 ps.Publisher().subscribe(self.ZoomSelectMode,
612 631 'Set Zoom Select Mode')
613   -
614 632 ps.Publisher().subscribe(self.ChangeSliceMode,
615 633 'Set Change Slice Mode')
616   -
617 634 ps.Publisher().subscribe(self.WindowLevelMode,
618 635 'Bright and contrast adjustment')
  636 + ps.Publisher().subscribe(self.UpdateText,\
  637 + 'Update window and level text')
619 638  
620 639 def ChangeBrushOperation(self, pubsub_evt):
621 640 print pubsub_evt.data
... ... @@ -705,6 +724,7 @@ class Viewer(wx.Panel):
705 724  
706 725 actor_bound = actor.GetBounds()
707 726  
  727 + self.EnableText()
708 728 # Insert cursor
709 729 self.append_mode('EDITOR')
710 730  
... ...