# vtkPlaneWidget handle size

**URL:** https://discourse.vtk.org/t/vtkplanewidget-handle-size/13567
**Category:** Support
**Created:** [March 18, 2024, 1:40pm UTC](https://discourse.vtk.org/t/vtkplanewidget-handle-size/13567 "2024-03-18T13:40:38Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![codeling](https://discourse.vtk.org/user_avatar/discourse.vtk.org/codeling/32/3792_2.png) [@codeling](https://discourse.vtk.org/u/codeling)
#### Post date: [March 18, 2024, 1:40pm UTC](https://discourse.vtk.org/t/vtkplanewidget-handle-size/13567/1 "2024-03-18T13:40:39Z")

</div>

I’m trying to use vtkPlaneWidget, but the handle size adjustment does not work for my use case - it does not adapt properly to modified plane parameters. From looking at the code in the `vtkPlaneWidget::SizeHandles()` method, it completely ignores the user-specified `HandleSize` from the `vtk3DWidget` base class, and instead uses an internal `HandleSizeFactor` and an InitialSize to somehow automatically adjust the handle sizes. In my experiments, this basically only works properly for a “unit” plane of length 1; if adapting the plane points via SetOrigin/SetPoint1/SetPoint2, the plane itself adjusts fine, but the handles soon get far too small or large to be useful.

This is my test code (only a small modification to the [vtkPlaneWidget example](https://examples.vtk.org/site/Cxx/Widgets/PlaneWidget) ):

```auto
#include <vtkNamedColors.h>
#include <vtkNew.h>
#include <vtkPlaneWidget.h>
#include <vtkRenderWindow.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkRenderer.h>

int main(int, char*[])
{
  vtkNew<vtkNamedColors> colors;

  vtkNew<vtkRenderer> renderer;
  renderer->SetBackground(colors->GetColor3d("SlateGray").GetData());

  vtkNew<vtkRenderWindow> renderWindow;
  renderWindow->AddRenderer(renderer);
  renderWindow->SetWindowName("PlaneWidget");

  vtkNew<vtkRenderWindowInteractor> renderWindowInteractor;
  renderWindowInteractor->SetRenderWindow(renderWindow);

  vtkNew<vtkPlaneWidget> planeWidget;
  planeWidget->SetInteractor(renderWindowInteractor);

  // MODIFICATION START
  const double CoordFactor = 10;
  planeWidget->SetOrigin(-1.0*CoordFactor, -1.0*CoordFactor, 0.0);
  planeWidget->SetPoint1( 1.0*CoordFactor, -1.0*CoordFactor, 0.0);
  planeWidget->SetPoint2(-1.0*CoordFactor, 1.0*CoordFactor, 0.0);
  // MODIFICATION END

  planeWidget->On();

  renderWindowInteractor->Initialize();

  renderer->ResetCamera();
  renderWindow->Render();
  renderWindowInteractor->Start();

  return EXIT_SUCCESS;
}

```

Is the above an unexpected way of changing the plane parameters? Since vtkPlaneWidget itself provides these methods, I assume not?

For `CoordFactor = 0.5`, I get the same looks as when I remove modification:  
 ![PlaneWidget CoordFactor=0.5](https://discourse.vtk.org/uploads/default/original/2X/c/cc611c414e8b7c2cbd88aa88033bfc548e21cdd2.png)

For `CoordFactor = 2`, the handle spheres are already shown very small:  
 ![PlaneWidget CoordFactor=2](https://discourse.vtk.org/uploads/default/original/2X/4/439eaea3341c1cf8399ca8a447fce0fb7cd3f2e0.png)

As far as I read [the vtk3DWidget documentation, the “HandleSize”](https://vtk.org/doc/nightly/html/classvtk3DWidget.html#aa64ff939ff0163b73da30b19c7cfcbfd) should specificy the size of the handles in fractions of the window size.  
So there’s 2 problems with vtkPlaneWidget which I see here:  
(1) vtkPlaneWidget does not consider the HandleSize  
(2) the modified handle size automatism for vtkPlaneWidget only works for default plane parameters.

---

<div class="post-metadata">

### Author: ![codeling](https://discourse.vtk.org/user_avatar/discourse.vtk.org/codeling/32/3792_2.png) [@codeling](https://discourse.vtk.org/u/codeling)
#### Post date: [October 29, 2024, 12:15pm UTC](https://discourse.vtk.org/t/vtkplanewidget-handle-size/13567/2 "2024-10-29T12:15:27Z")

</div>

Am I doing something wrong here, or is nobody else using vtkPlaneWidget?

---

<div class="post-metadata">

### Author: ![jaswantp](https://discourse.vtk.org/user_avatar/discourse.vtk.org/jaswantp/32/10046_2.png) [@jaswantp](https://discourse.vtk.org/u/jaswantp)
#### Post date: [October 29, 2024, 12:24pm UTC](https://discourse.vtk.org/t/vtkplanewidget-handle-size/13567/3 "2024-10-29T12:24:25Z")

</div>

Hello @codeling,

I think not many people use `vtkPlaneWidget`. Can you try the `vtkImplicitPlaneWidget2` instead? [https://examples.vtk.org/site/Cxx/Widgets/ImplicitPlaneWidget2/](https://examples.vtk.org/site/Cxx/Widgets/ImplicitPlaneWidget2/)

Otherwise, can you contribute the bug fix for vtkPlaneWidget? You can find detailed steps on the development process we follow for VTK including how to prepare a merge request at [Developer’s Guide - VTK documentation](https://docs.vtk.org/en/latest/developers_guide/index.html)

Btw, apologies for the lack in responses. I may have missed a notification for this one and there are not many developers working in this part of VTK.

---

<div class="post-metadata">

### Author: ![codeling](https://discourse.vtk.org/user_avatar/discourse.vtk.org/codeling/32/3792_2.png) [@codeling](https://discourse.vtk.org/u/codeling)
#### Post date: [October 29, 2024, 2:29pm UTC](https://discourse.vtk.org/t/vtkplanewidget-handle-size/13567/4 "2024-10-29T14:29:40Z")

</div>

Thanks for the fast reply!

I looked at it, and on a quick glance it seems not ideal for our purposes - I don’t want or need the bounding box around the plane; and I could also not see how to get/set the “orientation” of the plane (which is possible in vtkPlaneWidget via origin/point1/point2) - maybe via the bounding box?.

I guess I’ll stick with vtkPlaneWidget for now.

I guess the kind of duplication between vtkPlaneWidget / vtkImplicitPlaneWidget / vtkImplicitPlaneWidget2 exists for legacy reasons?

---

<div class="post-metadata">

### Author: ![codeling](https://discourse.vtk.org/user_avatar/discourse.vtk.org/codeling/32/3792_2.png) [@codeling](https://discourse.vtk.org/u/codeling)
#### Post date: [October 29, 2024, 2:35pm UTC](https://discourse.vtk.org/t/vtkplanewidget-handle-size/13567/5 "2024-10-29T14:35:58Z")

</div>

> [@jaswantp](#):
>
> Otherwise, can you contribute the bug fix for vtkPlaneWidget? You can find detailed steps on the development process we follow for VTK including how to prepare a merge request at [Developer’s Guide - VTK documentation](https://docs.vtk.org/en/latest/developers_guide/index.html)

I would have to experiment a bit more to get my solution working more generically I think, but I will consider doing that (if vtkPlaneWidget isn’t considered deprecated?).
