[vtkusers] From world coordinates to vtkBorderWidget's coordinate???

Arnaud Gelas arnaudgelas at gmail.com
Fri Apr 11 09:28:25 EDT 2014


Note that I first naively try to set Position and Position2 in world
coordinate, but it does not work as well (as it was done in the following
broken wiki example:
http://cmake.org/Wiki/VTK/Examples/Broken/Cxx/Widgets/BorderWorldCoords )


On Fri, Apr 11, 2014 at 3:13 PM, Arnaud Gelas <arnaudgelas at gmail.com> wrote:

> Hi all,
>
> I have world coordinates for both corners of a rectangle and I would like
> to draw the corresponding rectangle using vtkBorderWidget /
> vtkBorderRepresentation.
>
> Assuming the 2 locations are:
>         * double lowerLeftCorner[3], upperRightCorner[3];
>
> How would you set it to Position and Position2, by the means of
> PositionCoordinate and Position2Coordinate?
>
> I have tried the following:
>
>         vtkSmartPointer< vtkCoordinate > temp = vtkSmartPointer<
> vtkCoordinate >::New();
>         temp->SetCoordinateSystemToWorld();
>         temp->SetValue( lowerLeftCorner[0], lowerLeftCorner[1],
> lowerLeftCorner[2] );
>
>         double* left = temp->GetComputedDoubleDisplayValue( renderer );
>
>         renderer->DisplayToNormalizedDisplay( left[0], left[1] );
>         renderer->NormalizedDisplayToViewport( left[0], left[1] );
>         renderer->ViewportToNormalizedViewPort( left[0], left[1] );
>
>         borderRepresentation->GetPositionCoordinate()->SetValue( left[0],
> left[1] );
>
> I have tried doing the same for upperRightCorner, or making it relative as
> it is done inside vtkBorderRepresentation, i.e.
>
>         borderRepresentation->GetPositionCoordinate()->SetValue( right[0],
> right[1] );
>
> or
>         borderRepresentation->GetPositionCoordinate()->SetValue( right[0]
> - left[0], right[1] - left[1] );
>
>
> It does not appear right on the screen afterwards... I am definitively
> missing something here...
>
> What is the correct way to proceed?
>
>
> I would really appreciate if anyone could enlighten me here!!!
>
> Best,
> Arnaud
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20140411/8781b71a/attachment.html>


More information about the vtkusers mailing list