Commit a00db00acbb9b09eeeeea2bfb8aaa80740926139

Authored by Paulo Henrique Junqueira Amorim
1 parent 64b968f7

ENH: Popup menu in the right button

invesalius/data/viewer_slice.py
... ... @@ -52,6 +52,7 @@ class Viewer(wx.Panel):
52 52 self.modes = []#['DEFAULT']
53 53 self.left_pressed = 0
54 54 self.right_pressed = 0
  55 + self.last_position_mouse_move = ()
55 56  
56 57 # All renderers and image actors in this viewer
57 58 self.slice_data_list = []
... ... @@ -104,8 +105,13 @@ class Viewer(wx.Panel):
104 105  
105 106 def OnContextMenu(self, evt):
106 107 self.right_pressed = 0
107   - self.PopupMenu(self.menu)
108   -
  108 + if (self.last_position_mouse_move ==\
  109 + self.interactor.GetLastEventPosition()):
  110 + self.PopupMenu(self.menu)
  111 +
  112 + evt.Skip()
  113 +
  114 +
109 115 def SetPopupMenu(self, menu):
110 116 self.menu = menu
111 117  
... ... @@ -253,6 +259,9 @@ class Viewer(wx.Panel):
253 259  
254 260 def OnRightClick(self, evt, obj):
255 261 print "OnRightClick"
  262 + self.last_position_mouse_move = \
  263 + self.interactor.GetLastEventPosition()
  264 +
256 265 self.right_pressed = 1
257 266  
258 267 def OnReleaseRightButton(self, evt, obj):
... ... @@ -261,7 +270,6 @@ class Viewer(wx.Panel):
261 270 ps.Publisher().sendMessage('Update slice viewer')
262 271  
263 272 def OnLeftClick(self, evt, obj):
264   - print "OnLeftClick"
265 273 self.left_pressed = 1
266 274  
267 275 def OnZoomLeftClick(self, evt, obj):
... ... @@ -640,6 +648,8 @@ class Viewer(wx.Panel):
640 648 coord[2])
641 649  
642 650 def OnZoomMoveRight(self, evt, obj):
  651 +
  652 +
643 653 if (self.right_pressed):
644 654 print "OnZoomMoveRight"
645 655 evt.Dolly()
... ...
invesalius/mode.py
... ... @@ -97,19 +97,10 @@ class SliceMode(object):
97 97  
98 98 level = const.LEVEL[state]
99 99 max_level = max(self.stack.keys())
100   -
101   -
  100 +
102 101 # Insert new state into stack
103 102 self.stack[level] = state
104   - #print "ADD---->"
105   - #print self.stack
106   - #print level
107   - #print state
108   - # Only will affect InVesalius behaviour if it is the highest
109   - # level in stack
110   - #if level == max_level:
111   - # let viewer slice and other classes know this
112   - # change (cursor, interaction, etc)
  103 +
113 104 ps.Publisher().sendMessage('Set slice mode', state)
114 105  
115 106 def RemoveState(self, state):
... ...