diff --git a/invesalius/data/styles.py b/invesalius/data/styles.py index 922762c..d0f1ff0 100644 --- a/invesalius/data/styles.py +++ b/invesalius/data/styles.py @@ -529,7 +529,7 @@ class CrossInteractorStyle(DefaultInteractorStyle): # Publisher.sendMessage('Update cross position', arg=None, position=(wx, wy, wz, 0., 0., 0.)) - self.ScrollSlice(coord) + # self.ScrollSlice(coord) # iren.Render() @@ -550,6 +550,14 @@ class CrossInteractorStyle(DefaultInteractorStyle): Publisher.sendMessage(('Set scroll position', 'SAGITAL'), index=coord[0]) + def OnScrollBar(self, *args, **kwargs): + # Update other slice's cross according to the new focal point from + # the actual orientation. + x, y, z = self.viewer.cross.GetFocalPoint() + self.viewer.UpdateSlicesNavigation(None, (x, y, z, 0.0, 0.0, 0.0)) + Publisher.sendMessage('Set cross focal point', position=(x, y, z)) + Publisher.sendMessage('Update slice viewer') + class TractsInteractorStyle(CrossInteractorStyle): """ diff --git a/invesalius/data/viewer_slice.py b/invesalius/data/viewer_slice.py index 9b06def..cfa7f05 100644 --- a/invesalius/data/viewer_slice.py +++ b/invesalius/data/viewer_slice.py @@ -570,11 +570,15 @@ class Viewer(wx.Panel): ux, uy, uz = position[:3] px, py = self.get_slice_pixel_coord_by_world_pos(ux, uy, uz) coord = self.calcultate_scroll_position(px, py) + print(position, coord) self.cross.SetFocalPoint((ux, uy, uz)) self.ScrollSlice(coord) self.interactor.Render() + def SetCrossFocalPoint(self, position): + self.cross.SetFocalPoint(position) + def ScrollSlice(self, coord): if self.orientation == "AXIAL": Publisher.sendMessage(('Set scroll position', 'SAGITAL'), @@ -818,6 +822,9 @@ class Viewer(wx.Panel): self.orientation)) Publisher.subscribe(self.__update_cross_position, 'Update cross position') + Publisher.subscribe(self.__update_cross_position, + 'Update cross position %s' % self.orientation) + Publisher.subscribe(self.SetCrossFocalPoint, 'Set cross focal point') # Publisher.subscribe(self.UpdateSlicesNavigation, # 'Co-registered points') ### @@ -1294,14 +1301,13 @@ class Viewer(wx.Panel): self.set_slice_number(pos) if update3D: self.UpdateSlice3D(pos) - if self.state == const.SLICE_STATE_CROSS: - # Update other slice's cross according to the new focal point from - # the actual orientation. - x, y, z = self.cross.GetFocalPoint() - Publisher.sendMessage('Update cross position', arg=None, position=(x, y, z, 0., 0., 0.)) - Publisher.sendMessage('Update slice viewer') - else: - self.interactor.Render() + + try: + self.style.OnScrollBar() + except AttributeError: + print("Do not have OnScrollBar") + + self.interactor.Render() if evt: if self._flush_buffer: self.slice_.apply_slice_buffer_to_mask(self.orientation) -- libgit2 0.21.2