protected bool TransformPoints(IList <DoubleVector4> points, List <Vector4> output, Rect viewRect, DoubleVector3 min, DoubleVector3 max)
        {
            output.Clear();
            DoubleVector3 range = max - min;

            if (Math.Abs(range.x) <= 0.0001f || Math.Abs(range.y) < 0.0001f)
            {
                return(false);
            }
            double radiusMultiplier = Math.Min(viewRect.width / Math.Abs(range.x), viewRect.height / Math.Abs(range.y));
            bool   HasSize          = false;

            for (int i = 0; i < points.Count; i++)
            {
                DoubleVector4 point = points[i];
                DoubleVector4 res   = ChartCommon.interpolateInRect(viewRect, new DoubleVector3((point.x - min.x) / range.x, (point.y - min.y) / range.y));
                res.z = 0.0;
                res.w = point.w * radiusMultiplier;
                if (point.w > 0f)
                {
                    HasSize = true;
                }
                output.Add(res.ToVector4());
            }
            return(HasSize);
        }
示例#2
0
        protected void TransformPoints(IList <DoubleVector3> points, Rect viewRect, DoubleVector3 min, DoubleVector3 max)
        {
            DoubleVector3 range = max - min;

            if (range.x <= 0.0001f || range.y < 0.0001f)
            {
                return;
            }
            double radiusMultiplier = Math.Min(viewRect.width / range.x, viewRect.height / range.y);

            for (int i = 0; i < points.Count; i++)
            {
                DoubleVector3 point = points[i];
                DoubleVector4 res   = interpolateInRect(viewRect, new DoubleVector3((point.x - min.x) / range.x, (point.y - min.y) / range.y));
                res.z     = point.z * radiusMultiplier;
                points[i] = res.ToDoubleVector3();
            }
        }
        protected void TransformPoints(IList <DoubleVector4> points, List <Vector4> output, Rect viewRect, DoubleVector3 min, DoubleVector3 max)
        {
            output.Clear();
            DoubleVector3 range = max - min;

            if (range.x <= 0.0001f || range.y < 0.0001f)
            {
                return;
            }
            double radiusMultiplier = Math.Min(viewRect.width / range.x, viewRect.height / range.y);

            for (int i = 0; i < points.Count; i++)
            {
                DoubleVector4 point = points[i];
                DoubleVector4 res   = ChartCommon.interpolateInRect(viewRect, new DoubleVector3((point.x - min.x) / range.x, (point.y - min.y) / range.y));
                res.z = 0.0;
                res.w = point.w * radiusMultiplier;
                output.Add(res.ToVector4());
            }
        }
