diff --git a/invesalius/data/viewer_slice.py b/invesalius/data/viewer_slice.py index e0bca6f..c6663b0 100644 --- a/invesalius/data/viewer_slice.py +++ b/invesalius/data/viewer_slice.py @@ -875,6 +875,9 @@ class Viewer(wx.Panel): Publisher.subscribe(self.SetInterpolatedSlices, "Set interpolated slices") Publisher.subscribe(self.UpdateInterpolatedSlice, "Update Slice Interpolation") + Publisher.subscribe(self.GetCrossPos, "Set Update cross pos") + Publisher.subscribe(self.UpdateCross, "Update cross pos") + def RefreshViewer(self): self.Refresh() @@ -1489,6 +1492,17 @@ class Viewer(wx.Panel): self.slice_data.renderer.ResetCamera() + def GetCrossPos(self): + spacing = self.slice_data.actor.GetInput().GetSpacing() + Publisher.sendMessage("Cross focal point", coord = self.cross.GetFocalPoint(), spacing = spacing) + + def UpdateCross(self, coord): + self.cross.SetFocalPoint(coord) + Publisher.sendMessage('Set ball reference position', position=self.cross.GetFocalPoint()) + Publisher.sendMessage('Co-registered points', arg=None, position=(coord[0], coord[1], coord[2], 0., 0., 0.)) + self.OnScrollBar() + self.interactor.Render() + def AddActors(self, actors, slice_number): "Inserting actors" pos = self.scroll.GetThumbPosition() diff --git a/invesalius/gui/dialogs.py b/invesalius/gui/dialogs.py index d233913..4a1cf44 100644 --- a/invesalius/gui/dialogs.py +++ b/invesalius/gui/dialogs.py @@ -3789,17 +3789,38 @@ class GoToDialog(wx.Dialog): self.SetSizer(main_sizer) main_sizer.Fit(self) + self.orientation = None + + self.__bind_events() + btn_ok.Bind(wx.EVT_BUTTON, self.OnOk) + def __bind_events(self): + Publisher.subscribe(self.SetNewFocalPoint,'Cross focal point') + def OnOk(self, evt): try: slice_number = int(self.goto_slice.GetValue()) - orientation = self.goto_orientation.GetClientData(self.goto_orientation.GetSelection()) + orientation = self.orientation = self.goto_orientation.GetClientData(self.goto_orientation.GetSelection()) + Publisher.sendMessage(("Set scroll position", orientation), index=slice_number) + Publisher.sendMessage('Set Update cross pos') + except ValueError: pass self.Close() + def SetNewFocalPoint(self, coord, spacing): + newCoord = list(coord) + if self.orientation=='AXIAL': + newCoord[2] = int(self.goto_slice.GetValue())*spacing[2] + if self.orientation == 'CORONAL': + newCoord[1] = int(self.goto_slice.GetValue())*spacing[1] + if self.orientation == 'SAGITAL': + newCoord[0] = int(self.goto_slice.GetValue())*spacing[0] + + Publisher.sendMessage('Update cross pos', coord = newCoord) + def Close(self): wx.Dialog.Close(self) self.Destroy() -- libgit2 0.21.2