Commit a343ff3be889983ad0e39f47a070ac23d18fa21e
1 parent
50d89b62
Exists in
master
and in
68 other branches
STL: Added comments / cleaned up code
Showing
1 changed file
with
430 additions
and
320 deletions
Show diff stats
invesalius/gui/frame.py
| @@ -35,10 +35,10 @@ import project as prj | @@ -35,10 +35,10 @@ import project as prj | ||
| 35 | import session as ses | 35 | import session as ses |
| 36 | import utils | 36 | import utils |
| 37 | 37 | ||
| 38 | - | ||
| 39 | -# Layout tools' IDs - this is used only locally, therefore doesn't need | ||
| 40 | -# to be defined in constants.py | ||
| 41 | -VIEW_TOOLS = [ID_LAYOUT, ID_TEXT] = [wx.NewId() for number in range(2)] | 38 | +# Layout tools' IDs - this is used only locally, therefore doesn't |
| 39 | +# need to be defined in constants.py | ||
| 40 | +VIEW_TOOLS = [ID_LAYOUT, ID_TEXT] =\ | ||
| 41 | + [wx.NewId() for number in range(2)] | ||
| 42 | 42 | ||
| 43 | class Frame(wx.Frame): | 43 | class Frame(wx.Frame): |
| 44 | """ | 44 | """ |
| @@ -53,19 +53,15 @@ class Frame(wx.Frame): | @@ -53,19 +53,15 @@ class Frame(wx.Frame): | ||
| 53 | size=wx.Size(1024, 748), #size = wx.DisplaySize(), | 53 | size=wx.Size(1024, 748), #size = wx.DisplaySize(), |
| 54 | style=wx.DEFAULT_FRAME_STYLE, title='InVesalius 3') | 54 | style=wx.DEFAULT_FRAME_STYLE, title='InVesalius 3') |
| 55 | self.Center(wx.BOTH) | 55 | self.Center(wx.BOTH) |
| 56 | - self.SetIcon(wx.Icon(os.path.join(const.ICON_DIR, "invesalius.ico"), | ||
| 57 | - wx.BITMAP_TYPE_ICO)) | ||
| 58 | - self.Maximize() | 56 | + icon_path = os.path.join(const.ICON_DIR, "invesalius.ico") |
| 57 | + self.SetIcon(wx.Icon(icon_path, wx.BITMAP_TYPE_ICO)) | ||
| 58 | + #self.Maximize() | ||
| 59 | 59 | ||
| 60 | # Set menus, status and task bar | 60 | # Set menus, status and task bar |
| 61 | self.SetMenuBar(MenuBar(self)) | 61 | self.SetMenuBar(MenuBar(self)) |
| 62 | self.SetStatusBar(StatusBar(self)) | 62 | self.SetStatusBar(StatusBar(self)) |
| 63 | 63 | ||
| 64 | - # TaskBarIcon has different behaviours according to the | ||
| 65 | - # platform: | ||
| 66 | - # - win32: Show icon on "Notification Area" at "Task Bar" | ||
| 67 | - # - darwin: Show icon on Dock | ||
| 68 | - # - linux2: ? - TODO: find what it does | 64 | + # Set TaskBarIcon |
| 69 | TaskBarIcon(self) | 65 | TaskBarIcon(self) |
| 70 | 66 | ||
| 71 | # Create aui manager and insert content in it | 67 | # Create aui manager and insert content in it |
| @@ -79,18 +75,19 @@ class Frame(wx.Frame): | @@ -79,18 +75,19 @@ class Frame(wx.Frame): | ||
| 79 | """ | 75 | """ |
| 80 | Bind events related to pubsub. | 76 | Bind events related to pubsub. |
| 81 | """ | 77 | """ |
| 82 | - ps.Publisher().subscribe(self._BeginBusyCursor, 'Begin busy cursor') | ||
| 83 | - ps.Publisher().subscribe(self._ShowContentPanel, 'Cancel DICOM load') | ||
| 84 | - ps.Publisher().subscribe(self._Exit, 'Close Window') | ||
| 85 | - ps.Publisher().subscribe(self._EndBusyCursor, 'End busy cursor') | ||
| 86 | - ps.Publisher().subscribe(self._HideContentPanel, 'Hide content panel') | ||
| 87 | - ps.Publisher().subscribe(self._HideImportPanel, 'Hide import panel') | ||
| 88 | - ps.Publisher().subscribe(self._HideTask, 'Hide task panel') | ||
| 89 | - ps.Publisher().subscribe(self._SetProjectName, 'Set project name') | ||
| 90 | - ps.Publisher().subscribe(self._ShowContentPanel, 'Show content panel') | ||
| 91 | - ps.Publisher().subscribe(self._ShowImportPanel, 'Show import panel in frame') | ||
| 92 | - ps.Publisher().subscribe(self._ShowTask, 'Show task panel') | ||
| 93 | - ps.Publisher().subscribe(self._UpdateAUI, 'Update AUI') | 78 | + sub = ps.Publisher().subscribe |
| 79 | + sub(self._BeginBusyCursor, 'Begin busy cursor') | ||
| 80 | + sub(self._ShowContentPanel, 'Cancel DICOM load') | ||
| 81 | + sub(self._Exit, 'Close Window') | ||
| 82 | + sub(self._EndBusyCursor, 'End busy cursor') | ||
| 83 | + sub(self._HideContentPanel, 'Hide content panel') | ||
| 84 | + sub(self._HideImportPanel, 'Hide import panel') | ||
| 85 | + sub(self._HideTask, 'Hide task panel') | ||
| 86 | + sub(self._SetProjectName, 'Set project name') | ||
| 87 | + sub(self._ShowContentPanel, 'Show content panel') | ||
| 88 | + sub(self._ShowImportPanel, 'Show import panel in frame') | ||
| 89 | + sub(self._ShowTask, 'Show task panel') | ||
| 90 | + sub(self._UpdateAUI, 'Update AUI') | ||
| 94 | 91 | ||
| 95 | def __bind_events_wx(self): | 92 | def __bind_events_wx(self): |
| 96 | """ | 93 | """ |
| @@ -123,16 +120,16 @@ class Frame(wx.Frame): | @@ -123,16 +120,16 @@ class Frame(wx.Frame): | ||
| 123 | aui_manager.AddPane(viewers.Panel(self), wx.aui.AuiPaneInfo(). | 120 | aui_manager.AddPane(viewers.Panel(self), wx.aui.AuiPaneInfo(). |
| 124 | Caption(_("Data panel")).CaptionVisible(False). | 121 | Caption(_("Data panel")).CaptionVisible(False). |
| 125 | Centre().CloseButton(False).Floatable(False). | 122 | Centre().CloseButton(False).Floatable(False). |
| 126 | - Hide().Layer(1).MaximizeButton(True).Name("Data"). | ||
| 127 | - Position(1)) | 123 | + Hide().Layer(1).MaximizeButton(True). |
| 124 | + Name("Data").Position(1)) | ||
| 128 | 125 | ||
| 129 | # This is the DICOM import panel. When the two panels above | 126 | # This is the DICOM import panel. When the two panels above |
| 130 | # are shown, this should be hiden | 127 | # are shown, this should be hiden |
| 128 | + caption = _("Preview medical data to be reconstructed") | ||
| 131 | aui_manager.AddPane(imp.Panel(self), wx.aui.AuiPaneInfo(). | 129 | aui_manager.AddPane(imp.Panel(self), wx.aui.AuiPaneInfo(). |
| 132 | Name("Import").Centre().Hide(). | 130 | Name("Import").Centre().Hide(). |
| 133 | MaximizeButton(True).Floatable(True). | 131 | MaximizeButton(True).Floatable(True). |
| 134 | - Caption(_("Preview medical data to be reconstructed")). | ||
| 135 | - CaptionVisible(True)) | 132 | + Caption(caption).CaptionVisible(True)) |
| 136 | 133 | ||
| 137 | # Add toolbars to manager | 134 | # Add toolbars to manager |
| 138 | # This is pretty tricky -- order on win32 is inverted when | 135 | # This is pretty tricky -- order on win32 is inverted when |
| @@ -189,7 +186,7 @@ class Frame(wx.Frame): | @@ -189,7 +186,7 @@ class Frame(wx.Frame): | ||
| 189 | try: | 186 | try: |
| 190 | wx.EndBusyCursor() | 187 | wx.EndBusyCursor() |
| 191 | except wx._core.PyAssertionError: | 188 | except wx._core.PyAssertionError: |
| 192 | - #xEndBusyCursor(): no matching wxBeginBusyCursor() for wxEndBusyCursor() | 189 | + #no matching wxBeginBusyCursor() for wxEndBusyCursor() |
| 193 | pass | 190 | pass |
| 194 | 191 | ||
| 195 | def _Exit(self, pubsub_evt): | 192 | def _Exit(self, pubsub_evt): |
| @@ -330,7 +327,8 @@ class Frame(wx.Frame): | @@ -330,7 +327,8 @@ class Frame(wx.Frame): | ||
| 330 | """ | 327 | """ |
| 331 | Show getting started window. | 328 | Show getting started window. |
| 332 | """ | 329 | """ |
| 333 | - path = os.path.join(const.DOC_DIR, "user_guide_invesalius3a.pdf") | 330 | + path = os.path.join(const.DOC_DIR, |
| 331 | + "user_guide_invesalius3a.pdf") | ||
| 334 | webbrowser.open(path) | 332 | webbrowser.open(path) |
| 335 | 333 | ||
| 336 | def ShowImportDicomPanel(self): | 334 | def ShowImportDicomPanel(self): |
| @@ -357,7 +355,8 @@ class Frame(wx.Frame): | @@ -357,7 +355,8 @@ class Frame(wx.Frame): | ||
| 357 | 355 | ||
| 358 | class MenuBar(wx.MenuBar): | 356 | class MenuBar(wx.MenuBar): |
| 359 | """ | 357 | """ |
| 360 | - MenuBar which contains menus used to control project, tools and help. | 358 | + MenuBar which contains menus used to control project, tools and |
| 359 | + help. | ||
| 361 | """ | 360 | """ |
| 362 | def __init__(self, parent): | 361 | def __init__(self, parent): |
| 363 | wx.MenuBar.__init__(self) | 362 | wx.MenuBar.__init__(self) |
| @@ -382,7 +381,8 @@ class MenuBar(wx.MenuBar): | @@ -382,7 +381,8 @@ class MenuBar(wx.MenuBar): | ||
| 382 | # events should be binded directly from wx.Menu / wx.MenuBar | 381 | # events should be binded directly from wx.Menu / wx.MenuBar |
| 383 | # message "Binding events of wx.MenuBar" on [wxpython-users] | 382 | # message "Binding events of wx.MenuBar" on [wxpython-users] |
| 384 | # mail list in Oct 20 2008 | 383 | # mail list in Oct 20 2008 |
| 385 | - ps.Publisher().subscribe(self.OnEnableState, "Enable state project") | 384 | + sub = ps.Publisher().subscribe |
| 385 | + sub(self.OnEnableState, "Enable state project") | ||
| 386 | 386 | ||
| 387 | def __init_items(self): | 387 | def __init_items(self): |
| 388 | """ | 388 | """ |
| @@ -392,48 +392,54 @@ class MenuBar(wx.MenuBar): | @@ -392,48 +392,54 @@ class MenuBar(wx.MenuBar): | ||
| 392 | 392 | ||
| 393 | # FILE | 393 | # FILE |
| 394 | file_menu = wx.Menu() | 394 | file_menu = wx.Menu() |
| 395 | - file_menu.Append(const.ID_DICOM_IMPORT, _("Import DICOM...\tCtrl+I")) | ||
| 396 | - #file_menu.Append(const.ID_DICOM_LOAD_NET, _("Import DICOM from PACS...")) | ||
| 397 | - file_menu.Append(const.ID_PROJECT_OPEN, _("Open Project...\tCtrl+O")) | ||
| 398 | - file_menu.Append(const.ID_PROJECT_SAVE, _("Save Project\tCtrl+S")) | ||
| 399 | - file_menu.Append(const.ID_PROJECT_SAVE_AS, _("Save Project As...")) | ||
| 400 | - file_menu.Append(const.ID_PROJECT_CLOSE, _("Close Project")) | 395 | + app = file_menu.Append |
| 396 | + app(const.ID_DICOM_IMPORT, _("Import DICOM...\tCtrl+I")) | ||
| 397 | + #app(const.ID_DICOM_LOAD_NET, _("Import DICOM from PACS...")) | ||
| 398 | + app(const.ID_PROJECT_OPEN, _("Open Project...\tCtrl+O")) | ||
| 399 | + app(const.ID_PROJECT_SAVE, _("Save Project\tCtrl+S")) | ||
| 400 | + app(const.ID_PROJECT_SAVE_AS, _("Save Project As...")) | ||
| 401 | + app(const.ID_PROJECT_CLOSE, _("Close Project")) | ||
| 401 | file_menu.AppendSeparator() | 402 | file_menu.AppendSeparator() |
| 402 | - #file_menu.Append(const.ID_PROJECT_INFO, _("Project Information...")) | 403 | + #app(const.ID_PROJECT_INFO, _("Project Information...")) |
| 403 | #file_menu.AppendSeparator() | 404 | #file_menu.AppendSeparator() |
| 404 | - #file_menu.Append(const.ID_SAVE_SCREENSHOT, _("Save Screenshot")) | ||
| 405 | - #file_menu.Append(const.ID_PRINT_SCREENSHOT, _("Print Screenshot")) | 405 | + #app(const.ID_SAVE_SCREENSHOT, _("Save Screenshot")) |
| 406 | + #app(const.ID_PRINT_SCREENSHOT, _("Print Screenshot")) | ||
| 406 | #file_menu.AppendSeparator() | 407 | #file_menu.AppendSeparator() |
| 407 | - #file_menu.Append(1, "C:\InvData\sample.inv") | 408 | + #app(1, "C:\InvData\sample.inv") |
| 408 | #file_menu.AppendSeparator() | 409 | #file_menu.AppendSeparator() |
| 409 | - file_menu.Append(const.ID_EXIT, _("Exit")) | 410 | + app(const.ID_EXIT, _("Exit")) |
| 410 | 411 | ||
| 411 | # EDIT | 412 | # EDIT |
| 412 | #file_edit = wx.Menu() | 413 | #file_edit = wx.Menu() |
| 413 | - #file_edit.Append(wx.ID_UNDO, "Undo\tCtrl+Z") | ||
| 414 | - #file_edit.Append(wx.ID_REDO, "Redo\tCtrl+Y") | ||
| 415 | - #file_edit.Append(const.ID_EDIT_LIST, "Show Undo List...") | 414 | + #app = file_edit.Append |
| 415 | + #app(wx.ID_UNDO, "Undo\tCtrl+Z") | ||
| 416 | + #app(wx.ID_REDO, "Redo\tCtrl+Y") | ||
| 417 | + #app(const.ID_EDIT_LIST, "Show Undo List...") | ||
| 416 | 418 | ||
| 417 | # VIEW | 419 | # VIEW |
| 418 | #view_tool_menu = wx.Menu() | 420 | #view_tool_menu = wx.Menu() |
| 419 | - #view_tool_menu.Append(const.ID_TOOL_PROJECT, "Project Toolbar") | ||
| 420 | - #view_tool_menu.Append(const.ID_TOOL_LAYOUT, "Layout Toolbar") | ||
| 421 | - #view_tool_menu.Append(const.ID_TOOL_OBJECT, "Object Toolbar") | ||
| 422 | - #view_tool_menu.Append(const.ID_TOOL_SLICE, "Slice Toolbar") | 421 | + #app = view_tool_menu.Append |
| 422 | + #app(const.ID_TOOL_PROJECT, "Project Toolbar") | ||
| 423 | + #app(const.ID_TOOL_LAYOUT, "Layout Toolbar") | ||
| 424 | + #app(const.ID_TOOL_OBJECT, "Object Toolbar") | ||
| 425 | + #app(const.ID_TOOL_SLICE, "Slice Toolbar") | ||
| 423 | 426 | ||
| 424 | #view_layout_menu = wx.Menu() | 427 | #view_layout_menu = wx.Menu() |
| 425 | - #view_layout_menu.Append(const.ID_TASK_BAR, "Task Bar") | ||
| 426 | - #view_layout_menu.Append(const.ID_VIEW_FOUR, "Four View") | 428 | + #app = view_layout_menu.Append |
| 429 | + #app(const.ID_TASK_BAR, "Task Bar") | ||
| 430 | + #app(const.ID_VIEW_FOUR, "Four View") | ||
| 427 | 431 | ||
| 428 | #view_menu = wx.Menu() | 432 | #view_menu = wx.Menu() |
| 429 | - #view_menu.AppendMenu(-1, "Toolbars",view_tool_menu) | ||
| 430 | - #view_menu.AppendMenu(-1, "Layout", view_layout_menu) | 433 | + #app = view_menu.Append |
| 434 | + #appm = view_menu.AppendMenu | ||
| 435 | + #appm(-1, "Toolbars",view_tool_menu) | ||
| 436 | + #appm(-1, "Layout", view_layout_menu) | ||
| 431 | #view_menu.AppendSeparator() | 437 | #view_menu.AppendSeparator() |
| 432 | - #view_menu.Append(const.ID_VIEW_FULL, "Fullscreen\tCtrl+F") | 438 | + #app(const.ID_VIEW_FULL, "Fullscreen\tCtrl+F") |
| 433 | #view_menu.AppendSeparator() | 439 | #view_menu.AppendSeparator() |
| 434 | - #view_menu.Append(const.ID_VIEW_TEXT, "2D & 3D Text") | 440 | + #app(const.ID_VIEW_TEXT, "2D & 3D Text") |
| 435 | #view_menu.AppendSeparator() | 441 | #view_menu.AppendSeparator() |
| 436 | - #view_menu.Append(const.ID_VIEW_3D_BACKGROUND, "3D Background Colour") | 442 | + #app(const.ID_VIEW_3D_BACKGROUND, "3D Background Colour") |
| 437 | 443 | ||
| 438 | # TOOLS | 444 | # TOOLS |
| 439 | #tools_menu = wx.Menu() | 445 | #tools_menu = wx.Menu() |
| @@ -452,13 +458,17 @@ class MenuBar(wx.MenuBar): | @@ -452,13 +458,17 @@ class MenuBar(wx.MenuBar): | ||
| 452 | 458 | ||
| 453 | # TODO: Check what is necessary under MacOS to show | 459 | # TODO: Check what is necessary under MacOS to show |
| 454 | # InVesalius and not Python | 460 | # InVesalius and not Python |
| 455 | - # first menu item... Didn't manage to solve it up to now, the 3 lines | ||
| 456 | - # bellow are a frustated test, based on wxPython Demo | 461 | + # first menu item... Didn't manage to solve it up to now, |
| 462 | + # the 3 lines bellow are a frustated test, based on wxPython | ||
| 463 | + # Demo | ||
| 464 | + | ||
| 457 | # TODO: Google about this | 465 | # TODO: Google about this |
| 458 | #test_menu = wx.Menu() | 466 | #test_menu = wx.Menu() |
| 459 | - #test_item = test_menu.Append(-1, '&About InVesalius','InVesalius') | ||
| 460 | - #wx.App.SetMacAboutMenuItemId(test_item.GetId()) | 467 | + #item = test_menu.Append(-1, |
| 468 | + # &About InVesalius','InVesalius') | ||
| 469 | + #wx.App.SetMacAboutMenuItemId(item.GetId()) | ||
| 461 | 470 | ||
| 471 | + # Add all menus to menubar | ||
| 462 | self.Append(file_menu, _("File")) | 472 | self.Append(file_menu, _("File")) |
| 463 | #self.Append(file_edit, "Edit") | 473 | #self.Append(file_edit, "Edit") |
| 464 | #self.Append(view_menu, "View") | 474 | #self.Append(view_menu, "View") |
| @@ -466,7 +476,6 @@ class MenuBar(wx.MenuBar): | @@ -466,7 +476,6 @@ class MenuBar(wx.MenuBar): | ||
| 466 | #self.Append(options_menu, "Options") | 476 | #self.Append(options_menu, "Options") |
| 467 | self.Append(help_menu, _("Help")) | 477 | self.Append(help_menu, _("Help")) |
| 468 | 478 | ||
| 469 | - | ||
| 470 | def OnEnableState(self, pubsub_evt): | 479 | def OnEnableState(self, pubsub_evt): |
| 471 | """ | 480 | """ |
| 472 | Based on given state, enables or disables menu items which | 481 | Based on given state, enables or disables menu items which |
| @@ -496,7 +505,6 @@ class MenuBar(wx.MenuBar): | @@ -496,7 +505,6 @@ class MenuBar(wx.MenuBar): | ||
| 496 | # ------------------------------------------------------------------ | 505 | # ------------------------------------------------------------------ |
| 497 | # ------------------------------------------------------------------ | 506 | # ------------------------------------------------------------------ |
| 498 | 507 | ||
| 499 | - | ||
| 500 | class ProgressBar(wx.Gauge): | 508 | class ProgressBar(wx.Gauge): |
| 501 | """ | 509 | """ |
| 502 | Progress bar / gauge. | 510 | Progress bar / gauge. |
| @@ -513,8 +521,8 @@ class ProgressBar(wx.Gauge): | @@ -513,8 +521,8 @@ class ProgressBar(wx.Gauge): | ||
| 513 | """ | 521 | """ |
| 514 | Bind events related to pubsub. | 522 | Bind events related to pubsub. |
| 515 | """ | 523 | """ |
| 516 | - ps.Publisher().subscribe(self._Layout, | ||
| 517 | - 'ProgressBar Reposition') | 524 | + sub = ps.Publisher().subscribe |
| 525 | + sub(self._Layout, 'ProgressBar Reposition') | ||
| 518 | 526 | ||
| 519 | def _Layout(self, evt_pubsub=None): | 527 | def _Layout(self, evt_pubsub=None): |
| 520 | """ | 528 | """ |
| @@ -538,7 +546,6 @@ class ProgressBar(wx.Gauge): | @@ -538,7 +546,6 @@ class ProgressBar(wx.Gauge): | ||
| 538 | # ------------------------------------------------------------------ | 546 | # ------------------------------------------------------------------ |
| 539 | # ------------------------------------------------------------------ | 547 | # ------------------------------------------------------------------ |
| 540 | 548 | ||
| 541 | - | ||
| 542 | class StatusBar(wx.StatusBar): | 549 | class StatusBar(wx.StatusBar): |
| 543 | """ | 550 | """ |
| 544 | Control general status (both text and gauge) | 551 | Control general status (both text and gauge) |
| @@ -562,10 +569,9 @@ class StatusBar(wx.StatusBar): | @@ -562,10 +569,9 @@ class StatusBar(wx.StatusBar): | ||
| 562 | """ | 569 | """ |
| 563 | Bind events related to pubsub. | 570 | Bind events related to pubsub. |
| 564 | """ | 571 | """ |
| 565 | - ps.Publisher().subscribe(self._SetProgressValue, | ||
| 566 | - 'Update status in GUI') | ||
| 567 | - ps.Publisher().subscribe(self._SetProgressLabel, | ||
| 568 | - 'Update status text in GUI') | 572 | + sub = ps.Publisher().subscribe |
| 573 | + sub(self._SetProgressValue, 'Update status in GUI') | ||
| 574 | + sub(self._SetProgressLabel, 'Update status text in GUI') | ||
| 569 | 575 | ||
| 570 | def _SetProgressValue(self, pubsub_evt): | 576 | def _SetProgressValue(self, pubsub_evt): |
| 571 | """ | 577 | """ |
| @@ -593,12 +599,17 @@ class StatusBar(wx.StatusBar): | @@ -593,12 +599,17 @@ class StatusBar(wx.StatusBar): | ||
| 593 | label = pubsub_evt.data | 599 | label = pubsub_evt.data |
| 594 | self.SetStatusText(label, 0) | 600 | self.SetStatusText(label, 0) |
| 595 | 601 | ||
| 596 | - | ||
| 597 | # ------------------------------------------------------------------ | 602 | # ------------------------------------------------------------------ |
| 598 | # ------------------------------------------------------------------ | 603 | # ------------------------------------------------------------------ |
| 599 | # ------------------------------------------------------------------ | 604 | # ------------------------------------------------------------------ |
| 600 | 605 | ||
| 601 | class TaskBarIcon(wx.TaskBarIcon): | 606 | class TaskBarIcon(wx.TaskBarIcon): |
| 607 | + """ | ||
| 608 | + TaskBarIcon has different behaviours according to the platform: | ||
| 609 | + - win32: Show icon on "Notification Area" at "Task Bar" | ||
| 610 | + - darwin: Show icon on Dock | ||
| 611 | + - linux2: ? - TODO: find what it does | ||
| 612 | + """ | ||
| 602 | def __init__(self, parent=None): | 613 | def __init__(self, parent=None): |
| 603 | wx.TaskBarIcon.__init__(self) | 614 | wx.TaskBarIcon.__init__(self) |
| 604 | self.frame = parent | 615 | self.frame = parent |
| @@ -614,67 +625,91 @@ class TaskBarIcon(wx.TaskBarIcon): | @@ -614,67 +625,91 @@ class TaskBarIcon(wx.TaskBarIcon): | ||
| 614 | def OnTaskBarActivate(self): | 625 | def OnTaskBarActivate(self): |
| 615 | pass | 626 | pass |
| 616 | 627 | ||
| 617 | - | ||
| 618 | # ------------------------------------------------------------------ | 628 | # ------------------------------------------------------------------ |
| 619 | # ------------------------------------------------------------------ | 629 | # ------------------------------------------------------------------ |
| 620 | # ------------------------------------------------------------------ | 630 | # ------------------------------------------------------------------ |
| 621 | 631 | ||
| 622 | class ProjectToolBar(wx.ToolBar): | 632 | class ProjectToolBar(wx.ToolBar): |
| 633 | + """ | ||
| 634 | + Toolbar related to general project operations, including: import, | ||
| 635 | + open, save and saveas, among others. | ||
| 636 | + """ | ||
| 623 | def __init__(self, parent): | 637 | def __init__(self, parent): |
| 638 | + style = wx.TB_FLAT|wx.TB_NODIVIDER| wx.TB_DOCKABLE | ||
| 624 | wx.ToolBar.__init__(self, parent, -1, wx.DefaultPosition, | 639 | wx.ToolBar.__init__(self, parent, -1, wx.DefaultPosition, |
| 625 | wx.DefaultSize, | 640 | wx.DefaultSize, |
| 626 | - wx.TB_FLAT|wx.TB_NODIVIDER| wx.TB_DOCKABLE) | ||
| 627 | - | 641 | + style) |
| 628 | self.SetToolBitmapSize(wx.Size(32,32)) | 642 | self.SetToolBitmapSize(wx.Size(32,32)) |
| 629 | 643 | ||
| 630 | self.parent = parent | 644 | self.parent = parent |
| 645 | + | ||
| 646 | + # Used to enable/disable menu items if project is opened or | ||
| 647 | + # not. Eg. save should only be available if a project is open | ||
| 648 | + self.enable_items = [const.ID_PROJECT_SAVE] | ||
| 649 | + | ||
| 631 | self.__init_items() | 650 | self.__init_items() |
| 632 | self.__bind_events() | 651 | self.__bind_events() |
| 633 | 652 | ||
| 634 | - #FIXME: | ||
| 635 | - self.save_as = True | 653 | + self.Realize() |
| 654 | + self.SetStateProjectClose() | ||
| 655 | + | ||
| 656 | + def __bind_events(self): | ||
| 657 | + """ | ||
| 658 | + Bind events related to pubsub. | ||
| 659 | + """ | ||
| 660 | + sub = ps.Publisher().subscribe | ||
| 661 | + sub(self._EnableState, "Enable state project") | ||
| 636 | 662 | ||
| 637 | def __init_items(self): | 663 | def __init_items(self): |
| 638 | - | 664 | + """ |
| 665 | + Add tools into toolbar. | ||
| 666 | + """ | ||
| 667 | + # Load bitmaps | ||
| 668 | + d = const.ICON_DIR | ||
| 639 | if sys.platform == 'darwin': | 669 | if sys.platform == 'darwin': |
| 640 | - BMP_NET = wx.Bitmap(os.path.join(const.ICON_DIR, | ||
| 641 | - "file_from_internet_original.png"), | ||
| 642 | - wx.BITMAP_TYPE_PNG) | ||
| 643 | - BMP_IMPORT = wx.Bitmap(os.path.join(const.ICON_DIR, | ||
| 644 | - "file_import_original.png"), | ||
| 645 | - wx.BITMAP_TYPE_PNG) | ||
| 646 | - BMP_OPEN = wx.Bitmap(os.path.join(const.ICON_DIR,"file_open_original.png"), | ||
| 647 | - wx.BITMAP_TYPE_PNG) | ||
| 648 | - BMP_SAVE = wx.Bitmap(os.path.join(const.ICON_DIR, | ||
| 649 | - "file_save_original.png"), | ||
| 650 | - wx.BITMAP_TYPE_PNG) | ||
| 651 | - BMP_PRINT = wx.Bitmap(os.path.join(const.ICON_DIR, | ||
| 652 | - "print_original.png"), | ||
| 653 | - wx.BITMAP_TYPE_PNG) | ||
| 654 | - BMP_PHOTO = wx.Bitmap(os.path.join(const.ICON_DIR, | ||
| 655 | - "tool_photo_original.png"), | ||
| 656 | - wx.BITMAP_TYPE_PNG) | 670 | + path = os.path.join(d,"file_from_internet_original.png") |
| 671 | + BMP_NET = wx.Bitmap(path, wx.BITMAP_TYPE_PNG) | ||
| 672 | + | ||
| 673 | + path = os.path.join(d, "file_import_original.png") | ||
| 674 | + BMP_IMPORT = wx.Bitmap(path, wx.BITMAP_TYPE_PNG) | ||
| 675 | + | ||
| 676 | + path = os.path.join(d, "file_open_original.png") | ||
| 677 | + BMP_OPEN = wx.Bitmap(path, wx.BITMAP_TYPE_PNG) | ||
| 678 | + | ||
| 679 | + path = os.path.join(d, "file_save_original.png") | ||
| 680 | + BMP_SAVE = wx.Bitmap(path, wx.BITMAP_TYPE_PNG) | ||
| 681 | + | ||
| 682 | + path = os.path.join(d, "print_original.png") | ||
| 683 | + BMP_PRINT = wx.Bitmap(path, wx.BITMAP_TYPE_PNG) | ||
| 684 | + | ||
| 685 | + path = os.path.join(d, "tool_photo_original.png") | ||
| 686 | + BMP_PHOTO = wx.Bitmap(path, wx.BITMAP_TYPE_PNG) | ||
| 657 | else: | 687 | else: |
| 658 | - BMP_NET = wx.Bitmap(os.path.join(const.ICON_DIR,"file_from_internet.png"), | ||
| 659 | - wx.BITMAP_TYPE_PNG) | ||
| 660 | - BMP_IMPORT = wx.Bitmap(os.path.join(const.ICON_DIR, "file_import.png"), | ||
| 661 | - wx.BITMAP_TYPE_PNG) | ||
| 662 | - BMP_OPEN = wx.Bitmap(os.path.join(const.ICON_DIR,"file_open.png"), | ||
| 663 | - wx.BITMAP_TYPE_PNG) | ||
| 664 | - BMP_SAVE = wx.Bitmap(os.path.join(const.ICON_DIR, "file_save.png"), | ||
| 665 | - wx.BITMAP_TYPE_PNG) | ||
| 666 | - BMP_PRINT = wx.Bitmap(os.path.join(const.ICON_DIR, "print.png"), | ||
| 667 | - wx.BITMAP_TYPE_PNG) | ||
| 668 | - BMP_PHOTO = wx.Bitmap(os.path.join(const.ICON_DIR, "tool_photo.png"), | ||
| 669 | - wx.BITMAP_TYPE_PNG) | 688 | + path = os.path.join(d, "file_from_internet.png") |
| 689 | + BMP_NET = wx.Bitmap(path, wx.BITMAP_TYPE_PNG) | ||
| 670 | 690 | ||
| 691 | + path = os.path.join(d, "file_import.png") | ||
| 692 | + BMP_IMPORT = wx.Bitmap(path, wx.BITMAP_TYPE_PNG) | ||
| 693 | + | ||
| 694 | + path = os.path.join(d, "file_open.png") | ||
| 695 | + BMP_OPEN = wx.Bitmap(path, wx.BITMAP_TYPE_PNG) | ||
| 671 | 696 | ||
| 672 | - #self.AddLabelTool(const.ID_DICOM_LOAD_NET, | ||
| 673 | - # "Load medical image...", | ||
| 674 | - # BMP_NET) | 697 | + path = os.path.join(d, "file_save.png") |
| 698 | + BMP_SAVE = wx.Bitmap(path, wx.BITMAP_TYPE_PNG) | ||
| 699 | + | ||
| 700 | + path = os.path.join(d, "print.png"), | ||
| 701 | + BMP_PRINT = wx.Bitmap(path, wx.BITMAP_TYPE_PNG) | ||
| 702 | + | ||
| 703 | + path = os.path.join(d, "tool_photo.png"), | ||
| 704 | + BMP_PHOTO = wx.Bitmap(path, wx.BITMAP_TYPE_PNG) | ||
| 705 | + | ||
| 706 | + # Create tool items based on bitmaps | ||
| 675 | self.AddLabelTool(const.ID_DICOM_IMPORT, | 707 | self.AddLabelTool(const.ID_DICOM_IMPORT, |
| 676 | _("Import medical image..."), | 708 | _("Import medical image..."), |
| 677 | BMP_IMPORT) | 709 | BMP_IMPORT) |
| 710 | + #self.AddLabelTool(const.ID_DICOM_LOAD_NET, | ||
| 711 | + # "Load medical image...", | ||
| 712 | + # BMP_NET) | ||
| 678 | self.AddLabelTool(const.ID_PROJECT_OPEN, | 713 | self.AddLabelTool(const.ID_PROJECT_OPEN, |
| 679 | _("Open InVesalius 3 project..."), | 714 | _("Open InVesalius 3 project..."), |
| 680 | BMP_OPEN) | 715 | BMP_OPEN) |
| @@ -687,56 +722,32 @@ class ProjectToolBar(wx.ToolBar): | @@ -687,56 +722,32 @@ class ProjectToolBar(wx.ToolBar): | ||
| 687 | #self.AddLabelTool(const.ID_PRINT_SCREENSHOT, | 722 | #self.AddLabelTool(const.ID_PRINT_SCREENSHOT, |
| 688 | # "Print medical image...", | 723 | # "Print medical image...", |
| 689 | # BMP_PRINT) | 724 | # BMP_PRINT) |
| 690 | - self.enable_items = [const.ID_PROJECT_SAVE] | ||
| 691 | - | ||
| 692 | - self.Realize() | ||
| 693 | - self.SetStateProjectClose() | ||
| 694 | - | ||
| 695 | - def SetStateProjectOpen(self): | ||
| 696 | - for tool in self.enable_items: | ||
| 697 | - self.EnableTool(tool, True) | ||
| 698 | 725 | ||
| 699 | - def SetStateProjectClose(self): | ||
| 700 | - for tool in self.enable_items: | ||
| 701 | - self.EnableTool(tool, False) | ||
| 702 | - | ||
| 703 | - def OnEnableState(self, pubsub_evt): | 726 | + def _EnableState(self, pubsub_evt): |
| 727 | + """ | ||
| 728 | + Based on given state, enable or disable menu items which | ||
| 729 | + depend if project is open or not. | ||
| 730 | + """ | ||
| 704 | state = pubsub_evt.data | 731 | state = pubsub_evt.data |
| 705 | if state: | 732 | if state: |
| 706 | self.SetStateProjectOpen() | 733 | self.SetStateProjectOpen() |
| 707 | else: | 734 | else: |
| 708 | self.SetStateProjectClose() | 735 | self.SetStateProjectClose() |
| 709 | 736 | ||
| 710 | - def __bind_events(self): | ||
| 711 | - ps.Publisher().subscribe(self.OnEnableState, "Enable state project") | ||
| 712 | - | ||
| 713 | - #self.Bind(wx.EVT_TOOL, self.OnToolSave, id=const.ID_PROJECT_SAVE) | ||
| 714 | - #self.Bind(wx.EVT_TOOL, self.OnToolOpen, id=const.ID_PROJECT_OPEN) | ||
| 715 | - #self.Bind(wx.EVT_TOOL, self.OnToolImport, id=const.ID_DICOM_IMPORT) | ||
| 716 | - | ||
| 717 | - def OnToolImport(self, event): | ||
| 718 | - dirpath = dlg.ShowImportDirDialog() | ||
| 719 | - if dirpath: | ||
| 720 | - ps.Publisher().sendMessage("Load data to import panel", dirpath) | ||
| 721 | - event.Skip() | ||
| 722 | - | ||
| 723 | - def OnToolOpen(self, event): | ||
| 724 | - filepath = dlg.ShowOpenProjectDialog() | ||
| 725 | - if filepath: | ||
| 726 | - ps.Publisher().sendMessage('Open Project', filepath) | ||
| 727 | - event.Skip() | ||
| 728 | - | ||
| 729 | - def OnToolSave(self, event): | ||
| 730 | - proj = prj.Project() | ||
| 731 | - filename = (prj.name).replace(' ','_') | ||
| 732 | - if prj.save_as: | ||
| 733 | - filename = dlg.ShowSaveAsProjectDialog(filename) | ||
| 734 | - if filename: | ||
| 735 | - prj.save_as = False | ||
| 736 | - else: | ||
| 737 | - return | ||
| 738 | - ps.Publisher().sendMessage('Save Project',filename) | ||
| 739 | - event.Skip() | 737 | + def SetStateProjectClose(self): |
| 738 | + """ | ||
| 739 | + Disable menu items (e.g. save) when project is closed. | ||
| 740 | + """ | ||
| 741 | + for tool in self.enable_items: | ||
| 742 | + self.EnableTool(tool, False) | ||
| 743 | + | ||
| 744 | + def SetStateProjectOpen(self): | ||
| 745 | + """ | ||
| 746 | + Enable menu items (e.g. save) when project is opened. | ||
| 747 | + """ | ||
| 748 | + for tool in self.enable_items: | ||
| 749 | + self.EnableTool(tool, True) | ||
| 750 | + | ||
| 740 | 751 | ||
| 741 | 752 | ||
| 742 | # ------------------------------------------------------------------ | 753 | # ------------------------------------------------------------------ |
| @@ -744,109 +755,126 @@ class ProjectToolBar(wx.ToolBar): | @@ -744,109 +755,126 @@ class ProjectToolBar(wx.ToolBar): | ||
| 744 | # ------------------------------------------------------------------ | 755 | # ------------------------------------------------------------------ |
| 745 | 756 | ||
| 746 | class ObjectToolBar(wx.ToolBar): | 757 | class ObjectToolBar(wx.ToolBar): |
| 758 | + """ | ||
| 759 | + Toolbar related to general object operations, including: zoom | ||
| 760 | + move, rotate, brightness/contrast, etc. | ||
| 761 | + """ | ||
| 747 | def __init__(self, parent): | 762 | def __init__(self, parent): |
| 763 | + style = wx.TB_FLAT|wx.TB_NODIVIDER | wx.TB_DOCKABLE | ||
| 748 | wx.ToolBar.__init__(self, parent, -1, wx.DefaultPosition, | 764 | wx.ToolBar.__init__(self, parent, -1, wx.DefaultPosition, |
| 749 | - wx.DefaultSize, | ||
| 750 | - wx.TB_FLAT|wx.TB_NODIVIDER | wx.TB_DOCKABLE) | 765 | + wx.DefaultSize, style) |
| 751 | 766 | ||
| 752 | self.SetToolBitmapSize(wx.Size(32,32)) | 767 | self.SetToolBitmapSize(wx.Size(32,32)) |
| 768 | + | ||
| 753 | self.parent = parent | 769 | self.parent = parent |
| 770 | + # Used to enable/disable menu items if project is opened or | ||
| 771 | + # not. Eg. save should only be available if a project is open | ||
| 772 | + self.enable_items = [const.STATE_WL, const.STATE_PAN, | ||
| 773 | + const.STATE_SPIN, const.STATE_ZOOM_SL, | ||
| 774 | + const.STATE_ZOOM] | ||
| 754 | 775 | ||
| 755 | self.__init_items() | 776 | self.__init_items() |
| 756 | self.__bind_events() | 777 | self.__bind_events() |
| 757 | self.__bind_events_wx() | 778 | self.__bind_events_wx() |
| 758 | 779 | ||
| 759 | - def __init_items(self): | 780 | + self.Realize() |
| 781 | + self.SetStateProjectClose() | ||
| 782 | + | ||
| 783 | + def __bind_events(self): | ||
| 784 | + """ | ||
| 785 | + Bind events related to pubsub. | ||
| 786 | + """ | ||
| 787 | + sub = ps.Publisher().subscribe | ||
| 788 | + sub(self._EnableState, "Enable state project") | ||
| 789 | + sub(self._UntoggleAllItems, 'Untoggle object toolbar items') | ||
| 790 | + | ||
| 791 | + | ||
| 792 | + def __bind_events_wx(self): | ||
| 793 | + """ | ||
| 794 | + Bind normal events from wx (except pubsub related). | ||
| 795 | + """ | ||
| 796 | + self.Bind(wx.EVT_TOOL, self.OnToggle) | ||
| 760 | 797 | ||
| 798 | + def __init_items(self): | ||
| 799 | + """ | ||
| 800 | + Add tools into toolbar. | ||
| 801 | + """ | ||
| 802 | + d = const.ICON_DIR | ||
| 761 | if sys.platform == 'darwin': | 803 | if sys.platform == 'darwin': |
| 762 | - BMP_ROTATE = wx.Bitmap(os.path.join(const.ICON_DIR, | ||
| 763 | - "tool_rotate_original.gif"), | ||
| 764 | - wx.BITMAP_TYPE_GIF) | ||
| 765 | - BMP_MOVE =wx.Bitmap(os.path.join(const.ICON_DIR, | ||
| 766 | - "tool_translate_original.png"), | ||
| 767 | - wx.BITMAP_TYPE_PNG) | ||
| 768 | - BMP_ZOOM = wx.Bitmap(os.path.join(const.ICON_DIR, | ||
| 769 | - "tool_zoom_original.png"), | ||
| 770 | - wx.BITMAP_TYPE_PNG) | ||
| 771 | - BMP_ZOOM_SELECT = wx.Bitmap(os.path.join(const.ICON_DIR, | ||
| 772 | - "tool_zoom_select_original.png"), | ||
| 773 | - wx.BITMAP_TYPE_PNG) | ||
| 774 | - BMP_CONTRAST = wx.Bitmap(os.path.join(const.ICON_DIR, | ||
| 775 | - "tool_contrast_original.png"), | ||
| 776 | - wx.BITMAP_TYPE_PNG) | 804 | + path = os.path.join(d, "tool_rotate_original.gif") |
| 805 | + BMP_ROTATE = wx.Bitmap(path, wx.BITMAP_TYPE_GIF) | ||
| 806 | + | ||
| 807 | + path = os.path.join(d, "tool_translate_original.png") | ||
| 808 | + BMP_MOVE =wx.Bitmap(path, wx.BITMAP_TYPE_PNG) | ||
| 809 | + | ||
| 810 | + path = os.path.join(d, "tool_zoom_original.png") | ||
| 811 | + BMP_ZOOM = wx.Bitmap(path, wx.BITMAP_TYPE_PNG) | ||
| 812 | + | ||
| 813 | + path = os.path.join(d, "tool_zoom_select_original.png") | ||
| 814 | + BMP_ZOOM_SELECT = wx.Bitmap(path, wx.BITMAP_TYPE_PNG) | ||
| 815 | + | ||
| 816 | + path = os.path.join(d, "tool_contrast_original.png") | ||
| 817 | + BMP_CONTRAST = wx.Bitmap(path, wx.BITMAP_TYPE_PNG) | ||
| 777 | else: | 818 | else: |
| 819 | + path = os.path.join(d, "tool_rotate.gif") | ||
| 820 | + BMP_ROTATE = wx.Bitmap(path, wx.BITMAP_TYPE_GIF) | ||
| 821 | + | ||
| 822 | + path = os.path.join(d, "tool_translate.png") | ||
| 823 | + BMP_MOVE =wx.Bitmap(path, wx.BITMAP_TYPE_PNG) | ||
| 824 | + | ||
| 825 | + path = os.path.join(d, "tool_zoom.png") | ||
| 826 | + BMP_ZOOM = wx.Bitmap(path, wx.BITMAP_TYPE_PNG) | ||
| 778 | 827 | ||
| 779 | - BMP_ROTATE = wx.Bitmap(os.path.join(const.ICON_DIR, | ||
| 780 | - "tool_rotate.gif"), | ||
| 781 | - wx.BITMAP_TYPE_GIF) | ||
| 782 | - BMP_MOVE = wx.Bitmap(os.path.join(const.ICON_DIR, | ||
| 783 | - "tool_translate.gif"), | ||
| 784 | - wx.BITMAP_TYPE_GIF) | ||
| 785 | - BMP_ZOOM = wx.Bitmap(os.path.join(const.ICON_DIR, "tool_zoom.png"), | ||
| 786 | - wx.BITMAP_TYPE_PNG) | ||
| 787 | - BMP_ZOOM_SELECT = wx.Bitmap(os.path.join(const.ICON_DIR, | ||
| 788 | - "tool_zoom_select.png"), | ||
| 789 | - wx.BITMAP_TYPE_PNG) | ||
| 790 | - BMP_CONTRAST = wx.Bitmap(os.path.join(const.ICON_DIR, | ||
| 791 | - "tool_contrast.png"), | ||
| 792 | - wx.BITMAP_TYPE_PNG) | 828 | + path = os.path.join(d, "tool_zoom_select.png") |
| 829 | + BMP_ZOOM_SELECT = wx.Bitmap(path, wx.BITMAP_TYPE_PNG) | ||
| 793 | 830 | ||
| 831 | + path = os.path.join(d, "tool_contrast.png") | ||
| 832 | + BMP_CONTRAST = wx.Bitmap(path, wx.BITMAP_TYPE_PNG) | ||
| 833 | + | ||
| 834 | + # Create tool items based on bitmaps | ||
| 794 | self.AddLabelTool(const.STATE_ZOOM, | 835 | self.AddLabelTool(const.STATE_ZOOM, |
| 795 | _("Zoom"), | 836 | _("Zoom"), |
| 796 | BMP_ZOOM, | 837 | BMP_ZOOM, |
| 797 | kind = wx.ITEM_CHECK) | 838 | kind = wx.ITEM_CHECK) |
| 798 | - | ||
| 799 | self.AddLabelTool(const.STATE_ZOOM_SL, | 839 | self.AddLabelTool(const.STATE_ZOOM_SL, |
| 800 | _("Zoom based on selection"), | 840 | _("Zoom based on selection"), |
| 801 | BMP_ZOOM_SELECT, | 841 | BMP_ZOOM_SELECT, |
| 802 | kind = wx.ITEM_CHECK) | 842 | kind = wx.ITEM_CHECK) |
| 803 | - | ||
| 804 | self.AddLabelTool(const.STATE_SPIN, | 843 | self.AddLabelTool(const.STATE_SPIN, |
| 805 | _("Rotate"), BMP_ROTATE, | 844 | _("Rotate"), BMP_ROTATE, |
| 806 | kind = wx.ITEM_CHECK) | 845 | kind = wx.ITEM_CHECK) |
| 807 | - | ||
| 808 | self.AddLabelTool(const.STATE_PAN, | 846 | self.AddLabelTool(const.STATE_PAN, |
| 809 | _("Move"), BMP_MOVE, | 847 | _("Move"), BMP_MOVE, |
| 810 | kind = wx.ITEM_CHECK) | 848 | kind = wx.ITEM_CHECK) |
| 811 | - | ||
| 812 | self.AddLabelTool(const.STATE_WL, | 849 | self.AddLabelTool(const.STATE_WL, |
| 813 | _("Window and Level"), BMP_CONTRAST, | 850 | _("Window and Level"), BMP_CONTRAST, |
| 814 | kind = wx.ITEM_CHECK) | 851 | kind = wx.ITEM_CHECK) |
| 815 | 852 | ||
| 816 | - self.enable_items = [const.STATE_WL, const.STATE_PAN, const.STATE_SPIN, | ||
| 817 | - const.STATE_ZOOM_SL, const.STATE_ZOOM,] | ||
| 818 | - | ||
| 819 | - self.Realize() | ||
| 820 | - self.SetStateProjectClose() | ||
| 821 | - | ||
| 822 | - | ||
| 823 | - def OnEnableState(self, pubsub_evt): | 853 | + def _EnableState(self, pubsub_evt): |
| 854 | + """ | ||
| 855 | + Based on given state, enable or disable menu items which | ||
| 856 | + depend if project is open or not. | ||
| 857 | + """ | ||
| 824 | state = pubsub_evt.data | 858 | state = pubsub_evt.data |
| 825 | if state: | 859 | if state: |
| 826 | self.SetStateProjectOpen() | 860 | self.SetStateProjectOpen() |
| 827 | else: | 861 | else: |
| 828 | self.SetStateProjectClose() | 862 | self.SetStateProjectClose() |
| 829 | 863 | ||
| 830 | - def SetStateProjectOpen(self): | ||
| 831 | - for tool in self.enable_items: | ||
| 832 | - self.EnableTool(tool, True) | ||
| 833 | - | ||
| 834 | - def SetStateProjectClose(self): | ||
| 835 | - for tool in self.enable_items: | ||
| 836 | - self.EnableTool(tool, False) | ||
| 837 | - self.UntoggleAllItems() | ||
| 838 | - | ||
| 839 | - | ||
| 840 | - def __bind_events_wx(self): | ||
| 841 | - self.Bind(wx.EVT_TOOL, self.OnToggle) | ||
| 842 | - | ||
| 843 | - def __bind_events(self): | ||
| 844 | - ps.Publisher().subscribe(self.UntoggleAllItems, | ||
| 845 | - 'Untoggle object toolbar items') | ||
| 846 | - ps.Publisher().subscribe(self.OnEnableState, "Enable state project") | ||
| 847 | - | 864 | + def _UntoggleAllItems(self, pubsub_evt=None): |
| 865 | + """ | ||
| 866 | + Untoggle all items on toolbar. | ||
| 867 | + """ | ||
| 868 | + for id in const.TOOL_STATES: | ||
| 869 | + state = self.GetToolState(id) | ||
| 870 | + if state: | ||
| 871 | + self.ToggleTool(id, False) | ||
| 848 | 872 | ||
| 849 | def OnToggle(self, evt): | 873 | def OnToggle(self, evt): |
| 874 | + """ | ||
| 875 | + Update status of other items on toolbar (only one item | ||
| 876 | + should be toggle each time). | ||
| 877 | + """ | ||
| 850 | id = evt.GetId() | 878 | id = evt.GetId() |
| 851 | state = self.GetToolState(id) | 879 | state = self.GetToolState(id) |
| 852 | if state: | 880 | if state: |
| @@ -859,83 +887,114 @@ class ObjectToolBar(wx.ToolBar): | @@ -859,83 +887,114 @@ class ObjectToolBar(wx.ToolBar): | ||
| 859 | state = self.GetToolState(item) | 887 | state = self.GetToolState(item) |
| 860 | if state and (item != id): | 888 | if state and (item != id): |
| 861 | self.ToggleTool(item, False) | 889 | self.ToggleTool(item, False) |
| 862 | - | ||
| 863 | evt.Skip() | 890 | evt.Skip() |
| 864 | 891 | ||
| 892 | + def SetStateProjectClose(self): | ||
| 893 | + """ | ||
| 894 | + Disable menu items (e.g. zoom) when project is closed. | ||
| 895 | + """ | ||
| 896 | + for tool in self.enable_items: | ||
| 897 | + self.EnableTool(tool, False) | ||
| 898 | + self._UntoggleAllItems() | ||
| 865 | 899 | ||
| 866 | - def UntoggleAllItems(self, pubsub_evt=None): | ||
| 867 | - for id in const.TOOL_STATES: | ||
| 868 | - state = self.GetToolState(id) | ||
| 869 | - if state: | ||
| 870 | - self.ToggleTool(id, False) | ||
| 871 | - | 900 | + def SetStateProjectOpen(self): |
| 901 | + """ | ||
| 902 | + Enable menu items (e.g. zoom) when project is opened. | ||
| 903 | + """ | ||
| 904 | + for tool in self.enable_items: | ||
| 905 | + self.EnableTool(tool, True) | ||
| 872 | 906 | ||
| 873 | # ------------------------------------------------------------------ | 907 | # ------------------------------------------------------------------ |
| 874 | # ------------------------------------------------------------------ | 908 | # ------------------------------------------------------------------ |
| 875 | # ------------------------------------------------------------------ | 909 | # ------------------------------------------------------------------ |
| 876 | 910 | ||
| 877 | class SliceToolBar(wx.ToolBar): | 911 | class SliceToolBar(wx.ToolBar): |
| 912 | + """ | ||
| 913 | + Toolbar related to 2D slice specific operations, including: cross | ||
| 914 | + intersection reference and scroll slices. | ||
| 915 | + """ | ||
| 878 | def __init__(self, parent): | 916 | def __init__(self, parent): |
| 917 | + style = wx.TB_FLAT|wx.TB_NODIVIDER | wx.TB_DOCKABLE | ||
| 879 | wx.ToolBar.__init__(self, parent, -1, wx.DefaultPosition, | 918 | wx.ToolBar.__init__(self, parent, -1, wx.DefaultPosition, |
| 880 | wx.DefaultSize, | 919 | wx.DefaultSize, |
| 881 | - wx.TB_FLAT|wx.TB_NODIVIDER | wx.TB_DOCKABLE) | 920 | + style) |
| 882 | 921 | ||
| 883 | self.SetToolBitmapSize(wx.Size(32,32)) | 922 | self.SetToolBitmapSize(wx.Size(32,32)) |
| 884 | 923 | ||
| 885 | self.parent = parent | 924 | self.parent = parent |
| 925 | + self.enable_items = [const.SLICE_STATE_SCROLL, | ||
| 926 | + const.SLICE_STATE_CROSS] | ||
| 886 | self.__init_items() | 927 | self.__init_items() |
| 887 | self.__bind_events() | 928 | self.__bind_events() |
| 888 | self.__bind_events_wx() | 929 | self.__bind_events_wx() |
| 889 | 930 | ||
| 931 | + self.Realize() | ||
| 932 | + self.SetStateProjectClose() | ||
| 933 | + | ||
| 890 | def __init_items(self): | 934 | def __init_items(self): |
| 935 | + """ | ||
| 936 | + Add tools into toolbar. | ||
| 937 | + """ | ||
| 938 | + d = const.ICON_DIR | ||
| 891 | if sys.platform == 'darwin': | 939 | if sys.platform == 'darwin': |
| 892 | - BMP_SLICE = wx.Bitmap(os.path.join(const.ICON_DIR, | ||
| 893 | - "slice_original.png"), | ||
| 894 | - wx.BITMAP_TYPE_PNG) | 940 | + path = os.path.join(d, "slice_original.png") |
| 941 | + BMP_SLICE = wx.Bitmap(path, wx.BITMAP_TYPE_PNG) | ||
| 895 | 942 | ||
| 896 | - BMP_CROSS = wx.Bitmap(os.path.join(const.ICON_DIR,"cross_original.png"), | ||
| 897 | - wx.BITMAP_TYPE_PNG) | 943 | + path = os.path.join(d,"cross_original.png") |
| 944 | + BMP_CROSS = wx.Bitmap(path, wx.BITMAP_TYPE_PNG) | ||
| 898 | else: | 945 | else: |
| 899 | - BMP_SLICE = wx.Bitmap(os.path.join(const.ICON_DIR, "slice.png"), | ||
| 900 | - wx.BITMAP_TYPE_PNG) | ||
| 901 | - | ||
| 902 | - BMP_CROSS = wx.Bitmap(os.path.join(const.ICON_DIR, "cross.png"), | ||
| 903 | - wx.BITMAP_TYPE_PNG) | 946 | + path = os.path.join(d, "slice.png") |
| 947 | + BMP_SLICE = wx.Bitmap(path, wx.BITMAP_TYPE_PNG) | ||
| 904 | 948 | ||
| 949 | + path = os.path.join(d,"cross.png") | ||
| 950 | + BMP_CROSS = wx.Bitmap(path, wx.BITMAP_TYPE_PNG) | ||
| 905 | 951 | ||
| 906 | self.AddCheckTool(const.SLICE_STATE_SCROLL, BMP_SLICE) | 952 | self.AddCheckTool(const.SLICE_STATE_SCROLL, BMP_SLICE) |
| 907 | self.AddCheckTool(const.SLICE_STATE_CROSS, BMP_CROSS) | 953 | self.AddCheckTool(const.SLICE_STATE_CROSS, BMP_CROSS) |
| 908 | 954 | ||
| 909 | - self.enable_items = [const.SLICE_STATE_SCROLL, const.SLICE_STATE_CROSS,] | ||
| 910 | - self.Realize() | ||
| 911 | - self.SetStateProjectClose() | ||
| 912 | - | ||
| 913 | - def SetStateProjectOpen(self): | ||
| 914 | - for tool in self.enable_items: | ||
| 915 | - self.EnableTool(tool, True) | ||
| 916 | - | ||
| 917 | - def SetStateProjectClose(self): | ||
| 918 | - for tool in self.enable_items: | ||
| 919 | - self.EnableTool(tool, False) | 955 | + def __bind_events(self): |
| 956 | + """ | ||
| 957 | + Bind events related to pubsub. | ||
| 958 | + """ | ||
| 959 | + sub = ps.Publisher().subscribe | ||
| 960 | + sub(self._EnableState, "Enable state project") | ||
| 961 | + sub(self._UntoggleAllItems, 'Untoggle slice toolbar items') | ||
| 920 | 962 | ||
| 921 | def __bind_events_wx(self): | 963 | def __bind_events_wx(self): |
| 922 | - self.Bind(wx.EVT_TOOL, self.OnClick) | ||
| 923 | - | ||
| 924 | - def __bind_events(self): | ||
| 925 | - ps.Publisher().subscribe(self.UntoggleAllItems, | ||
| 926 | - 'Untoggle slice toolbar items') | ||
| 927 | - ps.Publisher().subscribe(self.OnEnableState, "Enable state project") | 964 | + """ |
| 965 | + Bind normal events from wx (except pubsub related). | ||
| 966 | + """ | ||
| 967 | + self.Bind(wx.EVT_TOOL, self.OnToggle) | ||
| 928 | 968 | ||
| 929 | - def OnEnableState(self, pubsub_evt): | 969 | + def _EnableState(self, pubsub_evt): |
| 970 | + """ | ||
| 971 | + Based on given state, enable or disable menu items which | ||
| 972 | + depend if project is open or not. | ||
| 973 | + """ | ||
| 930 | state = pubsub_evt.data | 974 | state = pubsub_evt.data |
| 931 | if state: | 975 | if state: |
| 932 | self.SetStateProjectOpen() | 976 | self.SetStateProjectOpen() |
| 933 | else: | 977 | else: |
| 934 | self.SetStateProjectClose() | 978 | self.SetStateProjectClose() |
| 935 | - self.UntoggleAllItems() | 979 | + self._UntoggleAllItems() |
| 936 | 980 | ||
| 981 | + def _UntoggleAllItems(self, pubsub_evt=None): | ||
| 982 | + """ | ||
| 983 | + Untoggle all items on toolbar. | ||
| 984 | + """ | ||
| 985 | + for id in const.TOOL_SLICE_STATES: | ||
| 986 | + state = self.GetToolState(id) | ||
| 987 | + if state: | ||
| 988 | + self.ToggleTool(id, False) | ||
| 989 | + if id == const.SLICE_STATE_CROSS: | ||
| 990 | + msg = 'Set cross visibility' | ||
| 991 | + ps.Publisher().sendMessage(msg, 0) | ||
| 937 | 992 | ||
| 938 | - def OnClick(self, evt): | 993 | + def OnToggle(self, evt): |
| 994 | + """ | ||
| 995 | + Update status of other items on toolbar (only one item | ||
| 996 | + should be toggle each time). | ||
| 997 | + """ | ||
| 939 | id = evt.GetId() | 998 | id = evt.GetId() |
| 940 | state = self.GetToolState(id) | 999 | state = self.GetToolState(id) |
| 941 | 1000 | ||
| @@ -952,115 +1011,168 @@ class SliceToolBar(wx.ToolBar): | @@ -952,115 +1011,168 @@ class SliceToolBar(wx.ToolBar): | ||
| 952 | 1011 | ||
| 953 | evt.Skip() | 1012 | evt.Skip() |
| 954 | 1013 | ||
| 1014 | + def SetStateProjectClose(self): | ||
| 1015 | + """ | ||
| 1016 | + Disable menu items (e.g. cross) when project is closed. | ||
| 1017 | + """ | ||
| 1018 | + for tool in self.enable_items: | ||
| 1019 | + self.EnableTool(tool, False) | ||
| 955 | 1020 | ||
| 956 | - def UntoggleAllItems(self, pubsub_evt=None): | ||
| 957 | - for id in const.TOOL_SLICE_STATES: | ||
| 958 | - state = self.GetToolState(id) | ||
| 959 | - if state: | ||
| 960 | - self.ToggleTool(id, False) | ||
| 961 | - if id == const.SLICE_STATE_CROSS: | ||
| 962 | - ps.Publisher().sendMessage('Set cross visibility', 0) | ||
| 963 | - | 1021 | + def SetStateProjectOpen(self): |
| 1022 | + """ | ||
| 1023 | + Enable menu items (e.g. cross) when project is opened. | ||
| 1024 | + """ | ||
| 1025 | + for tool in self.enable_items: | ||
| 1026 | + self.EnableTool(tool, True) | ||
| 964 | 1027 | ||
| 965 | # ------------------------------------------------------------------ | 1028 | # ------------------------------------------------------------------ |
| 966 | # ------------------------------------------------------------------ | 1029 | # ------------------------------------------------------------------ |
| 967 | # ------------------------------------------------------------------ | 1030 | # ------------------------------------------------------------------ |
| 968 | 1031 | ||
| 969 | class LayoutToolBar(wx.ToolBar): | 1032 | class LayoutToolBar(wx.ToolBar): |
| 1033 | + """ | ||
| 1034 | + Toolbar related to general layout/ visualization configuration | ||
| 1035 | + e.g: show/hide task panel and show/hide text on viewers. | ||
| 1036 | + """ | ||
| 970 | def __init__(self, parent): | 1037 | def __init__(self, parent): |
| 1038 | + style = wx.TB_FLAT|wx.TB_NODIVIDER | wx.TB_DOCKABLE | ||
| 971 | wx.ToolBar.__init__(self, parent, -1, wx.DefaultPosition, | 1039 | wx.ToolBar.__init__(self, parent, -1, wx.DefaultPosition, |
| 972 | wx.DefaultSize, | 1040 | wx.DefaultSize, |
| 973 | - wx.TB_FLAT|wx.TB_NODIVIDER | wx.TB_DOCKABLE) | 1041 | + style) |
| 974 | 1042 | ||
| 975 | self.SetToolBitmapSize(wx.Size(32,32)) | 1043 | self.SetToolBitmapSize(wx.Size(32,32)) |
| 976 | 1044 | ||
| 977 | self.parent = parent | 1045 | self.parent = parent |
| 978 | self.__init_items() | 1046 | self.__init_items() |
| 979 | - self.__bind_events_wx() | ||
| 980 | self.__bind_events() | 1047 | self.__bind_events() |
| 1048 | + self.__bind_events_wx() | ||
| 1049 | + | ||
| 981 | self.ontool_layout = False | 1050 | self.ontool_layout = False |
| 982 | self.ontool_text = True | 1051 | self.ontool_text = True |
| 1052 | + self.enable_items = [ID_TEXT] | ||
| 983 | 1053 | ||
| 984 | - def __init_items(self): | 1054 | + self.Realize() |
| 1055 | + self.SetStateProjectClose() | ||
| 1056 | + | ||
| 1057 | + def __bind_events(self): | ||
| 1058 | + """ | ||
| 1059 | + Bind events related to pubsub. | ||
| 1060 | + """ | ||
| 1061 | + sub = ps.Publisher().subscribe | ||
| 1062 | + sub(self._EnableState, "Enable state project") | ||
| 1063 | + sub(self._SetLayoutWithTask, "Set layout button data only") | ||
| 1064 | + sub(self._SetLayoutWithoutTask, "Set layout button full") | ||
| 1065 | + | ||
| 1066 | + def __bind_events_wx(self): | ||
| 1067 | + """ | ||
| 1068 | + Bind normal events from wx (except pubsub related). | ||
| 1069 | + """ | ||
| 1070 | + self.Bind(wx.EVT_TOOL, self.OnToggle) | ||
| 985 | 1071 | ||
| 1072 | + def __init_items(self): | ||
| 1073 | + """ | ||
| 1074 | + Add tools into toolbar. | ||
| 1075 | + """ | ||
| 1076 | + d = const.ICON_DIR | ||
| 986 | if sys.platform == 'darwin': | 1077 | if sys.platform == 'darwin': |
| 987 | - self.BMP_WITHOUT_MENU =\ | ||
| 988 | - wx.Bitmap(os.path.join(const.ICON_DIR, | ||
| 989 | - "layout_data_only_original.gif"), | ||
| 990 | - wx.BITMAP_TYPE_GIF) | ||
| 991 | - self.BMP_WITH_MENU = wx.Bitmap(os.path.join(const.ICON_DIR, | ||
| 992 | - "layout_full_original.gif"), | ||
| 993 | - wx.BITMAP_TYPE_GIF) | 1078 | + # Bitmaps for show/hide task panel item |
| 1079 | + p = os.path.join(d, "layout_data_only_original.gif") | ||
| 1080 | + self.BMP_WITHOUT_MENU = wx.Bitmap(p, wx.BITMAP_TYPE_GIF) | ||
| 994 | 1081 | ||
| 995 | - self.BMP_WITHOUT_TEXT =\ | ||
| 996 | - wx.Bitmap(os.path.join(const.ICON_DIR,"text_inverted_original.png")) | 1082 | + p = os.path.join(d, "layout_full_original.gif") |
| 1083 | + self.BMP_WITHOUT_MENU = wx.Bitmap(p, wx.BITMAP_TYPE_GIF) | ||
| 997 | 1084 | ||
| 998 | - self.BMP_WITH_TEXT = wx.Bitmap(os.path.join(const.ICON_DIR,"text_original.png")) | 1085 | + # Bitmaps for show/hide task item |
| 1086 | + p = os.path.join(d, "text_inverted_original.png") | ||
| 1087 | + self.BMP_WITHOUT_TEXT = wx.Bitmap(p, wx.BITMAP_TYPE_PNG) | ||
| 999 | 1088 | ||
| 1000 | - else: | ||
| 1001 | - self.BMP_WITHOUT_MENU = wx.Bitmap(os.path.join(const.ICON_DIR, | ||
| 1002 | - "layout_data_only.gif"), | ||
| 1003 | - wx.BITMAP_TYPE_GIF) | ||
| 1004 | - self.BMP_WITH_MENU = wx.Bitmap(os.path.join(const.ICON_DIR, | ||
| 1005 | - "layout_full.gif"), | ||
| 1006 | - wx.BITMAP_TYPE_GIF) | ||
| 1007 | - self.BMP_WITH_TEXT = wx.Bitmap(os.path.join(const.ICON_DIR,"text.gif"), wx.BITMAP_TYPE_GIF) | ||
| 1008 | - self.BMP_WITHOUT_TEXT = wx.Bitmap(os.path.join(const.ICON_DIR,"text_inverted.png")) | ||
| 1009 | - | ||
| 1010 | - self.AddLabelTool(ID_LAYOUT, "",bitmap=self.BMP_WITHOUT_MENU, | ||
| 1011 | -shortHelp= _("Hide task panel")) | ||
| 1012 | - self.AddLabelTool(ID_TEXT, "",bitmap=self.BMP_WITH_TEXT, shortHelp= _("Hide text")) | 1089 | + p = os.path.join(d, "text_original.png") |
| 1090 | + self.BMP_WITH_TEXT = wx.Bitmap(p, wx.BITMAP_TYPE_PNG) | ||
| 1013 | 1091 | ||
| 1014 | - self.enable_items = [ID_TEXT] | ||
| 1015 | - self.Realize() | ||
| 1016 | - self.SetStateProjectClose() | 1092 | + else: |
| 1093 | + # Bitmaps for show/hide task panel item | ||
| 1094 | + p = os.path.join(d, "layout_data_only.gif") | ||
| 1095 | + self.BMP_WITHOUT_MENU = wx.Bitmap(p, wx.BITMAP_TYPE_GIF) | ||
| 1017 | 1096 | ||
| 1018 | - def SetStateProjectOpen(self): | ||
| 1019 | - self.ontool_text = False | ||
| 1020 | - self.OnText() | ||
| 1021 | - for tool in self.enable_items: | ||
| 1022 | - self.EnableTool(tool, True) | 1097 | + p = os.path.join(d, "layout_full.gif") |
| 1098 | + self.BMP_WITHOUT_MENU = wx.Bitmap(p, wx.BITMAP_TYPE_GIF) | ||
| 1023 | 1099 | ||
| 1024 | - def SetStateProjectClose(self): | ||
| 1025 | - self.ontool_text = True | ||
| 1026 | - self.OnText() | ||
| 1027 | - for tool in self.enable_items: | ||
| 1028 | - self.EnableTool(tool, False) | 1100 | + # Bitmaps for show/hide task item |
| 1101 | + p = os.path.join(d, "text_inverted.png") | ||
| 1102 | + self.BMP_WITHOUT_TEXT = wx.Bitmap(p, wx.BITMAP_TYPE_PNG) | ||
| 1029 | 1103 | ||
| 1030 | - def __bind_events(self): | ||
| 1031 | - ps.Publisher().subscribe(self.SetLayoutButtonOnlyData, | ||
| 1032 | - "Set layout button data only") | ||
| 1033 | - ps.Publisher().subscribe(self.SetLayoutButtonFull, | ||
| 1034 | - "Set layout button full") | 1104 | + p = os.path.join(d, "text.png") |
| 1105 | + self.BMP_WITH_TEXT = wx.Bitmap(p, wx.BITMAP_TYPE_PNG) | ||
| 1035 | 1106 | ||
| 1036 | - ps.Publisher().subscribe(self.OnEnableState, "Enable state project") | 1107 | + self.AddLabelTool(ID_LAYOUT, |
| 1108 | + "", | ||
| 1109 | + bitmap=self.BMP_WITHOUT_MENU, | ||
| 1110 | + shortHelp= _("Hide task panel")) | ||
| 1111 | + self.AddLabelTool(ID_TEXT, | ||
| 1112 | + "", | ||
| 1113 | + bitmap=self.BMP_WITH_TEXT, | ||
| 1114 | + shortHelp= _("Hide text")) | ||
| 1037 | 1115 | ||
| 1038 | - def OnEnableState(self, pubsub_evt): | 1116 | + def _EnableState(self, pubsub_evt): |
| 1117 | + """ | ||
| 1118 | + Based on given state, enable or disable menu items which | ||
| 1119 | + depend if project is open or not. | ||
| 1120 | + """ | ||
| 1039 | state = pubsub_evt.data | 1121 | state = pubsub_evt.data |
| 1040 | if state: | 1122 | if state: |
| 1041 | self.SetStateProjectOpen() | 1123 | self.SetStateProjectOpen() |
| 1042 | else: | 1124 | else: |
| 1043 | self.SetStateProjectClose() | 1125 | self.SetStateProjectClose() |
| 1044 | 1126 | ||
| 1127 | + def _SetLayoutWithoutTask(self, pubsub_evt): | ||
| 1128 | + """ | ||
| 1129 | + Set item bitmap to task panel hiden. | ||
| 1130 | + """ | ||
| 1131 | + self.SetToolNormalBitmap(ID_LAYOUT,self.BMP_WITHOUT_MENU) | ||
| 1045 | 1132 | ||
| 1133 | + def _SetLayoutWithTask(self, pubsub_evt): | ||
| 1134 | + """ | ||
| 1135 | + Set item bitmap to task panel shown. | ||
| 1136 | + """ | ||
| 1137 | + self.SetToolNormalBitmap(ID_LAYOUT,self.BMP_WITH_MENU) | ||
| 1046 | 1138 | ||
| 1047 | - def __bind_events_wx(self): | ||
| 1048 | - self.Bind(wx.EVT_TOOL, self.OnClick) | ||
| 1049 | - | ||
| 1050 | - def OnClick(self, event): | 1139 | + def OnToggle(self, event): |
| 1140 | + """ | ||
| 1141 | + Update status of toolbar item (bitmap and help) | ||
| 1142 | + """ | ||
| 1051 | id = event.GetId() | 1143 | id = event.GetId() |
| 1052 | if id == ID_LAYOUT: | 1144 | if id == ID_LAYOUT: |
| 1053 | - self.OnLayout() | 1145 | + self.ToggleLayout() |
| 1054 | elif id== ID_TEXT: | 1146 | elif id== ID_TEXT: |
| 1055 | - self.OnText() | ||
| 1056 | - | 1147 | + self.ToggleText() |
| 1057 | 1148 | ||
| 1058 | for item in VIEW_TOOLS: | 1149 | for item in VIEW_TOOLS: |
| 1059 | state = self.GetToolState(item) | 1150 | state = self.GetToolState(item) |
| 1060 | if state and (item != id): | 1151 | if state and (item != id): |
| 1061 | self.ToggleTool(item, False) | 1152 | self.ToggleTool(item, False) |
| 1062 | 1153 | ||
| 1063 | - def OnLayout(self): | 1154 | + def SetStateProjectClose(self): |
| 1155 | + """ | ||
| 1156 | + Disable menu items (e.g. text) when project is closed. | ||
| 1157 | + """ | ||
| 1158 | + self.ontool_text = True | ||
| 1159 | + self.ToggleText() | ||
| 1160 | + for tool in self.enable_items: | ||
| 1161 | + self.EnableTool(tool, False) | ||
| 1162 | + | ||
| 1163 | + def SetStateProjectOpen(self): | ||
| 1164 | + """ | ||
| 1165 | + Disable menu items (e.g. text) when project is closed. | ||
| 1166 | + """ | ||
| 1167 | + self.ontool_text = False | ||
| 1168 | + self.ToggleText() | ||
| 1169 | + for tool in self.enable_items: | ||
| 1170 | + self.EnableTool(tool, True) | ||
| 1171 | + | ||
| 1172 | + def ToggleLayout(self): | ||
| 1173 | + """ | ||
| 1174 | + Based on previous layout item state, toggle it. | ||
| 1175 | + """ | ||
| 1064 | if self.ontool_layout: | 1176 | if self.ontool_layout: |
| 1065 | self.SetToolNormalBitmap(ID_LAYOUT,self.BMP_WITHOUT_MENU) | 1177 | self.SetToolNormalBitmap(ID_LAYOUT,self.BMP_WITHOUT_MENU) |
| 1066 | ps.Publisher().sendMessage('Show task panel') | 1178 | ps.Publisher().sendMessage('Show task panel') |
| @@ -1073,7 +1185,10 @@ shortHelp= _("Hide task panel")) | @@ -1073,7 +1185,10 @@ shortHelp= _("Hide task panel")) | ||
| 1073 | self.SetToolShortHelp(ID_LAYOUT, _("Show task panel")) | 1185 | self.SetToolShortHelp(ID_LAYOUT, _("Show task panel")) |
| 1074 | self.ontool_layout = True | 1186 | self.ontool_layout = True |
| 1075 | 1187 | ||
| 1076 | - def OnText(self): | 1188 | + def ToggleText(self): |
| 1189 | + """ | ||
| 1190 | + Based on previous text item state, toggle it. | ||
| 1191 | + """ | ||
| 1077 | if self.ontool_text: | 1192 | if self.ontool_text: |
| 1078 | self.SetToolNormalBitmap(ID_TEXT,self.BMP_WITH_TEXT) | 1193 | self.SetToolNormalBitmap(ID_TEXT,self.BMP_WITH_TEXT) |
| 1079 | ps.Publisher().sendMessage('Hide text actors on viewers') | 1194 | ps.Publisher().sendMessage('Hide text actors on viewers') |
| @@ -1087,8 +1202,3 @@ shortHelp= _("Hide task panel")) | @@ -1087,8 +1202,3 @@ shortHelp= _("Hide task panel")) | ||
| 1087 | ps.Publisher().sendMessage('Update AUI') | 1202 | ps.Publisher().sendMessage('Update AUI') |
| 1088 | self.ontool_text = True | 1203 | self.ontool_text = True |
| 1089 | 1204 | ||
| 1090 | - def SetLayoutButtonOnlyData(self, pubsub_evt): | ||
| 1091 | - self.SetToolNormalBitmap(ID_LAYOUT,self.BMP_WITH_MENU) | ||
| 1092 | - | ||
| 1093 | - def SetLayoutButtonFull(self, pubsub_evt): | ||
| 1094 | - self.SetToolNormalBitmap(ID_LAYOUT,self.BMP_WITHOUT_MENU) |