Skip to content

Commit

Permalink
Merge pull request #859 from rmatsuda/add-show-robots-warnings
Browse files Browse the repository at this point in the history
Add show robots warnings in viewer volume
  • Loading branch information
rmatsuda authored Oct 15, 2024
2 parents 4ad6094 + f5faf9b commit cd7740f
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions invesalius/data/viewer_volume.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ def __init__(self, parent):
self.pTarget = [0.0, 0.0, 0.0]

self.distance_text = None
self.robot_warnings_text = None

# self.obj_axes = None
self.mark_actor = None
Expand Down Expand Up @@ -468,6 +469,9 @@ def __bind_events(self):
Publisher.subscribe(self.OnUnsetTarget, "Unset target")
Publisher.subscribe(self.OnUpdateAngleThreshold, "Update angle threshold")
Publisher.subscribe(self.OnUpdateDistanceThreshold, "Update distance threshold")
Publisher.subscribe(
self.OnUpdateRobotWarning, "Robot to Neuronavigation: Update robot warning"
)
Publisher.subscribe(self.OnUpdateTracts, "Update tracts")
Publisher.subscribe(self.OnUpdateEfieldvis, "Update efield vis")
Publisher.subscribe(self.InitializeColorArray, "Initialize color array")
Expand Down Expand Up @@ -859,6 +863,10 @@ def OnUpdateDistanceThreshold(self, dist_threshold):
print("updated to ", dist_threshold)
self.distance_threshold = dist_threshold

def OnUpdateRobotWarning(self, robot_warning):
if self.robot_warnings_text is not None:
self.robot_warnings_text.SetValue(robot_warning)

def IsTargetMode(self):
return self.target_mode

Expand Down Expand Up @@ -984,6 +992,17 @@ def EnableTargetMode(self):
# Store the object for 'distance' text so it can be modified when distance changes.
self.distance_text = distance_text

# Remove the previous actor for 'distance' text
if self.robot_warnings_text is not None:
self.ren.RemoveActor(self.robot_warnings_text.actor)

# Create new actor for 'distance' text
robot_warnings_text = self.CreateRobotWarningsText()
self.ren.AddActor(robot_warnings_text.actor)

# Store the object for 'distance' text so it can be modified when distance changes.
self.robot_warnings_text = robot_warnings_text

self.CreateTargetGuide()

self.ren.ResetCamera()
Expand Down Expand Up @@ -1019,6 +1038,10 @@ def DisableTargetMode(self):
if self.distance_text is not None:
self.ren.RemoveActor(self.distance_text.actor)

# Remove the actor for 'distance' text.
if self.robot_warnings_text is not None:
self.ren.RemoveActor(self.robot_warnings_text.actor)

self.camera_show_object = None
if self.actor_peel:
if self.object_orientation_torus_actor:
Expand Down Expand Up @@ -1246,6 +1269,17 @@ def CreateVTKObjectMatrix(self, direction, orientation):

return m_img_vtk

def CreateRobotWarningsText(self):
robot_warnings_text = vtku.Text()

robot_warnings_text.SetSize(const.TEXT_SIZE_DISTANCE_DURING_NAVIGATION)
robot_warnings_text.SetPosition((const.X, 1.02 - const.YZ))
robot_warnings_text.SetVerticalJustificationToBottom()
robot_warnings_text.SetColour((1, 1, 0))
robot_warnings_text.BoldOn()

return robot_warnings_text

def CreateDistanceText(self):
distance_text = vtku.Text()

Expand Down

0 comments on commit cd7740f

Please sign in to comment.