/// <summary>
        /// Returns a value indicating whether the specified point is contained
        /// in the ellipse.
        /// </summary>
        /// <param name="point"></param>
        /// <returns></returns>
        public override bool Contains(PointF point)
        {
            /// TODO (CR Oct 2011): duplicated in InvariantEllipsePrimitive - should combine.

            if (CoordinateSystem == CoordinateSystem.Destination)
            {
                point = SpatialTransform.ConvertToSource(point);
            }

            CoordinateSystem = CoordinateSystem.Source;
            // Semi major/minor axes
            float      a    = Width / 2;
            float      b    = Height / 2;
            RectangleF rect = BoundingBox;

            ResetCoordinateSystem();

            // Center of ellipse
            float xCenter = rect.Left + a;
            float yCenter = rect.Top + b;

            float x = point.X - xCenter;
            float y = point.Y - yCenter;

            return((x * x) / (a * a) + (y * y) / (b * b) <= 1);
        }
Esempio n. 2
0
        internal static float ConvertSweepAngle(float sweepAngle, float startAngle, SpatialTransform transform, CoordinateSystem targetSystem)
        {
            PointF x = new PointF(100, 0);

            PointF[] startVector = new PointF[] { x };
            Matrix   rotation    = new Matrix();

            rotation.Rotate(startAngle);
            rotation.TransformVectors(startVector);

            PointF[] sweepVector = (PointF[])startVector.Clone();
            rotation.Reset();
            rotation.Rotate(sweepAngle);
            rotation.TransformVectors(sweepVector);
            rotation.Dispose();

            SizeF startVectorTransformed, sweepVectorTransformed;

            if (targetSystem == Graphics.CoordinateSystem.Destination)
            {
                startVectorTransformed = transform.ConvertToDestination(new SizeF(startVector[0]));
                sweepVectorTransformed = transform.ConvertToDestination(new SizeF(sweepVector[0]));
            }
            else
            {
                startVectorTransformed = transform.ConvertToSource(new SizeF(startVector[0]));
                sweepVectorTransformed = transform.ConvertToSource(new SizeF(sweepVector[0]));
            }

            // simply return the angle between the start and sweep angle, in the target system.
            return((int)Math.Round(Vector.SubtendedAngle(sweepVectorTransformed.ToPointF(), PointF.Empty, startVectorTransformed.ToPointF())));
        }
        public PatientOrientationHelper(SpatialTransform imageTransform, PatientOrientation patientOrientation)
        {
            Platform.CheckForNullReference(imageTransform, "imageTransform");
            Platform.CheckForNullReference(patientOrientation, "patientOrientation");

            _imageTransform = imageTransform;
            _patientOrientation = patientOrientation;
            AngleTolerance = 1;
        }
        public PatientOrientationHelper(SpatialTransform imageTransform, ImageOrientationPatient imageOrientationPatient)
        {
            Platform.CheckForNullReference(imageTransform, "imageTransform");
            Platform.CheckForNullReference(imageOrientationPatient, "imageOrientationPatient");

            _imageTransform = imageTransform;
            _imageOrientationPatient = imageOrientationPatient;
            AngleTolerance = 1;
        }
Esempio n. 5
0
		/// <summary>
		/// Cloning constructor.
		/// </summary>
		protected SpatialTransform(SpatialTransform source, ICloningContext context)
		{
			context.CloneFields(source, this);

			if (source._cumulativeTransform != null)
				_cumulativeTransform = source._cumulativeTransform.Clone();

			if (source._transform != null)
				_transform = source._transform.Clone();
		}
Esempio n. 6
0
        /// <summary>
        /// Performs a hit test on the <see cref="ArcPrimitive"/> at a given point.
        /// </summary>
        /// <param name="point">The mouse position in destination coordinates.</param>
        /// <returns>
        /// <b>True</b> if <paramref name="point"/> "hits" the <see cref="ArcPrimitive"/>,
        /// <b>false</b> otherwise.
        /// </returns>
        /// <remarks>
        /// A "hit" is defined as when the mouse position is <see cref="VectorGraphic.HitTestDistance"/>
        /// screen pixels away from any point on the arc.
        /// </remarks>
        public override bool HitTest(Point point)
        {
            this.CoordinateSystem = CoordinateSystem.Source;

            bool result = ArcPrimitive.HitTest(
                SpatialTransform.ConvertToSource(point), this.Rectangle,
                this.StartAngle, this.SweepAngle,
                this.SpatialTransform);

            this.ResetCoordinateSystem();

            return(result);
        }
        internal static bool HitTest(PointF point, RectangleF boundingBox, SpatialTransform transform)
        {
            GraphicsPath path = new GraphicsPath();

            path.AddEllipse(RectangleUtilities.ConvertToPositiveRectangle(boundingBox));

            Pen  pen    = new Pen(Brushes.White, HitTestDistance / transform.CumulativeScale);
            bool result = path.IsOutlineVisible(point, pen);

            path.Dispose();
            pen.Dispose();

            return(result);
        }
        /// <summary>
        /// Cloning constructor.
        /// </summary>
        protected SpatialTransform(SpatialTransform source, ICloningContext context)
        {
            context.CloneFields(source, this);

            if (source._cumulativeTransform != null)
            {
                _cumulativeTransform = source._cumulativeTransform.Clone();
            }

            if (source._transform != null)
            {
                _transform = source._transform.Clone();
            }
        }
