[vtkusers] rotated border widget

Pat Moran Pat.Moran at neuwave.com
Mon Jun 4 13:27:29 EDT 2012


Hello,
I am creating a border around a contour (created with a polydata object) displayed on some image data.  The border is created using the vtkBorderWidget with its dimensions based on the bounds of the contour.  When I rotate the camera, the border widget is not redrawn as expected.  The position and position2 points for the border widget match those of the contour object, but the sides of the border are not parallel to the world coordinate axes as I would expect.  Does anyone know why the border widget behaves this way?  Is there a way to alter this behavior?  Is there something I'm doing wrong in my set up of the widget representation?
Code I'm using to set the border widget is given below.
double[] bounds = myContour.GetBounds();
double[] position = new double[2];
double[] position2 = new double[2];

position[0] = bounds[0];
position[1] = bounds[2];
position2[0] = bounds[1];
position2[1] = bounds[3];

_representation = vtkBorderRepresentation.New();
_representation.SetMoving(1);            _representation.GetPositionCoordinate().SetCoordinateSystemToWorld(); _representation.GetPosition2Coordinate().SetCoordinateSystemToWorld();
_representation.SetShowBorderToOn();
_representation.SetPickable(1);
_representation.SetProportionalResize(1);
_representation.SetPlaceFactor(1.1);
_representation.SetTolerance(15);
_representation.SetMinimumSize(5, 5);
SetBoxPosition(position, position2);

Where the SetBoxPosition method is as follows:
if (_representation != null)
{
double[] scaledPosition = new double[3];
      double[] scaledPosition2 = new double[2];

      scaledPosition[0] = position[0] - _boxOffset;
      scaledPosition[1] = position[1] - _boxOffset;
      scaledPosition2[0] = position2[0] + _boxOffset;
      scaledPosition2[1] = position2[1] + _boxOffset;

      //Position2 is really the dimensions of the box.
     _representation.SetPosition(scaledPosition[0], scaledPosition[1]);
     _representation.SetPosition2(scaledPosition2[0] - scaledPosition[0],
                    scaledPosition2[1] - scaledPosition[1]);
}

Thanks,
Pat
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20120604/1bc79392/attachment.htm>


More information about the vtkusers mailing list