[vtkusers] vtkSphereWidget-how to initialize handle

Burlen burlen at apollo.sr.unh.edu
Mon Jul 11 16:59:18 EDT 2005


Hi, I am attempting to use the vtkSphereWidget to position lights, I have a 
light in the sceene and want the center of the sphere on the lights focal 
point handle to be positioned on the light itself. There may or maynot be 
actors in the sceene and there may not be data around at the time of the 
light positioning so PlaceWidget() won't work. 

The problem I am having is that there is no SetHandlePosition() function, and 
initially the handle (it's on) doesn't appear in the sceene only the 
wireframe. Once the frame is clicked the handle apears in the scene but at 
the center of the sphere, it can't be selected because the wireframe catches 
the clicks. To select the handle I have to zoom inside the frame, click the 
handle then start to move it, at that point it snaps to the sphere radius and 
is no longer visible until the camera is reset, and the frame is clicked 
again.

I am not sure what I am doing wrong, and I hope that one can get around using 
PlaceWidget() and setProp3D()...

loc = thisLight->GetPosition();
foc = thisLight->GetFocalPoint();
r = sqrt(pow(loc[0]-foc[0],2)+pow(loc[1]-foc[1],2)+pow(loc[2]-foc[2],2));
		
		
swid = vtkSphereWidget::New();
swid->GetSphereProperty()->SetColor(0,0,0);
swid->GetHandleProperty()->SetColor(0,0,0);
swid->SetCenter(foc[0], foc[1], foc[2]);
swid->SetRadius(r);
swid->SetHandleDirection((foc[0]-loc[0])/r, (foc[1]-loc[1])/r,
(foc[2]-loc[2])/r);
swid->SetInteractor(iren);
swid->TranslationOff();
swid->HandleVisibilityOn();
swid->SetEnabled(1);
swid->On();



More information about the vtkusers mailing list