Commit dc3c7ce0c05f727e5f8341c33dc64df8cc91a8c5
1 parent
ea59efb9
Exists in
master
and in
3 other branches
Enabling or disabling mip controls according to the projection type
Showing
1 changed file
with
26 additions
and
5 deletions
Show diff stats
invesalius/data/viewer_slice.py
@@ -73,13 +73,13 @@ class ContourMIPConfig(wx.Panel): | @@ -73,13 +73,13 @@ class ContourMIPConfig(wx.Panel): | ||
73 | self.inverted = wx.CheckBox(self, -1, "inverted") | 73 | self.inverted = wx.CheckBox(self, -1, "inverted") |
74 | 74 | ||
75 | txt_mip_size = wx.StaticText(self, -1, "MIP size", style=wx.ALIGN_CENTER_HORIZONTAL) | 75 | txt_mip_size = wx.StaticText(self, -1, "MIP size", style=wx.ALIGN_CENTER_HORIZONTAL) |
76 | - txt_mip_border = wx.StaticText(self, -1, "Border") | 76 | + self.txt_mip_border = wx.StaticText(self, -1, "Border") |
77 | 77 | ||
78 | sizer = wx.BoxSizer(wx.HORIZONTAL) | 78 | sizer = wx.BoxSizer(wx.HORIZONTAL) |
79 | sizer.Add(txt_mip_size, 0, wx.EXPAND | wx.ALL, 2) | 79 | sizer.Add(txt_mip_size, 0, wx.EXPAND | wx.ALL, 2) |
80 | sizer.Add(self.mip_size_spin, 0, wx.EXPAND) | 80 | sizer.Add(self.mip_size_spin, 0, wx.EXPAND) |
81 | sizer.AddSpacer((10, 0)) | 81 | sizer.AddSpacer((10, 0)) |
82 | - sizer.Add(txt_mip_border, 0, wx.EXPAND | wx.ALL, 2) | 82 | + sizer.Add(self.txt_mip_border, 0, wx.EXPAND | wx.ALL, 2) |
83 | sizer.Add(self.border_spin, 0, wx.EXPAND) | 83 | sizer.Add(self.border_spin, 0, wx.EXPAND) |
84 | sizer.AddSpacer((10, 0)) | 84 | sizer.AddSpacer((10, 0)) |
85 | sizer.Add(self.inverted, 0, wx.EXPAND) | 85 | sizer.Add(self.inverted, 0, wx.EXPAND) |
@@ -96,6 +96,8 @@ class ContourMIPConfig(wx.Panel): | @@ -96,6 +96,8 @@ class ContourMIPConfig(wx.Panel): | ||
96 | self.border_spin.Bind(wx.EVT_SPINCTRL, self.OnSetMIPBorder) | 96 | self.border_spin.Bind(wx.EVT_SPINCTRL, self.OnSetMIPBorder) |
97 | self.inverted.Bind(wx.EVT_CHECKBOX, self.OnCheckInverted) | 97 | self.inverted.Bind(wx.EVT_CHECKBOX, self.OnCheckInverted) |
98 | 98 | ||
99 | + Publisher.subscribe(self._set_projection_type, 'Set projection type') | ||
100 | + | ||
99 | def OnSetMIPSize(self, evt): | 101 | def OnSetMIPSize(self, evt): |
100 | val = self.mip_size_spin.GetValue() | 102 | val = self.mip_size_spin.GetValue() |
101 | Publisher.sendMessage('Set MIP size %s' % self.orientation, val) | 103 | Publisher.sendMessage('Set MIP size %s' % self.orientation, val) |
@@ -108,6 +110,24 @@ class ContourMIPConfig(wx.Panel): | @@ -108,6 +110,24 @@ class ContourMIPConfig(wx.Panel): | ||
108 | val = self.inverted.GetValue() | 110 | val = self.inverted.GetValue() |
109 | Publisher.sendMessage('Set MIP Invert %s' % self.orientation, val) | 111 | Publisher.sendMessage('Set MIP Invert %s' % self.orientation, val) |
110 | 112 | ||
113 | + def _set_projection_type(self, pubsub_evt): | ||
114 | + tprojection = pubsub_evt.data | ||
115 | + | ||
116 | + if tprojection in (const.PROJECTION_MIDA, | ||
117 | + const.PROJECTION_CONTOUR_MIDA): | ||
118 | + self.inverted.Enable() | ||
119 | + else: | ||
120 | + self.inverted.Disable() | ||
121 | + | ||
122 | + if tprojection in (const.PROJECTION_CONTOUR_MIP, | ||
123 | + const.PROJECTION_CONTOUR_MIDA): | ||
124 | + self.border_spin.Enable() | ||
125 | + self.txt_mip_border.Enable() | ||
126 | + else: | ||
127 | + self.border_spin.Disable() | ||
128 | + self.txt_mip_border.Disable() | ||
129 | + | ||
130 | + | ||
111 | 131 | ||
112 | class Viewer(wx.Panel): | 132 | class Viewer(wx.Panel): |
113 | 133 | ||
@@ -1199,9 +1219,10 @@ class Viewer(wx.Panel): | @@ -1199,9 +1219,10 @@ class Viewer(wx.Panel): | ||
1199 | def OnShowMIPInterface(self, pubsub_evt): | 1219 | def OnShowMIPInterface(self, pubsub_evt): |
1200 | value = pubsub_evt.data | 1220 | value = pubsub_evt.data |
1201 | if value: | 1221 | if value: |
1202 | - self.mip_ctrls.Show() | ||
1203 | - self.GetSizer().Add(self.mip_ctrls, 0, wx.EXPAND|wx.GROW|wx.ALL, 2) | ||
1204 | - self.Layout() | 1222 | + if not self.mip_ctrls.Shown: |
1223 | + self.mip_ctrls.Show() | ||
1224 | + self.GetSizer().Add(self.mip_ctrls, 0, wx.EXPAND|wx.GROW|wx.ALL, 2) | ||
1225 | + self.Layout() | ||
1205 | else: | 1226 | else: |
1206 | self.mip_ctrls.Hide() | 1227 | self.mip_ctrls.Hide() |
1207 | self.GetSizer().Remove(self.mip_ctrls) | 1228 | self.GetSizer().Remove(self.mip_ctrls) |