Пример #1
0
        private static ImageEdge GetTransformedEdge(SizeF[] transformedVectors, ImageEdge viewportEdge)
        {
            //the original (untransformed) vector for this viewport edge.
            SizeF thisViewportEdge = _edgeVectors[(int)viewportEdge];

            //find out which edge in the source image has moved to this edge of the viewport.
            for (int index = 0; index < transformedVectors.Length; ++index)
            {
                //normalize the vector before comparing.
                SizeF  transformedVector = transformedVectors[index];
                double magnitude         = Math.Sqrt(transformedVector.Width * transformedVector.Width +
                                                     transformedVector.Height * transformedVector.Height);

                transformedVector.Width  = (float)Math.Round(transformedVector.Width / magnitude);
                transformedVector.Height = (float)Math.Round(transformedVector.Height / magnitude);

                //is it the same as the original vector for this edge?
                if (transformedVector == thisViewportEdge)
                {
                    //return the image edge that has now moved to this edge of the viewport.
                    return((ImageEdge)index);
                }
            }

            //this should never happen.
            throw new IndexOutOfRangeException("The transformed edge does not have a corresponding value.");
        }
Пример #2
0
        private PatientDirection GetEdgeDirection(ImageEdge imageEdge, PatientDirection.Component component)
        {
            bool negativeDirection = (imageEdge == ImageEdge.Left || imageEdge == ImageEdge.Top);
            bool rowValues         = (imageEdge == ImageEdge.Left || imageEdge == ImageEdge.Right);

            var direction = PatientDirection.Empty;

            if (rowValues)
            {
                //TODO (CR June 2011): tertiary?
                if (component == PatientDirection.Component.Primary)
                {
                    direction = GetPrimaryRowDirection();
                }
                else if (component == PatientDirection.Component.Secondary)
                {
                    direction = GetSecondaryRowDirection();
                }
            }
            else
            {
                //TODO (CR June 2011): tertiary?
                if (component == PatientDirection.Component.Primary)
                {
                    direction = GetPrimaryColumnDirection();
                }
                else if (component == PatientDirection.Component.Secondary)
                {
                    direction = GetSecondaryColumnDirection();
                }
            }

            return(negativeDirection ? direction.OpposingDirection : direction);
        }
 public PatientDirection GetPrimaryEdgeDirection(ImageEdge viewportEdge)
 {
     var imageEdgeVectors = GetImageEdgeVectors();
     //find out which source image edge got transformed to coincide with this viewport edge.
     var transformedEdge = GetTransformedEdge(imageEdgeVectors, viewportEdge);
     return GetEdgeDirection(transformedEdge, PatientDirection.Component.Primary);
 }
Пример #4
0
        public PatientDirection GetSecondaryEdgeDirection(ImageEdge viewportEdge)
        {
            var imageEdgeVectors = GetImageEdgeVectors();
            //find out which source image edge got transformed to coincide with this viewport edge.
            var transformedEdge = GetTransformedEdge(imageEdgeVectors, viewportEdge);

            return(GetEdgeDirection(transformedEdge, PatientDirection.Component.Secondary));
        }
        public PatientDirection GetEdgeDirection(ImageEdge viewportEdge)
        {
            var direction = GetPrimaryEdgeDirection(viewportEdge);
            if (!direction.IsEmpty)
            {
                direction += GetSecondaryEdgeDirection(viewportEdge);
                //TODO (CR June 2011): Tertiary?
            }

            return direction;
        }
Пример #6
0
        public PatientDirection GetEdgeDirection(ImageEdge viewportEdge)
        {
            var direction = GetPrimaryEdgeDirection(viewportEdge);

            if (!direction.IsEmpty)
            {
                direction += GetSecondaryEdgeDirection(viewportEdge);
                //TODO (CR June 2011): Tertiary?
            }

            return(direction);
        }
