Commit 93a8d517cc49714941077f091d132f3dc8136a8b

Authored by tfmoraes
1 parent 84732784

Changing slice using keyboard is working again

invesalius/data/slice_.py
@@ -126,6 +126,16 @@ class Slice(object): @@ -126,6 +126,16 @@ class Slice(object):
126 ps.Publisher().subscribe(self.OnRemoveMasks, 'Remove masks') 126 ps.Publisher().subscribe(self.OnRemoveMasks, 'Remove masks')
127 ps.Publisher().subscribe(self.OnDuplicateMasks, 'Duplicate masks') 127 ps.Publisher().subscribe(self.OnDuplicateMasks, 'Duplicate masks')
128 128
  129 + def GetMaxSliceNumber(self, orientation):
  130 + shape = self.matrix.shape
  131 +
  132 + if orientation == 'AXIAL':
  133 + return shape[0]
  134 + elif orientation == 'CORONAL':
  135 + return shape[1]
  136 + elif orientation == 'SAGITAL':
  137 + return shape[2]
  138 +
129 def OnRemoveMasks(self, pubsub_evt): 139 def OnRemoveMasks(self, pubsub_evt):
130 selected_items = pubsub_evt.data 140 selected_items = pubsub_evt.data
131 proj = Project() 141 proj = Project()
invesalius/data/viewer_slice.py
@@ -1330,7 +1330,7 @@ class Viewer(wx.Panel): @@ -1330,7 +1330,7 @@ class Viewer(wx.Panel):
1330 pos = self.scroll.GetThumbPosition() 1330 pos = self.scroll.GetThumbPosition()
1331 1331
1332 min = 0 1332 min = 0
1333 - max = self.actor.GetSliceNumberMax() 1333 + max = self.slice_.GetMaxSliceNumber(self.orientation)
1334 1334
1335 if (evt.GetKeyCode() == wx.WXK_UP and pos > min): 1335 if (evt.GetKeyCode() == wx.WXK_UP and pos > min):
1336 self.OnScrollForward() 1336 self.OnScrollForward()
@@ -1359,7 +1359,7 @@ class Viewer(wx.Panel): @@ -1359,7 +1359,7 @@ class Viewer(wx.Panel):
1359 1359
1360 def OnScrollBackward(self, evt=None, obj=None): 1360 def OnScrollBackward(self, evt=None, obj=None):
1361 pos = self.scroll.GetThumbPosition() 1361 pos = self.scroll.GetThumbPosition()
1362 - max = self.actor.GetSliceNumberMax() 1362 + max = self.slice_.GetMaxSliceNumber(self.orientation)
1363 1363
1364 if(pos < max): 1364 if(pos < max):
1365 pos = pos + 1 1365 pos = pos + 1