Commit 3d7e12f300ce049d3a04922df521a23f7b8e9e22
1 parent
2014adfc
Exists in
master
Added an tool to set ww&wl manually using a dialog (closes #212)
Showing
3 changed files
with
79 additions
and
1 deletions
Show diff stats
invesalius/constants.py
... | ... | @@ -519,6 +519,8 @@ ID_CREATE_MASK = wx.NewId() |
519 | 519 | ID_GOTO_SLICE = wx.NewId() |
520 | 520 | ID_GOTO_COORD = wx.NewId() |
521 | 521 | |
522 | +ID_MANUAL_WWWL = wx.NewId() | |
523 | + | |
522 | 524 | #--------------------------------------------------------- |
523 | 525 | STATE_DEFAULT = 1000 |
524 | 526 | STATE_WL = 1001 | ... | ... |
invesalius/gui/dialogs.py
... | ... | @@ -3989,3 +3989,73 @@ class SetCOMport(wx.Dialog): |
3989 | 3989 | |
3990 | 3990 | def GetValue(self): |
3991 | 3991 | return self.com_ports.GetString(self.com_ports.GetSelection()) |
3992 | + | |
3993 | + | |
3994 | +class ManualWWWLDialog(wx.Dialog): | |
3995 | + def __init__(self, parent): | |
3996 | + wx.Dialog.__init__(self, parent, -1, _("Set WW&WL manually")) | |
3997 | + self._init_gui() | |
3998 | + | |
3999 | + def _init_gui(self): | |
4000 | + import invesalius.data.slice_ as slc | |
4001 | + ww = slc.Slice().window_width | |
4002 | + wl = slc.Slice().window_level | |
4003 | + | |
4004 | + self.txt_wl = wx.TextCtrl(self, -1, str(int(wl))) | |
4005 | + wl_sizer = wx.BoxSizer(wx.HORIZONTAL) | |
4006 | + wl_sizer.Add(wx.StaticText(self, -1, _("Window Level")), 0, wx.ALIGN_CENTER_VERTICAL) | |
4007 | + wl_sizer.Add(self.txt_wl, 1, wx.ALL | wx.EXPAND, 5) | |
4008 | + wl_sizer.Add(wx.StaticText(self, -1, _("WL")), 0, wx.ALIGN_CENTER_VERTICAL) | |
4009 | + | |
4010 | + self.txt_ww = wx.TextCtrl(self, -1, str(int(ww))) | |
4011 | + ww_sizer = wx.BoxSizer(wx.HORIZONTAL) | |
4012 | + ww_sizer.Add(wx.StaticText(self, -1, _("Window Width")), 0, wx.ALIGN_CENTER_VERTICAL) | |
4013 | + ww_sizer.Add(self.txt_ww, 1, wx.ALL | wx.EXPAND, 5) | |
4014 | + ww_sizer.Add(wx.StaticText(self, -1, _("WW")), 0, wx.ALIGN_CENTER_VERTICAL) | |
4015 | + | |
4016 | + btn_ok = wx.Button(self, wx.ID_OK) | |
4017 | + btn_cancel = wx.Button(self, wx.ID_CANCEL) | |
4018 | + btnsizer = wx.StdDialogButtonSizer() | |
4019 | + btnsizer.AddButton(btn_ok) | |
4020 | + btnsizer.AddButton(btn_cancel) | |
4021 | + btnsizer.Realize() | |
4022 | + | |
4023 | + main_sizer = wx.BoxSizer(wx.VERTICAL) | |
4024 | + main_sizer.Add(wl_sizer, 1, wx.ALL | wx.EXPAND, 5) | |
4025 | + main_sizer.Add(ww_sizer, 1, wx.ALL | wx.EXPAND, 5) | |
4026 | + main_sizer.Add(btnsizer, 1, wx.ALL | wx.EXPAND, 5) | |
4027 | + | |
4028 | + btn_ok.Bind(wx.EVT_BUTTON, self.OnOK) | |
4029 | + btn_cancel.Bind(wx.EVT_BUTTON, self.OnCancel) | |
4030 | + self.Bind(wx.EVT_CLOSE, self.OnClose) | |
4031 | + | |
4032 | + self.SetSizer(main_sizer) | |
4033 | + main_sizer.Fit(self) | |
4034 | + main_sizer.SetSizeHints(self) | |
4035 | + | |
4036 | + self.Layout() | |
4037 | + self.Center() | |
4038 | + | |
4039 | + def OnOK(self, evt): | |
4040 | + try: | |
4041 | + ww = int(self.txt_ww.GetValue()) | |
4042 | + wl = int(self.txt_wl.GetValue()) | |
4043 | + except ValueError: | |
4044 | + self.Close() | |
4045 | + return | |
4046 | + | |
4047 | + Publisher.sendMessage('Bright and contrast adjustment image', window=ww, level=wl) | |
4048 | + const.WINDOW_LEVEL['Manual'] = (ww, wl) | |
4049 | + Publisher.sendMessage('Check window and level other') | |
4050 | + Publisher.sendMessage('Update window level value', window=ww, level=wl) | |
4051 | + #Necessary update the slice plane in the volume case exists | |
4052 | + Publisher.sendMessage('Update slice viewer') | |
4053 | + Publisher.sendMessage('Render volume viewer') | |
4054 | + | |
4055 | + self.Close() | |
4056 | + | |
4057 | + def OnCancel(self, evt): | |
4058 | + self.Close() | |
4059 | + | |
4060 | + def OnClose(self, evt): | |
4061 | + self.Destroy() | ... | ... |
invesalius/gui/frame.py
... | ... | @@ -478,6 +478,10 @@ class Frame(wx.Frame): |
478 | 478 | ddlg = dlg.MaskDensityDialog(self) |
479 | 479 | ddlg.Show() |
480 | 480 | |
481 | + elif id == const.ID_MANUAL_WWWL: | |
482 | + wwwl_dlg = dlg.ManualWWWLDialog(self) | |
483 | + wwwl_dlg.Show() | |
484 | + | |
481 | 485 | elif id == const.ID_THRESHOLD_SEGMENTATION: |
482 | 486 | Publisher.sendMessage("Show panel", panel_id=const.ID_THRESHOLD_SEGMENTATION) |
483 | 487 | Publisher.sendMessage('Disable actual style') |
... | ... | @@ -818,7 +822,8 @@ class MenuBar(wx.MenuBar): |
818 | 822 | const.ID_MASK_DENSITY_MEASURE, |
819 | 823 | const.ID_CREATE_SURFACE, |
820 | 824 | const.ID_CREATE_MASK, |
821 | - const.ID_GOTO_SLICE] | |
825 | + const.ID_GOTO_SLICE, | |
826 | + const.ID_MANUAL_WWWL] | |
822 | 827 | self.__init_items() |
823 | 828 | self.__bind_events() |
824 | 829 | |
... | ... | @@ -981,6 +986,7 @@ class MenuBar(wx.MenuBar): |
981 | 986 | |
982 | 987 | mask_density_menu = image_menu.Append(const.ID_MASK_DENSITY_MEASURE, _(u'Mask Density measure')) |
983 | 988 | reorient_menu = image_menu.Append(const.ID_REORIENT_IMG, _(u'Reorient image\tCtrl+Shift+R')) |
989 | + image_menu.Append(const.ID_MANUAL_WWWL, _("Set WW&&WL manually")) | |
984 | 990 | |
985 | 991 | reorient_menu.Enable(False) |
986 | 992 | tools_menu.Append(-1, _(u'Image'), image_menu) | ... | ... |