[vtkusers] X values of GetPositionCoordinate() & GetEventPosition()differ by 1 pixel
John Platt
jcplatt at lineone.net
Thu Apr 7 16:56:00 EDT 2005
Hi All,
My mistake. I hadn't realized that viewport coordinates refer to pixel
centres. Changing the BL coordinate from (0, 0) to (0.5, 0.5) did the
trick. Does anyone know of any info on coordinate values for predictable
rasterization in VTK?
John.
-----Original Message-----
From: vtkusers-bounces at vtk.org [mailto:vtkusers-bounces at vtk.org] On
Behalf Of John Platt
Sent: 07 April 2005 16:58
To: vtkusers at vtk.org
Subject: [vtkusers] X values of GetPositionCoordinate() &
GetEventPosition()differ by 1 pixel
Hi Users,
I have a 2-D actor rendering polydata representing the border of a
rectangle as 1 polyline. The points for the polydata are created using
the position of the 2-D actor in viewport coordinates as follows
int *pos1, *pos2;
pos1 = this->BorderActor->GetPositionCoordinate()->
GetComputedViewportValue(this->CurrentRenderer);
pos2 = this->BorderActor->GetPosition2Coordinate()->
GetComputedViewportValue(this->CurrentRenderer);
vtkPoints* pts = this->BorderPolyData->GetPoints();
int width = pos2[0] - pos1[0];
int height = pos2[1] - pos1[1];
pts->SetPoint( 0, 0, 0, 0 );
pts->SetPoint( 1, width, 0, 0 );
pts->SetPoint( 2, width, height, 0 );
pts->SetPoint( 3, 0, height, 0 );
When trying to select the left hand edge of the rectangle (0,3), the
display value returned from the interactor using GetEventPosition()[0]
is always 1 pixel less than the actors GetPositionCoordinate()->
GetComputedViewportValue(this->CurrentRenderer)[0].
Also, when the border is drawn using the default actor 2-D position (
(0,0) & (0.5,0.5) ), the left hand edge is not visible.
There are no problems with any of the other 3 edges - picking or
displaying.
Can anybody explain this behaviour.
Many thanks.
John.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20050407/e06d207f/attachment.htm>
More information about the vtkusers
mailing list