Commit b278e13c80b1645d07bfb92aebdf4bfbbaf1266e
1 parent
63be42db
Exists in
master
and in
68 other branches
ENH: Option to select the interval in the import panel
Showing
2 changed files
with
34 additions
and
22 deletions
Show diff stats
invesalius/control.py
| @@ -379,10 +379,8 @@ class Controller(): | @@ -379,10 +379,8 @@ class Controller(): | ||
| 379 | dirpath = session.CreateProject(filename) | 379 | dirpath = session.CreateProject(filename) |
| 380 | proj.SavePlistProject(dirpath, filename) | 380 | proj.SavePlistProject(dirpath, filename) |
| 381 | 381 | ||
| 382 | - | ||
| 383 | - | ||
| 384 | def OnOpenDicomGroup(self, pubsub_evt): | 382 | def OnOpenDicomGroup(self, pubsub_evt): |
| 385 | - group = pubsub_evt.data | 383 | + group, interval = pubsub_evt.data |
| 386 | imagedata, dicom = self.OpenDicomGroup(group, gui=True) | 384 | imagedata, dicom = self.OpenDicomGroup(group, gui=True) |
| 387 | self.CreateDicomProject(imagedata, dicom) | 385 | self.CreateDicomProject(imagedata, dicom) |
| 388 | self.LoadProject() | 386 | self.LoadProject() |
invesalius/gui/import_panel.py
| @@ -75,6 +75,11 @@ class InnerPanel(wx.Panel): | @@ -75,6 +75,11 @@ class InnerPanel(wx.Panel): | ||
| 75 | 75 | ||
| 76 | self.patients = [] | 76 | self.patients = [] |
| 77 | 77 | ||
| 78 | + self._init_ui() | ||
| 79 | + self._bind_events() | ||
| 80 | + self._bind_pubsubevt() | ||
| 81 | + | ||
| 82 | + def _init_ui(self): | ||
| 78 | splitter = spl.MultiSplitterWindow(self, style=wx.SP_LIVE_UPDATE) | 83 | splitter = spl.MultiSplitterWindow(self, style=wx.SP_LIVE_UPDATE) |
| 79 | splitter.SetOrientation(wx.VERTICAL) | 84 | splitter.SetOrientation(wx.VERTICAL) |
| 80 | self.splitter = splitter | 85 | self.splitter = splitter |
| @@ -82,46 +87,42 @@ class InnerPanel(wx.Panel): | @@ -82,46 +87,42 @@ class InnerPanel(wx.Panel): | ||
| 82 | panel = wx.Panel(self) | 87 | panel = wx.Panel(self) |
| 83 | #button = wx.Button(panel, -1, _("Import medical images"), (20, 20)) | 88 | #button = wx.Button(panel, -1, _("Import medical images"), (20, 20)) |
| 84 | 89 | ||
| 85 | - | ||
| 86 | - btn_ok = wx.Button(panel, wx.ID_OK) | ||
| 87 | - btn_ok.SetDefault() | 90 | + self.btn_ok = wx.Button(panel, wx.ID_OK) |
| 91 | + self.btn_ok.SetDefault() | ||
| 88 | btn_cancel = wx.Button(panel, wx.ID_CANCEL) | 92 | btn_cancel = wx.Button(panel, wx.ID_CANCEL) |
| 89 | - | 93 | + |
| 90 | btnsizer = wx.StdDialogButtonSizer() | 94 | btnsizer = wx.StdDialogButtonSizer() |
| 91 | - btnsizer.AddButton(btn_ok) | 95 | + btnsizer.AddButton(self.btn_ok) |
| 92 | btnsizer.AddButton(btn_cancel) | 96 | btnsizer.AddButton(btn_cancel) |
| 93 | btnsizer.Realize() | 97 | btnsizer.Realize() |
| 94 | 98 | ||
| 95 | - combo_interval = wx.ComboBox(panel, -1, "", choices= const.IMPORT_INTERVAL, | 99 | + self.combo_interval = wx.ComboBox(panel, -1, "", choices=const.IMPORT_INTERVAL, |
| 96 | style=wx.CB_DROPDOWN|wx.CB_READONLY) | 100 | style=wx.CB_DROPDOWN|wx.CB_READONLY) |
| 97 | - combo_interval.SetSelection(0) | 101 | + self.combo_interval.SetSelection(0) |
| 98 | 102 | ||
| 99 | inner_sizer = wx.BoxSizer(wx.HORIZONTAL) | 103 | inner_sizer = wx.BoxSizer(wx.HORIZONTAL) |
| 100 | inner_sizer.AddSizer(btnsizer, 0, wx.LEFT|wx.TOP, 5) | 104 | inner_sizer.AddSizer(btnsizer, 0, wx.LEFT|wx.TOP, 5) |
| 101 | - inner_sizer.Add(combo_interval, 0, wx.LEFT|wx.RIGHT|wx.TOP, 8) | 105 | + inner_sizer.Add(self.combo_interval, 0, wx.LEFT|wx.RIGHT|wx.TOP, 5) |
| 102 | panel.SetSizer(inner_sizer) | 106 | panel.SetSizer(inner_sizer) |
| 103 | inner_sizer.Fit(panel) | 107 | inner_sizer.Fit(panel) |
| 104 | - | 108 | + |
| 105 | sizer = wx.BoxSizer(wx.VERTICAL) | 109 | sizer = wx.BoxSizer(wx.VERTICAL) |
| 106 | sizer.Add(splitter, 20, wx.EXPAND) | 110 | sizer.Add(splitter, 20, wx.EXPAND) |
| 107 | sizer.Add(panel, 1, wx.EXPAND|wx.LEFT, 90) | 111 | sizer.Add(panel, 1, wx.EXPAND|wx.LEFT, 90) |
| 108 | - | 112 | + |
| 109 | self.SetSizer(sizer) | 113 | self.SetSizer(sizer) |
| 110 | sizer.Fit(self) | 114 | sizer.Fit(self) |
| 111 | 115 | ||
| 112 | - self.Layout() | ||
| 113 | - self.Update() | ||
| 114 | - self.SetAutoLayout(1) | ||
| 115 | - | ||
| 116 | self.text_panel = TextPanel(splitter) | 116 | self.text_panel = TextPanel(splitter) |
| 117 | splitter.AppendWindow(self.text_panel, 250) | 117 | splitter.AppendWindow(self.text_panel, 250) |
| 118 | - | 118 | + |
| 119 | self.image_panel = ImagePanel(splitter) | 119 | self.image_panel = ImagePanel(splitter) |
| 120 | splitter.AppendWindow(self.image_panel, 250) | 120 | splitter.AppendWindow(self.image_panel, 250) |
| 121 | - | ||
| 122 | - self._bind_events() | ||
| 123 | - self._bind_pubsubevt() | ||
| 124 | - | 121 | + |
| 122 | + self.Layout() | ||
| 123 | + self.Update() | ||
| 124 | + self.SetAutoLayout(1) | ||
| 125 | + | ||
| 125 | def _bind_pubsubevt(self): | 126 | def _bind_pubsubevt(self): |
| 126 | ps.Publisher().subscribe(self.ShowDicomPreview, "Load import panel") | 127 | ps.Publisher().subscribe(self.ShowDicomPreview, "Load import panel") |
| 127 | 128 | ||
| @@ -129,6 +130,7 @@ class InnerPanel(wx.Panel): | @@ -129,6 +130,7 @@ class InnerPanel(wx.Panel): | ||
| 129 | self.Bind(EVT_SELECT_SERIE, self.OnSelectSerie) | 130 | self.Bind(EVT_SELECT_SERIE, self.OnSelectSerie) |
| 130 | self.Bind(EVT_SELECT_SLICE, self.OnSelectSlice) | 131 | self.Bind(EVT_SELECT_SLICE, self.OnSelectSlice) |
| 131 | self.Bind(EVT_SELECT_PATIENT, self.OnSelectPatient) | 132 | self.Bind(EVT_SELECT_PATIENT, self.OnSelectPatient) |
| 133 | + self.btn_ok.Bind(wx.EVT_BUTTON, self.OnLoadDicom) | ||
| 132 | 134 | ||
| 133 | def ShowDicomPreview(self, pubsub_evt): | 135 | def ShowDicomPreview(self, pubsub_evt): |
| 134 | dicom_groups = pubsub_evt.data | 136 | dicom_groups = pubsub_evt.data |
| @@ -149,6 +151,12 @@ class InnerPanel(wx.Panel): | @@ -149,6 +151,12 @@ class InnerPanel(wx.Panel): | ||
| 149 | 151 | ||
| 150 | def OnSelectPatient(self, evt): | 152 | def OnSelectPatient(self, evt): |
| 151 | print "You've selected the patient", evt.GetSelectID() | 153 | print "You've selected the patient", evt.GetSelectID() |
| 154 | + | ||
| 155 | + def OnLoadDicom(self, evt): | ||
| 156 | + group = self.text_panel.GetSelection() | ||
| 157 | + interval = self.combo_interval.GetSelection() | ||
| 158 | + | ||
| 159 | + ps.Publisher().sendMessage('Open DICOM group', (group, interval)) | ||
| 152 | 160 | ||
| 153 | 161 | ||
| 154 | class TextPanel(wx.Panel): | 162 | class TextPanel(wx.Panel): |
| @@ -312,6 +320,12 @@ class TextPanel(wx.Panel): | @@ -312,6 +320,12 @@ class TextPanel(wx.Panel): | ||
| 312 | self.tree.SelectItem(item) | 320 | self.tree.SelectItem(item) |
| 313 | self._selected_by_user = True | 321 | self._selected_by_user = True |
| 314 | 322 | ||
| 323 | + def GetSelection(self): | ||
| 324 | + """Get selected item""" | ||
| 325 | + item = self.tree.GetSelection() | ||
| 326 | + group = self.tree.GetItemPyData(item) | ||
| 327 | + return group | ||
| 328 | + | ||
| 315 | 329 | ||
| 316 | class ImagePanel(wx.Panel): | 330 | class ImagePanel(wx.Panel): |
| 317 | def __init__(self, parent): | 331 | def __init__(self, parent): |