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,8 +178,8 @@ class Viewer(wx.Panel):
178 178
179 def OnBrushClick(self, obj, evt_vtk): 179 def OnBrushClick(self, obj, evt_vtk):
180 self.mouse_pressed = 1 180 self.mouse_pressed = 1
181 -  
182 - 181 +
  182 +
183 coord = self.GetCoordinateCursor() 183 coord = self.GetCoordinateCursor()
184 self.cursor.SetPosition(coord) 184 self.cursor.SetPosition(coord)
185 self.cursor.SetEditionPosition(self.GetCoordinateCursorEdition()) 185 self.cursor.SetEditionPosition(self.GetCoordinateCursorEdition())
@@ -192,8 +192,8 @@ class Viewer(wx.Panel): @@ -192,8 +192,8 @@ class Viewer(wx.Panel):
192 evt_msg = 'Add mask pixel' 192 evt_msg = 'Add mask pixel'
193 elif self._brush_cursor_op == 'Threshold': 193 elif self._brush_cursor_op == 'Threshold':
194 evt_msg = 'Edit mask pixel' 194 evt_msg = 'Edit mask pixel'
195 -  
196 - pixels = itertools.ifilter(self.TestOperationPosition, 195 +
  196 + pixels = itertools.ifilter(self.TestOperationPosition,
197 self.cursor.GetPixels()) 197 self.cursor.GetPixels())
198 for coord in pixels: 198 for coord in pixels:
199 ps.Publisher().sendMessage(evt_msg, coord) 199 ps.Publisher().sendMessage(evt_msg, coord)
@@ -217,7 +217,7 @@ class Viewer(wx.Panel): @@ -217,7 +217,7 @@ class Viewer(wx.Panel):
217 evt_msg = 'Edit mask pixel' 217 evt_msg = 'Edit mask pixel'
218 218
219 if self.mouse_pressed: 219 if self.mouse_pressed:
220 - pixels = itertools.ifilter(self.TestOperationPosition, 220 + pixels = itertools.ifilter(self.TestOperationPosition,
221 self.cursor.GetPixels()) 221 self.cursor.GetPixels())
222 for coord in pixels: 222 for coord in pixels:
223 ps.Publisher().sendMessage(evt_msg, coord) 223 ps.Publisher().sendMessage(evt_msg, coord)
@@ -338,6 +338,7 @@ class Viewer(wx.Panel): @@ -338,6 +338,7 @@ class Viewer(wx.Panel):
338 338
339 def __bind_events_wx(self): 339 def __bind_events_wx(self):
340 self.scroll.Bind(wx.EVT_SCROLL, self.OnScrollBar) 340 self.scroll.Bind(wx.EVT_SCROLL, self.OnScrollBar)
  341 + self.interactor.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown)
341 342
342 def LoadImagedata(self, pubsub_evt): 343 def LoadImagedata(self, pubsub_evt):
343 imagedata = pubsub_evt.data 344 imagedata = pubsub_evt.data
@@ -453,15 +454,33 @@ class Viewer(wx.Panel): @@ -453,15 +454,33 @@ class Viewer(wx.Panel):
453 if evt: 454 if evt:
454 evt.Skip() 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 def SetSliceNumber(self, index): 475 def SetSliceNumber(self, index):
457 self.text_actor.SetInput(str(index)) 476 self.text_actor.SetInput(str(index))
458 self.slice_number = index 477 self.slice_number = index
459 self.__update_display_extent() 478 self.__update_display_extent()
460 - 479 +
461 position = {"SAGITAL": {0: self.slice_number}, 480 position = {"SAGITAL": {0: self.slice_number},
462 "CORONAL": {1: self.slice_number}, 481 "CORONAL": {1: self.slice_number},
463 "AXIAL": {2: self.slice_number}} 482 "AXIAL": {2: self.slice_number}}
464 - 483 +
465 ps.Publisher().sendMessage('Update cursor single position in slice', 484 ps.Publisher().sendMessage('Update cursor single position in slice',
466 position[self.orientation]) 485 position[self.orientation])
467 486