# Change vtkDistanceWidget handles radius

**URL:** https://discourse.vtk.org/t/change-vtkdistancewidget-handles-radius/5428
**Category:** Web
**Created:** [March 23, 2021, 3:49pm UTC](https://discourse.vtk.org/t/change-vtkdistancewidget-handles-radius/5428 "2021-03-23T15:49:11Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![ronzim](https://discourse.vtk.org/user_avatar/discourse.vtk.org/ronzim/32/3153_2.png) [@ronzim](https://discourse.vtk.org/u/ronzim)
#### Post date: [March 23, 2021, 3:49pm UTC](https://discourse.vtk.org/t/change-vtkdistancewidget-handles-radius/5428/1 "2021-03-23T15:49:11Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Yohann\_Bearzi](https://discourse.vtk.org/user_avatar/discourse.vtk.org/yohann_bearzi/32/671_2.png) [@Yohann\_Bearzi](https://discourse.vtk.org/u/Yohann_Bearzi)
#### Post date: [March 23, 2021, 3:59pm UTC](https://discourse.vtk.org/t/change-vtkdistancewidget-handles-radius/5428/2 "2021-03-23T15:59:37Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![ronzim](https://discourse.vtk.org/user_avatar/discourse.vtk.org/ronzim/32/3153_2.png) [@ronzim](https://discourse.vtk.org/u/ronzim)
#### Post date: [March 23, 2021, 4:10pm UTC](https://discourse.vtk.org/t/change-vtkdistancewidget-handles-radius/5428/3 "2021-03-23T16:10:39Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Forrest](https://discourse.vtk.org/user_avatar/discourse.vtk.org/forrest/32/300_2.png) [@Forrest](https://discourse.vtk.org/u/Forrest)
#### Post date: [March 23, 2021, 4:23pm UTC](https://discourse.vtk.org/t/change-vtkdistancewidget-handles-radius/5428/4 "2021-03-23T16:23:43Z")

</div>

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:

```auto
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](https://github.com/Kitware/paraview-glance/blob/master/src/vtk/Distance2DWidget/index.js#L46) along with [the corresponding state](https://github.com/Kitware/paraview-glance/blob/master/src/vtk/Distance2DWidget/state.js#L11) that sets the handles to a radius of 50 pixels. (Or diameter? I forget which one it sets.) The [PolyLineWidget](https://kitware.github.io/vtk-js/examples/PolyLineWidget.html) also demonstrates the handle scaling.

---

<div class="post-metadata">

### Author: ![ronzim](https://discourse.vtk.org/user_avatar/discourse.vtk.org/ronzim/32/3153_2.png) [@ronzim](https://discourse.vtk.org/u/ronzim)
#### Post date: [March 23, 2021, 4:29pm UTC](https://discourse.vtk.org/t/change-vtkdistancewidget-handles-radius/5428/5 "2021-03-23T16:29:47Z")

</div>

Thank you Forrest, that’s what I was looking for. I will give also a look to your suggestion.  
bye
