[vtkusers] problems using vtkSplineWidget
dean.inglis at camris.ca
dean.inglis at camris.ca
Fri Feb 16 09:17:00 EST 2007
[vtkusers] problems using vtkSplineWidget
Hi Wouter,
since your interactor style is vtkInteractorStyleImage,
are you trying to overlay your spline widget on top
of a vtkImageActor? What are you using vtkSplineWidget
for?
1) vtkSplineWidget uses the "old" handle sizing paradigm.
Before the new widget design framework, widget handles
were set to a percentage of the display window diagonal
(see code in vtk3DWidget.cxx) and the diagonal of initial bounds
the widget is placed in (when PlaceWidget is called with
some 3D bounds). You can adjust this by
calling
widget->SetHandleSize(scale_factor);
Or, by calling PlaceWidget again with new bounds.
The behaviour you observe while interacting is expected,
(try using vtkBoxWidget for example), as the handles
will resize themselves at the END of user interaction and
not during user interaction.
The new contour widget classes have on the fly handle sizing
that may be more to your liking.
2) Initializing the handles with vtkPoints is fine, and
you may also want to specify whether the spline should
be open or closed. After initializing, you may want
to tell the spline's renderer to Render instead of enabling/disabling
the spline.
Dean
Hi all!
I'm facing more than one difficulty using and controlling the vtkSplineWidget.
Problem 1: I'm setting the size of the handles (see code below), and
that works fine untill I move one of the handles, then the size all
handles become around 2 times larger... It cannot be fixed by setting
the size again..
Problem 2: I added handles by using InitializeHandles(see code below).
The handles looked fine, but the line was drawn through only 5 instead
of the +-30 handles. Till I move a handle, then it's drawn
correctly... I solved the problem by using:
spline->On(); spline->Off(); spline->On();
But I hope this is not the right way to do it...
Anybody knows how to solve problem 1, or more general: does anybody
has more documentation on the vtkSplineWidget than the available
Doxygen documentation, threads on this mailing list, the examples, the
tests, and the VTK user guide?
By the way: Methods like ProjectToPlaneOn(),
SetProjectionNormalToZAxes() and SetProjectionPosition(0) do not have
effect in my case. Possibly because I'm using the
vtkInteractorStyleImage as the interactor.
Many thanks in advance.
Cheers,
Wouter
CreateSplineWidget(vtkSplineWidget* spline, vtkPoints* points) {
//configure the spline widget
spline->SetCurrentRenderer( renderer );
spline->SetDefaultRenderer( renderer );
spline->SetInteractor( iren );
double bnds[6];
points->GetBounds( bnds );
spline->PlaceWidget( bnds[0], bnds[1], bnds[2], bnds[3], bnds[4], bnds[5] );
//spline->SetProjectionNormalToZAxes(); //not needed
//spline->SetProjectionPosition(); //not needed
//define properties handles
double bnds[6];
points->GetBounds( bnds );
spline->PlaceWidget( bnds[0], bnds[1], bnds[2], bnds[3], bnds[4], bnds[5] );
//define properties handles
spline->SetHandleSize( 0.005 );
vtkProperty* prop = vtkProperty::New();
prop->SetColor( 0.01, 0.9, 0.01 );
spline->SetHandleProperty( prop );
spline->SetSelectedHandleProperty( prop );
//set handles
spline->SetNumberOfHandles(points->GetNumberOfPoints()); //not needed
spline->InitializeHandles(points);
//show spline
spline->On();
spline->Off();
spline->On();
}
More information about the vtkusers
mailing list