Commit a00db00acbb9b09eeeeea2bfb8aaa80740926139
1 parent
64b968f7
Exists in
master
and in
6 other branches
ENH: Popup menu in the right button
Showing
2 changed files
with
15 additions
and
14 deletions
Show diff stats
invesalius/data/viewer_slice.py
@@ -52,6 +52,7 @@ class Viewer(wx.Panel): | @@ -52,6 +52,7 @@ class Viewer(wx.Panel): | ||
52 | self.modes = []#['DEFAULT'] | 52 | self.modes = []#['DEFAULT'] |
53 | self.left_pressed = 0 | 53 | self.left_pressed = 0 |
54 | self.right_pressed = 0 | 54 | self.right_pressed = 0 |
55 | + self.last_position_mouse_move = () | ||
55 | 56 | ||
56 | # All renderers and image actors in this viewer | 57 | # All renderers and image actors in this viewer |
57 | self.slice_data_list = [] | 58 | self.slice_data_list = [] |
@@ -104,8 +105,13 @@ class Viewer(wx.Panel): | @@ -104,8 +105,13 @@ class Viewer(wx.Panel): | ||
104 | 105 | ||
105 | def OnContextMenu(self, evt): | 106 | def OnContextMenu(self, evt): |
106 | self.right_pressed = 0 | 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 | def SetPopupMenu(self, menu): | 115 | def SetPopupMenu(self, menu): |
110 | self.menu = menu | 116 | self.menu = menu |
111 | 117 | ||
@@ -253,6 +259,9 @@ class Viewer(wx.Panel): | @@ -253,6 +259,9 @@ class Viewer(wx.Panel): | ||
253 | 259 | ||
254 | def OnRightClick(self, evt, obj): | 260 | def OnRightClick(self, evt, obj): |
255 | print "OnRightClick" | 261 | print "OnRightClick" |
262 | + self.last_position_mouse_move = \ | ||
263 | + self.interactor.GetLastEventPosition() | ||
264 | + | ||
256 | self.right_pressed = 1 | 265 | self.right_pressed = 1 |
257 | 266 | ||
258 | def OnReleaseRightButton(self, evt, obj): | 267 | def OnReleaseRightButton(self, evt, obj): |
@@ -261,7 +270,6 @@ class Viewer(wx.Panel): | @@ -261,7 +270,6 @@ class Viewer(wx.Panel): | ||
261 | ps.Publisher().sendMessage('Update slice viewer') | 270 | ps.Publisher().sendMessage('Update slice viewer') |
262 | 271 | ||
263 | def OnLeftClick(self, evt, obj): | 272 | def OnLeftClick(self, evt, obj): |
264 | - print "OnLeftClick" | ||
265 | self.left_pressed = 1 | 273 | self.left_pressed = 1 |
266 | 274 | ||
267 | def OnZoomLeftClick(self, evt, obj): | 275 | def OnZoomLeftClick(self, evt, obj): |
@@ -640,6 +648,8 @@ class Viewer(wx.Panel): | @@ -640,6 +648,8 @@ class Viewer(wx.Panel): | ||
640 | coord[2]) | 648 | coord[2]) |
641 | 649 | ||
642 | def OnZoomMoveRight(self, evt, obj): | 650 | def OnZoomMoveRight(self, evt, obj): |
651 | + | ||
652 | + | ||
643 | if (self.right_pressed): | 653 | if (self.right_pressed): |
644 | print "OnZoomMoveRight" | 654 | print "OnZoomMoveRight" |
645 | evt.Dolly() | 655 | evt.Dolly() |
invesalius/mode.py
@@ -97,19 +97,10 @@ class SliceMode(object): | @@ -97,19 +97,10 @@ class SliceMode(object): | ||
97 | 97 | ||
98 | level = const.LEVEL[state] | 98 | level = const.LEVEL[state] |
99 | max_level = max(self.stack.keys()) | 99 | max_level = max(self.stack.keys()) |
100 | - | ||
101 | - | 100 | + |
102 | # Insert new state into stack | 101 | # Insert new state into stack |
103 | self.stack[level] = state | 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 | ps.Publisher().sendMessage('Set slice mode', state) | 104 | ps.Publisher().sendMessage('Set slice mode', state) |
114 | 105 | ||
115 | def RemoveState(self, state): | 106 | def RemoveState(self, state): |