From 9bbd13653e18798d01156585746925c6cb4f5928 Mon Sep 17 00:00:00 2001 From: paulojamorim Date: Fri, 28 Aug 2009 14:38:56 +0000 Subject: [PATCH] ENH: Redesigned way to store the values of window and level --- invesalius/control.py | 12 +++++++++--- invesalius/data/viewer_slice.py | 20 ++++++++++---------- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/invesalius/control.py b/invesalius/control.py index ef53aef..13af03d 100755 --- a/invesalius/control.py +++ b/invesalius/control.py @@ -79,6 +79,9 @@ class Controller(): proj.window = window = const.WINDOW_LEVEL['Bone'][0] proj.level = level = const.WINDOW_LEVEL['Bone'][1] + ps.Publisher().sendMessage('Update window level value',\ + (proj.window, proj.level)) + if not imagedata: print "Sorry, but there are no medical images supported on this dir." else: @@ -86,9 +89,9 @@ class Controller(): proj.SetAcquisitionModality(acquisition_modality) proj.imagedata = imagedata proj.original_orientation = orientation - proj.window = float(window) - proj.level = float(level) - + proj.window = window = float(window) + proj.level = level = float(level) + threshold_range = proj.imagedata.GetScalarRange() const.THRESHOLD_OUTVALUE = threshold_range[0] @@ -103,6 +106,9 @@ class Controller(): #Initial Window and Level ps.Publisher().sendMessage('Bright and contrast adjustment image',\ (proj.window, proj.level)) + + ps.Publisher().sendMessage('Update window level value',\ + (proj.window, proj.level)) # Call frame so it shows slice and volume related panels ps.Publisher().sendMessage('Show content panel') diff --git a/invesalius/data/viewer_slice.py b/invesalius/data/viewer_slice.py index 59df884..4fe7b49 100755 --- a/invesalius/data/viewer_slice.py +++ b/invesalius/data/viewer_slice.py @@ -226,24 +226,24 @@ class Viewer(wx.Panel): self.acum_achange_level += mouse_y - self.last_y self.last_x, self.last_y = mouse_x, mouse_y - proj = project.Project() - proj.window = self.acum_achange_window - proj.level = self.acum_achange_level - ps.Publisher().sendMessage('Bright and contrast adjustment image', - (proj.window, proj.level)) + (self.acum_achange_window, self.acum_achange_level)) ps.Publisher().sendMessage('Update window and level text',\ - "WL: %d WW: %d"%(proj.level, proj.window)) + "WL: %d WW: %d"%(self.acum_achange_window,\ + self.acum_achange_level)) self.interactor.Render() def OnWindowLevelClick(self, evt, obj): - proj = project.Project() - self.acum_achange_window, self.acum_achange_level = (proj.window, proj.level) self.last_x, self.last_y = self.interactor.GetLastEventPosition() self.mouse_pressed = 1 + def UpdateWindowLevelValue(self, pubsub_evt): + window, level = pubsub_evt.data + self.acum_achange_window, self.acum_achange_level = (window, level) + + def OnChangeSliceMove(self, evt, obj): min = 0 @@ -656,8 +656,8 @@ class Viewer(wx.Panel): #### ps.Publisher().subscribe(self.UpdateText,\ 'Update window and level text') - #ps.Publisher().subscribe(self.UpdateCkeckPopUpMenu,\ - # 'Update ckeck popup menu') + ps.Publisher().subscribe(self.UpdateWindowLevelValue,\ + 'Update window level value') def ChangeBrushOperation(self, pubsub_evt): print pubsub_evt.data -- libgit2 0.21.2