Esempio n. 9
0
        internal static float ConvertStartAngle(float angle, SpatialTransform transform, CoordinateSystem targetSystem)
        {
            PointF xVector = new PointF(100, 0);

            Matrix rotation = new Matrix();

            PointF[] angleVector = new PointF[] { xVector };
            rotation.Rotate(angle);
            rotation.TransformVectors(angleVector);
            rotation.Dispose();

            SizeF xVectorTransformed, angleVectorTransformed;

            if (targetSystem == Graphics.CoordinateSystem.Destination)
            {
                xVectorTransformed     = transform.ConvertToDestination(new SizeF(xVector));
                angleVectorTransformed = transform.ConvertToDestination(new SizeF(angleVector[0]));
            }
            else
            {
                xVectorTransformed     = transform.ConvertToSource(new SizeF(xVector));
                angleVectorTransformed = transform.ConvertToSource(new SizeF(angleVector[0]));
            }

            float xRotationOffset =
                (int)Math.Round(Vector.SubtendedAngle(xVectorTransformed.ToPointF(), PointF.Empty, xVector));

            float angleTransformed =
                (int)Math.Round(Vector.SubtendedAngle(angleVectorTransformed.ToPointF(), PointF.Empty, xVectorTransformed.ToPointF()));

            // have to figure out where x-axis moved to and then return the difference between the angle
            // and the x-axis, where both are in 'target' coordinates.
            float returnAngle = angleTransformed + xRotationOffset;

            if (returnAngle < 0)
            {
                returnAngle += 360;
            }

            return(returnAngle);
        }
Esempio n. 10
0
		internal static float ConvertSweepAngle(float sweepAngle, float startAngle, SpatialTransform transform, CoordinateSystem targetSystem)
		{
			PointF x = new PointF(100, 0);

			PointF[] startVector = new PointF[] { x };
			Matrix rotation = new Matrix();
			rotation.Rotate(startAngle);
			rotation.TransformVectors(startVector);

			PointF[] sweepVector = (PointF[])startVector.Clone();
			rotation.Reset();
			rotation.Rotate(sweepAngle);
			rotation.TransformVectors(sweepVector);
			rotation.Dispose();

			SizeF startVectorTransformed, sweepVectorTransformed;
			if (targetSystem == Graphics.CoordinateSystem.Destination)
			{
				startVectorTransformed = transform.ConvertToDestination(new SizeF(startVector[0]));
				sweepVectorTransformed = transform.ConvertToDestination(new SizeF(sweepVector[0]));
			}
			else
			{
				startVectorTransformed = transform.ConvertToSource(new SizeF(startVector[0]));
				sweepVectorTransformed = transform.ConvertToSource(new SizeF(sweepVector[0]));
			}

			// simply return the angle between the start and sweep angle, in the target system.
			return (int)Math.Round(Vector.SubtendedAngle(sweepVectorTransformed.ToPointF(), PointF.Empty, startVectorTransformed.ToPointF()));
		}
Esempio n. 11
0
		internal static float ConvertStartAngle(float angle, SpatialTransform transform, CoordinateSystem targetSystem)
		{
			PointF xVector = new PointF(100, 0);

			Matrix rotation = new Matrix();
			PointF[] angleVector = new PointF[] { xVector };
			rotation.Rotate(angle);
			rotation.TransformVectors(angleVector);
			rotation.Dispose();

			SizeF xVectorTransformed, angleVectorTransformed;
			if (targetSystem == Graphics.CoordinateSystem.Destination)
			{
				xVectorTransformed = transform.ConvertToDestination(new SizeF(xVector));
				angleVectorTransformed = transform.ConvertToDestination(new SizeF(angleVector[0]));
			}
			else
			{
				xVectorTransformed = transform.ConvertToSource(new SizeF(xVector));
				angleVectorTransformed = transform.ConvertToSource(new SizeF(angleVector[0]));
			}

			float xRotationOffset =
				(int)Math.Round(Vector.SubtendedAngle(xVectorTransformed.ToPointF(), PointF.Empty, xVector));

			float angleTransformed =
				(int)Math.Round(Vector.SubtendedAngle(angleVectorTransformed.ToPointF(), PointF.Empty, xVectorTransformed.ToPointF()));

			// have to figure out where x-axis moved to and then return the difference between the angle
			// and the x-axis, where both are in 'target' coordinates.
			float returnAngle = angleTransformed + xRotationOffset;
			if (returnAngle < 0)
				returnAngle += 360;

			return returnAngle;
		}
Esempio n. 12
0
		internal static bool HitTest(
			PointF point, 
			RectangleF boundingBox, 
			float startAngle,
			float sweepAngle,
			SpatialTransform transform)
		{
			GraphicsPath path = new GraphicsPath();
			path.AddArc(RectangleUtilities.ConvertToPositiveRectangle(boundingBox), startAngle, sweepAngle);

			Pen pen = new Pen(Brushes.White, HitTestDistance / transform.CumulativeScale);
			bool result = path.IsOutlineVisible(point, pen);

			path.Dispose();
			pen.Dispose();

			return result;
		}
		/// <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="imageOrientationPatient">the image orientation patient (direction cosines)</param>
		/// <returns></returns>
		internal string GetAnnotationTextInternal(SpatialTransform imageTransform, ImageOrientationPatient imageOrientationPatient)
		{
			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, imageOrientationPatient);
		}
Esempio n. 14
0
 internal void SetParentGraphic(IGraphic parentGraphic)
 {
     _parentGraphic = parentGraphic;
     SpatialTransform.ForceRecalculation();
 }