예제 #1
0
        private static float GetDisplayedWidth(IPresentationImage presentationImage, RectangleF referenceDisplayedRectangle)
        {
            IImageSpatialTransform transform = GetImageTransform(presentationImage);
            Frame frame = GetFrame(presentationImage);

            //Convert the displayed width to source dimensions
            SizeF sourceSize = transform.ConvertToSource(new SizeF(referenceDisplayedRectangle.Width, 0));
            float x          = Math.Abs(sourceSize.Width);
            float y          = Math.Abs(sourceSize.Height);

            //The displayed width is the magnitude of the line in source coordinates,
            //but one of xLength or yLength will always be zero, so we can optimize.
            if (x > y)
            {
                return(x * (float)frame.NormalizedPixelSpacing.Column);
            }

            return(y * (float)frame.NormalizedPixelSpacing.Row);
        }
예제 #2
0
        public override string GetAnnotationText(IPresentationImage presentationImage)
        {
            if (presentationImage == null)
            {
                return(String.Empty);
            }

            IImageSopProvider imageSopProvider = presentationImage as IImageSopProvider;

            if (imageSopProvider == null)
            {
                return(String.Empty);
            }

            ISpatialTransformProvider spatialTransformProvider = presentationImage as ISpatialTransformProvider;

            if (spatialTransformProvider == null)
            {
                return(String.Empty);
            }

            // 2D DFOV value doesn't make a lot of sense when the "image" is 3D, so we're blanking it out until we define what DFOV means in this context
            if (presentationImage is ISpatialTransform3DProvider)
            {
                return(String.Empty);
            }

            IImageSpatialTransform transform = spatialTransformProvider.SpatialTransform as IImageSpatialTransform;

            if (transform == null)
            {
                return(String.Empty);
            }

            if (transform.RotationXY % 90 != 0)
            {
                return(SR.ValueNotApplicable);
            }

            Frame        frame = imageSopProvider.Frame;
            PixelSpacing normalizedPixelSpacing = frame.NormalizedPixelSpacing;

            if (normalizedPixelSpacing.IsNull)
            {
                return(String.Empty);
            }

            RectangleF sourceRectangle      = new RectangleF(0, 0, frame.Columns, frame.Rows);
            RectangleF destinationRectangle = transform.ConvertToDestination(sourceRectangle);

            destinationRectangle = RectangleUtilities.Intersect(destinationRectangle, presentationImage.ClientRectangle);

            //Convert the displayed width and height to source dimensions
            SizeF widthInSource  = transform.ConvertToSource(new SizeF(destinationRectangle.Width, 0));
            SizeF heightInSource = transform.ConvertToSource(new SizeF(0, destinationRectangle.Height));

            //The displayed FOV is given by the magnitude of each line in source coordinates, but
            //for each of the 2 lines, one of x or y will be zero, so we can optimize.

            float x1 = Math.Abs(widthInSource.Width);
            float y1 = Math.Abs(widthInSource.Height);
            float x2 = Math.Abs(heightInSource.Width);
            float y2 = Math.Abs(heightInSource.Height);

            double displayedFieldOfViewX, displayedFieldOfViewY;

            if (x1 > y1)             //the image is not rotated
            {
                displayedFieldOfViewX = x1 * normalizedPixelSpacing.Column / 10;
                displayedFieldOfViewY = y2 * normalizedPixelSpacing.Row / 10;
            }
            else             //the image is rotated by 90 or 270 degrees
            {
                displayedFieldOfViewX = x2 * normalizedPixelSpacing.Column / 10;
                displayedFieldOfViewY = y1 * normalizedPixelSpacing.Row / 10;
            }

            return(String.Format(SR.FormatCentimeters, String.Format(SR.Format2Dimensions, displayedFieldOfViewX.ToString("F1"), displayedFieldOfViewY.ToString("F1"))));
        }