[vtkusers] From world coordinates to vtkBorderWidget's coordinate???
Waldo Valenzuela
waldo.valenzuela at hotmail.com
Tue Apr 15 10:37:46 EDT 2014
Hi Arnaud,
Do you want to draw a 2D rectangle over a 3D scene, parallel to the viewer?
On 11 Apr 2014, at 15:28, Arnaud Gelas <arnaudgelas at gmail.com> wrote:
> 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
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20140415/2566b7e1/attachment.html>
More information about the vtkusers
mailing list