Commit 350bc7c1c57c2028350180e84a823f984dc0167d
Committed by
Thiago Franco de Moraes
1 parent
ab86ef44
Exists in
master
Fixing the cross focal point update in Go To Slice tool (#173)
Showing
2 changed files
with
36 additions
and
1 deletions
Show diff stats
invesalius/data/viewer_slice.py
@@ -875,6 +875,9 @@ class Viewer(wx.Panel): | @@ -875,6 +875,9 @@ class Viewer(wx.Panel): | ||
875 | Publisher.subscribe(self.SetInterpolatedSlices, "Set interpolated slices") | 875 | Publisher.subscribe(self.SetInterpolatedSlices, "Set interpolated slices") |
876 | Publisher.subscribe(self.UpdateInterpolatedSlice, "Update Slice Interpolation") | 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 | def RefreshViewer(self): | 882 | def RefreshViewer(self): |
880 | self.Refresh() | 883 | self.Refresh() |
@@ -1489,6 +1492,17 @@ class Viewer(wx.Panel): | @@ -1489,6 +1492,17 @@ class Viewer(wx.Panel): | ||
1489 | 1492 | ||
1490 | self.slice_data.renderer.ResetCamera() | 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 | def AddActors(self, actors, slice_number): | 1506 | def AddActors(self, actors, slice_number): |
1493 | "Inserting actors" | 1507 | "Inserting actors" |
1494 | pos = self.scroll.GetThumbPosition() | 1508 | pos = self.scroll.GetThumbPosition() |
invesalius/gui/dialogs.py
@@ -3789,17 +3789,38 @@ class GoToDialog(wx.Dialog): | @@ -3789,17 +3789,38 @@ class GoToDialog(wx.Dialog): | ||
3789 | self.SetSizer(main_sizer) | 3789 | self.SetSizer(main_sizer) |
3790 | main_sizer.Fit(self) | 3790 | main_sizer.Fit(self) |
3791 | 3791 | ||
3792 | + self.orientation = None | ||
3793 | + | ||
3794 | + self.__bind_events() | ||
3795 | + | ||
3792 | btn_ok.Bind(wx.EVT_BUTTON, self.OnOk) | 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 | def OnOk(self, evt): | 3801 | def OnOk(self, evt): |
3795 | try: | 3802 | try: |
3796 | slice_number = int(self.goto_slice.GetValue()) | 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 | Publisher.sendMessage(("Set scroll position", orientation), index=slice_number) | 3806 | Publisher.sendMessage(("Set scroll position", orientation), index=slice_number) |
3807 | + Publisher.sendMessage('Set Update cross pos') | ||
3808 | + | ||
3799 | except ValueError: | 3809 | except ValueError: |
3800 | pass | 3810 | pass |
3801 | self.Close() | 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 | def Close(self): | 3824 | def Close(self): |
3804 | wx.Dialog.Close(self) | 3825 | wx.Dialog.Close(self) |
3805 | self.Destroy() | 3826 | self.Destroy() |