public override void Draw(Graphics canvas, DistortionHelper distorter, IImageToViewportTransformer transformer, bool selected, long currentTimestamp)
        {
            if (!Visible || CalibrationHelper == null)
            {
                return;
            }

            if (CalibrationHelper.CalibratorType == CalibratorType.Plane && !CalibrationHelper.CalibrationByPlane_IsValid())
            {
                return;
            }

            CoordinateSystemGrid grid = CalibrationHelper.GetCoordinateSystemGrid();

            using (Pen penLine = styleHelper.GetBackgroundPen(255))
            {
                DrawGrid(canvas, distorter, transformer, grid);
            }
        }
Ejemplo n.º 2
0
        public override void Draw(Graphics _canvas, CoordinateSystem _transformer, bool _bSelected, long _iCurrentTimestamp)
        {
            double fOpacityFactor = m_InfosFading.GetOpacityFactor(_iCurrentTimestamp);

            if (fOpacityFactor <= 0)
            {
                return;
            }

            Point     pointO      = _transformer.Transform(m_PointO);
            Point     pointA      = _transformer.Transform(m_PointA);
            Point     pointB      = _transformer.Transform(m_PointB);
            Rectangle boundingBox = _transformer.Transform(m_BoundingBox);

            using (Pen penEdges = m_StyleHelper.GetBackgroundPen((int)(fOpacityFactor * 255)))
                using (SolidBrush brushEdges = m_StyleHelper.GetBackgroundBrush((int)(fOpacityFactor * 255)))
                    using (SolidBrush brushFill = m_StyleHelper.GetBackgroundBrush((int)(fOpacityFactor * m_iDefaultBackgroundAlpha)))
                    {
                        // Disk section
                        _canvas.FillPie(brushFill, boundingBox, m_fStartAngle, m_fSweepAngle);
                        _canvas.DrawPie(penEdges, boundingBox, m_fStartAngle, m_fSweepAngle);

                        // Edges
                        _canvas.DrawLine(penEdges, pointO, pointA);
                        _canvas.DrawLine(penEdges, pointO, pointB);

                        // Handlers
                        _canvas.DrawEllipse(penEdges, pointO.Box(3));
                        _canvas.FillEllipse(brushEdges, pointA.Box(3));
                        _canvas.FillEllipse(brushEdges, pointB.Box(3));

                        SolidBrush fontBrush = m_StyleHelper.GetForegroundBrush((int)(fOpacityFactor * 255));
                        int        angle     = (int)Math.Floor(-m_fSweepAngle);
                        string     label     = angle.ToString() + "°";
                        Font       tempFont  = m_StyleHelper.GetFont((float)_transformer.Scale);
                        SizeF      labelSize = _canvas.MeasureString(label, tempFont);

                        // Background
                        float      shiftx        = (float)(_transformer.Scale * m_TextShift.X);
                        float      shifty        = (float)(_transformer.Scale * m_TextShift.Y);
                        PointF     textOrigin    = new PointF(shiftx + pointO.X - labelSize.Width / 2, shifty + pointO.Y - labelSize.Height / 2);
                        RectangleF backRectangle = new RectangleF(textOrigin, labelSize);
                        RoundedRectangle.Draw(_canvas, backRectangle, brushFill, tempFont.Height / 4, false);

                        // Text
                        _canvas.DrawString(label, tempFont, fontBrush, backRectangle.Location);

                        tempFont.Dispose();
                        fontBrush.Dispose();
                    }
        }
Ejemplo n.º 3
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;
            }

            ComputeValues(transformer);

            Point     pointO      = transformer.Transform(points["o"]);
            Point     pointA      = transformer.Transform(points["a"]);
            Point     pointB      = transformer.Transform(points["b"]);
            Rectangle boundingBox = transformer.Transform(angleHelper.SweepAngle.BoundingBox);

            if (boundingBox.Size == Size.Empty)
            {
                return;
            }

            using (Pen penEdges = styleHelper.GetBackgroundPen((int)(opacityFactor * 255)))
                using (SolidBrush brushEdges = styleHelper.GetBackgroundBrush((int)(opacityFactor * 255)))
                    using (SolidBrush brushFill = styleHelper.GetBackgroundBrush((int)(opacityFactor * defaultBackgroundAlpha)))
                    {
                        penEdges.Width = 2;

                        // Disk section
                        canvas.FillPie(brushFill, boundingBox, angleHelper.SweepAngle.Start, angleHelper.SweepAngle.Sweep);
                        canvas.DrawArc(penEdges, boundingBox, angleHelper.SweepAngle.Start, angleHelper.SweepAngle.Sweep);

                        // Edges
                        penEdges.DashStyle = DashStyle.Dash;
                        canvas.DrawLine(penEdges, pointO, pointA);
                        penEdges.DashStyle = DashStyle.Solid;
                        canvas.DrawLine(penEdges, pointO, pointB);

                        // Handlers
                        canvas.DrawEllipse(penEdges, pointO.Box(3));
                        canvas.FillEllipse(brushEdges, pointA.Box(3));
                        canvas.FillEllipse(brushEdges, pointB.Box(3));

                        angleHelper.DrawText(canvas, opacityFactor, brushFill, pointO, transformer, CalibrationHelper, styleHelper);
                    }
        }
