[vtkusers] From world coordinates to vtkBorderWidget's coordinate???
    Arnaud Gelas 
    arnaudgelas at gmail.com
       
    Fri Apr 11 09:13:03 EDT 2014
    
    
  
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
    
    
More information about the vtkusers
mailing list