Commit 9cd994d38f5bdbf94bdff8fa4d6f6134410097c3

Authored by Thiago Franco de Moraes
1 parent ebd964af
Exists in master

Updating cross when scrolling (FIX #253)

invesalius/data/styles.py
@@ -529,7 +529,7 @@ class CrossInteractorStyle(DefaultInteractorStyle): @@ -529,7 +529,7 @@ class CrossInteractorStyle(DefaultInteractorStyle):
529 # 529 #
530 530
531 Publisher.sendMessage('Update cross position', arg=None, position=(wx, wy, wz, 0., 0., 0.)) 531 Publisher.sendMessage('Update cross position', arg=None, position=(wx, wy, wz, 0., 0., 0.))
532 - self.ScrollSlice(coord) 532 + # self.ScrollSlice(coord)
533 533
534 # iren.Render() 534 # iren.Render()
535 535
@@ -550,6 +550,14 @@ class CrossInteractorStyle(DefaultInteractorStyle): @@ -550,6 +550,14 @@ class CrossInteractorStyle(DefaultInteractorStyle):
550 Publisher.sendMessage(('Set scroll position', 'SAGITAL'), 550 Publisher.sendMessage(('Set scroll position', 'SAGITAL'),
551 index=coord[0]) 551 index=coord[0])
552 552
  553 + def OnScrollBar(self, *args, **kwargs):
  554 + # Update other slice's cross according to the new focal point from
  555 + # the actual orientation.
  556 + x, y, z = self.viewer.cross.GetFocalPoint()
  557 + self.viewer.UpdateSlicesNavigation(None, (x, y, z, 0.0, 0.0, 0.0))
  558 + Publisher.sendMessage('Set cross focal point', position=(x, y, z))
  559 + Publisher.sendMessage('Update slice viewer')
  560 +
553 561
554 class TractsInteractorStyle(CrossInteractorStyle): 562 class TractsInteractorStyle(CrossInteractorStyle):
555 """ 563 """
invesalius/data/viewer_slice.py
@@ -570,11 +570,15 @@ class Viewer(wx.Panel): @@ -570,11 +570,15 @@ class Viewer(wx.Panel):
570 ux, uy, uz = position[:3] 570 ux, uy, uz = position[:3]
571 px, py = self.get_slice_pixel_coord_by_world_pos(ux, uy, uz) 571 px, py = self.get_slice_pixel_coord_by_world_pos(ux, uy, uz)
572 coord = self.calcultate_scroll_position(px, py) 572 coord = self.calcultate_scroll_position(px, py)
  573 + print(position, coord)
573 574
574 self.cross.SetFocalPoint((ux, uy, uz)) 575 self.cross.SetFocalPoint((ux, uy, uz))
575 self.ScrollSlice(coord) 576 self.ScrollSlice(coord)
576 self.interactor.Render() 577 self.interactor.Render()
577 578
  579 + def SetCrossFocalPoint(self, position):
  580 + self.cross.SetFocalPoint(position)
  581 +
578 def ScrollSlice(self, coord): 582 def ScrollSlice(self, coord):
579 if self.orientation == "AXIAL": 583 if self.orientation == "AXIAL":
580 Publisher.sendMessage(('Set scroll position', 'SAGITAL'), 584 Publisher.sendMessage(('Set scroll position', 'SAGITAL'),
@@ -818,6 +822,9 @@ class Viewer(wx.Panel): @@ -818,6 +822,9 @@ class Viewer(wx.Panel):
818 self.orientation)) 822 self.orientation))
819 Publisher.subscribe(self.__update_cross_position, 823 Publisher.subscribe(self.__update_cross_position,
820 'Update cross position') 824 'Update cross position')
  825 + Publisher.subscribe(self.__update_cross_position,
  826 + 'Update cross position %s' % self.orientation)
  827 + Publisher.subscribe(self.SetCrossFocalPoint, 'Set cross focal point')
821 # Publisher.subscribe(self.UpdateSlicesNavigation, 828 # Publisher.subscribe(self.UpdateSlicesNavigation,
822 # 'Co-registered points') 829 # 'Co-registered points')
823 ### 830 ###
@@ -1294,14 +1301,13 @@ class Viewer(wx.Panel): @@ -1294,14 +1301,13 @@ class Viewer(wx.Panel):
1294 self.set_slice_number(pos) 1301 self.set_slice_number(pos)
1295 if update3D: 1302 if update3D:
1296 self.UpdateSlice3D(pos) 1303 self.UpdateSlice3D(pos)
1297 - if self.state == const.SLICE_STATE_CROSS:  
1298 - # Update other slice's cross according to the new focal point from  
1299 - # the actual orientation.  
1300 - x, y, z = self.cross.GetFocalPoint()  
1301 - Publisher.sendMessage('Update cross position', arg=None, position=(x, y, z, 0., 0., 0.))  
1302 - Publisher.sendMessage('Update slice viewer')  
1303 - else:  
1304 - self.interactor.Render() 1304 +
  1305 + try:
  1306 + self.style.OnScrollBar()
  1307 + except AttributeError:
  1308 + print("Do not have OnScrollBar")
  1309 +
  1310 + self.interactor.Render()
1305 if evt: 1311 if evt:
1306 if self._flush_buffer: 1312 if self._flush_buffer:
1307 self.slice_.apply_slice_buffer_to_mask(self.orientation) 1313 self.slice_.apply_slice_buffer_to_mask(self.orientation)