Commit b278e13c80b1645d07bfb92aebdf4bfbbaf1266e
1 parent
63be42db
Exists in
master
and in
6 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 | 379 | dirpath = session.CreateProject(filename) |
380 | 380 | proj.SavePlistProject(dirpath, filename) |
381 | 381 | |
382 | - | |
383 | - | |
384 | 382 | def OnOpenDicomGroup(self, pubsub_evt): |
385 | - group = pubsub_evt.data | |
383 | + group, interval = pubsub_evt.data | |
386 | 384 | imagedata, dicom = self.OpenDicomGroup(group, gui=True) |
387 | 385 | self.CreateDicomProject(imagedata, dicom) |
388 | 386 | self.LoadProject() | ... | ... |
invesalius/gui/import_panel.py
... | ... | @@ -75,6 +75,11 @@ class InnerPanel(wx.Panel): |
75 | 75 | |
76 | 76 | self.patients = [] |
77 | 77 | |
78 | + self._init_ui() | |
79 | + self._bind_events() | |
80 | + self._bind_pubsubevt() | |
81 | + | |
82 | + def _init_ui(self): | |
78 | 83 | splitter = spl.MultiSplitterWindow(self, style=wx.SP_LIVE_UPDATE) |
79 | 84 | splitter.SetOrientation(wx.VERTICAL) |
80 | 85 | self.splitter = splitter |
... | ... | @@ -82,46 +87,42 @@ class InnerPanel(wx.Panel): |
82 | 87 | panel = wx.Panel(self) |
83 | 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 | 92 | btn_cancel = wx.Button(panel, wx.ID_CANCEL) |
89 | - | |
93 | + | |
90 | 94 | btnsizer = wx.StdDialogButtonSizer() |
91 | - btnsizer.AddButton(btn_ok) | |
95 | + btnsizer.AddButton(self.btn_ok) | |
92 | 96 | btnsizer.AddButton(btn_cancel) |
93 | 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 | 100 | style=wx.CB_DROPDOWN|wx.CB_READONLY) |
97 | - combo_interval.SetSelection(0) | |
101 | + self.combo_interval.SetSelection(0) | |
98 | 102 | |
99 | 103 | inner_sizer = wx.BoxSizer(wx.HORIZONTAL) |
100 | 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 | 106 | panel.SetSizer(inner_sizer) |
103 | 107 | inner_sizer.Fit(panel) |
104 | - | |
108 | + | |
105 | 109 | sizer = wx.BoxSizer(wx.VERTICAL) |
106 | 110 | sizer.Add(splitter, 20, wx.EXPAND) |
107 | 111 | sizer.Add(panel, 1, wx.EXPAND|wx.LEFT, 90) |
108 | - | |
112 | + | |
109 | 113 | self.SetSizer(sizer) |
110 | 114 | sizer.Fit(self) |
111 | 115 | |
112 | - self.Layout() | |
113 | - self.Update() | |
114 | - self.SetAutoLayout(1) | |
115 | - | |
116 | 116 | self.text_panel = TextPanel(splitter) |
117 | 117 | splitter.AppendWindow(self.text_panel, 250) |
118 | - | |
118 | + | |
119 | 119 | self.image_panel = ImagePanel(splitter) |
120 | 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 | 126 | def _bind_pubsubevt(self): |
126 | 127 | ps.Publisher().subscribe(self.ShowDicomPreview, "Load import panel") |
127 | 128 | |
... | ... | @@ -129,6 +130,7 @@ class InnerPanel(wx.Panel): |
129 | 130 | self.Bind(EVT_SELECT_SERIE, self.OnSelectSerie) |
130 | 131 | self.Bind(EVT_SELECT_SLICE, self.OnSelectSlice) |
131 | 132 | self.Bind(EVT_SELECT_PATIENT, self.OnSelectPatient) |
133 | + self.btn_ok.Bind(wx.EVT_BUTTON, self.OnLoadDicom) | |
132 | 134 | |
133 | 135 | def ShowDicomPreview(self, pubsub_evt): |
134 | 136 | dicom_groups = pubsub_evt.data |
... | ... | @@ -149,6 +151,12 @@ class InnerPanel(wx.Panel): |
149 | 151 | |
150 | 152 | def OnSelectPatient(self, evt): |
151 | 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 | 162 | class TextPanel(wx.Panel): |
... | ... | @@ -312,6 +320,12 @@ class TextPanel(wx.Panel): |
312 | 320 | self.tree.SelectItem(item) |
313 | 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 | 330 | class ImagePanel(wx.Panel): |
317 | 331 | def __init__(self, parent): | ... | ... |