Commit ea59efb991b8c6f7ec6693cbc0a68380234bc776

Authored by Thiago Franco de Moraes
1 parent cf4a4dbc

Added option to change projection type by context menu

Showing 1 changed file with 28 additions and 0 deletions   Show diff stats
invesalius/gui/widgets/slice_menu.py
... ... @@ -20,6 +20,7 @@
20 20 # detalhes.
21 21 #--------------------------------------------------------------------------
22 22 import sys
  23 +from collections import OrderedDict
23 24  
24 25 import wx
25 26 from wx.lib.pubsub import pub as Publisher
... ... @@ -30,6 +31,15 @@ import presets
30 31  
31 32 from gui.dialogs import ClutImagedataDialog
32 33  
  34 +PROJECTIONS_ID = OrderedDict(((_('Normal'), const.PROJECTION_NORMAL),
  35 + (_('MaxIP'), const.PROJECTION_MaxIP),
  36 + (_('MinIP'), const.PROJECTION_MinIP),
  37 + (_('MeanIP'), const.PROJECTION_MeanIP),
  38 + (_('MIDA'), const.PROJECTION_MIDA),
  39 + (_('Contour MaxIP'), const.PROJECTION_CONTOUR_MIP),
  40 + (_('Contour MIDA'), const.PROJECTION_CONTOUR_MIDA),) )
  41 +
  42 +
33 43 class SliceMenu(wx.Menu):
34 44 def __init__(self):
35 45 wx.Menu.__init__(self)
... ... @@ -111,6 +121,15 @@ class SliceMenu(wx.Menu):
111 121 submenu_pseudo_colours.AppendItem(color_item)
112 122 self.ID_TO_TOOL_ITEM[new_id] = color_item
113 123 self.pseudo_color_items[new_id] = color_item
  124 +
  125 + # --------------- Sub menu of the projection type ---------------------
  126 + submenu_projection = wx.Menu()
  127 + for name in PROJECTIONS_ID:
  128 + new_id = wx.NewId()
  129 + projection_item = wx.MenuItem(submenu_projection, new_id, name,
  130 + kind=wx.ITEM_RADIO)
  131 + submenu_projection.AppendItem(projection_item)
  132 + self.ID_TO_TOOL_ITEM[new_id] = projection_item
114 133  
115 134 flag_tiling = False
116 135 #------------ Sub menu of the image tiling ---------------
... ... @@ -130,6 +149,7 @@ class SliceMenu(wx.Menu):
130 149 # Add sub itens in the menu
131 150 self.AppendMenu(-1, _("Window width and level"), submenu_wl)
132 151 self.AppendMenu(-1, _("Pseudo color"), submenu_pseudo_colours)
  152 + self.AppendMenu(-1, _("Projection type"), submenu_projection)
133 153 ###self.AppendMenu(-1, _("Image Tiling"), submenu_image_tiling)
134 154  
135 155 # It doesn't work in Linux
... ... @@ -139,6 +159,7 @@ class SliceMenu(wx.Menu):
139 159 submenu_wl.Bind(wx.EVT_MENU, self.OnPopup)
140 160 submenu_pseudo_colours.Bind(wx.EVT_MENU, self.OnPopup)
141 161 submenu_image_tiling.Bind(wx.EVT_MENU, self.OnPopup)
  162 + submenu_projection.Bind(wx.EVT_MENU, self.OnPopup)
142 163  
143 164 self.__bind_events()
144 165  
... ... @@ -169,6 +190,7 @@ class SliceMenu(wx.Menu):
169 190 id = evt.GetId()
170 191 item = self.ID_TO_TOOL_ITEM[evt.GetId()]
171 192 key = item.GetLabel()
  193 + print 'Key', key
172 194 if(key in const.WINDOW_LEVEL.keys()):
173 195 window, level = const.WINDOW_LEVEL[key]
174 196 Publisher.sendMessage('Bright and contrast adjustment image',
... ... @@ -216,6 +238,12 @@ class SliceMenu(wx.Menu):
216 238 Publisher.sendMessage('Set slice viewer layout', values)
217 239 Publisher.sendMessage('Update slice viewer')
218 240  
  241 + elif key in PROJECTIONS_ID:
  242 + print 'Key', key
  243 + pid = PROJECTIONS_ID[key]
  244 + Publisher.sendMessage('Set projection type', pid)
  245 + Publisher.sendMessage('Reload actual slice')
  246 +
219 247 elif key == _('Custom'):
220 248 if self.cdialog is None:
221 249 slc = sl.Slice()
... ...