Ejemplo n.º 1
0
        public override void Draw(Graphics canvas, DistortionHelper distorter, IImageToViewportTransformer transformer, bool selected, long currentTimestamp)
        {
            double opacityFactor = infosFading.GetOpacityFactor(currentTimestamp);

            if (tracking)
            {
                opacityFactor = 1.0;
            }

            if (opacityFactor <= 0)
            {
                return;
            }

            int   iAlpha = (int)(opacityFactor * 255);
            Point c      = transformer.Transform(points["0"]);

            using (Pen p = styleHelper.GetPen(iAlpha))
                using (SolidBrush b = styleHelper.GetBrush((int)(opacityFactor * defaultBackgroundAlpha)))
                {
                    canvas.DrawLine(p, c.X - defaultRadius, c.Y, c.X + defaultRadius, c.Y);
                    canvas.DrawLine(p, c.X, c.Y - defaultRadius, c.X, c.Y + defaultRadius);
                    canvas.FillEllipse(b, c.Box(defaultRadius + 1));
                }

            if (trackExtraData != TrackExtraData.None)
            {
                string text = GetExtraDataText(infosFading.ReferenceTimestamp);
                miniLabel.SetText(text);
                miniLabel.Draw(canvas, transformer, opacityFactor);
            }
        }
        public override void Draw(Graphics canvas, DistortionHelper distorter, IImageToViewportTransformer transformer, bool selected, long currentTimestamp)
        {
            double opacityFactor = infosFading.GetOpacityTrackable(trackingTimestamps, currentTimestamp);

            if (opacityFactor <= 0)
            {
                return;
            }

            Point start = transformer.Transform(points["a"]);
            Point end   = transformer.Transform(points["b"]);

            using (Pen penEdges = styleHelper.GetPen(opacityFactor, transformer.Scale))
                using (Brush brush = styleHelper.GetBrush(opacityFactor))
                {
                    if (distorter != null && distorter.Initialized)
                    {
                        DrawDistorted(canvas, distorter, transformer, penEdges, brush, start, end);
                    }
                    else
                    {
                        DrawStraight(canvas, transformer, penEdges, brush, start, end);
                    }
                }

            if (trackExtraData != TrackExtraData.None)
            {
                string text = GetExtraDataText();
                miniLabel.SetText(text);
                miniLabel.Draw(canvas, transformer, opacityFactor);
            }
        }
Ejemplo n.º 3
0
        public override void Draw(Graphics canvas, DistortionHelper distorter, IImageToViewportTransformer transformer, bool selected, long currentTimestamp)
        {
            double opacityFactor = infosFading.GetOpacityFactor(currentTimestamp);

            if (opacityFactor <= 0)
            {
                return;
            }

            int alpha = (int)(opacityFactor * 255);

            using (Pen p = styleHelper.GetPen(alpha, transformer.Scale))
            {
                if (styleHelper.PenShape == PenShape.Dash)
                {
                    p.DashStyle = DashStyle.Dash;
                }

                // The center of the original circle is still the correct center even in perspective.
                PointF circleCenter = transformer.Transform(center);
                DrawCenter(canvas, p, circleCenter.ToPoint());

                if (CalibrationHelper.CalibratorType == CalibratorType.Plane)
                {
                    // Draw the circle in perspective.
                    PointF     ellipseCenter = transformer.Transform(ellipseInImage.Center);
                    float      semiMinorAxis = transformer.Transform((int)ellipseInImage.SemiMinorAxis);
                    float      semiMajorAxis = transformer.Transform((int)ellipseInImage.SemiMajorAxis);
                    Ellipse    ellipse       = new Ellipse(ellipseCenter, semiMajorAxis, semiMinorAxis, ellipseInImage.Rotation);
                    RectangleF rect          = new RectangleF(-ellipse.SemiMajorAxis, -ellipse.SemiMinorAxis, ellipse.SemiMajorAxis * 2, ellipse.SemiMinorAxis * 2);
                    float      angle         = (float)(ellipse.Rotation * MathHelper.RadiansToDegrees);

                    canvas.TranslateTransform(ellipse.Center.X, ellipse.Center.Y);
                    canvas.RotateTransform(angle);

                    canvas.DrawEllipse(p, rect);

                    canvas.RotateTransform(-angle);
                    canvas.TranslateTransform(-ellipse.Center.X, -ellipse.Center.Y);
                }
                else
                {
                    Rectangle boundingBox = transformer.Transform(center.Box(radius));
                    canvas.DrawEllipse(p, boundingBox);
                }

                if (trackExtraData != TrackExtraData.None)
                {
                    // Draw lines from the center to the periphery of the circle to show the radius or diameter.
                    if (trackExtraData == TrackExtraData.Radius)
                    {
                        PointF radiusRight = transformer.Transform(radiusRightInImage);
                        canvas.DrawLine(p, circleCenter, radiusRight);
                    }
                    else if (trackExtraData == TrackExtraData.Diameter)
                    {
                        PointF radiusLeft  = transformer.Transform(radiusLeftInImage);
                        PointF radiusRight = transformer.Transform(radiusRightInImage);
                        canvas.DrawLine(p, radiusLeft, radiusRight);
                    }

                    string text = GetExtraDataText(infosFading.ReferenceTimestamp);
                    miniLabel.SetText(text);
                    miniLabel.Draw(canvas, transformer, opacityFactor);
                }
            }
        }