[vtkusers] vtkSphereHandleRepresentation problem

Greg Ushomirsky gregus at gmail.com
Tue Apr 15 07:38:10 EDT 2008


Hi,

I'm having a problem using vtkSphereHandleRepresentation class. I have
a simple program that places the widget at the location of an existing
actor. When I press "i", I expect to see the sphere and be able to
move it.. However, what happens is (1)  I don't see the sphere widget
(2)  the cursor changes into a hand the first time around, but, after
I click on the middle of the actor (where the sphere handle should
be), the cursor changes back into an arrow. After that, no matter how
many times I press "i", it looks like the interaction doesn't start
again.   What am I doing wrong??

Below is an excerpt from the program I use. Note that if I create a
vtkPointHandleRepresentation instead of a
vtkSphereHandleRepresentation, or even if I make a
vtkPolygonalHandleRepresentation and feed it a sphere source, the
interaction proceeds as it should, or at least the widget is visible.
This leads me to believe that there may be a problem with
vtkSphereHandleRepresentation.

Also, it would be helpful to have either an example of the class being
used, or at least a regression test that can be used as a basis for
new code. Do these exist??

Thanks in advance,
Greg

=======code===============
#include "vtkCamera.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkPolyData.h"
#include "vtkPointSource.h"
#include "vtkRenderer.h"
#include "vtkActor.h"
#include "vtkProperty.h"
#include "vtkSmartPointer.h"
#include "vtkPolyDataMapper.h"
#include "vtkParticleReader.h"
#include "vtkCylinderSource.h"
#include "vtkPointHandleRepresentation3D.h"
#include "vtkSphereHandleRepresentation.h"
#include "vtkPolygonalHandleRepresentation3D.h"
#include "vtkHandleWidget.h"
#include "vtkIndent.h"

int main( int argc, char *argv[] )
{
	vtkSmartPointer<vtkRenderer> ren 				= vtkRenderer::New();
	vtkSmartPointer<vtkRenderWindow> renWin			= vtkRenderWindow::New();
	renWin->AddRenderer(ren);

	vtkSmartPointer<vtkRenderWindowInteractor> iren	=
vtkRenderWindowInteractor::New();
	iren->SetRenderWindow(renWin);

	vtkSmartPointer<vtkCylinderSource> src		= vtkCylinderSource::New();
	vtkSmartPointer<vtkPolyDataMapper> mapper		= vtkPolyDataMapper::New();
	mapper->SetInputConnection(src->GetOutputPort());

	vtkSmartPointer<vtkActor> actor					= vtkActor::New();
	actor->SetMapper(mapper);

	ren->AddActor(actor);

        //THIS WIDGET DOES NOT WORK
	vtkSmartPointer<vtkSphereHandleRepresentation> handleRep =
vtkSphereHandleRepresentation::New();

        //BUT THIS ONE SEEMS TO WORK JUST FINE
	//vtkSmartPointer<vtkPointHandleRepresentation3D> handleRep =
vtkPointHandleRepresentation3D::New();

	//OR EVEN THIS ONE
	//vtkSmartPointer<vtkPolygonalHandleRepresentation3D> handleRep =
vtkPolygonalHandleRepresentation3D::New();
	//vtkSmartPointer<vtkSphereSource> sph = vtkSphereSource::New();
	//sph->SetThetaResolution(16);   sph->SetPhiResolution(8); sph->SetRadius(0.1);
	//handleRep->SetHandle(sph->GetOutput());


	handleRep->PlaceWidget(actor->GetBounds());
	vtkHandleWidget *handleWidget = vtkHandleWidget::New();
	handleWidget->SetInteractor(iren);
	handleWidget->SetRepresentation(handleRep);


	ren->SetBackground(0,0,0);	
	iren->Initialize();
	
	renWin->Render();
	
	iren->Start();
	
	return 0;
}



More information about the vtkusers mailing list