Hi, I have a vtkDistanceWidget in a vtk scene, but handles are so small you can’t interact with them. I searched for a “setRadius” method and I found it in the SphereHandleRepresentation, but it’s not clear to me how to reach that method from a vtkDistanceWidget.
Thank you all
You can access to the distance representation using vtkDistanceRepresentation* vtkDistanceWidget::GetDistanceRepresentation()
.
From there, you can set the handle representation you want to use for the to end points of the distance widget, by calling vtkDistanceRepresentation::SetHandleRepresentation
with the parameters you want. You can feed in a vtkSphereHandleRepresentation
inside this setter. You should call then vtkDistanceRepresentation::InitiateHandleRepresentation
, which will create 2 instances of the representation you previously set, and shallow copy it.
Thank you Yohann for your answer, but I forgot to mention that I’m using vtk.js ! I guess there is a similar method but I cannot find it
For vtk.js, setting the handle sphere radius is controlled by the widget state’s scale. For the distance widget, you should be able to do something like the following:
distanceWidget.getWidgetState().getHandleList().forEach(function (handleState) => {
handleState.setScale1(value);
});
If you want to have the handles be scaled such that they stay a fixed radius in pixels, you’ll need to extend the DistanceWidget to tell the representations to scale in pixels. See this custom distance widget along with the corresponding state that sets the handles to a radius of 50 pixels. (Or diameter? I forget which one it sets.) The PolyLineWidget also demonstrates the handle scaling.
Thank you Forrest, that’s what I was looking for. I will give also a look to your suggestion.
bye