Exemplo n.º 1
0
        internal override double GetPolarDistance(Point point)
        {
            var coordinates = RadMath.ToPolarCoordinates(new RadPoint(point.X, point.Y), new RadPoint(this.CenterPoint.X, this.CenterPoint.Y));

            var normalizedStartAngle = this.startAngle % 360;

            if (this.CenterPoint.X < point.X && this.CenterPoint.Y < point.Y)
            {
                // IV quadrant
                if (this.startAngle + this.sweepAngle > 360)
                {
                    normalizedStartAngle = this.startAngle - 360;
                }
            }

            var pointRadius = coordinates.Item1;

            // Outside of bounds.
            if (coordinates.Item2 <= normalizedStartAngle || coordinates.Item2 >= normalizedStartAngle + this.sweepAngle)
            {
                pointRadius = double.PositiveInfinity;
            }

            return(Math.Max(0, pointRadius - (this.Radius - this.InnerRadius) / 2 + this.InnerRadius));
        }
Exemplo n.º 2
0
        public IEnumerable <RadialSegment> HitTest(Point point)
        {
            foreach (var area in this.registeredAreas)
            {
                if (area.HitTestVisible)
                {
                    var polarPointTuple = RadMath.ToPolarCoordinates(new RadPoint(point.X, point.Y), new RadPoint(this.owner.ActualWidth / 2, this.owner.ActualHeight / 2), true);

                    var segment = area.HitTest(new RadPolarPoint(polarPointTuple.Item1, polarPointTuple.Item2));

                    if (segment != null)
                    {
                        yield return(segment);
                    }
                }
            }

            yield break;
        }
Exemplo n.º 3
0
        internal override Tuple <object, object> ConvertPointToData(RadPoint coordinates)
        {
            object polarValue  = null;
            object radialValue = null;

            if (this.view != null)
            {
                RadRect plotArea   = this.plotArea.layoutSlot;
                double  panOffsetX = this.view.PlotOriginX * plotArea.Width;
                double  panOffsetY = this.view.PlotOriginY * plotArea.Height;

                // todo: The plotArea.Width/Height are the width/height of the whole (zoomed) polar chart, not the visual part of it.
                RadRect plotAreaVirtualSize = new RadRect(plotArea.X, plotArea.Y, plotArea.Width, plotArea.Height);

                var polarCoordinates = RadMath.ToPolarCoordinates(new RadPoint(coordinates.X - panOffsetX, coordinates.Y - panOffsetY), plotAreaVirtualSize.Center, true);
                var radius           = polarCoordinates.Item1;
                var angle            = polarCoordinates.Item2;

                if (this.primaryFirstAxis != null && this.primaryFirstAxis.isUpdated)
                {
                    NumericalAxisModel polarAxis = this.primaryFirstAxis as NumericalAxisModel;
                    var polarAxisPlotArea        = new RadRect(plotAreaVirtualSize.Center.X, plotAreaVirtualSize.Y, plotAreaVirtualSize.Width / 2, plotAreaVirtualSize.Height / 2);
                    polarValue = polarAxis.ConvertPhysicalUnitsToData(radius + polarAxisPlotArea.X, polarAxisPlotArea);
                }

                if (this.primarySecondAxis != null && this.primarySecondAxis.isUpdated)
                {
                    var actualAngle = this.primarySecondAxis.IsInverse ? (360 - angle) % 360 : angle;

                    if (this.primarySecondAxis is CategoricalAxisModel)
                    {
                        CategoricalAxisModel radarAxis = this.primarySecondAxis as CategoricalRadialAxisModel;
                        radialValue = radarAxis.ConvertPhysicalUnitsToData(actualAngle, plotAreaVirtualSize);
                    }
                    else
                    {
                        radialValue = actualAngle;
                    }
                }
            }

            return(new Tuple <object, object>(polarValue, radialValue));
        }