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:
For CoordFactor = 2
, the handle spheres are already shown very small:
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.