示例#4
0
        protected int ClipPoints(IList <DoubleVector3> points, List <DoubleVector4> res, out Rect uv)
        {
            double minX    = ((IInternalGraphData)Data).GetMinValue(0, false);
            double minY    = ((IInternalGraphData)Data).GetMinValue(1, false);
            double maxX    = ((IInternalGraphData)Data).GetMaxValue(0, false);
            double maxY    = ((IInternalGraphData)Data).GetMaxValue(1, false);
            double xScroll = GetScrollOffset(0) + minX;
            double yScroll = GetScrollOffset(1) + minY;
            double xSize   = maxX - minX;
            double ySize   = maxY - minY;
            double xOut    = xScroll + xSize;
            //float yOut = yScroll + ySize;
            bool prevOut = false;
            bool prevIn  = false;

            double maxXLocal = double.MinValue, minXLocal = double.MaxValue, maxYLocal = double.MinValue, minYLocal = double.MaxValue;

            minX = double.MaxValue;
            minY = double.MaxValue;
            maxX = double.MinValue;
            maxY = double.MinValue;
            int refrenceIndex = 0;

            for (int i = 0; i < points.Count; i++)
            {
                bool pOut = prevOut;
                bool pIn  = prevIn;
                prevOut = false;
                prevIn  = false;
                DoubleVector3 point = points[i];
                UpdateMinMax(points[i], ref minX, ref minY, ref maxX, ref maxY);

                if (point.x < xScroll || point.x > xOut) // || point.y < yScroll || point.y > yOut)
                {
                    prevOut = true;
                    if (pIn)
                    {
                        res.Add(point.ToDoubleVector4());
                        //   uv = CreateUvRect(new Rect(minX, minY, maxX - minX, maxY - minY), new Rect(minXLocal, minYLocal, maxXLocal - minXLocal, maxYLocal - minYLocal));
                        //   return refrenceIndex;
                    }
                    if (pOut)
                    {
                        if (point.x > xOut && points[i - 1].x < xScroll)
                        {
                            UpdateMinMax(points[i - 1], ref minXLocal, ref minYLocal, ref maxXLocal, ref maxYLocal);
                            UpdateMinMax(point, ref minXLocal, ref minYLocal, ref maxXLocal, ref maxYLocal);
                            res.Add(points[i - 1].ToDoubleVector4());
                            res.Add(point.ToDoubleVector4());
                        }
                    }
                }
                else
                {
                    prevIn = true;
                    if (pOut)
                    {
                        refrenceIndex = i - 1;
                        UpdateMinMax(points[i - 1], ref minXLocal, ref minYLocal, ref maxXLocal, ref maxYLocal);
                        res.Add(points[i - 1].ToDoubleVector4());
                    }
                    UpdateMinMax(point, ref minXLocal, ref minYLocal, ref maxXLocal, ref maxYLocal);
                    res.Add(point.ToDoubleVector4());
                }
            }
            for (int i = 0; i < res.Count; i++)
            {
                DoubleVector4 p = res[i];
                p.w    = p.z;
                p.z    = 0f;
                res[i] = p;
            }
            uv = CreateUvRect(new Rect((float)minX, (float)minY, (float)(maxX - minX), (float)(maxY - minY)), new Rect((float)minXLocal, (float)yScroll, (float)(maxXLocal - minXLocal), (float)(ySize)));
            return(refrenceIndex);
        }
        protected int ClipPoints(IList <DoubleVector3> points, List <DoubleVector4> res, out Rect uv)
        {
            double minX, minY, maxX, maxY, xScroll, yScroll, xSize, ySize, xOut;

            GetScrollParams(out minX, out minY, out maxX, out maxY, out xScroll, out yScroll, out xSize, out ySize, out xOut);

            bool prevOut = false;
            bool prevIn  = false;

            double maxXLocal = double.MinValue, minXLocal = double.MaxValue, maxYLocal = double.MinValue, minYLocal = double.MaxValue;

            minX = double.MaxValue;
            minY = double.MaxValue;
            maxX = double.MinValue;
            maxY = double.MinValue;
            int refrenceIndex = 0;

            for (int i = 0; i < points.Count; i++)
            {
                bool pOut = prevOut;
                bool pIn  = prevIn;
                prevOut = false;
                prevIn  = false;
                DoubleVector3 point = points[i];
                UpdateMinMax(points[i], ref minX, ref minY, ref maxX, ref maxY);

                if (point.x < xScroll || point.x > xOut) // || point.y < yScroll || point.y > yOut)
                {
                    prevOut = true;
                    if (pIn)
                    {
                        res.Add(point.ToDoubleVector4());
                        //   uv = CreateUvRect(new Rect(minX, minY, maxX - minX, maxY - minY), new Rect(minXLocal, minYLocal, maxXLocal - minXLocal, maxYLocal - minYLocal));
                        //   return refrenceIndex;
                    }
                    if (pOut)
                    {
                        if (point.x > xOut && points[i - 1].x < xScroll)
                        {
                            UpdateMinMax(points[i - 1], ref minXLocal, ref minYLocal, ref maxXLocal, ref maxYLocal);
                            UpdateMinMax(point, ref minXLocal, ref minYLocal, ref maxXLocal, ref maxYLocal);
                            res.Add(points[i - 1].ToDoubleVector4());
                            res.Add(point.ToDoubleVector4());
                        }
                    }
                }
                else
                {
                    prevIn = true;
                    if (pOut)
                    {
                        refrenceIndex = i - 1;
                        UpdateMinMax(points[i - 1], ref minXLocal, ref minYLocal, ref maxXLocal, ref maxYLocal);
                        res.Add(points[i - 1].ToDoubleVector4());
                    }
                    UpdateMinMax(point, ref minXLocal, ref minYLocal, ref maxXLocal, ref maxYLocal);
                    res.Add(point.ToDoubleVector4());
                }
            }
            for (int i = 0; i < res.Count; i++)
            {
                DoubleVector4 p = res[i];
                p.w    = p.z;
                p.z    = 0f;
                res[i] = p;
            }
            uv = CreateUvRect(new Rect((float)minX, (float)minY, (float)(maxX - minX), (float)(maxY - minY)), new Rect((float)minXLocal, (float)yScroll, (float)(maxXLocal - minXLocal), (float)(ySize)));
            return(refrenceIndex);
        }