Commit f7dab69fdf4f6dbddc42b2adadd0d783364af617
1 parent
32368b96
Exists in
master
and in
56 other branches
Added some controls to config the mip visualizations
Showing
1 changed file
with
46 additions
and
2 deletions
Show diff stats
invesalius/data/viewer_slice.py
| ... | ... | @@ -32,6 +32,11 @@ import styles |
| 32 | 32 | import wx |
| 33 | 33 | from wx.lib.pubsub import pub as Publisher |
| 34 | 34 | |
| 35 | +try: | |
| 36 | + from agw import floatspin as FS | |
| 37 | +except ImportError: # if it's not there locally, try the wxPython lib. | |
| 38 | + import wx.lib.agw.floatspin as FS | |
| 39 | + | |
| 35 | 40 | import constants as const |
| 36 | 41 | import cursor_actors as ca |
| 37 | 42 | import data.slice_ as sl |
| ... | ... | @@ -51,6 +56,26 @@ ORIENTATIONS = { |
| 51 | 56 | "SAGITAL": const.SAGITAL, |
| 52 | 57 | } |
| 53 | 58 | |
| 59 | + | |
| 60 | +class ContourMIPConfig(wx.Panel): | |
| 61 | + def __init__(self, prnt): | |
| 62 | + wx.Panel.__init__(self, prnt) | |
| 63 | + self.mip_size_spin = wx.SpinCtrl(self, -1, min=1, max=120, initial=1) | |
| 64 | + self.border_spin = FS.FloatSpin(self, -1, min_val=0, max_val=10, | |
| 65 | + increment=0.01, value=0.1, | |
| 66 | + agwStyle=FS.FS_LEFT) | |
| 67 | + | |
| 68 | + sizer = wx.BoxSizer(wx.HORIZONTAL) | |
| 69 | + sizer.Add(self.mip_size_spin, 1, wx.EXPAND) | |
| 70 | + sizer.Add(self.border_spin, 1, wx.EXPAND) | |
| 71 | + self.SetSizer(sizer) | |
| 72 | + sizer.Fit(self) | |
| 73 | + | |
| 74 | + self.Layout() | |
| 75 | + self.Update() | |
| 76 | + self.SetAutoLayout(1) | |
| 77 | + | |
| 78 | + | |
| 54 | 79 | class Viewer(wx.Panel): |
| 55 | 80 | |
| 56 | 81 | def __init__(self, prnt, orientation='AXIAL'): |
| ... | ... | @@ -113,12 +138,16 @@ class Viewer(wx.Panel): |
| 113 | 138 | |
| 114 | 139 | scroll = wx.ScrollBar(self, -1, style=wx.SB_VERTICAL) |
| 115 | 140 | self.scroll = scroll |
| 141 | + | |
| 142 | + self.mip_ctrls = ContourMIPConfig(self) | |
| 143 | + | |
| 116 | 144 | sizer = wx.BoxSizer(wx.HORIZONTAL) |
| 117 | 145 | sizer.Add(self.interactor, 1, wx.EXPAND|wx.GROW) |
| 146 | + sizer.Add(scroll, 0, wx.EXPAND|wx.GROW) | |
| 118 | 147 | |
| 119 | - background_sizer = wx.BoxSizer(wx.HORIZONTAL) | |
| 148 | + background_sizer = wx.BoxSizer(wx.VERTICAL) | |
| 120 | 149 | background_sizer.AddSizer(sizer, 1, wx.EXPAND|wx.GROW|wx.ALL, 2) |
| 121 | - background_sizer.Add(scroll, 0, wx.EXPAND|wx.GROW) | |
| 150 | + background_sizer.Add(self.mip_ctrls, 0, wx.EXPAND|wx.GROW|wx.ALL, 2) | |
| 122 | 151 | self.SetSizer(background_sizer) |
| 123 | 152 | background_sizer.Fit(self) |
| 124 | 153 | |
| ... | ... | @@ -742,6 +771,9 @@ class Viewer(wx.Panel): |
| 742 | 771 | self.interactor.Bind(wx.EVT_RIGHT_UP, self.OnContextMenu) |
| 743 | 772 | self.interactor.Bind(wx.EVT_SIZE, self.OnSize) |
| 744 | 773 | |
| 774 | + self.mip_ctrls.mip_size_spin.Bind(wx.EVT_SPINCTRL, self.OnSetMIPSize) | |
| 775 | + self.mip_ctrls.border_spin.Bind(wx.EVT_SPINCTRL, self.OnSetMIPBorder) | |
| 776 | + | |
| 745 | 777 | def LoadImagedata(self, pubsub_evt): |
| 746 | 778 | imagedata, mask_dict = pubsub_evt.data |
| 747 | 779 | self.SetInput(imagedata, mask_dict) |
| ... | ... | @@ -1105,6 +1137,18 @@ class Viewer(wx.Panel): |
| 1105 | 1137 | self.slice_data.SetSize((w, h)) |
| 1106 | 1138 | evt.Skip() |
| 1107 | 1139 | |
| 1140 | + def OnSetMIPSize(self, evt): | |
| 1141 | + val = self.mip_ctrls.mip_size_spin.GetValue() | |
| 1142 | + self.number_slices = val | |
| 1143 | + self.ReloadActualSlice() | |
| 1144 | + | |
| 1145 | + def OnSetMIPBorder(self, evt): | |
| 1146 | + val = self.mip_ctrls.border_spin.GetValue() | |
| 1147 | + self.slice_.n_border = val | |
| 1148 | + buffer_ = self.slice_.buffer_slices[self.orientation] | |
| 1149 | + buffer_.discard_buffer() | |
| 1150 | + self.ReloadActualSlice() | |
| 1151 | + | |
| 1108 | 1152 | def set_slice_number(self, index): |
| 1109 | 1153 | image = self.slice_.GetSlices(self.orientation, index, |
| 1110 | 1154 | self.number_slices) | ... | ... |