public override int HitTest(PointF point, long currentTimestamp, DistortionHelper distorter, IImageToViewportTransformer transformer, bool zooming)
        {
            // Convention: miss = -1, object = 0, handle = n.
            if (!Visible)
            {
                return(-1);
            }

            int result = -1;

            if (HitTester.HitTest(points["0"], point, transformer))
            {
                return(1);
            }

            if (showGrid || showGraduations || showAxis)
            {
                CoordinateSystemGrid grid = CalibrationHelper.GetCoordinateSystemGrid();
                if (grid == null)
                {
                    return(-1);
                }

                if (grid.HorizontalAxis != null && IsPointOnRectifiedLine(point, grid.HorizontalAxis.Start, grid.HorizontalAxis.End, distorter, transformer))
                {
                    result = 2;
                }
                else if (grid.VerticalAxis != null && IsPointOnRectifiedLine(point, grid.VerticalAxis.Start, grid.VerticalAxis.End, distorter, transformer))
                {
                    result = 3;
                }
            }

            return(result);
        }
Esempio n. 2
0
        public override int HitTest(PointF point, long currentTimestamp, DistortionHelper distorter, IImageToViewportTransformer transformer, bool zooming)
        {
            int    result  = -1;
            double opacity = infosFading.GetOpacityFactor(currentTimestamp);

            if (!tracking && opacity <= 0)
            {
                return(-1);
            }

            foreach (KeyValuePair <string, PointF> p in points)
            {
                if (HitTester.HitTest(p.Value, point, transformer))
                {
                    result = int.Parse(p.Key) + 1;
                }
            }

            if (result == -1 && IsPointInObject(point, distorter, transformer))
            {
                result = 0;
            }

            return(result);
        }
Esempio n. 3
0
        public override int HitTest(PointF point, long currentTimestamp, DistortionHelper distorter, IImageToViewportTransformer transformer, bool zooming)
        {
            // Convention: miss = -1, object = 0, handle = n.
            int    result        = -1;
            double opacityFactor = infosFading.GetOpacityTrackable(trackingTimestamps, currentTimestamp);

            if (opacityFactor > 0)
            {
                if (HitTester.HitTest(points["o"], point, transformer))
                {
                    result = 1;
                }
                else if (HitTester.HitTest(points["a"], point, transformer))
                {
                    result = 2;
                }
                else if (HitTester.HitTest(points["b"], point, transformer))
                {
                    result = 3;
                }
                else if (IsPointInObject(point))
                {
                    result = 0;
                }
            }

            return(result);
        }
Esempio n. 4
0
        public override int HitTest(PointF point, long currentTimestamp, DistortionHelper distorter, IImageToViewportTransformer transformer, bool zooming)
        {
            double opacity = infosFading.GetOpacityFactor(currentTimestamp);

            if (opacity <= 0)
            {
                return(-1);
            }

            // Background label: 0, hidden resizer: 1, arrow end: 2.
            if (showArrow)
            {
                if (HitTester.HitTest(arrowEnd, point, transformer))
                {
                    return(2);
                }

                if (IsPointOnSegment(point, background.Rectangle.Center(), arrowEnd, transformer))
                {
                    return(0);
                }
            }

            // Compute the size of the hidden handle zone based on the font size.
            using (Font fontText = styleHelper.GetFont(1.0f))
            {
                int roundingRadius = fontText.Height / 4;
                return(background.HitTest(point, true, (int)(roundingRadius * 1.8f), transformer));
            }
        }
Esempio n. 5
0
        public int HitTest(PointF point, IImageToViewportTransformer transformer)
        {
            int result = -1;

            PointF topLeft  = new PointF(rectangle.Left, rectangle.Top);
            PointF topRight = new PointF(rectangle.Right, rectangle.Top);
            PointF botRight = new PointF(rectangle.Right, rectangle.Bottom);
            PointF botLeft  = new PointF(rectangle.Left, rectangle.Bottom);

            if (HitTester.HitTest(topLeft, point, transformer))
            {
                result = 1;
            }
            else if (HitTester.HitTest(topRight, point, transformer))
            {
                result = 2;
            }
            else if (HitTester.HitTest(botRight, point, transformer))
            {
                result = 3;
            }
            else if (HitTester.HitTest(botLeft, point, transformer))
            {
                result = 4;
            }
            else if (rectangle.Contains(point.ToPoint()))
            {
                result = 0;
            }

            return(result);
        }
