Commit 4efd8d3fa9d8dacabb5322e94618c9659f4c0fc9
1 parent
484baa25
Exists in
master
and in
6 other branches
ADD: Spin Control (rotate image)
Showing
1 changed file
with
33 additions
and
1 deletions
Show diff stats
invesalius/data/viewer_slice.py
@@ -99,7 +99,7 @@ class Viewer(wx.Panel): | @@ -99,7 +99,7 @@ class Viewer(wx.Panel): | ||
99 | self.ren = ren | 99 | self.ren = ren |
100 | 100 | ||
101 | def append_mode(self, mode): | 101 | def append_mode(self, mode): |
102 | - | 102 | + self.modes = [] |
103 | # Retrieve currently set modes | 103 | # Retrieve currently set modes |
104 | self.modes.append(mode) | 104 | self.modes.append(mode) |
105 | 105 | ||
@@ -120,6 +120,11 @@ class Viewer(wx.Panel): | @@ -120,6 +120,11 @@ class Viewer(wx.Panel): | ||
120 | "MouseMoveEvent": self.OnPanMove, | 120 | "MouseMoveEvent": self.OnPanMove, |
121 | "LeftButtonPressEvent": self.OnPanClick, | 121 | "LeftButtonPressEvent": self.OnPanClick, |
122 | "LeftButtonReleaseEvent": self.OnPanRelease | 122 | "LeftButtonReleaseEvent": self.OnPanRelease |
123 | + }, | ||
124 | + 'SPIN':{ | ||
125 | + "MouseMoveEvent": self.OnSpinMove, | ||
126 | + "LeftButtonPressEvent": self.OnSpinClick, | ||
127 | + "LeftButtonReleaseEvent": self.OnSpinRelease | ||
123 | } | 128 | } |
124 | } | 129 | } |
125 | 130 | ||
@@ -136,6 +141,11 @@ class Viewer(wx.Panel): | @@ -136,6 +141,11 @@ class Viewer(wx.Panel): | ||
136 | style.AddObserver(event, | 141 | style.AddObserver(event, |
137 | action[mode][event]) | 142 | action[mode][event]) |
138 | 143 | ||
144 | + def ChangeEditorMode(self, pubsub_evt): | ||
145 | + self.append_mode('EDITOR') | ||
146 | + self.mouse_pressed = 0 | ||
147 | + self.interactor.SetCursor(wx.StockCursor(wx.CURSOR_BLANK)) | ||
148 | + | ||
139 | def ChangePanMode(self, pubsub_evt): | 149 | def ChangePanMode(self, pubsub_evt): |
140 | self.append_mode('PAN') | 150 | self.append_mode('PAN') |
141 | self.mouse_pressed = 0 | 151 | self.mouse_pressed = 0 |
@@ -152,7 +162,24 @@ class Viewer(wx.Panel): | @@ -152,7 +162,24 @@ class Viewer(wx.Panel): | ||
152 | def OnPanClick(self, evt, obj): | 162 | def OnPanClick(self, evt, obj): |
153 | self.mouse_pressed = 1 | 163 | self.mouse_pressed = 1 |
154 | evt.StartPan() | 164 | evt.StartPan() |
165 | + | ||
166 | + def ChangeSpinMode(self, pubsub_evt): | ||
167 | + self.append_mode('SPIN') | ||
168 | + self.mouse_pressed = 0 | ||
169 | + self.interactor.SetCursor(wx.StockCursor(wx.CURSOR_SIZING)) | ||
155 | 170 | ||
171 | + def OnSpinRelease(self, evt, obj): | ||
172 | + self.mouse_pressed = 0 | ||
173 | + | ||
174 | + def OnSpinMove(self, evt, obj): | ||
175 | + if (self.mouse_pressed): | ||
176 | + evt.Spin() | ||
177 | + evt.OnRightButtonDown() | ||
178 | + | ||
179 | + def OnSpinClick(self, evt, obj): | ||
180 | + self.mouse_pressed = 1 | ||
181 | + evt.StartSpin() | ||
182 | + | ||
156 | def OnEnterInteractor(self, obj, evt): | 183 | def OnEnterInteractor(self, obj, evt): |
157 | self.interactor.SetCursor(wx.StockCursor(wx.CURSOR_BLANK)) | 184 | self.interactor.SetCursor(wx.StockCursor(wx.CURSOR_BLANK)) |
158 | 185 | ||
@@ -390,6 +417,11 @@ class Viewer(wx.Panel): | @@ -390,6 +417,11 @@ class Viewer(wx.Panel): | ||
390 | 'Set edition operation') | 417 | 'Set edition operation') |
391 | ps.Publisher().subscribe(self.ChangePanMode, | 418 | ps.Publisher().subscribe(self.ChangePanMode, |
392 | 'Set Pan Mode') | 419 | 'Set Pan Mode') |
420 | + ps.Publisher().subscribe(self.ChangeEditorMode, | ||
421 | + 'Set Editor Mode') | ||
422 | + ps.Publisher().subscribe(self.ChangeSpinMode, | ||
423 | + 'Set Spin Mode') | ||
424 | + | ||
393 | def ChangeBrushOperation(self, pubsub_evt): | 425 | def ChangeBrushOperation(self, pubsub_evt): |
394 | print pubsub_evt.data | 426 | print pubsub_evt.data |
395 | self._brush_cursor_op = pubsub_evt.data | 427 | self._brush_cursor_op = pubsub_evt.data |