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 | 47 | self.slice_data_list = [] |
| 48 | 48 | # The layout from slice_data, the first is number of cols, the second |
| 49 | 49 | # is the number of rows |
| 50 | - self.layout = (2, 2) | |
| 50 | + self.layout = (1, 1) | |
| 51 | 51 | |
| 52 | 52 | self.__init_gui() |
| 53 | 53 | |
| ... | ... | @@ -102,7 +102,7 @@ class Viewer(wx.Panel): |
| 102 | 102 | |
| 103 | 103 | # Retrieve currently set modes |
| 104 | 104 | self.modes.append(mode) |
| 105 | - | |
| 105 | + | |
| 106 | 106 | # All modes and bindings |
| 107 | 107 | action = {'DEFAULT': { |
| 108 | 108 | "MouseMoveEvent": self.OnCrossMove, |
| ... | ... | @@ -115,7 +115,12 @@ class Viewer(wx.Panel): |
| 115 | 115 | "LeftButtonReleaseEvent": self.OnMouseRelease, |
| 116 | 116 | "EnterEvent": self.OnEnterInteractor, |
| 117 | 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 | 126 | # Bind method according to current mode |
| ... | ... | @@ -130,7 +135,24 @@ class Viewer(wx.Panel): |
| 130 | 135 | # Bind event |
| 131 | 136 | style.AddObserver(event, |
| 132 | 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 | 156 | def OnEnterInteractor(self, obj, evt): |
| 135 | 157 | self.interactor.SetCursor(wx.StockCursor(wx.CURSOR_BLANK)) |
| 136 | 158 | |
| ... | ... | @@ -366,7 +388,8 @@ class Viewer(wx.Panel): |
| 366 | 388 | 'Set brush format') |
| 367 | 389 | ps.Publisher().subscribe(self.ChangeBrushOperation, |
| 368 | 390 | 'Set edition operation') |
| 369 | - | |
| 391 | + ps.Publisher().subscribe(self.ChangePanMode, | |
| 392 | + 'Set Pan Mode') | |
| 370 | 393 | def ChangeBrushOperation(self, pubsub_evt): |
| 371 | 394 | print pubsub_evt.data |
| 372 | 395 | self._brush_cursor_op = pubsub_evt.data | ... | ... |