예제 #1
0
        public override void Render(AnnContainerMapper mapper, AnnObject annObject)
        {
            if (mapper == null)
            {
                ExceptionHelper.ArgumentNullException("mapper");
            }
            if (annObject == null)
            {
                ExceptionHelper.ArgumentNullException("annObject");
            }

            IAnnDrawEngine engine = RenderingEngine as IAnnDrawEngine;

            if (engine != null)
            {
                base.Render(mapper, annObject);

                AnnIntersectionPointObject annIntersectionPointObject = annObject as AnnIntersectionPointObject;
                if (annIntersectionPointObject != null)
                {
                    int count = annIntersectionPointObject.Points.Count;
                    if (count < 2)
                    {
                        return;
                    }

                    LeadPointD[] leadPoints = mapper.PointsFromContainerCoordinates(annIntersectionPointObject.Points.ToArray(), annIntersectionPointObject.FixedStateOperations);

                    if (annIntersectionPointObject.SupportsStroke && annIntersectionPointObject.Stroke != null)
                    {
                        AnnStroke stroke = AnnStroke.Create(AnnSolidColorBrush.Create("Blue"), annIntersectionPointObject.Stroke.StrokeThickness);
                        stroke.StrokeDashArray = new double[] { 3, 1, 1, 1, 1, 1 }; // DashDotDot

                        IAnnDrawPen pen = engine.ToPen(mapper.StrokeFromContainerCoordinates(stroke, annIntersectionPointObject.FixedStateOperations), annIntersectionPointObject.Opacity);
                        try
                        {
                            if (leadPoints.Length > 2)
                            {
                                LeadPointD intersectionPoint = annIntersectionPointObject.IntersectionPoint;
                                intersectionPoint = mapper.PointFromContainerCoordinates(intersectionPoint, annIntersectionPointObject.FixedStateOperations);

                                double radius = mapper.LengthFromContainerCoordinates(annIntersectionPointObject.IntersectionPointRadius, annIntersectionPointObject.FixedStateOperations);
                                DrawPoint(annIntersectionPointObject, engine, intersectionPoint, radius);

                                if (leadPoints.Length < 5 && annIntersectionPointObject.IntersectionInsideContainer)
                                {
                                    engine.DrawLine(pen, leadPoints[3], intersectionPoint);
                                }
                            }
                        }
                        finally
                        {
                            engine.Destroy(pen);
                        }
                    }
                }
            }
        }
예제 #2
0
        private void DrawPoint(AnnMidlineObject annObject, IAnnDrawEngine engine, LeadPointD point, double radius)
        {
            LeadRectD  pointBounds = new LeadRectD(point.X - radius, point.Y - radius, radius * 2, radius * 2);
            LeadPointD topLeft     = pointBounds.TopLeft;
            LeadPointD topRight    = pointBounds.TopRight;
            LeadPointD bottomLeft  = pointBounds.BottomLeft;
            LeadPointD bottomRight = pointBounds.BottomRight;

            IAnnDrawPen pen = engine.ToPen(AnnStroke.Create(AnnSolidColorBrush.Create("blue"), annObject.Stroke.StrokeThickness), annObject.Opacity);

            try
            {
                engine.DrawLine(pen, topLeft, bottomRight);
                engine.DrawLine(pen, bottomLeft, topRight);
                engine.DrawLine(pen, new LeadPointD(point.X, (point.Y - pointBounds.Width / 2)), new LeadPointD(point.X, (point.Y + pointBounds.Width / 2)));
                engine.DrawLine(pen, new LeadPointD(point.X - pointBounds.Width / 2, point.Y), new LeadPointD(point.X + pointBounds.Width / 2, point.Y));
            }
            finally
            {
                engine.Destroy(pen);
            }
        }
        public override void Render(AnnContainerMapper mapper, AnnObject annObject)
        {
            if (mapper == null)
            {
                ExceptionHelper.ArgumentNullException("mapper");
            }
            if (annObject == null)
            {
                ExceptionHelper.ArgumentNullException("annObject");
            }

            IAnnDrawEngine engine = RenderingEngine as IAnnDrawEngine;

            if (engine != null)
            {
                LeadPointD[] leadPoints = annObject.Points.ToArray();
                int          linesCount = leadPoints.Length / 2;
                if (linesCount > 0)
                {
                    if (annObject.SupportsStroke && annObject.Stroke != null)
                    {
                        leadPoints = mapper.PointsFromContainerCoordinates(leadPoints, annObject.FixedStateOperations);

                        IAnnDrawPen pen = engine.ToPen(mapper.StrokeFromContainerCoordinates(annObject.Stroke, annObject.FixedStateOperations), annObject.Opacity);
                        try
                        {
                            for (int i = 0; i < linesCount; ++i)
                            {
                                LeadPointD firstPoint  = leadPoints[2 * i];
                                LeadPointD secondPoint = leadPoints[2 * i + 1];

                                engine.DrawLine(pen, firstPoint, secondPoint);
                            }
                        }
                        finally
                        {
                            engine.Destroy(pen);
                        }
                    }
                }
            }
        }
