Commit d3df8b246701a178d1c2b84180760ec74e9f7c2d
1 parent
c5bb280e
Exists in
master
and in
68 other branches
ENH: Pop-up menu slice
Showing
2 changed files
with
34 additions
and
68 deletions
Show diff stats
invesalius/data/viewer_slice.py
@@ -70,7 +70,6 @@ class Viewer(wx.Panel): | @@ -70,7 +70,6 @@ class Viewer(wx.Panel): | ||
70 | 70 | ||
71 | self.__bind_events() | 71 | self.__bind_events() |
72 | self.__bind_events_wx() | 72 | self.__bind_events_wx() |
73 | - self.__init_menus() | ||
74 | 73 | ||
75 | 74 | ||
76 | def __init_gui(self): | 75 | def __init_gui(self): |
@@ -88,47 +87,21 @@ class Viewer(wx.Panel): | @@ -88,47 +87,21 @@ class Viewer(wx.Panel): | ||
88 | background_sizer.Add(scroll, 0, wx.EXPAND|wx.GROW) | 87 | background_sizer.Add(scroll, 0, wx.EXPAND|wx.GROW) |
89 | self.SetSizer(background_sizer) | 88 | self.SetSizer(background_sizer) |
90 | background_sizer.Fit(self) | 89 | background_sizer.Fit(self) |
91 | - | ||
92 | - | 90 | + |
91 | + | ||
93 | self.Layout() | 92 | self.Layout() |
94 | self.Update() | 93 | self.Update() |
95 | self.SetAutoLayout(1) | 94 | self.SetAutoLayout(1) |
96 | 95 | ||
97 | self.interactor = interactor | 96 | self.interactor = interactor |
98 | - | ||
99 | - | ||
100 | - | ||
101 | - def __init_menus(self): | ||
102 | - | ||
103 | - menu = self.menu = wx.Menu() | ||
104 | - submenu_wl = wx.Menu() | ||
105 | - | ||
106 | - for name in sorted(const.WINDOW_LEVEL): | ||
107 | - new_id = wx.NewId() | ||
108 | - wl_item = wx.MenuItem(submenu_wl, new_id, name, kind=wx.ITEM_RADIO) | ||
109 | - submenu_wl.AppendItem(wl_item) | ||
110 | - ID_TO_TOOL_ITEM[new_id] = wl_item | ||
111 | - | ||
112 | - menu.AppendMenu(1, "Window Width & Level", submenu_wl) | ||
113 | - self.Bind(wx.EVT_MENU, self.OnPopupWindowLevel) | ||
114 | - self.Fit() | ||
115 | - | ||
116 | - | ||
117 | - | ||
118 | - def OnPopupWindowLevel(self, evt): | ||
119 | - item = ID_TO_TOOL_ITEM[evt.GetId()] | ||
120 | - key = item.GetLabel() | ||
121 | - window, level = const.WINDOW_LEVEL[key] | ||
122 | - | ||
123 | - ps.Publisher().sendMessage('Bright and contrast adjustment image', | ||
124 | - (window, level)) | ||
125 | - ps.Publisher().sendMessage('Update slice viewer') | ||
126 | - evt.Skip() | ||
127 | - | 97 | + |
98 | + | ||
128 | def OnContextMenu(self, evt): | 99 | def OnContextMenu(self, evt): |
129 | self.PopupMenu(self.menu) | 100 | self.PopupMenu(self.menu) |
130 | - #evt.Skip() | ||
131 | - | 101 | + |
102 | + def SetPopupMenu(self, menu): | ||
103 | + self.menu = menu | ||
104 | + | ||
132 | def __config_interactor(self): | 105 | def __config_interactor(self): |
133 | 106 | ||
134 | ren = vtk.vtkRenderer() | 107 | ren = vtk.vtkRenderer() |
@@ -138,9 +111,6 @@ class Viewer(wx.Panel): | @@ -138,9 +111,6 @@ class Viewer(wx.Panel): | ||
138 | 111 | ||
139 | self.cam = ren.GetActiveCamera() | 112 | self.cam = ren.GetActiveCamera() |
140 | self.ren = ren | 113 | self.ren = ren |
141 | - | ||
142 | - | ||
143 | - | ||
144 | 114 | ||
145 | def append_mode(self, mode): | 115 | def append_mode(self, mode): |
146 | 116 | ||
@@ -266,7 +236,7 @@ class Viewer(wx.Panel): | @@ -266,7 +236,7 @@ class Viewer(wx.Panel): | ||
266 | ps.Publisher().sendMessage('Update window and level text',\ | 236 | ps.Publisher().sendMessage('Update window and level text',\ |
267 | "WL: %d WW: %d"%(proj.level, proj.window)) | 237 | "WL: %d WW: %d"%(proj.level, proj.window)) |
268 | self.interactor.Render() | 238 | self.interactor.Render() |
269 | - | 239 | + |
270 | 240 | ||
271 | def OnWindowLevelClick(self, evt, obj): | 241 | def OnWindowLevelClick(self, evt, obj): |
272 | proj = project.Project() | 242 | proj = project.Project() |
@@ -373,7 +343,7 @@ class Viewer(wx.Panel): | @@ -373,7 +343,7 @@ class Viewer(wx.Panel): | ||
373 | ren = slice_data.renderer | 343 | ren = slice_data.renderer |
374 | size = ren.GetSize() | 344 | size = ren.GetSize() |
375 | 345 | ||
376 | - if (size[0] <= size[1] + 100): | 346 | + if (size[0] <= size[1] + 60): |
377 | 347 | ||
378 | bound = slice_data.actor.GetBounds() | 348 | bound = slice_data.actor.GetBounds() |
379 | 349 | ||
@@ -536,7 +506,7 @@ class Viewer(wx.Panel): | @@ -536,7 +506,7 @@ class Viewer(wx.Panel): | ||
536 | evt_msg = 'Add mask pixel' | 506 | evt_msg = 'Add mask pixel' |
537 | elif self._brush_cursor_op == const.BRUSH_THRESH: | 507 | elif self._brush_cursor_op == const.BRUSH_THRESH: |
538 | evt_msg = 'Edit mask pixel' | 508 | evt_msg = 'Edit mask pixel' |
539 | - | 509 | + |
540 | self.__update_cross_position(*coord) | 510 | self.__update_cross_position(*coord) |
541 | 511 | ||
542 | if self.mouse_pressed: | 512 | if self.mouse_pressed: |
@@ -686,28 +656,17 @@ class Viewer(wx.Panel): | @@ -686,28 +656,17 @@ class Viewer(wx.Panel): | ||
686 | #### | 656 | #### |
687 | ps.Publisher().subscribe(self.UpdateText,\ | 657 | ps.Publisher().subscribe(self.UpdateText,\ |
688 | 'Update window and level text') | 658 | 'Update window and level text') |
659 | + #ps.Publisher().subscribe(self.UpdateCkeckPopUpMenu,\ | ||
660 | + # 'Update ckeck popup menu') | ||
689 | 661 | ||
690 | def ChangeBrushOperation(self, pubsub_evt): | 662 | def ChangeBrushOperation(self, pubsub_evt): |
691 | print pubsub_evt.data | 663 | print pubsub_evt.data |
692 | self._brush_cursor_op = pubsub_evt.data | 664 | self._brush_cursor_op = pubsub_evt.data |
693 | 665 | ||
694 | - | ||
695 | - def popupID1(self, evt): | ||
696 | - print "A" | ||
697 | - print "...b..." | ||
698 | - | ||
699 | - evt.Skip() | ||
700 | - | ||
701 | - def popupID8(self, evt): | ||
702 | - print "B" | ||
703 | - evt.Skip() | ||
704 | - | ||
705 | def __bind_events_wx(self): | 666 | def __bind_events_wx(self): |
706 | self.scroll.Bind(wx.EVT_SCROLL, self.OnScrollBar) | 667 | self.scroll.Bind(wx.EVT_SCROLL, self.OnScrollBar) |
707 | - self.interactor.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown) | ||
708 | - self.interactor.Bind(wx.EVT_RIGHT_DOWN, self.OnContextMenu) | ||
709 | - | ||
710 | - | 668 | + self.interactor.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown) |
669 | + self.interactor.Bind(wx.EVT_CONTEXT_MENU, self.OnContextMenu) | ||
711 | 670 | ||
712 | def LoadImagedata(self, pubsub_evt): | 671 | def LoadImagedata(self, pubsub_evt): |
713 | imagedata = pubsub_evt.data | 672 | imagedata = pubsub_evt.data |
@@ -870,13 +829,13 @@ class Viewer(wx.Panel): | @@ -870,13 +829,13 @@ class Viewer(wx.Panel): | ||
870 | 829 | ||
871 | self.cross.SetFocalPoint(coordinates[self.orientation]) | 830 | self.cross.SetFocalPoint(coordinates[self.orientation]) |
872 | 831 | ||
873 | 832 | ||
874 | #print slice_number | 833 | #print slice_number |
875 | #print x, y, z | 834 | #print x, y, z |
876 | #print "Focal", self.cross.GetFocalPoint() | 835 | #print "Focal", self.cross.GetFocalPoint() |
877 | #print "bounds", self.cross.GetModelBounds() | 836 | #print "bounds", self.cross.GetModelBounds() |
878 | #print "actor bounds", slice_data.actor.GetBounds() | 837 | #print "actor bounds", slice_data.actor.GetBounds() |
879 | 838 | ||
880 | 839 | ||
881 | def __update_cursor_position(self, slice_data, position): | 840 | def __update_cursor_position(self, slice_data, position): |
882 | x, y, z = position | 841 | x, y, z = position |
@@ -956,7 +915,7 @@ class Viewer(wx.Panel): | @@ -956,7 +915,7 @@ class Viewer(wx.Panel): | ||
956 | 915 | ||
957 | def UpdateRender(self, evt): | 916 | def UpdateRender(self, evt): |
958 | self.interactor.Render() | 917 | self.interactor.Render() |
959 | - | 918 | + |
960 | def set_scroll_position(self, position): | 919 | def set_scroll_position(self, position): |
961 | self.scroll.SetThumbPosition(position) | 920 | self.scroll.SetThumbPosition(position) |
962 | self.OnScrollBar() | 921 | self.OnScrollBar() |
invesalius/gui/default_viewers.py
@@ -23,6 +23,7 @@ import wx.lib.agw.fourwaysplitter as fws | @@ -23,6 +23,7 @@ import wx.lib.agw.fourwaysplitter as fws | ||
23 | import wx.lib.pubsub as ps | 23 | import wx.lib.pubsub as ps |
24 | import data.viewer_slice as slice_viewer | 24 | import data.viewer_slice as slice_viewer |
25 | import data.viewer_volume as volume_viewer | 25 | import data.viewer_volume as volume_viewer |
26 | +import widgets.slice_menu as slice_menu_ | ||
26 | 27 | ||
27 | from gui.widgets.clut_raycasting import CLUTRaycastingWidget, \ | 28 | from gui.widgets.clut_raycasting import CLUTRaycastingWidget, \ |
28 | EVT_CLUT_POINT_CHANGED | 29 | EVT_CLUT_POINT_CHANGED |
@@ -92,6 +93,12 @@ class Panel(wx.Panel): | @@ -92,6 +93,12 @@ class Panel(wx.Panel): | ||
92 | self.s4 = s4 | 93 | self.s4 = s4 |
93 | self.p4 = p4 | 94 | self.p4 = p4 |
94 | 95 | ||
96 | + menu = slice_menu_.SliceMenu() | ||
97 | + p1.SetPopupMenu(menu) | ||
98 | + p2.SetPopupMenu(menu) | ||
99 | + p3.SetPopupMenu(menu) | ||
100 | + | ||
101 | + | ||
95 | if sys.platform == 'win32': | 102 | if sys.platform == 'win32': |
96 | self.aui_manager.AddPane(p1, s1) | 103 | self.aui_manager.AddPane(p1, s1) |
97 | self.aui_manager.AddPane(p2, s2) | 104 | self.aui_manager.AddPane(p2, s2) |
@@ -236,7 +243,7 @@ class VolumeInteraction(wx.Panel): | @@ -236,7 +243,7 @@ class VolumeInteraction(wx.Panel): | ||
236 | 243 | ||
237 | def OnPointChanged(self, evt): | 244 | def OnPointChanged(self, evt): |
238 | ps.Publisher.sendMessage('Set raycasting refresh', None) | 245 | ps.Publisher.sendMessage('Set raycasting refresh', None) |
239 | - ps.Publisher().sendMessage('Render volume viewer', None) | 246 | + ps.Publisher().sendMessage('Render volume viewer', None) |
240 | 247 | ||
241 | import wx.lib.platebtn as pbtn | 248 | import wx.lib.platebtn as pbtn |
242 | import wx.lib.buttons as btn | 249 | import wx.lib.buttons as btn |
@@ -251,7 +258,7 @@ ID_TO_BMP = {const.VOL_FRONT: ["Front", "../icons/view_front.png"], | @@ -251,7 +258,7 @@ ID_TO_BMP = {const.VOL_FRONT: ["Front", "../icons/view_front.png"], | ||
251 | const.VOL_BACK: ["Back", "../icons/view_back.png"], | 258 | const.VOL_BACK: ["Back", "../icons/view_back.png"], |
252 | const.VOL_TOP: ["Top", "../icons/view_top.png"], | 259 | const.VOL_TOP: ["Top", "../icons/view_top.png"], |
253 | const.VOL_BOTTOM: ["Bottom", "../icons/view_bottom.png"], | 260 | const.VOL_BOTTOM: ["Bottom", "../icons/view_bottom.png"], |
254 | - const.VOL_RIGHT: ["Right", "../icons/view_right.png"], | 261 | + const.VOL_RIGHT: ["Right", "../icons/view_right.png"], |
255 | const.VOL_LEFT: ["Left", "../icons/view_left.png"], | 262 | const.VOL_LEFT: ["Left", "../icons/view_left.png"], |
256 | const.VOL_ISO:["Isometric","../icons/view_isometric.png"] | 263 | const.VOL_ISO:["Isometric","../icons/view_isometric.png"] |
257 | } | 264 | } |
@@ -284,7 +291,7 @@ class VolumeToolPanel(wx.Panel): | @@ -284,7 +291,7 @@ class VolumeToolPanel(wx.Panel): | ||
284 | 291 | ||
285 | button_raycasting = pbtn.PlateButton(self, BUTTON_RAYCASTING,"", | 292 | button_raycasting = pbtn.PlateButton(self, BUTTON_RAYCASTING,"", |
286 | BMP_RAYCASTING, style=pbtn.PB_STYLE_SQUARE, | 293 | BMP_RAYCASTING, style=pbtn.PB_STYLE_SQUARE, |
287 | - size=(24,24)) | 294 | + size=(24,24)) |
288 | self.button_raycasting = button_raycasting | 295 | self.button_raycasting = button_raycasting |
289 | self.button_raycasting.Bind(wx.EVT_LEFT_DOWN, self.OnButtonRaycasting) | 296 | self.button_raycasting.Bind(wx.EVT_LEFT_DOWN, self.OnButtonRaycasting) |
290 | 297 | ||
@@ -305,7 +312,7 @@ class VolumeToolPanel(wx.Panel): | @@ -305,7 +312,7 @@ class VolumeToolPanel(wx.Panel): | ||
305 | else: | 312 | else: |
306 | size = (24,24) | 313 | size = (24,24) |
307 | sp = 5 | 314 | sp = 5 |
308 | - | 315 | + |
309 | button_colour= csel.ColourSelect(self, 111,colour=(0,0,0), | 316 | button_colour= csel.ColourSelect(self, 111,colour=(0,0,0), |
310 | size=size) | 317 | size=size) |
311 | button_colour.Bind(csel.EVT_COLOURSELECT, self.OnSelectColour) | 318 | button_colour.Bind(csel.EVT_COLOURSELECT, self.OnSelectColour) |
@@ -364,7 +371,7 @@ class VolumeToolPanel(wx.Panel): | @@ -364,7 +371,7 @@ class VolumeToolPanel(wx.Panel): | ||
364 | menu.Enable(RAYCASTING_TOOLS, 0) | 371 | menu.Enable(RAYCASTING_TOOLS, 0) |
365 | 372 | ||
366 | self.menu_raycasting = menu | 373 | self.menu_raycasting = menu |
367 | - menu.Bind(wx.EVT_MENU, self.OnMenuRaycasting) | 374 | + menu.Bind(wx.EVT_MENU, self.OnMenuRaycasting) |
368 | 375 | ||
369 | # VOLUME VIEW ANGLE BUTTON | 376 | # VOLUME VIEW ANGLE BUTTON |
370 | menu = wx.Menu() | 377 | menu = wx.Menu() |
@@ -396,9 +403,9 @@ class VolumeToolPanel(wx.Panel): | @@ -396,9 +403,9 @@ class VolumeToolPanel(wx.Panel): | ||
396 | self.menu_raycasting.Enable(RAYCASTING_TOOLS, 1) | 403 | self.menu_raycasting.Enable(RAYCASTING_TOOLS, 1) |
397 | else: | 404 | else: |
398 | self.menu_raycasting.Enable(RAYCASTING_TOOLS, 0) | 405 | self.menu_raycasting.Enable(RAYCASTING_TOOLS, 0) |
399 | - | 406 | + |
400 | else: | 407 | else: |
401 | - # Raycasting tool | 408 | + # Raycasting tool |
402 | # TODO: In future, when more tools are available | 409 | # TODO: In future, when more tools are available |
403 | item = ID_TO_TOOL_ITEM[evt.GetId()] | 410 | item = ID_TO_TOOL_ITEM[evt.GetId()] |
404 | #if not item.IsChecked(): | 411 | #if not item.IsChecked(): |
@@ -411,13 +418,13 @@ class VolumeToolPanel(wx.Panel): | @@ -411,13 +418,13 @@ class VolumeToolPanel(wx.Panel): | ||
411 | else: | 418 | else: |
412 | ps.Publisher().sendMessage('Enable raycasting tool', | 419 | ps.Publisher().sendMessage('Enable raycasting tool', |
413 | [ID_TO_TOOL[evt.GetId()],0]) | 420 | [ID_TO_TOOL[evt.GetId()],0]) |
414 | - | 421 | + |
415 | 422 | ||
416 | def OnMenuView(self, evt): | 423 | def OnMenuView(self, evt): |
417 | """Events from button menus.""" | 424 | """Events from button menus.""" |
418 | bmp = wx.Bitmap(ID_TO_BMP[evt.GetId()][1], wx.BITMAP_TYPE_PNG) | 425 | bmp = wx.Bitmap(ID_TO_BMP[evt.GetId()][1], wx.BITMAP_TYPE_PNG) |
419 | self.button_view.SetBitmapSelected(bmp) | 426 | self.button_view.SetBitmapSelected(bmp) |
420 | - | 427 | + |
421 | ps.Publisher().sendMessage('Set volume view angle', | 428 | ps.Publisher().sendMessage('Set volume view angle', |
422 | evt.GetId()) | 429 | evt.GetId()) |
423 | 430 |