Commit ddf1aff6fd810a3a2929b059217036c1f2c2c51d
1 parent
e0499e2f
Exists in
master
and in
6 other branches
ENH: GUI-Flow (tasks) - save surface and next step working
Showing
3 changed files
with
115 additions
and
85 deletions
Show diff stats
invesalius/gui/default_tasks.py
... | ... | @@ -118,6 +118,7 @@ class LowerTaskPanel(wx.Panel): |
118 | 118 | fpb.FPB_COLLAPSE_TO_BOTTOM) |
119 | 119 | |
120 | 120 | self.enable_items = [] |
121 | + self.overwrite = False | |
121 | 122 | |
122 | 123 | sizer = wx.BoxSizer(wx.VERTICAL) |
123 | 124 | sizer.Add(fold_panel, 1, wx.GROW|wx.EXPAND) |
... | ... | @@ -267,6 +268,19 @@ class UpperTaskPanel(wx.Panel): |
267 | 268 | def __bind_events(self): |
268 | 269 | self.fold_panel.Bind(fpb.EVT_CAPTIONBAR, self.OnFoldPressCaption) |
269 | 270 | ps.Publisher().subscribe(self.OnEnableState, "Enable state project") |
271 | + ps.Publisher().subscribe(self.OnOverwrite, 'Create surface from index') | |
272 | + ps.Publisher().subscribe(self.OnFoldSurface, 'Update surface info in GUI') | |
273 | + ps.Publisher().subscribe(self.OnFoldExport, 'Fold export task') | |
274 | + | |
275 | + def OnOverwrite(self, pubsub_evt): | |
276 | + self.overwrite = pubsub_evt.data[1] | |
277 | + | |
278 | + def OnFoldSurface(self, pubsub_evt): | |
279 | + if not self.overwrite: | |
280 | + self.fold_panel.Expand(self.fold_panel.GetFoldPanel(2)) | |
281 | + | |
282 | + def OnFoldExport(self, pubsub_evt): | |
283 | + self.fold_panel.Expand(self.fold_panel.GetFoldPanel(3)) | |
270 | 284 | |
271 | 285 | def OnEnableState(self, pubsub_evt): |
272 | 286 | state = pubsub_evt.data | ... | ... |
invesalius/gui/dialogs.py
... | ... | @@ -384,3 +384,81 @@ def ShowSavePresetDialog(default_filename="raycasting"): |
384 | 384 | filename = dlg.GetValue() |
385 | 385 | |
386 | 386 | return filename |
387 | + | |
388 | + | |
389 | +class NewSurfaceDialog(wx.Dialog): | |
390 | + def __init__(self, parent, ID, title, size=wx.DefaultSize, | |
391 | + pos=wx.DefaultPosition, style=wx.DEFAULT_DIALOG_STYLE, | |
392 | + useMetal=False): | |
393 | + | |
394 | + # Instead of calling wx.Dialog.__init__ we precreate the dialog | |
395 | + # so we can set an extra style that must be set before | |
396 | + # creation, and then we create the GUI object using the Create | |
397 | + # method. | |
398 | + pre = wx.PreDialog() | |
399 | + pre.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP) | |
400 | + pre.Create(parent, ID, title, pos, (500,300), style) | |
401 | + | |
402 | + # This next step is the most important, it turns this Python | |
403 | + # object into the real wrapper of the dialog (instead of pre) | |
404 | + # as far as the wxPython extension is concerned. | |
405 | + self.PostCreate(pre) | |
406 | + | |
407 | + # This extra style can be set after the UI object has been created. | |
408 | + if 'wxMac' in wx.PlatformInfo and useMetal: | |
409 | + self.SetExtraStyle(wx.DIALOG_EX_METAL) | |
410 | + | |
411 | + self.CenterOnScreen() | |
412 | + | |
413 | + # Now continue with the normal construction of the dialog | |
414 | + # contents | |
415 | + | |
416 | + # Label related to mask name | |
417 | + label_mask = wx.StaticText(self, -1, _("Select mask to be used for creating 3D surface:")) | |
418 | + | |
419 | + # Combo related to mask name | |
420 | + combo_surface_name = wx.ComboBox(self, -1, "", choices= MASK_LIST, | |
421 | + style=wx.CB_DROPDOWN|wx.CB_READONLY) | |
422 | + combo_surface_name.SetSelection(0) | |
423 | + if sys.platform != 'win32': | |
424 | + combo_surface_name.SetWindowVariant(wx.WINDOW_VARIANT_SMALL) | |
425 | + self.combo_surface_name = combo_surface_name | |
426 | + | |
427 | + | |
428 | + label_surface = wx.StaticText(self, -1, _("Set new surface name:")) | |
429 | + | |
430 | + text = wx.TextCtrl(self, -1, "", size=(80,-1)) | |
431 | + text.SetHelpText(_("Name of the new surface to be created")) | |
432 | + text.SetValue(_("Surface")) | |
433 | + self.text = text | |
434 | + | |
435 | + sizer = wx.BoxSizer(wx.VERTICAL) | |
436 | + sizer.Add(label_mask, 0, wx.ALL|wx.GROW|wx.EXPAND, 5) | |
437 | + sizer.Add(combo_surface_name, 1, wx.GROW|wx.EXPAND|wx.LEFT|wx.RIGHT, 10) | |
438 | + sizer.Add(label_surface, 0, wx.ALL|wx.GROW|wx.EXPAND, 5) | |
439 | + sizer.Add(text, 0, wx.GROW|wx.EXPAND|wx.RIGHT|wx.LEFT, 10) | |
440 | + | |
441 | + btnsizer = wx.StdDialogButtonSizer() | |
442 | + | |
443 | + #if wx.Platform != "__WXMSW__": | |
444 | + # btn = wx.ContextHelpButton(self) | |
445 | + # btnsizer.AddButton(btn) | |
446 | + | |
447 | + btn = wx.Button(self, wx.ID_OK) | |
448 | + btn.SetDefault() | |
449 | + btnsizer.AddButton(btn) | |
450 | + | |
451 | + btn = wx.Button(self, wx.ID_CANCEL) | |
452 | + btnsizer.AddButton(btn) | |
453 | + btnsizer.Realize() | |
454 | + | |
455 | + sizer.Add(btnsizer, 0, wx.ALIGN_RIGHT|wx.ALL, 5) | |
456 | + | |
457 | + self.SetSizer(sizer) | |
458 | + sizer.Fit(self) | |
459 | + | |
460 | + #def GetValue(self): | |
461 | + # return self.text.GetValue() + _("| mask: ") + MASK_LIST[self.combo_surface_name.GetSelection()] | |
462 | + | |
463 | + | |
464 | + | ... | ... |
invesalius/gui/task_surface.py
... | ... | @@ -23,11 +23,11 @@ import wx.lib.hyperlink as hl |
23 | 23 | import wx.lib.platebtn as pbtn |
24 | 24 | import wx.lib.pubsub as ps |
25 | 25 | |
26 | +import gui.dialogs as dlg | |
26 | 27 | import gui.widgets.foldpanelbar as fpb |
27 | -import widgets.colourselect as csel | |
28 | +import gui.widgets.colourselect as csel | |
28 | 29 | |
29 | 30 | #INTERPOLATION_MODE_LIST = ["Cubic", "Linear", "NearestNeighbor"] |
30 | -QUALITY_LIST = [_("Low"), _("Medium"), _("High"), _("Optimal *"), _("Custom")] | |
31 | 31 | SURFACE_LIST = [] |
32 | 32 | MASK_LIST = [] |
33 | 33 | MIN_TRANSPARENCY = 0 |
... | ... | @@ -102,7 +102,7 @@ class InnerTaskPanel(wx.Panel): |
102 | 102 | button_next = wx.Button(self, -1, _("Next step")) |
103 | 103 | if sys.platform != 'win32': |
104 | 104 | button_next.SetWindowVariant(wx.WINDOW_VARIANT_SMALL) |
105 | - #button_next.Bind(wx.EVT_BUTTON, self.OnButtonNextTask) | |
105 | + button_next.Bind(wx.EVT_BUTTON, self.OnButtonNextTask) | |
106 | 106 | |
107 | 107 | # Add line sizers into main sizer |
108 | 108 | main_sizer = wx.BoxSizer(wx.VERTICAL) |
... | ... | @@ -123,93 +123,18 @@ class InnerTaskPanel(wx.Panel): |
123 | 123 | self.OnLinkNewSurface() |
124 | 124 | |
125 | 125 | def OnButtonNextTask(self, evt): |
126 | - self.OnLinkNewSurface() | |
127 | 126 | if evt: |
127 | + ps.Publisher().sendMessage('Fold export task') | |
128 | 128 | evt.Skip() |
129 | 129 | |
130 | 130 | def OnLinkNewSurface(self, evt=None): |
131 | - dlg = NewSurfaceDialog(self, -1, _('InVesalius 3 - New surface')) | |
131 | + dlg = dlg.NewSurfaceDialog(self, -1, _('InVesalius 3 - New surface')) | |
132 | 132 | if dlg.ShowModal() == wx.ID_OK: |
133 | 133 | print "TODO: Send Signal - Create 3d surface %s \n" % dlg.GetValue() |
134 | 134 | dlg.Destroy() |
135 | 135 | if evt: |
136 | 136 | evt.Skip() |
137 | - #default_colour = wx.SystemSettings_GetColour(wx.SYS_COLOUR_MENUBAR) | |
138 | - #self.SetBackgroundColour(default_colour) | |
139 | 137 | |
140 | -class NewSurfaceDialog(wx.Dialog): | |
141 | - def __init__(self, parent, ID, title, size=wx.DefaultSize, | |
142 | - pos=wx.DefaultPosition, style=wx.DEFAULT_DIALOG_STYLE, | |
143 | - useMetal=False): | |
144 | - | |
145 | - # Instead of calling wx.Dialog.__init__ we precreate the dialog | |
146 | - # so we can set an extra style that must be set before | |
147 | - # creation, and then we create the GUI object using the Create | |
148 | - # method. | |
149 | - pre = wx.PreDialog() | |
150 | - pre.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP) | |
151 | - pre.Create(parent, ID, title, pos, (500,300), style) | |
152 | - | |
153 | - # This next step is the most important, it turns this Python | |
154 | - # object into the real wrapper of the dialog (instead of pre) | |
155 | - # as far as the wxPython extension is concerned. | |
156 | - self.PostCreate(pre) | |
157 | - | |
158 | - # This extra style can be set after the UI object has been created. | |
159 | - if 'wxMac' in wx.PlatformInfo and useMetal: | |
160 | - self.SetExtraStyle(wx.DIALOG_EX_METAL) | |
161 | - | |
162 | - self.CenterOnScreen() | |
163 | - | |
164 | - # Now continue with the normal construction of the dialog | |
165 | - # contents | |
166 | - | |
167 | - # Label related to mask name | |
168 | - label_mask = wx.StaticText(self, -1, _("Select mask to be used for creating 3D surface:")) | |
169 | - | |
170 | - # Combo related to mask name | |
171 | - combo_surface_name = wx.ComboBox(self, -1, "", choices= MASK_LIST, | |
172 | - style=wx.CB_DROPDOWN|wx.CB_READONLY) | |
173 | - combo_surface_name.SetSelection(0) | |
174 | - if sys.platform != 'win32': | |
175 | - combo_surface_name.SetWindowVariant(wx.WINDOW_VARIANT_SMALL) | |
176 | - self.combo_surface_name = combo_surface_name | |
177 | - | |
178 | - | |
179 | - label_surface = wx.StaticText(self, -1, _("Set new surface name:")) | |
180 | - | |
181 | - text = wx.TextCtrl(self, -1, "", size=(80,-1)) | |
182 | - text.SetHelpText(_("Name of the new surface to be created")) | |
183 | - text.SetValue(_("Surface")) | |
184 | - self.text = text | |
185 | - | |
186 | - sizer = wx.BoxSizer(wx.VERTICAL) | |
187 | - sizer.Add(label_mask, 0, wx.ALL|wx.GROW|wx.EXPAND, 5) | |
188 | - sizer.Add(combo_surface_name, 1, wx.GROW|wx.EXPAND|wx.LEFT|wx.RIGHT, 10) | |
189 | - sizer.Add(label_surface, 0, wx.ALL|wx.GROW|wx.EXPAND, 5) | |
190 | - sizer.Add(text, 0, wx.GROW|wx.EXPAND|wx.RIGHT|wx.LEFT, 10) | |
191 | - | |
192 | - btnsizer = wx.StdDialogButtonSizer() | |
193 | - | |
194 | - #if wx.Platform != "__WXMSW__": | |
195 | - # btn = wx.ContextHelpButton(self) | |
196 | - # btnsizer.AddButton(btn) | |
197 | - | |
198 | - btn = wx.Button(self, wx.ID_OK) | |
199 | - btn.SetDefault() | |
200 | - btnsizer.AddButton(btn) | |
201 | - | |
202 | - btn = wx.Button(self, wx.ID_CANCEL) | |
203 | - btnsizer.AddButton(btn) | |
204 | - btnsizer.Realize() | |
205 | - | |
206 | - sizer.Add(btnsizer, 0, wx.ALIGN_RIGHT|wx.ALL, 5) | |
207 | - | |
208 | - self.SetSizer(sizer) | |
209 | - sizer.Fit(self) | |
210 | - | |
211 | - #def GetValue(self): | |
212 | - # return self.text.GetValue() + _("| mask: ") + MASK_LIST[self.combo_surface_name.GetSelection()] | |
213 | 138 | |
214 | 139 | class FoldPanel(wx.Panel): |
215 | 140 | def __init__(self, parent): |
... | ... | @@ -239,7 +164,7 @@ class InnerFoldPanel(wx.Panel): |
239 | 164 | # parent panel. Perhaps we need to insert the item into the sizer also... |
240 | 165 | # Study this. |
241 | 166 | fold_panel = fpb.FoldPanelBar(self, -1, wx.DefaultPosition, |
242 | - (10, 170), 0,fpb.FPB_SINGLE_FOLD) | |
167 | + (10, 100), 0,fpb.FPB_SINGLE_FOLD) | |
243 | 168 | |
244 | 169 | # Fold panel style |
245 | 170 | style = fpb.CaptionBarStyle() |
... | ... | @@ -254,11 +179,14 @@ class InnerFoldPanel(wx.Panel): |
254 | 179 | leftSpacing=0, rightSpacing=0) |
255 | 180 | fold_panel.Expand(fold_panel.GetFoldPanel(0)) |
256 | 181 | |
257 | - # Fold 2 - Surface quality | |
258 | - item = fold_panel.AddFoldPanel(_("Surface quality"), collapsed=True) | |
182 | + # Fold 2 - Surface tools | |
183 | + item = fold_panel.AddFoldPanel(_("Advanced options"), collapsed=True) | |
259 | 184 | fold_panel.ApplyCaptionStyle(item, style) |
260 | - fold_panel.AddFoldPanelWindow(item, QualityAdjustment(item), Spacing= 0, | |
185 | + fold_panel.AddFoldPanelWindow(item, SurfaceTools(item), Spacing= 0, | |
261 | 186 | leftSpacing=0, rightSpacing=0) |
187 | + | |
188 | + #fold_panel.AddFoldPanelWindow(item, QualityAdjustment(item), Spacing= 0, | |
189 | + # leftSpacing=0, rightSpacing=0) | |
262 | 190 | #fold_panel.Expand(fold_panel.GetFoldPanel(1)) |
263 | 191 | |
264 | 192 | # Panel sizer to expand fold panel |
... | ... | @@ -270,6 +198,13 @@ class InnerFoldPanel(wx.Panel): |
270 | 198 | self.Update() |
271 | 199 | self.SetAutoLayout(1) |
272 | 200 | |
201 | + | |
202 | +class SurfaceTools(wx.Panel): | |
203 | + def __init__(self, parent): | |
204 | + wx.Panel.__init__(self, parent, size=(50,240)) | |
205 | + default_colour = wx.SystemSettings_GetColour(wx.SYS_COLOUR_MENUBAR) | |
206 | + self.SetBackgroundColour(default_colour) | |
207 | + | |
273 | 208 | class SurfaceProperties(wx.Panel): |
274 | 209 | def __init__(self, parent): |
275 | 210 | wx.Panel.__init__(self, parent, size=(50,240)) |
... | ... | @@ -386,14 +321,17 @@ class SurfaceProperties(wx.Panel): |
386 | 321 | (self.combo_surface_name.GetSelection(), |
387 | 322 | transparency)) |
388 | 323 | |
324 | + | |
389 | 325 | class QualityAdjustment(wx.Panel): |
390 | 326 | def __init__(self, parent): |
327 | + import constants as const | |
391 | 328 | wx.Panel.__init__(self, parent, size=(50,240)) |
392 | 329 | default_colour = wx.SystemSettings_GetColour(wx.SYS_COLOUR_MENUBAR) |
393 | 330 | self.SetBackgroundColour(default_colour) |
394 | 331 | |
395 | 332 | # LINE 1 |
396 | - combo_quality = wx.ComboBox(self, -1, "", choices= QUALITY_LIST, | |
333 | + | |
334 | + combo_quality = wx.ComboBox(self, -1, "", choices=const.SURFACE_QUALITY.keys(), | |
397 | 335 | style=wx.CB_DROPDOWN|wx.CB_READONLY) |
398 | 336 | combo_quality.SetSelection(3) |
399 | 337 | combo_quality.SetWindowVariant(wx.WINDOW_VARIANT_SMALL) | ... | ... |