Commit 579b78ed8e632ef559c533fbdbe5ec55e691aeff
1 parent
20d330b7
Exists in
master
and in
6 other branches
ADD: Menu bar items (under devel)
Showing
3 changed files
with
175 additions
and
62 deletions
Show diff stats
invesalius/constants.py
... | ... | @@ -32,7 +32,6 @@ TEXT_COLOUR = (1,1,1) |
32 | 32 | |
33 | 33 | (X,Y) = (0.03, 0.97) |
34 | 34 | TEXT_POS_LEFT_UP = (X, Y) |
35 | -TEXT_POSITION = TEXT_POS_LEFT_UP | |
36 | 35 | #------------------------------------------------------------------ |
37 | 36 | TEXT_POS_LEFT_DOWN = (X, 1-Y) # SetVerticalJustificationToBottom |
38 | 37 | #------------------------------------------------------------------ |
... | ... | @@ -306,8 +305,20 @@ VTK_WARNING = 0 |
306 | 305 | |
307 | 306 | #---------------------------------------------------------- |
308 | 307 | |
309 | -[ID_FILE_IMPORT, ID_FILE_LOAD_INTERNET, ID_FILE_SAVE, ID_FILE_PHOTO, | |
310 | -ID_FILE_PRINT, ID_FILE_OPEN] = [wx.NewId() for number in range(6)] | |
308 | +[ID_DICOM_IMPORT, ID_PROJECT_OPEN, ID_PROJECT_SAVE_AS, ID_PROJECT_SAVE, | |
309 | +ID_PROJECT_CLOSE, ID_PROJECT_INFO, ID_SAVE_SCREENSHOT, ID_DICOM_LOAD_NET, | |
310 | +ID_PRINT_SCREENSHOT, ID_EXIT] = [wx.NewId() for number in range(10)] | |
311 | + | |
312 | + | |
313 | +[ID_EDIT_UNDO, ID_EDIT_REDO, ID_EDIT_LIST] =\ | |
314 | + [wx.NewId() for number in range(3)] | |
315 | +[ID_TOOL_PROJECT, ID_TOOL_LAYOUT, ID_TOOL_OBJECT, ID_TOOL_SLICE] =\ | |
316 | + [wx.NewId() for number in range(4)] | |
317 | +[ID_TASK_BAR, ID_VIEW_FOUR] =\ | |
318 | + [wx.NewId() for number in range(2)] | |
319 | +[ID_VIEW_FULL, ID_VIEW_TEXT, ID_VIEW_3D_BACKGROUND] =\ | |
320 | + [wx.NewId() for number in range(3)] | |
321 | + | |
311 | 322 | |
312 | 323 | |
313 | 324 | #--------------------------------------------------------- | ... | ... |
invesalius/gui/frame.py
... | ... | @@ -213,9 +213,70 @@ class Frame(wx.Frame): |
213 | 213 | evt.Skip() |
214 | 214 | |
215 | 215 | def OnMenuClick(self, evt): |
216 | - ps.Publisher().sendMessage(("Run menu item", | |
217 | - str(evt.GetId()))) | |
218 | - | |
216 | + #ps.Publisher().sendMessage(("Event from GUI", | |
217 | + # evt.GetId())) | |
218 | + id = evt.GetId() | |
219 | + if id == const.ID_DICOM_IMPORT: | |
220 | + self.ImportDicom() | |
221 | + elif id == const.ID_PROJECT_OPEN: | |
222 | + self.OpenProject() | |
223 | + elif id == const.ID_PROJECT_SAVE: | |
224 | + if Project().save_as: | |
225 | + self.SaveAsProject() | |
226 | + else: | |
227 | + self.SaveProject() | |
228 | + elif id == const.ID_PROJECT_SAVE_AS: | |
229 | + self.SaveAsProject() | |
230 | + elif id == const.ID_PROJECT_CLOSE: | |
231 | + self.CloseProject() | |
232 | + elif id == const.ID_EXIT: | |
233 | + self.Exit() | |
234 | + | |
235 | + def ImportDicom(self): | |
236 | + dirpath = dlg.ShowImportDirDialog() | |
237 | + if dirpath: | |
238 | + ps.Publisher().sendMessage("Load data to import panel", dirpath) | |
239 | + | |
240 | + def OpenProject(self): | |
241 | + filepath = dlg.ShowOpenProjectDialog() | |
242 | + if filepath: | |
243 | + ps.Publisher().sendMessage('Open Project', filepath) | |
244 | + | |
245 | + def SaveAsProject(self): | |
246 | + self.SaveProject(True) | |
247 | + | |
248 | + def SaveProject(self, saveas=False): | |
249 | + filename = (Project().name).replace(' ','_') | |
250 | + if Project().save_as or saveas: | |
251 | + filename = dlg.ShowSaveAsProjectDialog(filename) | |
252 | + if filename: | |
253 | + Project().save_as = False | |
254 | + else: | |
255 | + return | |
256 | + ps.Publisher().sendMessage('Save Project',filename) | |
257 | + | |
258 | + | |
259 | + def SaveAsOld(self): | |
260 | + | |
261 | + filename = (Project().name).replace(' ','_') | |
262 | + filename = dlg.ShowSaveAsProjectDialog(filename) | |
263 | + if filename: | |
264 | + Project().save_as = False | |
265 | + else: | |
266 | + return | |
267 | + self.SaveProject(filename) | |
268 | + | |
269 | + def SaveProjectOld(self, filename=None): | |
270 | + if not filename: | |
271 | + filename = Project().name | |
272 | + ps.Publisher().sendMessage('Save Project',filename) | |
273 | + | |
274 | + def CloseProject(self): | |
275 | + print "TODO: CloseProject" | |
276 | + | |
277 | + def Exit(self): | |
278 | + print "TODO: Exit" | |
279 | + | |
219 | 280 | def ShowTask(self, pubsub_evt): |
220 | 281 | self.aui_manager.GetPane("Tasks").Show() |
221 | 282 | self.aui_manager.Update() |
... | ... | @@ -244,31 +305,80 @@ class MenuBar(wx.MenuBar): |
244 | 305 | |
245 | 306 | def __init_items(self): |
246 | 307 | |
308 | + # FILE | |
247 | 309 | file_menu = wx.Menu() |
248 | - file_menu.Append(const.ID_FILE_IMPORT, "Import...") | |
249 | - file_menu.Append(101, "Exit") | |
250 | - | |
251 | - view_menu = wx.Menu() | |
252 | - view_menu.Append(101, "Fullscreen") | |
253 | - | |
254 | - tools_menu = wx.Menu() | |
255 | - | |
256 | - options_menu = wx.Menu() | |
257 | - | |
310 | + #file_menu.Append(const.ID_DICOM_LOAD_NET, "Import DICOM from Internet...") | |
311 | + file_menu.Append(const.ID_DICOM_IMPORT, "Import DICOM...\tCtrl+I") | |
312 | + file_menu.Append(const.ID_PROJECT_OPEN, "Open Project...\tCtrl+O") | |
313 | + file_menu.Append(const.ID_PROJECT_SAVE, "Save Project\tCtrl+S") | |
314 | + file_menu.Append(const.ID_PROJECT_SAVE_AS, "Save Project As...") | |
315 | + file_menu.Append(const.ID_PROJECT_CLOSE, "Close Project") | |
316 | + file_menu.AppendSeparator() | |
317 | + #file_menu.Append(const.ID_PROJECT_INFO, "Project Information...") | |
318 | + #file_menu.AppendSeparator() | |
319 | + #file_menu.Append(const.ID_SAVE_SCREENSHOT, "Save Screenshot") | |
320 | + #file_menu.Append(const.ID_PRINT_SCREENSHOT, "Print Screenshot") | |
321 | + #file_menu.AppendSeparator() | |
322 | + #file_menu.Append(1, "C:\InvData\sample.inv") | |
323 | + #file_menu.AppendSeparator() | |
324 | + file_menu.Append(const.ID_EXIT, "Exit") | |
325 | + | |
326 | + # EDIT | |
327 | + #file_edit = wx.Menu() | |
328 | + #file_edit.Append(wx.ID_UNDO, "Undo\tCtrl+Z") | |
329 | + #file_edit.Append(wx.ID_REDO, "Redo\tCtrl+Y") | |
330 | + #file_edit.Append(const.ID_EDIT_LIST, "Show Undo List...") | |
331 | + | |
332 | + # VIEW | |
333 | + #view_tool_menu = wx.Menu() | |
334 | + #view_tool_menu.Append(const.ID_TOOL_PROJECT, "Project Toolbar") | |
335 | + #view_tool_menu.Append(const.ID_TOOL_LAYOUT, "Layout Toolbar") | |
336 | + #view_tool_menu.Append(const.ID_TOOL_OBJECT, "Object Toolbar") | |
337 | + #view_tool_menu.Append(const.ID_TOOL_SLICE, "Slice Toolbar") | |
338 | + | |
339 | + #view_layout_menu = wx.Menu() | |
340 | + #view_layout_menu.Append(const.ID_TASK_BAR, "Task Bar") | |
341 | + #view_layout_menu.Append(const.ID_VIEW_FOUR, "Four View") | |
342 | + | |
343 | + | |
344 | + #view_menu = wx.Menu() | |
345 | + #view_menu.AppendMenu(-1, "Toolbars",view_tool_menu) | |
346 | + #view_menu.AppendMenu(-1, "Layout", view_layout_menu) | |
347 | + #view_menu.AppendSeparator() | |
348 | + #view_menu.Append(const.ID_VIEW_FULL, "Fullscreen\tCtrl+F") | |
349 | + #view_menu.AppendSeparator() | |
350 | + #view_menu.Append(const.ID_VIEW_TEXT, "2D & 3D Text") | |
351 | + #view_menu.AppendSeparator() | |
352 | + #view_menu.Append(const.ID_VIEW_3D_BACKGROUND, "3D Background Colour") | |
353 | + | |
354 | + # TOOLS | |
355 | + #tools_menu = wx.Menu() | |
356 | + | |
357 | + # OPTIONS | |
358 | + #options_menu = wx.Menu() | |
359 | + #options_menu.Append(104, "Preferences...") | |
360 | + | |
361 | + # HELP | |
258 | 362 | help_menu = wx.Menu() |
363 | + help_menu.Append(105, "Getting Started...") | |
364 | + #help_menu.Append(108, "User Manual...") | |
365 | + help_menu.AppendSeparator() | |
366 | + help_menu.Append(106, "About...") | |
367 | + #help_menu.Append(107, "Check For Updates Now...") | |
259 | 368 | |
260 | 369 | # TODO: Check what is necessary under MacOS to show Groo and not Python |
261 | 370 | # first menu item... Didn't manage to solve it up to now, the 3 lines |
262 | 371 | # bellow are a frustated test, based on wxPython Demo |
263 | 372 | # TODO: Google about this |
264 | - test_menu = wx.Menu() | |
265 | - test_item = test_menu.Append(-1, '&About Groo', 'Groo RULES!!!') | |
266 | - wx.App.SetMacAboutMenuItemId(test_item.GetId()) | |
373 | + #test_menu = wx.Menu() | |
374 | + #test_item = test_menu.Append(-1, '&About Groo', 'Groo RULES!!!') | |
375 | + #wx.App.SetMacAboutMenuItemId(test_item.GetId()) | |
267 | 376 | |
268 | 377 | self.Append(file_menu, "File") |
269 | - self.Append(view_menu, "View") | |
270 | - self.Append(tools_menu, "Tools") | |
271 | - self.Append(options_menu, "Options") | |
378 | + #self.Append(file_edit, "Edit") | |
379 | + #self.Append(view_menu, "View") | |
380 | + #self.Append(tools_menu, "Tools") | |
381 | + #self.Append(options_menu, "Options") | |
272 | 382 | self.Append(help_menu, "Help") |
273 | 383 | |
274 | 384 | def __bind_events(self): |
... | ... | @@ -276,19 +386,8 @@ class MenuBar(wx.MenuBar): |
276 | 386 | # events should be binded directly from wx.Menu / wx.MenuBar |
277 | 387 | # message "Binding events of wx.MenuBar" on [wxpython-users] |
278 | 388 | # mail list in Oct 20 2008 |
279 | - #self.parent.Bind(wx.EVT_MENU, self.OnNew, id=ID_NEW) | |
280 | - #self.parent.Bind(wx.EVT_MENU, self.OnOpen, id=ID_OPEN) | |
281 | 389 | pass |
282 | 390 | |
283 | - def OnNew(self, event): | |
284 | - print "New" | |
285 | - ps.Publisher().sendMessage(('NEW PROJECT')) | |
286 | - event.Skip() | |
287 | - | |
288 | - def OnOpen(self, event): | |
289 | - print "Open" | |
290 | - event.Skip() | |
291 | - | |
292 | 391 | # ------------------------------------------------------------------ |
293 | 392 | class ProgressBar(wx.Gauge): |
294 | 393 | |
... | ... | @@ -422,31 +521,33 @@ class ProjectToolBar(wx.ToolBar): |
422 | 521 | BMP_PHOTO = wx.Bitmap(os.path.join(const.ICON_DIR, "tool_photo.png"), |
423 | 522 | wx.BITMAP_TYPE_PNG) |
424 | 523 | |
425 | - self.AddLabelTool(const.ID_FILE_LOAD_INTERNET, | |
426 | - "Load medical image...", | |
427 | - BMP_NET) | |
428 | - self.AddLabelTool(const.ID_FILE_IMPORT, | |
524 | + | |
525 | + #self.AddLabelTool(const.ID_DICOM_LOAD_NET, | |
526 | + # "Load medical image...", | |
527 | + # BMP_NET) | |
528 | + self.AddLabelTool(const.ID_DICOM_IMPORT, | |
429 | 529 | "Import medical image...", |
430 | 530 | BMP_IMPORT) |
431 | - self.AddLabelTool(const.ID_FILE_OPEN, | |
531 | + self.AddLabelTool(const.ID_PROJECT_OPEN, | |
432 | 532 | "Open InVesalius 3 project...", |
433 | 533 | BMP_OPEN) |
434 | - self.AddLabelTool(const.ID_FILE_SAVE, | |
534 | + self.AddLabelTool(const.ID_PROJECT_SAVE, | |
435 | 535 | "Save InVesalius project", |
436 | 536 | BMP_SAVE) |
437 | - self.AddLabelTool(const.ID_FILE_PHOTO, | |
438 | - "Take photo of screen", | |
439 | - BMP_PHOTO) | |
440 | - self.AddLabelTool(const.ID_FILE_PRINT, | |
441 | - "Print medical image...", | |
442 | - BMP_PRINT) | |
537 | + #self.AddLabelTool(const.ID_SAVE_SCREENSHOT, | |
538 | + # "Take photo of screen", | |
539 | + # BMP_PHOTO) | |
540 | + #self.AddLabelTool(const.ID_PRINT_SCREENSHOT, | |
541 | + # "Print medical image...", | |
542 | + # BMP_PRINT) | |
443 | 543 | |
444 | 544 | self.Realize() |
445 | 545 | |
446 | 546 | def __bind_events(self): |
447 | - self.Bind(wx.EVT_TOOL, self.OnToolSave, id=const.ID_FILE_SAVE) | |
448 | - self.Bind(wx.EVT_TOOL, self.OnToolOpen, id=const.ID_FILE_OPEN) | |
449 | - self.Bind(wx.EVT_TOOL, self.OnToolImport, id=const.ID_FILE_IMPORT) | |
547 | + | |
548 | + self.Bind(wx.EVT_TOOL, self.OnToolSave, id=const.ID_PROJECT_SAVE) | |
549 | + self.Bind(wx.EVT_TOOL, self.OnToolOpen, id=const.ID_PROJECT_OPEN) | |
550 | + self.Bind(wx.EVT_TOOL, self.OnToolImport, id=const.ID_DICOM_IMPORT) | |
450 | 551 | |
451 | 552 | def OnToolImport(self, event): |
452 | 553 | dirpath = dlg.ShowImportDirDialog() | ... | ... |
invesalius/gui/task_importer.py
... | ... | @@ -70,14 +70,14 @@ class InnerTaskPanel(wx.Panel): |
70 | 70 | link_import_local.UpdateLink() |
71 | 71 | link_import_local.Bind(hl.EVT_HYPERLINK_LEFT, self.OnLinkImport) |
72 | 72 | |
73 | - tooltip = wx.ToolTip("Import DICOM files from PACS server") | |
74 | - link_import_pacs = hl.HyperLinkCtrl(self, -1,"Load from PACS server...") | |
75 | - link_import_pacs.SetUnderlines(False, False, False) | |
76 | - link_import_pacs.SetColours("BLACK", "BLACK", "BLACK") | |
77 | - link_import_pacs.SetToolTip(tooltip) | |
78 | - link_import_pacs.AutoBrowse(False) | |
79 | - link_import_pacs.UpdateLink() | |
80 | - link_import_pacs.Bind(hl.EVT_HYPERLINK_LEFT, self.OnLinkImportPACS) | |
73 | + #tooltip = wx.ToolTip("Import DICOM files from PACS server") | |
74 | + #link_import_pacs = hl.HyperLinkCtrl(self, -1,"Load from PACS server...") | |
75 | + #link_import_pacs.SetUnderlines(False, False, False) | |
76 | + #link_import_pacs.SetColours("BLACK", "BLACK", "BLACK") | |
77 | + #link_import_pacs.SetToolTip(tooltip) | |
78 | + #link_import_pacs.AutoBrowse(False) | |
79 | + #link_import_pacs.UpdateLink() | |
80 | + #link_import_pacs.Bind(hl.EVT_HYPERLINK_LEFT, self.OnLinkImportPACS) | |
81 | 81 | |
82 | 82 | tooltip = wx.ToolTip("Open an existing InVesalius project...") |
83 | 83 | link_open_proj = hl.HyperLinkCtrl(self,-1,"Open an existing project...") |
... | ... | @@ -101,8 +101,8 @@ class InnerTaskPanel(wx.Panel): |
101 | 101 | # Buttons related to hyperlinks |
102 | 102 | button_style = pbtn.PB_STYLE_SQUARE | pbtn.PB_STYLE_DEFAULT |
103 | 103 | |
104 | - button_import_pacs = pbtn.PlateButton(self, BTN_IMPORT_PACS, "", BMP_NET, | |
105 | - style=button_style) | |
104 | + #button_import_pacs = pbtn.PlateButton(self, BTN_IMPORT_PACS, "", BMP_NET, | |
105 | + # style=button_style) | |
106 | 106 | button_import_local = pbtn.PlateButton(self, BTN_IMPORT_LOCAL, "", |
107 | 107 | BMP_IMPORT, style=button_style) |
108 | 108 | button_open_proj = pbtn.PlateButton(self, BTN_OPEN_PROJECT, "", |
... | ... | @@ -115,10 +115,11 @@ class InnerTaskPanel(wx.Panel): |
115 | 115 | flag_link = wx.EXPAND|wx.GROW|wx.LEFT|wx.TOP |
116 | 116 | flag_button = wx.EXPAND | wx.GROW |
117 | 117 | |
118 | - fixed_sizer = wx.FlexGridSizer(rows=3, cols=2, hgap=2, vgap=0) | |
118 | + #fixed_sizer = wx.FlexGridSizer(rows=3, cols=2, hgap=2, vgap=0) | |
119 | + fixed_sizer = wx.FlexGridSizer(rows=2, cols=2, hgap=2, vgap=0) | |
119 | 120 | fixed_sizer.AddGrowableCol(0, 1) |
120 | - fixed_sizer.AddMany([ (link_import_pacs, 1, flag_link, 3), | |
121 | - (button_import_pacs, 0, flag_button), | |
121 | + fixed_sizer.AddMany([ #(link_import_pacs, 1, flag_link, 3), | |
122 | + #(button_import_pacs, 0, flag_button), | |
122 | 123 | (link_import_local, 1, flag_link, 3), |
123 | 124 | (button_import_local, 0, flag_button), |
124 | 125 | (link_open_proj, 1, flag_link, 3), |
... | ... | @@ -134,7 +135,7 @@ class InnerTaskPanel(wx.Panel): |
134 | 135 | self.sizer = main_sizer |
135 | 136 | |
136 | 137 | # Test load and unload specific projects' links |
137 | - self.TestLoadProjects() | |
138 | + #self.TestLoadProjects() | |
138 | 139 | |
139 | 140 | def OnLinkImport(self, event): |
140 | 141 | self.LinkImport() | ... | ... |