Esempio n. 6
0
        public override int HitTest(PointF point, long currentTimestamp, DistortionHelper distorter, IImageToViewportTransformer transformer, bool zooming)
        {
            int    result  = -1;
            double opacity = infosFading.GetOpacityFactor(currentTimestamp);

            if (tracking || opacity > 0)
            {
                if (ShowMeasurableInfo && labelMeasure.HitTest(point, transformer))
                {
                    result = 3;
                }
                else if (HitTester.HitTest(points["a"], point, transformer))
                {
                    result = 1;
                }
                else if (HitTester.HitTest(points["b"], point, transformer))
                {
                    result = 2;
                }
                else if (IsPointInObject(point, distorter, transformer))
                {
                    result = 0;
                }
            }

            return(result);
        }
        public override int HitTest(PointF point, long currentTimestamp, DistortionHelper distorter, IImageToViewportTransformer transformer, bool zooming)
        {
            int    result        = -1;
            double opacityFactor = infosFading.GetOpacityTrackable(trackingTimestamps, currentTimestamp);

            if (opacityFactor > 0)
            {
                if (trackExtraData != TrackExtraData.None && miniLabel.HitTest(point, transformer))
                {
                    result = 3;
                }
                else if (HitTester.HitTest(points["a"], point, transformer))
                {
                    result = 1;
                }
                else if (HitTester.HitTest(points["b"], point, transformer))
                {
                    result = 2;
                }
                else if (IsPointInObject(point, distorter, transformer))
                {
                    result = 0;
                }
            }

            return(result);
        }
Esempio n. 8
0
 private bool IsPointInObject(PointF point, IImageToViewportTransformer transformer)
 {
     using (GraphicsPath path = new GraphicsPath())
     {
         path.AddEllipse(points["o"].X - radius, points["o"].Y - radius, radius * 2, radius * 2);
         return(HitTester.HitTest(path, point, 0, true, transformer));
     }
 }
Esempio n. 9
0
 private bool IsPointOnHandler(PointF point, IImageToViewportTransformer transformer)
 {
     using (GraphicsPath path = new GraphicsPath())
     {
         path.AddArc(points["o"].X - radius, points["o"].Y - radius, radius * 2, radius * 2, 0, 360);
         return(HitTester.HitTest(path, point, 2, false, transformer));
     }
 }
 private bool IsPointInsideCircle(GenericPostureCircle circle, PointF point, IImageToViewportTransformer transformer)
 {
     using (GraphicsPath path = new GraphicsPath())
     {
         PointF center = circle.Center >= 0 ? genericPosture.PointList[circle.Center] : GetUntransformedComputedPoint(circle.Center);
         path.AddEllipse(center.Box(circle.Radius));
         return(HitTester.HitTest(path, point, 0, true, transformer));
     }
 }
 private bool IsPointOnPolyline(GenericPosturePolyline polyline, PointF point, IImageToViewportTransformer transformer)
 {
     using (GraphicsPath path = new GraphicsPath())
     {
         PointF[] points = polyline.Points.Select(i => genericPosture.PointList[i]).ToArray();
         path.AddCurve(points);
         return(HitTester.HitTest(path, point, polyline.Width, false, transformer));
     }
 }
 private bool IsPointOnArc(GenericPostureCircle circle, PointF point, IImageToViewportTransformer transformer)
 {
     using (GraphicsPath path = new GraphicsPath())
     {
         PointF center = circle.Center >= 0 ? genericPosture.PointList[circle.Center] : GetUntransformedComputedPoint(circle.Center);
         path.AddArc(center.Box(circle.Radius), 0, 360);
         return(HitTester.HitTest(path, point, circle.Width, false, transformer));
     }
 }
Esempio n. 13
0
        private bool IsPointInObject(PointF point, IImageToViewportTransformer transformer)
        {
            bool hit = false;

            using (GraphicsPath areaPath = new GraphicsPath())
            {
                GetHitPath(areaPath);
                hit = HitTester.HitTest(areaPath, point, 0, true, transformer);
            }
            return(hit);
        }
Esempio n. 14
0
        private bool IsPointInObject(PointF point, IImageToViewportTransformer transformer)
        {
            bool hit = false;

            using (GraphicsPath areaPath = new GraphicsPath())
            {
                areaPath.AddEllipse(center.Box(radius + styleHelper.LineSize));
                hit = HitTester.HitTest(areaPath, point, 0, true, transformer);
            }
            return(hit);
        }
