vtkPlaneWidget handle size

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 ):

#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

For CoordFactor = 2, the handle spheres are already shown very small:
PlaneWidget CoordFactor=2

As far as I read the vtk3DWidget documentation, the “HandleSize” 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.

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

Hello @codeling,

I think not many people use vtkPlaneWidget. Can you try the vtkImplicitPlaneWidget2 instead? 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

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.

1 Like

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?

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?).