[vtkusers] Position a widget in display coordinates?

Totte Karlsson totte at dunescientific.com
Tue Mar 17 21:07:04 EDT 2015


> I imagine I would need to go from normalized (2D) display values, say 
> (-0.8, -0.8) & (0.8,-0.8) which would be at the bottom of the window, 
> to world coordinates (3D).
> Any pointers on how to achieve this? 
Been trying the following code, where mSliderRep is the 3d slier 
representation;

     double p1[3] = { .2, 0.1, 0};
     double p2[3] = {0.8, 0.1, 0};

mSliderRep->GetPoint1Coordinate()->SetCoordinateSystemToNormalizedDisplay();
mSliderRep->GetPoint2Coordinate()->SetCoordinateSystemToNormalizedDisplay();
     mSliderRep->GetPoint1Coordinate()->SetValue(p1);
     mSliderRep->GetPoint2Coordinate()->SetValue(p2);

The above 'works' most of the time. But depending on the position of the 
camera, it does not work always!?
Have no idea why it only works for certain camera positions? Any clues?

tk


More information about the vtkusers mailing list