예제 #4
0
        public override void Render(AnnContainerMapper mapper, AnnObject annObject)
        {
            if (mapper == null)
            {
                ExceptionHelper.ArgumentNullException("mapper");
            }
            if (annObject == null)
            {
                ExceptionHelper.ArgumentNullException("annObject");
            }

            IAnnDrawEngine engine = RenderingEngine as IAnnDrawEngine;

            if (engine != null)
            {
                int count = annObject.Points.Count / 2;

                if (count > 1)
                {
                    LeadPointD[] tmpPoints = mapper.PointsFromContainerCoordinates(annObject.Points.ToArray(), annObject.FixedStateOperations);

                    if (annObject.SupportsStroke && annObject.Stroke != null)
                    {
                        IAnnDrawPen pen = engine.ToPen(mapper.StrokeFromContainerCoordinates(annObject.Stroke, annObject.FixedStateOperations), annObject.Opacity);
                        try
                        {
                            for (int i = 0; i < count; i++)
                            {
                                int index = 2 * i;
                                engine.DrawLine(pen, tmpPoints[index], tmpPoints[index + 1]);
                            }
                        }
                        finally
                        {
                            engine.Destroy(pen);
                        }
                    }
                }
            }
        }
예제 #5
0
        public override void Render(AnnContainerMapper mapper, AnnObject annObject)
        {
            if (mapper == null)
            {
                ExceptionHelper.ArgumentNullException("mapper");
            }
            if (annObject == null)
            {
                ExceptionHelper.ArgumentNullException("annObject");
            }

            IAnnDrawEngine engine = RenderingEngine as IAnnDrawEngine;

            if (engine != null)
            {
                base.Render(mapper, annObject);

                AnnMidlineObject annMidlineObject = annObject as AnnMidlineObject;
                if (annMidlineObject != null)
                {
                    LeadPointD[] leadPoints = annMidlineObject.Points.ToArray();
                    int          linesCount = leadPoints.Length / 2;
                    if (linesCount > 0)
                    {
                        LeadPointD[] linesCenters = new LeadPointD[linesCount];
                        leadPoints = mapper.PointsFromContainerCoordinates(leadPoints, annMidlineObject.FixedStateOperations);

                        if (annMidlineObject.SupportsStroke && annMidlineObject.Stroke != null)
                        {
                            double      radius = mapper.LengthFromContainerCoordinates(annMidlineObject.CenterPointRadius, annMidlineObject.FixedStateOperations);
                            IAnnDrawPen pen    = engine.ToPen(mapper.StrokeFromContainerCoordinates(annMidlineObject.Stroke, annMidlineObject.FixedStateOperations), annMidlineObject.Opacity);
                            try
                            {
                                for (int i = 0; i < linesCount; ++i)
                                {
                                    LeadPointD firstPoint  = leadPoints[2 * i];
                                    LeadPointD secondPoint = leadPoints[2 * i + 1];

                                    LeadPointD center = new LeadPointD((firstPoint.X + secondPoint.X) / 2, (firstPoint.Y + secondPoint.Y) / 2);
                                    DrawPoint(annMidlineObject, engine, center, radius);

                                    linesCenters[i] = center;
                                }

                                if (linesCount > 1)
                                {
                                    int count = linesCount - 1;
                                    for (int i = 0; i < count; ++i)
                                    {
                                        engine.DrawLine(pen, linesCenters[i], linesCenters[i + 1]); // draw midline
                                    }
                                }
                            }
                            finally
                            {
                                engine.Destroy(pen);
                            }
                        }
                    }
                }
            }
        }
        public override void Render(AnnContainerMapper mapper, AnnObject annObject)
        {
            if (mapper == null)
            {
                ExceptionHelper.ArgumentNullException("mapper");
            }
            if (annObject == null)
            {
                ExceptionHelper.ArgumentNullException("annObject");
            }

            IAnnDrawEngine engine = RenderingEngine as IAnnDrawEngine;

            if (engine != null)
            {
                base.Render(mapper, annObject);

                AnnCobbAngleObject annCobbAngleObject = annObject as AnnCobbAngleObject;
                if (annCobbAngleObject != null)
                {
                    int count = annCobbAngleObject.Points.Count;
                    if (count < 2)
                    {
                        return;
                    }

                    LeadPointD[] leadPoints = mapper.PointsFromContainerCoordinates(annCobbAngleObject.Points.ToArray(), annCobbAngleObject.FixedStateOperations);

                    if (annCobbAngleObject.SupportsStroke && annCobbAngleObject.Stroke != null)
                    {
                        AnnStroke stroke = AnnStroke.Create(AnnSolidColorBrush.Create("Blue"), annCobbAngleObject.Stroke.StrokeThickness);
                        stroke.StrokeDashArray = new double[] { 4, 2, 2, 2, 2, 2 };
                        IAnnDrawPen pen = engine.ToPen(mapper.StrokeFromContainerCoordinates(annCobbAngleObject.Stroke, annCobbAngleObject.FixedStateOperations), annCobbAngleObject.Opacity);
                        try
                        {
                            if (leadPoints.Length > 3)
                            {
                                AnnCobbAngleData cobbAngleData     = annCobbAngleObject.CobbAngleData;
                                LeadPointD       firstPoint        = mapper.PointFromContainerCoordinates(cobbAngleData.FirstPoint, annCobbAngleObject.FixedStateOperations);
                                LeadPointD       secondPoint       = mapper.PointFromContainerCoordinates(cobbAngleData.SecondPoint, annCobbAngleObject.FixedStateOperations);
                                LeadPointD       intersectionPoint = mapper.PointFromContainerCoordinates(cobbAngleData.IntersectionPoint, annCobbAngleObject.FixedStateOperations);

                                engine.DrawLine(pen, firstPoint, intersectionPoint);
                                engine.DrawLine(pen, secondPoint, intersectionPoint);

                                //Draw angle label
                                if (annCobbAngleObject.Labels.ContainsKey("CobbAngle"))
                                {
                                    AnnLabel label = annCobbAngleObject.Labels["CobbAngle"];
                                    if (label != null)
                                    {
                                        string precisionFormat = string.Format("XXX:F{0}", annCobbAngleObject.AnglePrecision);
                                        precisionFormat = precisionFormat.Replace("XXX", "{0");
                                        precisionFormat = string.Format("{0}{1}", precisionFormat, "}");

                                        string angle = string.Format(precisionFormat, cobbAngleData.Angle);

                                        label.Text             = angle;
                                        label.Foreground       = AnnSolidColorBrush.Create("Blue");
                                        label.OriginalPosition = cobbAngleData.IntersectionPoint;
                                    }
                                }
                            }
                        }
                        finally
                        {
                            engine.Destroy(pen);
                        }
                    }
                }
            }
        }