Пример #7
0
        /// <summary>
        /// Called by GetAnnotationText (and also by Unit Test code).  Making this function internal simply makes it easier
        /// to write unit tests for this class (don't have to implement a fake PresentationImage).
        /// </summary>
        /// <param name="imageTransform">the image transform</param>
        /// <param name="patientOrientation">the image orientation patient (direction cosines)</param>
        /// <returns></returns>
        internal string GetAnnotationTextInternal(SpatialTransform imageTransform, PatientOrientation patientOrientation)
        {
            SizeF[] imageEdgeVectors = new SizeF[4];
            for (int i = 0; i < 4; ++i)
            {
                imageEdgeVectors[i] = imageTransform.ConvertToDestination(_edgeVectors[i]);
            }

            //find out which source image edge got transformed to coincide with this viewport edge.
            ImageEdge transformedEdge = GetTransformedEdge(imageEdgeVectors);

            //get the marker for the appropriate (source) image edge.
            return(GetMarker(transformedEdge, patientOrientation));
        }
Пример #8
0
        /// <summary>
        /// Determines the (untransformed) marker for a particular image edge.
        /// </summary>
        /// <param name="imageEdge">the edge (image coordinates)</param>
        /// <param name="patientOrientation">the patient orientation construct of the image</param>
        /// <returns>a string representation of the direction (a 'marker')</returns>
        private string GetMarker(ImageEdge imageEdge, PatientOrientation patientOrientation)
        {
            bool negativeDirection = (imageEdge == ImageEdge.Left || imageEdge == ImageEdge.Top);
            bool rowValues         = (imageEdge == ImageEdge.Left || imageEdge == ImageEdge.Right);

            var direction = (rowValues ? patientOrientation.Row : patientOrientation.Column) ?? PatientDirection.Empty;

            if (negativeDirection)
            {
                direction = direction.OpposingDirection;
            }

            string markerText = "";

            markerText += GetMarkerText(direction.Primary);
            markerText += GetMarkerText(direction.Secondary);

            return(markerText);
        }
Пример #9
0
        /// <summary>
        /// Determines the (untransformed) marker for a particular image edge.
        /// </summary>
        /// <param name="imageEdge">the edge (image coordinates)</param>
        /// <param name="imageOrientationPatient">the direction cosines of the image</param>
        /// <returns>a string representation of the direction (a 'marker')</returns>
        private string GetMarker(ImageEdge imageEdge, ImageOrientationPatient imageOrientationPatient)
        {
            bool negativeDirection = (imageEdge == ImageEdge.Left || imageEdge == ImageEdge.Top);
            bool rowValues         = (imageEdge == ImageEdge.Left || imageEdge == ImageEdge.Right);

            string markerText = "";

            if (rowValues)
            {
                ImageOrientationPatient.Directions primary   = imageOrientationPatient.GetPrimaryRowDirection(negativeDirection);
                ImageOrientationPatient.Directions secondary = imageOrientationPatient.GetSecondaryRowDirection(negativeDirection, 1);
                markerText += GetMarkerText(primary);
                markerText += GetMarkerText(secondary);
            }
            else
            {
                ImageOrientationPatient.Directions primary   = imageOrientationPatient.GetPrimaryColumnDirection(negativeDirection);
                ImageOrientationPatient.Directions secondary = imageOrientationPatient.GetSecondaryColumnDirection(negativeDirection, 1);
                markerText += GetMarkerText(primary);
                markerText += GetMarkerText(secondary);
            }

            return(markerText);
        }
Пример #10
0
 public DirectionalMarkerAnnotationItem(ImageEdge viewportEdge)
     : base("Presentation.DirectionalMarkers." + viewportEdge.ToString(), new AnnotationResourceResolver(typeof(DirectionalMarkerAnnotationItem).Assembly))
 {
     _viewportEdge = viewportEdge;
 }
Пример #11
0
		public DirectionalMarkerAnnotationItem(ImageEdge viewportEdge)
			: base("Presentation.DirectionalMarkers." + viewportEdge.ToString(), new AnnotationResourceResolver(typeof (DirectionalMarkerAnnotationItem).Assembly))
		{
			_viewportEdge = viewportEdge;
		}
