[vtkusers] reg sphereWidget behavior
Dean Inglis
dean.inglis at camris.ca
Sat Mar 13 10:48:55 EST 2010
Somi,
the sphere widget reports its coords in spherical coordinates
(radius, theta, phi). Have a look at the VTK Wiki Examples:
for example VTK/Examples/Widgets/SphereWidget2
Dean
I use a sphere widget in my application, where a user can drag the sphere
around and at the end I do a "pick point" on the surface based on the end
location of the sphere.
On end interaction event, I get the mouse location and use that to pick
point.
For example this is what I do in my callback function:
int* pos1 = this->renderWindowInteractor->GetEventPosition();
picker->Pick(pos1[0], pos1[1], 0, this->renderer);
The problem is that the location of the sphere is not exactly under the
mouse while dragging but offset by some variable amount.
Is there any way where the sphere always is under the mouse while dragging
it ?
The is my code where I call the callback:
sphereWidgetReam = vtkSphereWidget::New();
sphereWidgetReam->SetInteractor(this->iren);
sphereCallbackReam = SphereCallback::New();
sphereCallbackReam->SetRenderer(this->aRenderer);
sphereCallbackReam->SetInteractor(this->iren);
sphereWidgetReam->AddObserver(vtkCommand::EndInteractionEvent,sphereCallbackReam);
sphereWidgetReam->GetSphereProperty()->SetColor(0,1,0);
sphereWidgetReam->GetSphereProperty()->SetOpacity(1);
sphereWidgetReam->SetRadius(3);
sphereWidgetReam->TranslationOn();
sphereWidgetReam->ScaleOff();
Thanks,
Somi
More information about the vtkusers
mailing list