From 5ae0b7a00fa708245cc1303af0265cb576c41315 Mon Sep 17 00:00:00 2001 From: sotodela Date: Fri, 5 Nov 2021 16:47:31 +0200 Subject: [PATCH] MOD marker to arrow with orientation --- invesalius/constants.py | 2 +- invesalius/data/viewer_volume.py | 30 ++++++++---------------------- invesalius/gui/task_navigator.py | 24 +++++++++++++++--------- 3 files changed, 24 insertions(+), 32 deletions(-) diff --git a/invesalius/constants.py b/invesalius/constants.py index 9278b6a..c2af073 100644 --- a/invesalius/constants.py +++ b/invesalius/constants.py @@ -671,7 +671,7 @@ Z_COLUMN = 6 MARKER_COLOUR = (1.0, 1.0, 0.) MARKER_SIZE = 2 - +ARROW_MARKER_SIZE = 10 CALIBRATION_TRACKER_SAMPLES = 10 FIDUCIAL_REGISTRATION_ERROR_THRESHOLD = 3.0 diff --git a/invesalius/data/viewer_volume.py b/invesalius/data/viewer_volume.py index a9d16ef..9ecf5e5 100644 --- a/invesalius/data/viewer_volume.py +++ b/invesalius/data/viewer_volume.py @@ -71,7 +71,7 @@ class Viewer(wx.Panel): self.initial_focus = None self.staticballs = [] - + self.static_arrows =[] self.style = None interactor = wxVTKRenderWindowInteractor(self, -1, size = self.GetSize()) @@ -602,33 +602,19 @@ class Viewer(wx.Panel): self.RemoveTarget() self.UpdateRender() - def AddMarkerwithOrientation(self, arrow_marker_id, size, color, coord): + def AddMarkerwithOrientation(self, arrow_id, size, color, coord): """ Markers arrow with orientation created by navigation tools and rendered in volume viewer. """ - self.arrow_marker_id = arrow_marker_id + + self.arrow_marker_id = arrow_id coord_flip = list(coord) coord_flip[1] = -coord_flip[1] - self.static_arrows.append(self.Add_ObjectArrow(self, coord_flip, coord_flip, color, size)) - # ball_ref = vtk.vtkSphereSource() - # ball_ref.SetRadius(size) - # ball_ref.SetCenter(coord_flip) - # - # mapper = vtk.vtkPolyDataMapper() - # mapper.SetInputConnection(ball_ref.GetOutputPort()) - # - # prop = vtk.vtkProperty() - # prop.SetColor(colour) - - # adding a new actor for the present ball - #self.static_arrows.append(vtk.vtkActor()) - - # self.static_arrows[self.arrow_marker_id].SetMapper(mapper) - # self.static_arrows[self.arrow_marker_id].SetProperty(prop) - - self.ren.AddActor(self.static_arrows[self.arrow_marker_id]) - self.arrow_marker_id += 1 + arrow_actor = self.Add_ObjectArrow(coord_flip[:3], coord_flip[3:6], color, size) + self.staticballs.append(arrow_actor) + self.ren.AddActor(self.staticballs[self.arrow_marker_id]) + self.arrow_marker_id +=1 #self.UpdateRender() self.Refresh() diff --git a/invesalius/gui/task_navigator.py b/invesalius/gui/task_navigator.py index 8051d42..d8988d6 100644 --- a/invesalius/gui/task_navigator.py +++ b/invesalius/gui/task_navigator.py @@ -1264,6 +1264,7 @@ class MarkersPanel(wx.Panel): self.marker_colour = const.MARKER_COLOUR self.marker_size = const.MARKER_SIZE + self.arrow_marker_size = const.ARROW_MARKER_SIZE self.current_session = 1 # Change marker size @@ -1615,7 +1616,8 @@ class MarkersPanel(wx.Panel): if marker.is_target: self.__set_marker_as_target(len(self.markers) - 1) - except: + except Exception as e: + print('hereee',e) wx.MessageBox(_("Invalid markers file."), _("InVesalius 3")) def OnMarkersVisibility(self, evt, ctrl): @@ -1681,14 +1683,18 @@ class MarkersPanel(wx.Panel): new_robot_marker.robot_target_matrix = self.current_robot_target_matrix # Note that ball_id is zero-based, so we assign it len(self.markers) before the new marker is added - Publisher.sendMessage('Add marker', ball_id=len(self.markers), - size=new_marker.size, - colour=new_marker.colour, - coord=new_marker.coord[:3]) - # Publisher.sendMessage('Add arrow marker', ball_id=len(self.markers), - # size=new_marker.size, - # colour=new_marker.colour, - # coord=new_marker.coord[:3]) + if label not in self.__list_fiducial_labels(): + Publisher.sendMessage('Add arrow marker', arrow_id=len(self.markers), + size=self.arrow_marker_size, + color=new_marker.colour, + coord=new_marker.coord) + else: + Publisher.sendMessage('Add marker', ball_id=len(self.markers), + size=new_marker.size, + colour=new_marker.colour, + coord=new_marker.coord[:3]) + print("marker marker",new_marker.size) + self.markers.append(new_marker) self.robot_markers.append(new_robot_marker) -- libgit2 0.21.2