renWin.AddRenderer(ren1) iren = vtk.vtkRenderWindowInteractor() iren.SetRenderWindow(renWin) # Create a test pipeline ss = vtk.vtkSphereSource() mapper = vtk.vtkPolyDataMapper() mapper.SetInput(ss.GetOutput()) actor = vtk.vtkActor() actor.SetMapper(mapper) # Create the widget and its representation handle = vtk.vtkPointHandleRepresentation2D() handle.GetProperty().SetColor(1,0,0) rep = vtk.vtkSeedRepresentation() rep.SetHandleRepresentation(handle) widget=vtk.vtkSeedWidget() widget.SetInteractor(iren) widget.SetRepresentation(rep) widget.AddObserver("PlacePointEvent", vtkSeedCallback) # Add the actors to the renderer, set the background and size ren1.AddActor(actor) ren1.SetBackground(0.1, 0.2, 0.4) renWin.SetSize(300, 300) iren.Initialize()
import vtk render = vtk.vtkRenderer() win = vtk.vtkRenderWindow() win.AddRenderer(render) interactor = vtk.vtkRenderWindowInteractor() interactor.SetRenderWindow(win) # create a representation handleRep = vtk.vtkPointHandleRepresentation2D() handleRep.GetProperty().SetColor(1,1,0) widgetRep = vtk.vtkSeedRepresentation() widgetRep.SetHandleRepresentation(handleRep) # create a seedwidget here seedWidget = vtk.vtkSeedWidget() seedWidget.SetInteractor(interactor) seedWidget.SetRepresentation(widgetRep) seedWidget.On() interactor.Start()
Created on Tue Jan 26 17:42:59 2016 @author: qinshuo """ import vtk render = vtk.vtkRenderer() win = vtk.vtkRenderWindow() win.AddRenderer(render) interactor = vtk.vtkRenderWindowInteractor() interactor.SetRenderWindow(win) # create a representation handleRep = vtk.vtkPointHandleRepresentation2D() handleRep.GetProperty().SetColor(1, 1, 0) widgetRep = vtk.vtkSeedRepresentation() widgetRep.SetHandleRepresentation(handleRep) # create a seedwidget here seedWidget = vtk.vtkSeedWidget() seedWidget.SetInteractor(interactor) seedWidget.SetRepresentation(widgetRep) seedWidget.On() interactor.Start()