I’m wondering if it is possible to modify the shape of the box that is displayed when I pick an area with ‘r’? I would like it to be circle where the center is the position the mouse was at when I pressed the mouse and the radius the distance from that previous position and the current mouse position?
I probably need to rewrite a vtkInteractorStyleRubberBandPick method, but which one and how.
I give a minimal code to start with.
import vtk
class MouseInteractorHighLightActor(vtk.vtkInteractorStyleRubberBandPick):
def __init__(self, parent=None):
self.AddObserver(vtk.vtkCommand.EndPickEvent, self.EndPickEventfunc)
return
def EndPickEventfunc(self, obj, event):
print('I was here!')
# A renderer and render window
renderer = vtk.vtkRenderer()
renderer.SetBackground(.3, .4, .5)
renwin = vtk.vtkRenderWindow()
renwin.AddRenderer(renderer)
# An interactor
interactor = vtk.vtkRenderWindowInteractor()
interactor.SetRenderWindow(renwin)
# add the custom style
style = MouseInteractorHighLightActor()
style.SetDefaultRenderer(renderer)
interactor.SetInteractorStyle(style)
# Add spheres to play with
for i in range(10):
source = vtk.vtkSphereSource()
source.SetRadius(vtk.vtkMath.Random(.5, 1.0))
source.SetCenter(vtk.vtkMath.Random(-5, 5), vtk.vtkMath.Random(-5, 5), vtk.vtkMath.Random(-5, 5))
source.SetPhiResolution(11)
source.SetThetaResolution(21)
mapper = vtk.vtkPolyDataMapper()
mapper.SetInputConnection(source.GetOutputPort())
actor = vtk.vtkActor()
actor.SetMapper(mapper)
actor.GetProperty().SetDiffuseColor(vtk.vtkMath.Random(.4, 1.0), vtk.vtkMath.Random(.4, 1.0), vtk.vtkMath.Random(.4, 1.0))
renderer.AddActor(actor)
# Start
interactor.Initialize()
interactor.Start()