import vtk
# Call back function

def planeCallback(obj, event):
    print('Origin point: {}, {}, {}'.format(*obj.GetOrigin()))

# A renderer and render window
renderer = vtk.vtkRenderer()
renderer.SetBackground(0, 0, 0)

renwin = vtk.vtkRenderWindow()
renwin.AddRenderer(renderer)

# An interactor
interactor = vtk.vtkRenderWindowInteractor()
interactor.SetRenderWindow(renwin)

# A Plane widget
planeWidget = vtk.vtkPlaneWidget()
planeWidget.SetInteractor(interactor)
planeWidget.SetRepresentationToSurface()
planeWidget.On()

# Connect the event to a function
planeWidget.AddObserver("InteractionEvent", planeCallback)

# Start
interactor.Initialize()
interactor.Start()

分类: python

发表评论

电子邮件地址不会被公开。 必填项已用*标注