Commit c49f127bdac73d411af3fc09b3ac7587c11a14cb

Authored by tfmoraes
1 parent 68370220

ADD: a method to Add a point reference, remove a point or remove all points

Showing 1 changed file with 42 additions and 1 deletions   Show diff stats
invesalius/data/viewer_volume.py
... ... @@ -86,6 +86,8 @@ class Viewer(wx.Panel):
86 86 self.picker = vtk.vtkPointPicker()
87 87 interactor.SetPicker(self.picker)
88 88 self.seed_points = []
  89 +
  90 + self.points_reference = []
89 91  
90 92  
91 93 def __bind_events(self):
... ... @@ -147,7 +149,6 @@ class Viewer(wx.Panel):
147 149 def OnEndSeed(self, pubsub_evt):
148 150 ps.Publisher().sendMessage("Create surface from seeds",
149 151 self.seed_points)
150   -
151 152  
152 153 def OnExportPicture(self, pubsub_evt):
153 154 ps.Publisher().sendMessage('Begin busy cursor')
... ... @@ -213,6 +214,43 @@ class Viewer(wx.Panel):
213 214 self.text.Show()
214 215 self.interactor.Render()
215 216  
  217 + def AddPointReference(self, position, radius=1, colour=(1, 0, 0)):
  218 + """
  219 + Add a point representation in the given x,y,z position with a optional
  220 + radius and colour.
  221 + """
  222 + point = vtk.vtkSphereSource()
  223 + point.SetCenter(position)
  224 + point.SetRadius(radius)
  225 +
  226 + mapper = vtk.vtkPolyDataMapper()
  227 + mapper.SetInput(point.GetOutput())
  228 +
  229 + p = vtk.vtkProperty()
  230 + p.SetColor(colour)
  231 +
  232 + actor = vtk.vtkActor()
  233 + actor.SetMapper(mapper)
  234 + actor.SetProperty(p)
  235 + actor.PickableOff()
  236 +
  237 + self.ren.AddActor(actor)
  238 +
  239 + self.points_reference.append(actor)
  240 +
  241 + def RemoveAllPointsReference(self):
  242 + for actor in self.points_reference:
  243 + self.ren.RemoveActor(actor)
  244 + self.points_reference = []
  245 +
  246 + def RemovePointReference(self, point):
  247 + """
  248 + Remove the point reference. The point argument is the position that is
  249 + added.
  250 + """
  251 + actor = self.points_reference.pop(point)
  252 + self.ren.RemoveActor(actor)
  253 +
216 254 def __bind_events_wx(self):
217 255 #self.Bind(wx.EVT_SIZE, self.OnSize)
218 256 pass
... ... @@ -550,6 +588,9 @@ class Viewer(wx.Panel):
550 588 self.picker.Pick(x, y, 0, self.ren)
551 589 point_id = self.picker.GetPointId()
552 590 self.seed_points.append(point_id)
  591 + self.AddPointReference(self.picker.GetPickPosition(), 5)
  592 + self.interactor.Render()
  593 +
553 594  
554 595 class SlicePlane:
555 596 def __init__(self):
... ...