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 | 70 | |
71 | 71 | self.__bind_events() |
72 | 72 | self.__bind_events_wx() |
73 | - self.__init_menus() | |
74 | 73 | |
75 | 74 | |
76 | 75 | def __init_gui(self): |
... | ... | @@ -88,47 +87,21 @@ class Viewer(wx.Panel): |
88 | 87 | background_sizer.Add(scroll, 0, wx.EXPAND|wx.GROW) |
89 | 88 | self.SetSizer(background_sizer) |
90 | 89 | background_sizer.Fit(self) |
91 | - | |
92 | - | |
90 | + | |
91 | + | |
93 | 92 | self.Layout() |
94 | 93 | self.Update() |
95 | 94 | self.SetAutoLayout(1) |
96 | 95 | |
97 | 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 | 99 | def OnContextMenu(self, evt): |
129 | 100 | self.PopupMenu(self.menu) |
130 | - #evt.Skip() | |
131 | - | |
101 | + | |
102 | + def SetPopupMenu(self, menu): | |
103 | + self.menu = menu | |
104 | + | |
132 | 105 | def __config_interactor(self): |
133 | 106 | |
134 | 107 | ren = vtk.vtkRenderer() |
... | ... | @@ -138,9 +111,6 @@ class Viewer(wx.Panel): |
138 | 111 | |
139 | 112 | self.cam = ren.GetActiveCamera() |
140 | 113 | self.ren = ren |
141 | - | |
142 | - | |
143 | - | |
144 | 114 | |
145 | 115 | def append_mode(self, mode): |
146 | 116 | |
... | ... | @@ -266,7 +236,7 @@ class Viewer(wx.Panel): |
266 | 236 | ps.Publisher().sendMessage('Update window and level text',\ |
267 | 237 | "WL: %d WW: %d"%(proj.level, proj.window)) |
268 | 238 | self.interactor.Render() |
269 | - | |
239 | + | |
270 | 240 | |
271 | 241 | def OnWindowLevelClick(self, evt, obj): |
272 | 242 | proj = project.Project() |
... | ... | @@ -373,7 +343,7 @@ class Viewer(wx.Panel): |
373 | 343 | ren = slice_data.renderer |
374 | 344 | size = ren.GetSize() |
375 | 345 | |
376 | - if (size[0] <= size[1] + 100): | |
346 | + if (size[0] <= size[1] + 60): | |
377 | 347 | |
378 | 348 | bound = slice_data.actor.GetBounds() |
379 | 349 | |
... | ... | @@ -536,7 +506,7 @@ class Viewer(wx.Panel): |
536 | 506 | evt_msg = 'Add mask pixel' |
537 | 507 | elif self._brush_cursor_op == const.BRUSH_THRESH: |
538 | 508 | evt_msg = 'Edit mask pixel' |
539 | - | |
509 | + | |
540 | 510 | self.__update_cross_position(*coord) |
541 | 511 | |
542 | 512 | if self.mouse_pressed: |
... | ... | @@ -686,28 +656,17 @@ class Viewer(wx.Panel): |
686 | 656 | #### |
687 | 657 | ps.Publisher().subscribe(self.UpdateText,\ |
688 | 658 | 'Update window and level text') |
659 | + #ps.Publisher().subscribe(self.UpdateCkeckPopUpMenu,\ | |
660 | + # 'Update ckeck popup menu') | |
689 | 661 | |
690 | 662 | def ChangeBrushOperation(self, pubsub_evt): |
691 | 663 | print pubsub_evt.data |
692 | 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 | 666 | def __bind_events_wx(self): |
706 | 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 | 671 | def LoadImagedata(self, pubsub_evt): |
713 | 672 | imagedata = pubsub_evt.data |
... | ... | @@ -870,13 +829,13 @@ class Viewer(wx.Panel): |
870 | 829 | |
871 | 830 | self.cross.SetFocalPoint(coordinates[self.orientation]) |
872 | 831 | |
873 | ||
832 | ||
874 | 833 | #print slice_number |
875 | 834 | #print x, y, z |
876 | 835 | #print "Focal", self.cross.GetFocalPoint() |
877 | 836 | #print "bounds", self.cross.GetModelBounds() |
878 | 837 | #print "actor bounds", slice_data.actor.GetBounds() |
879 | ||
838 | ||
880 | 839 | |
881 | 840 | def __update_cursor_position(self, slice_data, position): |
882 | 841 | x, y, z = position |
... | ... | @@ -956,7 +915,7 @@ class Viewer(wx.Panel): |
956 | 915 | |
957 | 916 | def UpdateRender(self, evt): |
958 | 917 | self.interactor.Render() |
959 | - | |
918 | + | |
960 | 919 | def set_scroll_position(self, position): |
961 | 920 | self.scroll.SetThumbPosition(position) |
962 | 921 | self.OnScrollBar() | ... | ... |
invesalius/gui/default_viewers.py
... | ... | @@ -23,6 +23,7 @@ import wx.lib.agw.fourwaysplitter as fws |
23 | 23 | import wx.lib.pubsub as ps |
24 | 24 | import data.viewer_slice as slice_viewer |
25 | 25 | import data.viewer_volume as volume_viewer |
26 | +import widgets.slice_menu as slice_menu_ | |
26 | 27 | |
27 | 28 | from gui.widgets.clut_raycasting import CLUTRaycastingWidget, \ |
28 | 29 | EVT_CLUT_POINT_CHANGED |
... | ... | @@ -92,6 +93,12 @@ class Panel(wx.Panel): |
92 | 93 | self.s4 = s4 |
93 | 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 | 102 | if sys.platform == 'win32': |
96 | 103 | self.aui_manager.AddPane(p1, s1) |
97 | 104 | self.aui_manager.AddPane(p2, s2) |
... | ... | @@ -236,7 +243,7 @@ class VolumeInteraction(wx.Panel): |
236 | 243 | |
237 | 244 | def OnPointChanged(self, evt): |
238 | 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 | 248 | import wx.lib.platebtn as pbtn |
242 | 249 | import wx.lib.buttons as btn |
... | ... | @@ -251,7 +258,7 @@ ID_TO_BMP = {const.VOL_FRONT: ["Front", "../icons/view_front.png"], |
251 | 258 | const.VOL_BACK: ["Back", "../icons/view_back.png"], |
252 | 259 | const.VOL_TOP: ["Top", "../icons/view_top.png"], |
253 | 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 | 262 | const.VOL_LEFT: ["Left", "../icons/view_left.png"], |
256 | 263 | const.VOL_ISO:["Isometric","../icons/view_isometric.png"] |
257 | 264 | } |
... | ... | @@ -284,7 +291,7 @@ class VolumeToolPanel(wx.Panel): |
284 | 291 | |
285 | 292 | button_raycasting = pbtn.PlateButton(self, BUTTON_RAYCASTING,"", |
286 | 293 | BMP_RAYCASTING, style=pbtn.PB_STYLE_SQUARE, |
287 | - size=(24,24)) | |
294 | + size=(24,24)) | |
288 | 295 | self.button_raycasting = button_raycasting |
289 | 296 | self.button_raycasting.Bind(wx.EVT_LEFT_DOWN, self.OnButtonRaycasting) |
290 | 297 | |
... | ... | @@ -305,7 +312,7 @@ class VolumeToolPanel(wx.Panel): |
305 | 312 | else: |
306 | 313 | size = (24,24) |
307 | 314 | sp = 5 |
308 | - | |
315 | + | |
309 | 316 | button_colour= csel.ColourSelect(self, 111,colour=(0,0,0), |
310 | 317 | size=size) |
311 | 318 | button_colour.Bind(csel.EVT_COLOURSELECT, self.OnSelectColour) |
... | ... | @@ -364,7 +371,7 @@ class VolumeToolPanel(wx.Panel): |
364 | 371 | menu.Enable(RAYCASTING_TOOLS, 0) |
365 | 372 | |
366 | 373 | self.menu_raycasting = menu |
367 | - menu.Bind(wx.EVT_MENU, self.OnMenuRaycasting) | |
374 | + menu.Bind(wx.EVT_MENU, self.OnMenuRaycasting) | |
368 | 375 | |
369 | 376 | # VOLUME VIEW ANGLE BUTTON |
370 | 377 | menu = wx.Menu() |
... | ... | @@ -396,9 +403,9 @@ class VolumeToolPanel(wx.Panel): |
396 | 403 | self.menu_raycasting.Enable(RAYCASTING_TOOLS, 1) |
397 | 404 | else: |
398 | 405 | self.menu_raycasting.Enable(RAYCASTING_TOOLS, 0) |
399 | - | |
406 | + | |
400 | 407 | else: |
401 | - # Raycasting tool | |
408 | + # Raycasting tool | |
402 | 409 | # TODO: In future, when more tools are available |
403 | 410 | item = ID_TO_TOOL_ITEM[evt.GetId()] |
404 | 411 | #if not item.IsChecked(): |
... | ... | @@ -411,13 +418,13 @@ class VolumeToolPanel(wx.Panel): |
411 | 418 | else: |
412 | 419 | ps.Publisher().sendMessage('Enable raycasting tool', |
413 | 420 | [ID_TO_TOOL[evt.GetId()],0]) |
414 | - | |
421 | + | |
415 | 422 | |
416 | 423 | def OnMenuView(self, evt): |
417 | 424 | """Events from button menus.""" |
418 | 425 | bmp = wx.Bitmap(ID_TO_BMP[evt.GetId()][1], wx.BITMAP_TYPE_PNG) |
419 | 426 | self.button_view.SetBitmapSelected(bmp) |
420 | - | |
427 | + | |
421 | 428 | ps.Publisher().sendMessage('Set volume view angle', |
422 | 429 | evt.GetId()) |
423 | 430 | ... | ... |