Ejemplo n.º 4
0
        public override void Draw(Graphics canvas, DistortionHelper distorter, IImageToViewportTransformer transformer, bool selected, long currentTimestamp)
        {
            double opacity = infosFading.GetOpacityFactor(currentTimestamp);

            if (tracking)
            {
                opacity = 1.0;
            }

            if (opacity <= 0)
            {
                return;
            }

            List <Point> points = transformer.Transform(genericPosture.PointList);

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

            alpha = Math.Max(0, Math.Min(255, alpha));

            int alphaBackground = (int)(opacity * defaultBackgroundAlpha);

            alphaBackground = Math.Max(0, Math.Min(255, alphaBackground));

            using (Pen penEdge = styleHelper.GetBackgroundPen(alpha))
                using (SolidBrush brushHandle = styleHelper.GetBackgroundBrush(alpha))
                    using (SolidBrush brushFill = styleHelper.GetBackgroundBrush(alphaBackground))
                    {
                        Color basePenEdgeColor     = penEdge.Color;
                        Color baseBrushHandleColor = brushHandle.Color;
                        Color baseBrushFillColor   = brushFill.Color;

                        DrawSegments(penEdge, basePenEdgeColor, alpha, canvas, transformer, points);
                        DrawCircles(penEdge, basePenEdgeColor, alpha, canvas, transformer, points);
                        DrawAngles(penEdge, basePenEdgeColor, brushFill, baseBrushFillColor, alpha, alphaBackground, opacity, canvas, transformer, points);
                        DrawPoints(brushHandle, baseBrushHandleColor, alpha, canvas, transformer, points);

                        DrawComputedPoints(penEdge, basePenEdgeColor, brushHandle, baseBrushHandleColor, alpha, opacity, canvas, transformer);
                        DrawDistances(brushFill, baseBrushFillColor, alphaBackground, opacity, canvas, transformer, points);
                        DrawPositions(brushFill, baseBrushFillColor, alphaBackground, opacity, canvas, transformer, points);

                        if (PreferencesManager.PlayerPreferences.EnableCustomToolsDebugMode)
                        {
                            DrawDebug(opacity, canvas, transformer, points);
                        }
                    }
        }
Ejemplo n.º 5
0
        public void Draw(Graphics _canvas, CoordinateSystem _transformer, double _fOpacityFactor)
        {
            using (SolidBrush fillBrush = m_StyleHelper.GetBackgroundBrush((int)(_fOpacityFactor * 255)))
                using (Pen p = m_StyleHelper.GetBackgroundPen((int)(_fOpacityFactor * 64)))
                    using (Font f = m_StyleHelper.GetFont((float)_transformer.Scale))
                        using (SolidBrush fontBrush = m_StyleHelper.GetForegroundBrush((int)(_fOpacityFactor * 255)))
                        {
                            // Small dot and connector.
                            Point attch  = _transformer.Transform(m_AttachLocation);
                            Point center = _transformer.Transform(m_Background.Center);
                            _canvas.FillEllipse(fillBrush, attch.Box(2));
                            _canvas.DrawLine(p, attch, center);

                            // Background and text.
                            SizeF     textSize = _canvas.MeasureString(m_Text, f);
                            Point     location = _transformer.Transform(m_Background.Rectangle.Location);
                            Size      size     = new Size((int)textSize.Width, (int)textSize.Height);
                            Rectangle rect     = new Rectangle(location, size);
                            RoundedRectangle.Draw(_canvas, rect, fillBrush, f.Height / 4, false);
                            _canvas.DrawString(m_Text, f, fontBrush, rect.Location);
                        }
        }