Esempio n. 15
0
        private bool IsPointOnHandler(PointF point, IImageToViewportTransformer transformer)
        {
            if (radius < 0)
            {
                return(false);
            }

            using (GraphicsPath areaPath = new GraphicsPath())
            {
                areaPath.AddArc(center.Box(radius), 25, 40);
                return(HitTester.HitTest(areaPath, point, styleHelper.LineSize, false, transformer));
            }
        }
Esempio n. 16
0
        private bool IsPointInObject(PointF point, IImageToViewportTransformer transformer)
        {
            using (GraphicsPath path = new GraphicsPath())
            {
                path.AddCurve(pointList.ToArray(), 0.5f);
                RectangleF bounds = path.GetBounds();
                if (bounds.IsEmpty)
                {
                    return(false);
                }

                return(HitTester.HitTest(path, point, styleHelper.LineSize, false, transformer));
            }
        }
Esempio n. 17
0
        private bool IsPointOnSegment(PointF point, PointF a, PointF b, IImageToViewportTransformer transformer)
        {
            using (GraphicsPath areaPath = new GraphicsPath())
            {
                if (a.NearlyCoincideWith(b))
                {
                    areaPath.AddLine(a.X, a.Y, a.X + 2, a.Y);
                }
                else
                {
                    areaPath.AddLine(a, b);
                }

                return(HitTester.HitTest(areaPath, point, styleHelper.LineSize, false, transformer));
            }
        }
        private bool IsPointOnSegment(GenericPostureSegment segment, PointF point, IImageToViewportTransformer transformer)
        {
            PointF start = segment.Start >= 0 ? genericPosture.PointList[segment.Start] : GetUntransformedComputedPoint(segment.Start);
            PointF end   = segment.End >= 0 ? genericPosture.PointList[segment.End] : GetUntransformedComputedPoint(segment.End);

            if (start == end)
            {
                return(false);
            }

            using (GraphicsPath path = new GraphicsPath())
            {
                path.AddLine(start, end);
                return(HitTester.HitTest(path, point, segment.Width, false, transformer));
            }
        }
        public override int HitTest(PointF point, long currentTimestamp, DistortionHelper distorter, IImageToViewportTransformer transformer, bool zooming)
        {
            // Convention: miss = -1, object = 0, handle = n.

            if (infosFading.GetOpacityFactor(currentTimestamp) <= 0)
            {
                return(-1);
            }

            for (int i = 0; i < points.Count; i++)
            {
                if (HitTester.HitTest(points[i], point, transformer))
                {
                    return(i + 1);
                }
            }

            return(-1);
        }
Esempio n. 20
0
        public override int HitTest(PointF point, long currentTimestamp, DistortionHelper distorter, IImageToViewportTransformer transformer, bool zooming)
        {
            // Convention: miss = -1, object = 0, handle = n.
            double opacity = infosFading.GetOpacityFactor(currentTimestamp);

            if (opacity <= 0)
            {
                return(-1);
            }

            for (int i = 0; i < 4; i++)
            {
                if (HitTester.HitTest(quadImage[i], point, transformer))
                {
                    return(i + 1);
                }
            }

            for (int i = 0; i < 4; i++)
            {
                using (GraphicsPath path = new GraphicsPath())
                {
                    PointF p1 = quadImage[i];
                    PointF p2 = quadImage[(i + 1) % 4];
                    if (!p1.NearlyCoincideWith(p2))
                    {
                        path.AddLine(p1, p2);
                        if (HitTester.HitTest(path, point, styleHelper.LineSize, false, transformer))
                        {
                            return(i + 5);
                        }
                    }
                }
            }

            if (quadImage.Contains(point))
            {
                return(0);
            }

            return(-1);
        }
Esempio n. 21
0
        public override int HitTest(PointF point, long currentTimestamp, DistortionHelper distorter, IImageToViewportTransformer transformer, bool zooming)
        {
            // Convention: miss = -1, object = 0, handle = n.
            int    result  = -1;
            double opacity = infosFading.GetOpacityFactor(currentTimestamp);

            if (tracking || opacity > 0)
            {
                if (trackExtraData != TrackExtraData.None && miniLabel.HitTest(point, transformer))
                {
                    result = 1;
                }
                else if (HitTester.HitTest(points["0"], point, transformer))
                {
                    result = 0;
                }
            }

            return(result);
        }
