[vtk-developers] vtkTextRepresentation Coordinates

Daniel Haehn haehn at bwh.harvard.edu
Tue Aug 3 16:50:59 EDT 2010


Hi guys,

I use the following code to set a position for a vtkTextWidget including a vtkTextRepresentation. I want to place the widget at a specific position obtained through a click in the render window.

      vtkTextWidget* textWidget = vtkTextWidget::New();
      VTK_CREATE(vtkTextRepresentation, textRep);
      ...
      textRep->SetPosition(x,y)

This only works if I convert the obtained coordinates:

     double x = this->GetInteractor()->GetEventPosition()[0];
     double y = this->GetInteractor()->GetEventPosition()[1];

     this->GetRenderer()->DisplayToNormalizedDisplay(x,y);
     this->GetRenderer()->NormalizedDisplayToViewport(x,y);
     this->GetRenderer()->ViewportToNormalizedViewport(x,y);

Am I doing something wrong? Is there an easier way?

Thank you,
Daniel


More information about the vtk-developers mailing list