Ejemplo n.º 6
0
        public void Draw(Graphics canvas, IImageToViewportTransformer transformer, double opacityFactor)
        {
            using (SolidBrush fillBrush = styleHelper.GetBackgroundBrush((int)(opacityFactor * 255)))
                using (Pen p = styleHelper.GetBackgroundPen((int)(opacityFactor * 64)))
                    using (Font f = styleHelper.GetFont((float)transformer.Scale))
                        using (SolidBrush fontBrush = styleHelper.GetForegroundBrush((int)(opacityFactor * 255)))
                        {
                            SizeF textSize = canvas.MeasureString(text, f);
                            Point location = transformer.Transform(background.Rectangle.Location);
                            Size  size     = new Size((int)textSize.Width, (int)textSize.Height);

                            SizeF untransformed = transformer.Untransform(textSize);
                            background.Rectangle = new RectangleF(background.Rectangle.Location, untransformed);

                            Point attch  = transformer.Transform(attachLocation);
                            Point center = transformer.Transform(background.Center);
                            canvas.FillEllipse(fillBrush, attch.Box(2));
                            canvas.DrawLine(p, attch, center);

                            Rectangle rect = new Rectangle(location, size);
                            RoundedRectangle.Draw(canvas, rect, fillBrush, f.Height / 4, false, false, null);
                            canvas.DrawString(text, f, fontBrush, rect.Location);
                        }
        }
Ejemplo n.º 7
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;
            }

            ComputeValues(transformer);

            Point     pointO      = transformer.Transform(points["o"]);
            Point     pointA      = transformer.Transform(points["a"]);
            Point     pointB      = transformer.Transform(points["b"]);
            Rectangle boundingBox = transformer.Transform(angleHelper.BoundingBox);

            if (boundingBox.Size == Size.Empty)
            {
                return;
            }

            using (Pen penEdges = styleHelper.GetBackgroundPen((int)(opacityFactor * 255)))
                using (SolidBrush brushEdges = styleHelper.GetBackgroundBrush((int)(opacityFactor * 255)))
                    using (SolidBrush brushFill = styleHelper.GetBackgroundBrush((int)(opacityFactor * defaultBackgroundAlpha)))
                    {
                        // Disk section
                        canvas.FillPie(brushFill, boundingBox, (float)angleHelper.Angle.Start, (float)angleHelper.Angle.Sweep);
                        canvas.DrawPie(penEdges, boundingBox, (float)angleHelper.Angle.Start, (float)angleHelper.Angle.Sweep);

                        // Edges
                        canvas.DrawLine(penEdges, pointO, pointA);
                        canvas.DrawLine(penEdges, pointO, pointB);

                        // Handlers
                        canvas.DrawEllipse(penEdges, pointO.Box(3));
                        canvas.FillEllipse(brushEdges, pointA.Box(3));
                        canvas.FillEllipse(brushEdges, pointB.Box(3));

                        SolidBrush fontBrush = styleHelper.GetForegroundBrush((int)(opacityFactor * 255));
                        float      angle     = CalibrationHelper.ConvertAngleFromDegrees(angleHelper.CalibratedAngle.Sweep);
                        string     label     = "";
                        if (CalibrationHelper.AngleUnit == AngleUnit.Degree)
                        {
                            label = string.Format("{0}{1}", (int)Math.Round(angle), CalibrationHelper.GetAngleAbbreviation());
                        }
                        else
                        {
                            label = string.Format("{0:0.00} {1}", angle, CalibrationHelper.GetAngleAbbreviation());
                        }

                        Font  tempFont  = styleHelper.GetFont((float)transformer.Scale);
                        SizeF labelSize = canvas.MeasureString(label, tempFont);

                        // Background
                        float      shiftx        = (float)(transformer.Scale * angleHelper.TextPosition.X);
                        float      shifty        = (float)(transformer.Scale * angleHelper.TextPosition.Y);
                        PointF     textOrigin    = new PointF(shiftx + pointO.X - labelSize.Width / 2, shifty + pointO.Y - labelSize.Height / 2);
                        RectangleF backRectangle = new RectangleF(textOrigin, labelSize);
                        RoundedRectangle.Draw(canvas, backRectangle, brushFill, tempFont.Height / 4, false, false, null);

                        // Text
                        canvas.DrawString(label, tempFont, fontBrush, backRectangle.Location);

                        tempFont.Dispose();
                        fontBrush.Dispose();
                    }
        }