[vtkusers] X values of GetPositionCoordinate() & GetEventPosition() differ by 1 pixel
John Platt
jcplatt at lineone.net
Thu Apr 7 11:57:56 EDT 2005
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/d94c7163/attachment.htm>
More information about the vtkusers
mailing list