Пример #12
0
		/// <summary>
		/// Determines the (untransformed) marker for a particular image edge.
		/// </summary>
		/// <param name="imageEdge">the edge (image coordinates)</param>
		/// <param name="patientOrientation">the patient orientation construct of the image</param>
		/// <returns>a string representation of the direction (a 'marker')</returns>
		private string GetMarker(ImageEdge imageEdge, PatientOrientation patientOrientation)
		{
			bool negativeDirection = (imageEdge == ImageEdge.Left || imageEdge == ImageEdge.Top);
			bool rowValues = (imageEdge == ImageEdge.Left || imageEdge == ImageEdge.Right);

			var direction = (rowValues ? patientOrientation.Row : patientOrientation.Column) ?? PatientDirection.Empty;
			if (negativeDirection)
				direction = direction.OpposingDirection;

			string markerText = "";
			markerText += GetMarkerText(direction.Primary);
			markerText += GetMarkerText(direction.Secondary);

			return markerText;
		}
Пример #13
0
		/// <summary>
		/// Determines the (untransformed) marker for a particular image edge.
		/// </summary>
		/// <param name="imageEdge">the edge (image coordinates)</param>
		/// <param name="imageOrientationPatient">the direction cosines of the image</param>
		/// <returns>a string representation of the direction (a 'marker')</returns>
		private string GetMarker(ImageEdge imageEdge, ImageOrientationPatient imageOrientationPatient)
		{
			bool negativeDirection = (imageEdge == ImageEdge.Left || imageEdge == ImageEdge.Top);
			bool rowValues = (imageEdge == ImageEdge.Left || imageEdge == ImageEdge.Right);

			string markerText = "";

			if (rowValues)
			{
				ImageOrientationPatient.Directions primary = imageOrientationPatient.GetPrimaryRowDirection(negativeDirection);
				ImageOrientationPatient.Directions secondary = imageOrientationPatient.GetSecondaryRowDirection(negativeDirection, 1);
				markerText += GetMarkerText(primary);
				markerText += GetMarkerText(secondary);
			}
			else
			{
				ImageOrientationPatient.Directions primary = imageOrientationPatient.GetPrimaryColumnDirection(negativeDirection);
				ImageOrientationPatient.Directions secondary = imageOrientationPatient.GetSecondaryColumnDirection(negativeDirection, 1);
				markerText += GetMarkerText(primary);
				markerText += GetMarkerText(secondary);
			}

			return markerText;
		}
        private PatientDirection GetEdgeDirection(ImageEdge imageEdge, PatientDirection.Component component)
		{
			bool negativeDirection = (imageEdge == ImageEdge.Left || imageEdge == ImageEdge.Top);
			bool rowValues = (imageEdge == ImageEdge.Left || imageEdge == ImageEdge.Right);

            var direction = PatientDirection.Empty;
            if (rowValues)
			{
                //TODO (CR June 2011): tertiary?
                if (component == PatientDirection.Component.Primary)
                    direction = GetPrimaryRowDirection();
                else if (component == PatientDirection.Component.Secondary)
                    direction = GetSecondaryRowDirection();
			}
			else
			{
                //TODO (CR June 2011): tertiary?
                if (component == PatientDirection.Component.Primary)
                    direction = GetPrimaryColumnDirection();
                else if (component == PatientDirection.Component.Secondary)
                    direction = GetSecondaryColumnDirection();
            }

            return negativeDirection ? direction.OpposingDirection : direction;
		}
        private static ImageEdge GetTransformedEdge(SizeF[] transformedVectors, ImageEdge viewportEdge)
        {
            //the original (untransformed) vector for this viewport edge.
            SizeF thisViewportEdge = _edgeVectors[(int)viewportEdge];

            //find out which edge in the source image has moved to this edge of the viewport.
            for (int index = 0; index < transformedVectors.Length; ++index)
            {
                //normalize the vector before comparing.
                SizeF transformedVector = transformedVectors[index];
                double magnitude = Math.Sqrt(transformedVector.Width * transformedVector.Width +
                                                transformedVector.Height * transformedVector.Height);

                transformedVector.Width = (float)Math.Round(transformedVector.Width / magnitude);
                transformedVector.Height = (float)Math.Round(transformedVector.Height / magnitude);

                //is it the same as the original vector for this edge?
                if (transformedVector == thisViewportEdge)
                {
                    //return the image edge that has now moved to this edge of the viewport.
                    return (ImageEdge)index;
                }
            }

            //this should never happen.
            throw new IndexOutOfRangeException("The transformed edge does not have a corresponding value.");
        }