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,6 +20,7 @@
20 # detalhes. 20 # detalhes.
21 #-------------------------------------------------------------------------- 21 #--------------------------------------------------------------------------
22 import sys 22 import sys
  23 +from collections import OrderedDict
23 24
24 import wx 25 import wx
25 from wx.lib.pubsub import pub as Publisher 26 from wx.lib.pubsub import pub as Publisher
@@ -30,6 +31,15 @@ import presets @@ -30,6 +31,15 @@ import presets
30 31
31 from gui.dialogs import ClutImagedataDialog 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 class SliceMenu(wx.Menu): 43 class SliceMenu(wx.Menu):
34 def __init__(self): 44 def __init__(self):
35 wx.Menu.__init__(self) 45 wx.Menu.__init__(self)
@@ -111,6 +121,15 @@ class SliceMenu(wx.Menu): @@ -111,6 +121,15 @@ class SliceMenu(wx.Menu):
111 submenu_pseudo_colours.AppendItem(color_item) 121 submenu_pseudo_colours.AppendItem(color_item)
112 self.ID_TO_TOOL_ITEM[new_id] = color_item 122 self.ID_TO_TOOL_ITEM[new_id] = color_item
113 self.pseudo_color_items[new_id] = color_item 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 flag_tiling = False 134 flag_tiling = False
116 #------------ Sub menu of the image tiling --------------- 135 #------------ Sub menu of the image tiling ---------------
@@ -130,6 +149,7 @@ class SliceMenu(wx.Menu): @@ -130,6 +149,7 @@ class SliceMenu(wx.Menu):
130 # Add sub itens in the menu 149 # Add sub itens in the menu
131 self.AppendMenu(-1, _("Window width and level"), submenu_wl) 150 self.AppendMenu(-1, _("Window width and level"), submenu_wl)
132 self.AppendMenu(-1, _("Pseudo color"), submenu_pseudo_colours) 151 self.AppendMenu(-1, _("Pseudo color"), submenu_pseudo_colours)
  152 + self.AppendMenu(-1, _("Projection type"), submenu_projection)
133 ###self.AppendMenu(-1, _("Image Tiling"), submenu_image_tiling) 153 ###self.AppendMenu(-1, _("Image Tiling"), submenu_image_tiling)
134 154
135 # It doesn't work in Linux 155 # It doesn't work in Linux
@@ -139,6 +159,7 @@ class SliceMenu(wx.Menu): @@ -139,6 +159,7 @@ class SliceMenu(wx.Menu):
139 submenu_wl.Bind(wx.EVT_MENU, self.OnPopup) 159 submenu_wl.Bind(wx.EVT_MENU, self.OnPopup)
140 submenu_pseudo_colours.Bind(wx.EVT_MENU, self.OnPopup) 160 submenu_pseudo_colours.Bind(wx.EVT_MENU, self.OnPopup)
141 submenu_image_tiling.Bind(wx.EVT_MENU, self.OnPopup) 161 submenu_image_tiling.Bind(wx.EVT_MENU, self.OnPopup)
  162 + submenu_projection.Bind(wx.EVT_MENU, self.OnPopup)
142 163
143 self.__bind_events() 164 self.__bind_events()
144 165
@@ -169,6 +190,7 @@ class SliceMenu(wx.Menu): @@ -169,6 +190,7 @@ class SliceMenu(wx.Menu):
169 id = evt.GetId() 190 id = evt.GetId()
170 item = self.ID_TO_TOOL_ITEM[evt.GetId()] 191 item = self.ID_TO_TOOL_ITEM[evt.GetId()]
171 key = item.GetLabel() 192 key = item.GetLabel()
  193 + print 'Key', key
172 if(key in const.WINDOW_LEVEL.keys()): 194 if(key in const.WINDOW_LEVEL.keys()):
173 window, level = const.WINDOW_LEVEL[key] 195 window, level = const.WINDOW_LEVEL[key]
174 Publisher.sendMessage('Bright and contrast adjustment image', 196 Publisher.sendMessage('Bright and contrast adjustment image',
@@ -216,6 +238,12 @@ class SliceMenu(wx.Menu): @@ -216,6 +238,12 @@ class SliceMenu(wx.Menu):
216 Publisher.sendMessage('Set slice viewer layout', values) 238 Publisher.sendMessage('Set slice viewer layout', values)
217 Publisher.sendMessage('Update slice viewer') 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 elif key == _('Custom'): 247 elif key == _('Custom'):
220 if self.cdialog is None: 248 if self.cdialog is None:
221 slc = sl.Slice() 249 slc = sl.Slice()