Commit 0ef19097714ba3d750fe4b79a859f912e31fe007
1 parent
57b0d8f6
Exists in
master
and in
68 other branches
ADD: Pan Mode
Showing
1 changed file
with
27 additions
and
4 deletions
Show diff stats
invesalius/data/viewer_slice.py
@@ -47,7 +47,7 @@ class Viewer(wx.Panel): | @@ -47,7 +47,7 @@ class Viewer(wx.Panel): | ||
47 | self.slice_data_list = [] | 47 | self.slice_data_list = [] |
48 | # The layout from slice_data, the first is number of cols, the second | 48 | # The layout from slice_data, the first is number of cols, the second |
49 | # is the number of rows | 49 | # is the number of rows |
50 | - self.layout = (2, 2) | 50 | + self.layout = (1, 1) |
51 | 51 | ||
52 | self.__init_gui() | 52 | self.__init_gui() |
53 | 53 | ||
@@ -102,7 +102,7 @@ class Viewer(wx.Panel): | @@ -102,7 +102,7 @@ class Viewer(wx.Panel): | ||
102 | 102 | ||
103 | # Retrieve currently set modes | 103 | # Retrieve currently set modes |
104 | self.modes.append(mode) | 104 | self.modes.append(mode) |
105 | - | 105 | + |
106 | # All modes and bindings | 106 | # All modes and bindings |
107 | action = {'DEFAULT': { | 107 | action = {'DEFAULT': { |
108 | "MouseMoveEvent": self.OnCrossMove, | 108 | "MouseMoveEvent": self.OnCrossMove, |
@@ -115,7 +115,12 @@ class Viewer(wx.Panel): | @@ -115,7 +115,12 @@ class Viewer(wx.Panel): | ||
115 | "LeftButtonReleaseEvent": self.OnMouseRelease, | 115 | "LeftButtonReleaseEvent": self.OnMouseRelease, |
116 | "EnterEvent": self.OnEnterInteractor, | 116 | "EnterEvent": self.OnEnterInteractor, |
117 | "LeaveEvent": self.OnLeaveInteractor | 117 | "LeaveEvent": self.OnLeaveInteractor |
118 | - } | 118 | + }, |
119 | + 'PAN':{ | ||
120 | + "MouseMoveEvent": self.OnPanMove, | ||
121 | + "LeftButtonPressEvent": self.OnPanClick, | ||
122 | + "LeftButtonReleaseEvent": self.OnPanRelease | ||
123 | + } | ||
119 | } | 124 | } |
120 | 125 | ||
121 | # Bind method according to current mode | 126 | # Bind method according to current mode |
@@ -130,7 +135,24 @@ class Viewer(wx.Panel): | @@ -130,7 +135,24 @@ class Viewer(wx.Panel): | ||
130 | # Bind event | 135 | # Bind event |
131 | style.AddObserver(event, | 136 | style.AddObserver(event, |
132 | action[mode][event]) | 137 | action[mode][event]) |
138 | + | ||
139 | + def ChangePanMode(self, pubsub_evt): | ||
140 | + self.append_mode('PAN') | ||
141 | + self.mouse_pressed = 0 | ||
142 | + self.interactor.SetCursor(wx.StockCursor(wx.CURSOR_SIZING)) | ||
143 | + | ||
144 | + def OnPanRelease(self, evt, obj): | ||
145 | + self.mouse_pressed = 0 | ||
133 | 146 | ||
147 | + def OnPanMove(self, evt, obj): | ||
148 | + if (self.mouse_pressed): | ||
149 | + evt.Pan() | ||
150 | + evt.OnRightButtonDown() | ||
151 | + | ||
152 | + def OnPanClick(self, evt, obj): | ||
153 | + self.mouse_pressed = 1 | ||
154 | + evt.StartPan() | ||
155 | + | ||
134 | def OnEnterInteractor(self, obj, evt): | 156 | def OnEnterInteractor(self, obj, evt): |
135 | self.interactor.SetCursor(wx.StockCursor(wx.CURSOR_BLANK)) | 157 | self.interactor.SetCursor(wx.StockCursor(wx.CURSOR_BLANK)) |
136 | 158 | ||
@@ -366,7 +388,8 @@ class Viewer(wx.Panel): | @@ -366,7 +388,8 @@ class Viewer(wx.Panel): | ||
366 | 'Set brush format') | 388 | 'Set brush format') |
367 | ps.Publisher().subscribe(self.ChangeBrushOperation, | 389 | ps.Publisher().subscribe(self.ChangeBrushOperation, |
368 | 'Set edition operation') | 390 | 'Set edition operation') |
369 | - | 391 | + ps.Publisher().subscribe(self.ChangePanMode, |
392 | + 'Set Pan Mode') | ||
370 | def ChangeBrushOperation(self, pubsub_evt): | 393 | def ChangeBrushOperation(self, pubsub_evt): |
371 | print pubsub_evt.data | 394 | print pubsub_evt.data |
372 | self._brush_cursor_op = pubsub_evt.data | 395 | self._brush_cursor_op = pubsub_evt.data |