Commit 7a8a4f1b92ca716883565a9d5541aac201b5fc35
1 parent
e2d5f585
Exists in
select_part
Showing dialog
Showing
2 changed files
with
79 additions
and
1 deletions
Show diff stats
invesalius/data/styles.py
... | ... | @@ -1933,6 +1933,7 @@ class SelectPartConfig(object): |
1933 | 1933 | def __init__(self): |
1934 | 1934 | self.mask = None |
1935 | 1935 | self.con_3d = 6 |
1936 | + self.dlg_visible = False | |
1936 | 1937 | |
1937 | 1938 | |
1938 | 1939 | class SelectMaskPartsInteractorStyle(DefaultInteractorStyle): |
... | ... | @@ -1947,7 +1948,7 @@ class SelectMaskPartsInteractorStyle(DefaultInteractorStyle): |
1947 | 1948 | self.slice_data = viewer.slice_data |
1948 | 1949 | |
1949 | 1950 | self.config = SelectPartConfig() |
1950 | - self.dlg_ffill = None | |
1951 | + self.dlg = None | |
1951 | 1952 | |
1952 | 1953 | self.t0 = 254 |
1953 | 1954 | self.t1 = 255 |
... | ... | @@ -1955,9 +1956,21 @@ class SelectMaskPartsInteractorStyle(DefaultInteractorStyle): |
1955 | 1956 | |
1956 | 1957 | self.AddObserver("LeftButtonPressEvent", self.OnSelect) |
1957 | 1958 | |
1959 | + def SetUp(self): | |
1960 | + if not self.config.dlg_visible: | |
1961 | + self.config.dlg_visible = True | |
1962 | + self.dlg= dialogs.SelectPartsOptionsDialog(self.config) | |
1963 | + self.dlg.Show() | |
1964 | + | |
1958 | 1965 | def CleanUp(self): |
1966 | + if (self.dlg is not None) and (self.config.dlg_visible): | |
1967 | + self.config.dlg_visible = False | |
1968 | + self.dlg.Destroy() | |
1969 | + self.dlg = None | |
1970 | + | |
1959 | 1971 | if self.config.mask: |
1960 | 1972 | self.viewer.slice_.SelectCurrentMask(self.config.mask.index) |
1973 | + Publisher.sendMessage('Change mask selected', self.config.mask.index) | |
1961 | 1974 | self.config.mask = None |
1962 | 1975 | del self.viewer.slice_.aux_matrices['SELECT'] |
1963 | 1976 | self.viewer.slice_.to_show_aux = '' | ... | ... |
invesalius/gui/dialogs.py
... | ... | @@ -1940,3 +1940,68 @@ class FFillOptionsDialog(wx.Dialog): |
1940 | 1940 | Publisher.sendMessage('Disable style', const.SLICE_STATE_MASK_FFILL) |
1941 | 1941 | evt.Skip() |
1942 | 1942 | self.Destroy() |
1943 | + | |
1944 | + | |
1945 | +class SelectPartsOptionsDialog(wx.Dialog): | |
1946 | + def __init__(self, config): | |
1947 | + pre = wx.PreDialog() | |
1948 | + pre.Create(wx.GetApp().GetTopWindow(), -1, _(u"Select mask parts"), style=wx.DEFAULT_DIALOG_STYLE|wx.FRAME_FLOAT_ON_PARENT) | |
1949 | + self.PostCreate(pre) | |
1950 | + | |
1951 | + self.config = config | |
1952 | + | |
1953 | + self._init_gui() | |
1954 | + | |
1955 | + def _init_gui(self): | |
1956 | + import data.mask as mask | |
1957 | + | |
1958 | + default_name = const.MASK_NAME_PATTERN %(mask.Mask.general_index+2) | |
1959 | + self.target_name = wx.TextCtrl(self, -1) | |
1960 | + self.target_name.SetValue(default_name) | |
1961 | + | |
1962 | + # Connectivity 3D | |
1963 | + self.conect3D_6 = wx.RadioButton(self, -1, "6", style=wx.RB_GROUP) | |
1964 | + self.conect3D_18 = wx.RadioButton(self, -1, "18") | |
1965 | + self.conect3D_26 = wx.RadioButton(self, -1, "26") | |
1966 | + | |
1967 | + if self.config.con_3d == 18: | |
1968 | + self.conect3D_18.SetValue(1) | |
1969 | + elif self.config.con_3d == 26: | |
1970 | + self.conect3D_26.SetValue(1) | |
1971 | + else: | |
1972 | + self.conect3D_6.SetValue(1) | |
1973 | + | |
1974 | + sizer = wx.GridBagSizer(11, 6) | |
1975 | + sizer.AddStretchSpacer((0, 0)) | |
1976 | + | |
1977 | + sizer.Add(wx.StaticText(self, -1, _(u"Target mask name")), (1, 0), (1, 2), flag=wx.LEFT, border=7) | |
1978 | + sizer.Add(self.target_name, (1, 3), (1, 3), flag=wx.RIGHT, border=7) | |
1979 | + | |
1980 | + sizer.AddStretchSpacer((2, 0)) | |
1981 | + | |
1982 | + sizer.Add(wx.StaticText(self, -1, _(u"3D Connectivity")), (3, 0), (1, 6), flag=wx.LEFT, border=9) | |
1983 | + sizer.Add(self.conect3D_6, (4, 0), flag=wx.LEFT, border=9) | |
1984 | + sizer.Add(self.conect3D_18, (4, 1), flag=wx.LEFT, border=9) | |
1985 | + sizer.Add(self.conect3D_26, (4, 2), flag=wx.LEFT, border=9) | |
1986 | + sizer.AddStretchSpacer((5, 0)) | |
1987 | + | |
1988 | + self.SetSizer(sizer) | |
1989 | + sizer.Fit(self) | |
1990 | + self.Layout() | |
1991 | + | |
1992 | + self.Bind(wx.EVT_RADIOBUTTON, self.OnSetRadio) | |
1993 | + self.Bind(wx.EVT_CLOSE, self.OnClose) | |
1994 | + | |
1995 | + def OnSetRadio(self, evt): | |
1996 | + if self.conect3D_6.GetValue(): | |
1997 | + self.config.con_3d = 6 | |
1998 | + elif self.conect3D_18.GetValue(): | |
1999 | + self.config.con_3d = 18 | |
2000 | + elif self.conect3D_26.GetValue(): | |
2001 | + self.config.con_3d = 2 | |
2002 | + | |
2003 | + def OnClose(self, evt): | |
2004 | + if self.config.dlg_visible: | |
2005 | + Publisher.sendMessage('Disable style', const.SLICE_STATE_SELECT_MASK_PARTS) | |
2006 | + evt.Skip() | |
2007 | + self.Destroy() | ... | ... |