Commit 006914780f0ece18d0e8547f355a1f7cdd6ab12c

Authored by Paulo Henrique Junqueira Amorim
1 parent 2ad2fd59

ADD: Change Slice with Keys Up and Down

Showing 1 changed file with 26 additions and 7 deletions   Show diff stats
invesalius/data/viewer_slice.py
... ... @@ -178,8 +178,8 @@ class Viewer(wx.Panel):
178 178  
179 179 def OnBrushClick(self, obj, evt_vtk):
180 180 self.mouse_pressed = 1
181   -
182   -
  181 +
  182 +
183 183 coord = self.GetCoordinateCursor()
184 184 self.cursor.SetPosition(coord)
185 185 self.cursor.SetEditionPosition(self.GetCoordinateCursorEdition())
... ... @@ -192,8 +192,8 @@ class Viewer(wx.Panel):
192 192 evt_msg = 'Add mask pixel'
193 193 elif self._brush_cursor_op == 'Threshold':
194 194 evt_msg = 'Edit mask pixel'
195   -
196   - pixels = itertools.ifilter(self.TestOperationPosition,
  195 +
  196 + pixels = itertools.ifilter(self.TestOperationPosition,
197 197 self.cursor.GetPixels())
198 198 for coord in pixels:
199 199 ps.Publisher().sendMessage(evt_msg, coord)
... ... @@ -217,7 +217,7 @@ class Viewer(wx.Panel):
217 217 evt_msg = 'Edit mask pixel'
218 218  
219 219 if self.mouse_pressed:
220   - pixels = itertools.ifilter(self.TestOperationPosition,
  220 + pixels = itertools.ifilter(self.TestOperationPosition,
221 221 self.cursor.GetPixels())
222 222 for coord in pixels:
223 223 ps.Publisher().sendMessage(evt_msg, coord)
... ... @@ -338,6 +338,7 @@ class Viewer(wx.Panel):
338 338  
339 339 def __bind_events_wx(self):
340 340 self.scroll.Bind(wx.EVT_SCROLL, self.OnScrollBar)
  341 + self.interactor.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown)
341 342  
342 343 def LoadImagedata(self, pubsub_evt):
343 344 imagedata = pubsub_evt.data
... ... @@ -453,15 +454,33 @@ class Viewer(wx.Panel):
453 454 if evt:
454 455 evt.Skip()
455 456  
  457 + def OnKeyDown(self, evt=None):
  458 + pos = self.scroll.GetThumbPosition()
  459 +
  460 + min = 0
  461 + max = self.actor.GetSliceNumberMax()
  462 +
  463 + if (evt.GetKeyCode() == 315 and pos > min):
  464 + pos = pos - 1
  465 + self.scroll.SetThumbPosition(pos)
  466 + self.OnScrollBar()
  467 + elif (evt.GetKeyCode() == 317 and pos < max):
  468 + pos = pos + 1
  469 + self.scroll.SetThumbPosition(pos)
  470 + self.OnScrollBar()
  471 + self.interactor.Render()
  472 + if evt:
  473 + evt.Skip()
  474 +
456 475 def SetSliceNumber(self, index):
457 476 self.text_actor.SetInput(str(index))
458 477 self.slice_number = index
459 478 self.__update_display_extent()
460   -
  479 +
461 480 position = {"SAGITAL": {0: self.slice_number},
462 481 "CORONAL": {1: self.slice_number},
463 482 "AXIAL": {2: self.slice_number}}
464   -
  483 +
465 484 ps.Publisher().sendMessage('Update cursor single position in slice',
466 485 position[self.orientation])
467 486  
... ...