Esempio n. 22
0
        public override int HitTest(PointF point, long currentTimestamp, DistortionHelper distorter, IImageToViewportTransformer transformer, bool zooming)
        {
            if (infosFading.GetOpacityFactor(currentTimestamp) <= 0)
            {
                return(-1);
            }

            for (int i = 0; i < 4; i++)
            {
                if (HitTester.HitTest(quadImage[i], point, transformer))
                {
                    return(i + 1);
                }
            }

            if (!zooming && !inPerspective && quadImage.Contains(point))
            {
                return(0);
            }

            return(-1);
        }
        private bool IsPointOnRectifiedLine(PointF p, PointF a, PointF b, DistortionHelper distorter, IImageToViewportTransformer transformer)
        {
            if (a == b)
            {
                return(false);
            }

            using (GraphicsPath path = new GraphicsPath())
            {
                if (distorter != null && distorter.Initialized)
                {
                    List <PointF> curve = distorter.DistortRectifiedLine(a, b);
                    path.AddCurve(curve.ToArray());
                }
                else
                {
                    path.AddLine(a, b);
                }

                return(HitTester.HitTest(path, p, 1, false, transformer));
            }
        }
Esempio n. 24
0
        private bool IsPointInObject(PointF point, DistortionHelper distorter, IImageToViewportTransformer transformer)
        {
            if (points.Count < 1)
            {
                return(false);
            }

            using (GraphicsPath path = new GraphicsPath())
            {
                if (points.Count == 1)
                {
                    path.AddRectangle(points["0"].Box(5));
                }
                else
                {
                    List <PointF> pp = new List <PointF>();
                    for (int i = 0; i < points.Count; i++)
                    {
                        PointF p = points[i.ToString()];
                        if (pp.Count == 0 || p != pp[pp.Count - 1])
                        {
                            pp.Add(p);
                        }
                    }

                    if (styleHelper.Curved)
                    {
                        path.AddCurve(pp.ToArray());
                    }
                    else
                    {
                        path.AddLines(pp.ToArray());
                    }
                }

                return(HitTester.HitTest(path, point, styleHelper.LineSize, false, transformer));
            }
        }
Esempio n. 25
0
        private bool IsPointInObject(PointF point, DistortionHelper distorter, IImageToViewportTransformer transformer)
        {
            using (GraphicsPath areaPath = new GraphicsPath())
            {
                if (points["a"].NearlyCoincideWith(points["b"]))
                {
                    areaPath.AddLine(points["a"].X, points["a"].Y, points["a"].X + 2, points["a"].Y + 2);
                }
                else
                {
                    if (distorter != null && distorter.Initialized)
                    {
                        List <PointF> curve = distorter.DistortLine(points["a"], points["b"]);
                        areaPath.AddCurve(curve.ToArray());
                    }
                    else
                    {
                        areaPath.AddLine(points["a"], points["b"]);
                    }
                }

                return(HitTester.HitTest(areaPath, point, styleHelper.LineSize, false, transformer));
            }
        }
        public override int HitTest(PointF point, long currentTimestamp, DistortionHelper distorter, IImageToViewportTransformer transformer, bool zooming)
        {
            // Convention: miss = -1, object = 0, handle = n.
            int    result  = -1;
            double opacity = infosFading.GetOpacityTrackable(trackingTimestamps, currentTimestamp);

            if (opacity <= 0)
            {
                return(-1);
            }

            for (int i = 0; i < genericPosture.Handles.Count; i++)
            {
                if (result >= 0)
                {
                    break;
                }

                if (!IsActive(genericPosture.Handles[i].OptionGroup))
                {
                    continue;
                }

                int reference = genericPosture.Handles[i].Reference;
                if (reference < 0)
                {
                    continue;
                }

                switch (genericPosture.Handles[i].Type)
                {
                case HandleType.Point:
                    if (reference < genericPosture.PointList.Count && HitTester.HitTest(genericPosture.PointList[reference], point, transformer))
                    {
                        result = i + 1;
                    }
                    break;

                case HandleType.Segment:
                    if (reference < genericPosture.Segments.Count && IsPointOnSegment(genericPosture.Segments[reference], point, transformer))
                    {
                        genericPosture.Handles[i].GrabPoint = point;
                        result = i + 1;
                    }
                    break;

                case HandleType.Ellipse:
                case HandleType.Circle:
                    if (reference < genericPosture.Circles.Count && IsPointOnArc(genericPosture.Circles[reference], point, transformer))
                    {
                        result = i + 1;
                    }
                    break;
                }
            }

            if (result == -1 && IsPointInObject(point, transformer))
            {
                result = 0;
            }

            return(result);
        }