[vtk-developers] vtkTextRepresentation Coordinates

Karthik Krishnan karthik.krishnan at kitware.com
Wed Aug 4 09:34:31 EDT 2010


Daniel:

That is because vtkBorderRepresentation manages its Position and
Position2Coordinates in the NormalizedViewport coodinate system.

See vtkBorderRepresentation.cxx line 45,48 :

  this->PositionCoordinate->SetCoordinateSystemToNormalizedViewport();
  this->Position2Coordinate->SetCoordinateSystemToNormalizedViewport();

Hence any values you set, are in-turn blindly passed on to the these ivars;
they are assumed to be in the coodinate system that these ivars are in.

--
karthik


On Wed, Aug 4, 2010 at 2:20 AM, Daniel Haehn <haehn at bwh.harvard.edu> wrote:

> 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
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtk-developers
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtk-developers/attachments/20100804/39e0b51a/attachment.html>


More information about the vtk-developers mailing list