[vtkusers] vtkBoxWidget handle size bug or feature?
Berti Krüger
berti_krueger at hotmail.com
Wed Feb 7 01:55:17 EST 2018
As i have seen by walking through the source code of vtkBoxWidget.cxx the
method for resizing the handles vtkBoxWidget::SizeHandles() is first called in
the constructor
vtkBoxWidget::vtkBoxWidget()
{
...
// Define the point coordinates
double bounds[6];
bounds[0] = -0.5;
bounds[1] = 0.5;
bounds[2] = -0.5;
bounds[3] = 0.5;
bounds[4] = -0.5;
bounds[5] = 0.5;
// Points 8-14 are down by PositionHandles();
this->PlaceWidget(bounds);
...
}
by the method
void vtkBoxWidget::PlaceWidget(double bds[6])
{
...
this->SizeHandles();
...
}
The method void vtkBoxWidget::SizeHandles() looks like this:
void vtkBoxWidget::SizeHandles()
{
double radius = this->vtk3DWidget::SizeHandles(1.5);
for(int i=0; i<7; i++)
{
this->HandleGeometry[i]->SetRadius(radius);
}
}
And it is also called in void vtkBoxWidget::OnLeftButtonUp(), void
vtkBoxWidget::OnMiddleButtonUp() and in void vtkBoxWidget::OnRightButtonUp().
So if you click on the widget the line
double radius = this->vtk3DWidget::SizeHandles(1.5);
is executed a second time after its execution in the constructor which results
in resizing of the spheres (factor 1.5 again).
Anyway. I have now subclassed vtkBoxWidget and have overwritten the
SizeHandles() method and it works now how i need it in my project.
Thanks again to the vtk developers for making vtk opensource.
Berti Krüger
PS: If anyone can help me with some enlightenment regarding the default
behaviour of vtkBoxWidget i would still be glad (e.g. bug or feature?).
Am Wed, 7 Feb 2018 06:21:55 +0000
schrieb Berti Krüger <berti_krueger at hotmail.com>:
> It seems i am not the only one who doesn't understand the logic behind the
> sizing of the vtkBoxWidget handles:
>
> http://massmail.spl.harvard.edu/public-archives/slicer-devel/2011/006000.html
>
> "Hello,
>
> I am using a vtkBoxWidget, and it seems the size of the handles depends on
> the ValidPick (to know if handle has been picked or not) (and on the
> renderer to. We have to set a current renderer before calling PlaceWidget.)
>
> So, when I am creating the box, ValidPick is 0 because handles have not been
> picked yet.
> The size of the handles is calculate with:
>
> return (this->HandleSize * factor * this->InitialLength);
>
>
> But, when we resize the box, ValidPick change to 1 (on
> OnLeftButtonDown() (same for middle and right button) ), and the size
> is now calculated like this:
>
> return (this->HandleSize * factor * sqrt(radius) );
>
>
> InitialLength has been replaced by sqrt(radius) (defined on
> vtk3DWidget::SizeHandles)
>
> But sqrt(radius) is different from InitalLength.
>
> So, when we create a vtkBoxWidget, handles are small, and when we resize it,
> handles are bigger.
>
>
> Is this normal, or it's a bug ?
>
> Thank you.
> Laurent."
>
>
>
> Am Mon, 5 Feb 2018 10:00:16 +0000
> schrieb Berti Krüger <berti_krueger at hotmail.com>:
>
> > Hello Everyone!
> >
> > I am currently using a vtkBoxWidget in my project (VTK 8.1). After i
> > created the vtkBoxWidget, the size handles (= vtkSphereActors) have not been
> > picked yet and are small and nice.
> >
> > But, when I resize the vtkBoxWidget (smaller or larger, it doesn't matter)
> > or simply click on it, the handles get bigger (radius increases) and stay
> > this way.
> >
> > They sometimes tend to get so large that they are piercing the mesh and
> > visually adding themselves to it, which is annoying. And they never get
> > smaller again, sometimes they get even larger.
> >
> > When i zoom out by large amount and then zoom in again, the handles get
> > normal ( = small) again.
> >
> > Is this the intented behaviour, and if so, what is the purpose of it or is
> > it a bug ?
> >
> >
> > Thank you very much in advance.
> >
> >
> > Berti Krüger
> >
> > _______________________________________________
> > Powered by www.kitware.com
> >
> > Visit other Kitware open-source projects at
> > http://www.kitware.com/opensource/opensource.html
> >
> > Please keep messages on-topic and check the VTK FAQ at:
> > http://www.vtk.org/Wiki/VTK_FAQ
> >
> > Search the list archives at: http://markmail.org/search/?q=vtkusers
> >
> > Follow this link to subscribe/unsubscribe:
> > https://vtk.org/mailman/listinfo/vtkusers
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Search the list archives at: http://markmail.org/search/?q=vtkusers
>
> Follow this link to subscribe/unsubscribe:
> https://vtk.org/mailman/listinfo/vtkusers
More information about the vtkusers
mailing list