Commit 350bc7c1c57c2028350180e84a823f984dc0167d

Authored by otaviocarlos
Committed by Thiago Franco de Moraes
1 parent ab86ef44
Exists in master

Fixing the cross focal point update in Go To Slice tool (#173)

invesalius/data/viewer_slice.py
... ... @@ -875,6 +875,9 @@ class Viewer(wx.Panel):
875 875 Publisher.subscribe(self.SetInterpolatedSlices, "Set interpolated slices")
876 876 Publisher.subscribe(self.UpdateInterpolatedSlice, "Update Slice Interpolation")
877 877  
  878 + Publisher.subscribe(self.GetCrossPos, "Set Update cross pos")
  879 + Publisher.subscribe(self.UpdateCross, "Update cross pos")
  880 +
878 881  
879 882 def RefreshViewer(self):
880 883 self.Refresh()
... ... @@ -1489,6 +1492,17 @@ class Viewer(wx.Panel):
1489 1492  
1490 1493 self.slice_data.renderer.ResetCamera()
1491 1494  
  1495 + def GetCrossPos(self):
  1496 + spacing = self.slice_data.actor.GetInput().GetSpacing()
  1497 + Publisher.sendMessage("Cross focal point", coord = self.cross.GetFocalPoint(), spacing = spacing)
  1498 +
  1499 + def UpdateCross(self, coord):
  1500 + self.cross.SetFocalPoint(coord)
  1501 + Publisher.sendMessage('Set ball reference position', position=self.cross.GetFocalPoint())
  1502 + Publisher.sendMessage('Co-registered points', arg=None, position=(coord[0], coord[1], coord[2], 0., 0., 0.))
  1503 + self.OnScrollBar()
  1504 + self.interactor.Render()
  1505 +
1492 1506 def AddActors(self, actors, slice_number):
1493 1507 "Inserting actors"
1494 1508 pos = self.scroll.GetThumbPosition()
... ...
invesalius/gui/dialogs.py
... ... @@ -3789,17 +3789,38 @@ class GoToDialog(wx.Dialog):
3789 3789 self.SetSizer(main_sizer)
3790 3790 main_sizer.Fit(self)
3791 3791  
  3792 + self.orientation = None
  3793 +
  3794 + self.__bind_events()
  3795 +
3792 3796 btn_ok.Bind(wx.EVT_BUTTON, self.OnOk)
3793 3797  
  3798 + def __bind_events(self):
  3799 + Publisher.subscribe(self.SetNewFocalPoint,'Cross focal point')
  3800 +
3794 3801 def OnOk(self, evt):
3795 3802 try:
3796 3803 slice_number = int(self.goto_slice.GetValue())
3797   - orientation = self.goto_orientation.GetClientData(self.goto_orientation.GetSelection())
  3804 + orientation = self.orientation = self.goto_orientation.GetClientData(self.goto_orientation.GetSelection())
  3805 +
3798 3806 Publisher.sendMessage(("Set scroll position", orientation), index=slice_number)
  3807 + Publisher.sendMessage('Set Update cross pos')
  3808 +
3799 3809 except ValueError:
3800 3810 pass
3801 3811 self.Close()
3802 3812  
  3813 + def SetNewFocalPoint(self, coord, spacing):
  3814 + newCoord = list(coord)
  3815 + if self.orientation=='AXIAL':
  3816 + newCoord[2] = int(self.goto_slice.GetValue())*spacing[2]
  3817 + if self.orientation == 'CORONAL':
  3818 + newCoord[1] = int(self.goto_slice.GetValue())*spacing[1]
  3819 + if self.orientation == 'SAGITAL':
  3820 + newCoord[0] = int(self.goto_slice.GetValue())*spacing[0]
  3821 +
  3822 + Publisher.sendMessage('Update cross pos', coord = newCoord)
  3823 +
3803 3824 def Close(self):
3804 3825 wx.Dialog.Close(self)
3805 3826 self.Destroy()
... ...