Esempio n. 1
0
        /// <summary>
        /// Renders a tick by drawing an lot of segments
        /// </summary>
        /// <param name="axis">The axis.</param>
        /// <param name="angleAxis">The angle axis.</param>
        /// <param name="x">The x-value.</param>
        /// <param name="pen">The pen.</param>
        private void RenderTickArc(Axis axis, AngleAxis angleAxis, double x, OxyPen pen)
        {
            // caution: make sure angleAxis.UpdateActualMaxMin(); has been called
            var minAngle = angleAxis.ActualMinimum;
            var maxAngle = angleAxis.ActualMaximum;

            // number of segment to draw a full circle
            // - decrease if you want get more speed
            // - increase if you want more detail
            // (making a public property of it would be a great idea)
            const double MaxSegments = 90.0;

            // compute the actual number of segments
            var segmentCount = (int)(MaxSegments * Math.Abs(angleAxis.EndAngle - angleAxis.StartAngle) / 360.0);

            var angleStep = (maxAngle - minAngle) / (segmentCount - 1);

            var points = new List <ScreenPoint>();

            for (var i = 0; i < segmentCount; i++)
            {
                var angle = minAngle + (i * angleStep);
                points.Add(axis.Transform(x, angle, angleAxis));
            }

            this.RenderContext.DrawLine(points, pen.Color, pen.Thickness, pen.ActualDashArray);
        }
Esempio n. 2
0
        /// <summary>
        /// Renders a tick, chooses the best implementation
        /// </summary>
        /// <param name="axis">The axis.</param>
        /// <param name="angleAxis">The angle axis.</param>
        /// <param name="x">The x-value.</param>
        /// <param name="pen">The pen.</param>
        private void RenderTick(Axis axis, AngleAxis angleAxis, double x, OxyPen pen)
        {
            var isFullCircle = Math.Abs(Math.Abs(angleAxis.EndAngle - angleAxis.StartAngle) - 360) < 1e-6;

            if (isFullCircle && pen.ActualDashArray == null)
            {
                this.RenderTickCircle(axis, angleAxis, x, pen);
            }
            else
            {
                this.RenderTickArc(axis, angleAxis, x, pen);
            }
        }
        /// <summary>
        /// Renders a tick by drawing an lot of segments
        /// </summary>
        /// <param name="axis">The axis.</param>
        /// <param name="angleAxis">The angle axis.</param>
        /// <param name="x">The x-value.</param>
        /// <param name="pen">The pen.</param>
        /// <param name="startAngle">The start angle.</param>
        /// <param name="endAngle">The end angle.</param>
        private void RenderTickArc(Axis axis, AngleAxis angleAxis, double x, OxyPen pen, double startAngle, double endAngle)
        {
            if (startAngle > endAngle)
            {
            }
            // caution: make sure angleAxis.UpdateActualMaxMin(); has been called

            // number of segment to draw a full circle
            // - decrease if you want get more speed
            // - increase if you want more detail
            // (making a public property of it would be a great idea)

            // compute the actual number of segments
            var segmentCount = (int)(MaxSegments * Math.Abs(endAngle - startAngle) / 360.0);

            if (angleAxis.FractionUnit == Math.PI || angleAxis.ActualMaximum == 2 * Math.PI)
            {
                segmentCount = (int)(MaxSegments * Math.Abs(endAngle - startAngle) / (2 * Math.PI));
                startAngle  *= rad;
                endAngle    *= rad;
            }

            segmentCount = Math.Max(segmentCount, 2);
            segmentCount = Math.Min(segmentCount, (int)MaxSegments);
            var angleStep = Math.Abs(endAngle - startAngle) / (segmentCount - 1);

            var points = new List <ScreenPoint>();

            for (var i = 0; i < segmentCount; i++)
            {
                var         angle = startAngle + (i * angleStep);
                ScreenPoint toadd = axis.Transform(x, angle, angleAxis);
                points.Add(toadd);
            }

            this.RenderContext.DrawLine(points, pen.Color, pen.Thickness, axis.EdgeRenderingMode, pen.ActualDashArray);
        }
        /// <summary>
        /// Renders a tick by drawing an lot of segments
        /// </summary>
        /// <param name="axis">The axis.</param>
        /// <param name="angleAxis">The angle axis.</param>
        /// <param name="x">The x-value.</param>
        /// <param name="pen">The pen.</param>
        private void RenderTickArc(Axis axis, AngleAxis angleAxis, double x, OxyPen pen)
        {
            // caution: make sure angleAxis.UpdateActualMaxMin(); has been called
            var minAngle = angleAxis.ActualMinimum;
            var maxAngle = angleAxis.ActualMaximum;

            // number of segment to draw a full circle
            // - decrease if you want get more speed
            // - increase if you want more detail
            // (making a public property of it would be a great idea)
            const double MaxSegments = 90.0;

            // compute the actual number of segments
            var segmentCount = (int)(MaxSegments * Math.Abs(angleAxis.EndAngle - angleAxis.StartAngle) / 360.0);

            var angleStep = (maxAngle - minAngle) / (segmentCount - 1);

            var points = new List<ScreenPoint>();

            for (var i = 0; i < segmentCount; i++)
            {
                var angle = minAngle + (i * angleStep);
                points.Add(axis.Transform(x, angle, angleAxis));
            }

            this.RenderContext.DrawLine(points, pen.Color, pen.Thickness, pen.ActualDashArray);
        }
        /// <summary>
        /// Renders a tick, chooses the best implementation
        /// </summary>
        /// <param name="axis">The axis.</param>
        /// <param name="angleAxis">The angle axis.</param>
        /// <param name="x">The x-value.</param>
        /// <param name="pen">The pen.</param>
        private void RenderTick(Axis axis, AngleAxis angleAxis, double x, OxyPen pen)
        {
            var isFullCircle = Math.Abs(Math.Abs(angleAxis.EndAngle - angleAxis.StartAngle) - 360) < 1e-6;

            if (isFullCircle && pen.ActualDashArray == null)
            {
                this.RenderTickCircle(axis, angleAxis, x, pen);
            }
            else
            {
                this.RenderTickArc(axis, angleAxis, x, pen);
            }
        }
Esempio n. 6
0
        public static PlotModel OffsetAngles()
        {
            var model = new PlotModel
            {
                Title = "Offset angle axis",
                PlotType = PlotType.Polar,
                PlotAreaBorderThickness = new OxyThickness(0),
                PlotMargins = new OxyThickness(60, 20, 4, 40)
            };

            var angleAxis = new AngleAxis
            {
                Minimum = 0,
                Maximum = Math.PI * 2,
                MajorStep = Math.PI / 4,
                MinorStep = Math.PI / 16,
                StringFormat = "0.00",
                StartAngle = 30,
                EndAngle = 390
            };
            model.Axes.Add(angleAxis);
            model.Axes.Add(new MagnitudeAxis());
            model.Series.Add(new FunctionSeries(t => t, t => t, 0, Math.PI * 6, 0.01));

            // Subscribe to the mouse down event on the line series.
            model.MouseDown += (s, e) =>
            {
                var increment = 0d;

                // Increment and decrement must be in degrees (corresponds to the StartAngle and EndAngle properties).
                if (e.ChangedButton == OxyMouseButton.Left)
                {
                    increment = 15;
                }

                if (e.ChangedButton == OxyMouseButton.Right)
                {
                    increment = -15;
                }

                if (Math.Abs(increment) > double.Epsilon)
                {
                    angleAxis.StartAngle += increment;
                    angleAxis.EndAngle += increment;
                    model.InvalidatePlot(false);
                    e.Handled = true;
                }
            };

            return model;
        }