[vtkusers] vtkAreaPicker, select a bunch of glyth speres and extract them into another actor, python

deonis denis.spasyuk at gmail.com
Tue Jan 12 11:40:08 EST 2016


Hell all, 

I am looking for a method to select a bunch of glyph objects (spheres) using
vtkAreaPicker and then extract those spheres into another actor. The goal is
to pick an object, move it to another actor and highlight it. I cannot seem
to find any python example of this operation. Here is my interactor class: 


class MyInteractorStyle(vtk.vtkInteractorStyleRubberBandPick):
 
    def __init__(self,parent=None):
       
self.AddObserver("MiddleButtonPressEvent",self.middleButtonPressEvent)
        self.AddObserver("RightButtonPressEvent",self.RightButtonPressEvent)
       
self.AddObserver("MiddleButtonReleaseEvent",self.middleButtonReleaseEvent)
        self.AddObserver("LeftButtonReleaseEvent",self.OnLeftButtonUpEvent)
        self.AddObserver("LeftButtonDownEvent",self.OnLeftButtonDownEvent)

    def OnLeftButtonDownEvent(self,obj,event):
               print("Left Button pressed")
               self.OnLeftButtonDown()
    def OnLeftButtonUpEvent(self,obj,event):
               print("Left Button pressed")
               self.SelectedMapper = vtk.vtkDataSetMapper()
               self.SelectedActor = vtk.vtkActor()
               self.SelectedActor.SetMapper(self.SelectedMapper)
               self.OnLeftButtonUp()
               frustum=self.GetInteractor().GetPicker().GetFrustum()
               extractGeometry = vtk.vtkExtractPolyDataGeometry()
               extractGeometry.SetImplicitFunction(frustum)
               extractGeometry.SetInputData(polydata)
               extractGeometry.Update()
               print(extractGeometry.GetOutput().GetNumberOfCells())
              
self.SelectedMapper.SetInputConnection(extractGeometry.GetOutputPort())
               self.SelectedMapper.ScalarVisibilityOff()
               self.SelectedActor.GetProperty().SetColor(1.0, 0.0, 0.0);
#(R,G,B)
               self.SelectedActor.GetProperty().SetPointSize(5)

any help appreciated!,

cheers,

Denis



--
View this message in context: http://vtk.1045678.n5.nabble.com/vtkAreaPicker-select-a-bunch-of-glyth-speres-and-extract-them-into-another-actor-python-tp5735924.html
Sent from the VTK - Users mailing list archive at Nabble.com.


More information about the vtkusers mailing list