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."); }
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); }
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; }
public PatientDirection GetEdgeDirection(ImageEdge viewportEdge) { var direction = GetPrimaryEdgeDirection(viewportEdge); if (!direction.IsEmpty) { direction += GetSecondaryEdgeDirection(viewportEdge); //TODO (CR June 2011): Tertiary? } return(direction); }
/// <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)); }
/// <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); }
/// <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); }
public DirectionalMarkerAnnotationItem(ImageEdge viewportEdge) : base("Presentation.DirectionalMarkers." + viewportEdge.ToString(), new AnnotationResourceResolver(typeof(DirectionalMarkerAnnotationItem).Assembly)) { _viewportEdge = viewportEdge; }
public DirectionalMarkerAnnotationItem(ImageEdge viewportEdge) : base("Presentation.DirectionalMarkers." + viewportEdge.ToString(), new AnnotationResourceResolver(typeof (DirectionalMarkerAnnotationItem).Assembly)) { _viewportEdge = viewportEdge; }
/// <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; }
/// <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."); }