internal string GetMouseOverText(Point pt)
        {
            int    x = pt.X, y = YRange.PxCount - 1 - pt.Y;
            double xval = XRange.PxToValue(x);
            double yval = YRange.PxToValue(y);

            if (Calcs.Count == 1)
            {
                var val = Calcs[0].GetValueAt(x, y);
                if (val != null)
                {
                    if (Calcs[0] is Calculator3D)
                    {
                        return("{0} @ ({1:G4}, {2:G4})".Localized(val.Value, xval, yval));
                    }
                    else
                    {
                        return("{0} @ X = {1:G8}".Localized(val.Value, xval));
                    }
                }
            }
            else if (Calcs.Count >= 2)
            {
                var fmt = Calcs.Count == 2 ? "G8" : "G5";
                return("{1} @ X = {0:G4}".Localized(xval,
                                                    string.Join("; ", Calcs.Select(c => (c.GetValueAt(x, y) ?? double.NaN).ToString(fmt)))));
            }
            return("");
        }
Пример #2
0
 internal void AddFeature(uint id, Envelope geometry, Interval?zRange, Interval?mRange)
 {
     NumRecords++;
     XRange = XRange.ExpandedByInterval(Interval.Create(geometry.MinX, geometry.MaxX));
     YRange = YRange.ExpandedByInterval(Interval.Create(geometry.MinY, geometry.MaxY));
     ZRange = ZRange.ExpandedByInterval(zRange ?? Interval.Create());
     MRange = MRange.ExpandedByInterval(mRange ?? Interval.Create());
 }
Пример #3
0
        private void UpdateRanges()
        {
            XRange.Freeze();
            YRange.Freeze();

            XRange.Update(0, 0);
            YRange.Update(0, 0);

            d_sortedData = null;
            bool makesorted = false;

            for (int i = 0; i < d_data.Count; ++i)
            {
                Point p = d_data[i];

                if (i == 0 || p.X < XRange.Min)
                {
                    XRange.Min = p.X;
                }

                if (i == 0 || p.X > XRange.Max)
                {
                    XRange.Max = p.X;
                }

                if (i == 0 || p.Y < YRange.Min)
                {
                    YRange.Min = p.Y;
                }

                if (i == 0 || p.Y > YRange.Max)
                {
                    YRange.Max = p.Y;
                }

                if (makesorted)
                {
                    d_sortedData.Add(p);
                }

                if (i != 0 && !makesorted && d_data[i - 1].X > p.X)
                {
                    makesorted = true;

                    d_sortedData = new SortedList <Point>(new PointComparer());

                    for (int j = 0; j <= i; ++j)
                    {
                        d_sortedData.Add(d_data[i]);
                    }
                }
            }

            XRange.Thaw();
            YRange.Thaw();
        }
        public Range3Single Intersect(Range3Single other)
        {
            var xrange = XRange.Intersect(other.XRange);
            var yrange = YRange.Intersect(other.YRange);
            var zrange = ZRange.Intersect(other.ZRange);

            return(new Range3Single
                       (new Vector3(xrange.Min, yrange.Min, zrange.Min),
                       new Vector3(xrange.Max, yrange.Max, zrange.Max)));
        }
        void DrawGridLines(Graphics g)
        {
            // Draw vertical lines based on X axis
            double xLo, xInterval = ChooseGridSpacing(out xLo, XRange);

            for (double x = xLo; x <= XRange.Hi; x += xInterval)
            {
                float px = (float)XRange.ValueToPx(x);
                g.DrawLine(XRange.LinePen, px, 0, px, YRange.PxCount);
            }
            if (XRange.Lo <= 0 && 0 <= XRange.Hi)
            {
                float px = (float)XRange.ValueToPx(0);
                g.DrawLine(XRange.AxisPen, px, 0, px, YRange.PxCount);
            }

            // Draw horizontal lines based on Y axis
            double yLo, yInterval = ChooseGridSpacing(out yLo, YRange);

            for (double y = yLo; y <= YRange.Hi; y += yInterval)
            {
                float px = YRange.PxCount - 1 - (float)YRange.ValueToPx(y);
                g.DrawLine(YRange.LinePen, 0, px, XRange.PxCount, px);
            }
            if (YRange.Lo <= 0 && 0 <= YRange.Hi)
            {
                float px = YRange.PxCount - 1 - (float)YRange.ValueToPx(0);
                g.DrawLine(YRange.AxisPen, 0, px, XRange.PxCount, px);
            }

            // Draw numeric labels
            float lastWidth = 0, lastPx = -1000;

            for (double x = xLo; x <= XRange.Hi; x += xInterval)
            {
                float px = (float)XRange.ValueToPx(x);
                if (px > 20 && px - lastPx > lastWidth)
                {
                    lastWidth = DrawText(g, x.ToString("G7"), px, Bitmap.Height - 4, XRange.AxisPen.Color, StringAlignment.Center, StringAlignment.Far).Width;
                    lastPx    = px;
                }
            }
            for (double y = yLo; y <= YRange.Hi; y += yInterval)
            {
                float px = Bitmap.Height - 1 - (float)YRange.ValueToPx(y);
                if (px > 10 && px < Bitmap.Height - 40)
                {
                    DrawText(g, y.ToString("G7"), 4, px, YRange.AxisPen.Color, StringAlignment.Near, StringAlignment.Center);
                }
            }
        }
        void RenderXFunc(Graphics g, double[] data, Pen pen)
        {
            if (data.Length == 0 || YRange.Lo >= YRange.Hi)
            {
                return;
            }

            g.SmoothingMode = SmoothingMode.AntiAlias;
            PointF[] points = new PointF[data.Length];
            int      x;

            for (x = 0; x < data.Length; x++)
            {
                float y = (float)(YRange.PxCount - 1 - YRange.ValueToPx(data[x]));
                points[x] = new PointF(x, (float)y);
            }
            DrawLinesSafe(g, pen, points);
        }
Пример #7
0
 public bool ContainsPoint(double x, double y, double z)
 {
     return(XRange.Contains(x) && YRange.Contains(y) && ZRange.Contains(z));
 }
Пример #8
0
        public override void Interpolate(Point3d position, Voxel voxel)
        {
            voxel.Position.X = position.X;
            voxel.Position.Y = position.Y;
            voxel.Position.Z = position.Z;

            if (!XRange.Contains(position.X) || !YRange.Contains(position.Y) || !ZRange.Contains(position.Z))
            {
                voxel.Value = DefaultPhysicalValue;
            }
            else
            {
                try
                {
                    //float x0 = 0, x1 = 0, y0 = 0, y1 = 0, z0 = 0, z1 = 0;
                    //int ix0 = 0, ix1 = 0, iy0 = 0, iy1 = 0, iz0 = 0, iz1 = 0;

                    if (ConstantGridSpacing)
                    {
                        ix0 = (int)((position.X - XCoords[0]) / GridSpacing.X);
                        if (ix0 >= XCoords.Length - 1)
                        {
                            ix1 = ix0 = XCoords.Length - 1;
                        }
                        else
                        {
                            ix1 = ix0 + 1;
                        }
                        x0 = XCoords[ix0];
                        x1 = XCoords[ix1];

                        iy0 = (int)((position.Y - YCoords[0]) / GridSpacing.Y);
                        if (iy0 >= YCoords.Length - 1)
                        {
                            iy1 = iy0 = YCoords.Length - 1;
                        }
                        else
                        {
                            iy1 = iy0 + 1;
                        }

                        y0 = YCoords[iy0];
                        y1 = YCoords[iy1];
                        if (GridSpacing.Z != 0)
                        {
                            iz0 = (int)((position.Z - ZCoords[0]) / GridSpacing.Z);
                            iz1 = iz0 + 1;

                            if (iz0 >= ZCoords.Length - 1)
                            {
                                iz1 = iz0 = ZCoords.Length - 1;
                            }
                            else
                            {
                                iz1 = iz0 + 1;
                            }

                            z0 = ZCoords[iz0];
                            z1 = ZCoords[iz1];
                        }
                        else
                        {
                            iz0 = 0; iz1 = 0;
                            z0  = ZCoords[iz0];
                            z1  = ZCoords[iz1];
                        }
                    }
                    else
                    {
                        var xt = binarySearchForSurroundingCoords(position.X, XCoords);
                        x0  = (float)xt.Item1;
                        x1  = (float)xt.Item2;
                        ix0 = xt.Item3;
                        ix1 = xt.Item4;
                        var yt = binarySearchForSurroundingCoords(position.Y, YCoords);
                        y0  = (float)yt.Item1;
                        y1  = (float)yt.Item2;
                        iy0 = yt.Item3;
                        iy1 = yt.Item4;
                        var zt = binarySearchForSurroundingCoords(position.Z, ZCoords);
                        z0  = (float)zt.Item1;
                        z1  = (float)zt.Item2;
                        iz0 = zt.Item3;
                        iz1 = zt.Item4;
                    }

                    voxel.Value = Interpolation.TrilinearInterpolate(
                        (float)position.X, (float)position.Y, (float)position.Z,
                        x0, y0, z0,
                        x1, y1, z1,
                        Data[getIndex(ix0, iy0, iz0)],
                        Data[getIndex(ix1, iy0, iz0)],
                        Data[getIndex(ix0, iy0, iz1)],
                        Data[getIndex(ix1, iy0, iz1)],
                        Data[getIndex(ix0, iy1, iz0)],
                        Data[getIndex(ix1, iy1, iz0)],
                        Data[getIndex(ix0, iy1, iz1)],
                        Data[getIndex(ix1, iy1, iz1)]);
                }
#pragma warning disable CS0168 // The variable 'e' is declared but never used
                catch (Exception e)
#pragma warning restore CS0168 // The variable 'e' is declared but never used
                {
                    voxel.Value = DefaultPhysicalValue;
                }
            }
        }
Пример #9
0
 public override string ToString()
 {
     return($"(XRange = {XRange.ToString()}, YRange = {YRange.ToString()}, ZRange = {ZRange.ToString()})");
 }
Пример #10
0
 public double Distance2(Vector2 point)
 {
     return(XRange.Distance2(point.X) + YRange.Distance2(point.Y));
 }
Пример #11
0
        // ----------------------------------------------------------------------------------------
        #region WireframeDimensions

        public void UpdateDimensions(Single3 origin)
        {
            XRange = XRange.Add(origin.X);
            YRange = YRange.Add(origin.Y);
            ZRange = ZRange.Add(origin.Z);
        }
Пример #12
0
        public override void Interpolate(Point3d position, Voxel voxel)
        {
            voxel.Position.X = position.X;
            voxel.Position.Y = position.Y;
            voxel.Position.Z = position.Z;

            if (!XRange.Contains(position.X) || !YRange.Contains(position.Y) || !ZRange.Contains(position.Z))
            {
                voxel.Value = 0;
            }
            else
            {
                float x0 = 0, x1 = 0, y0 = 0, y1 = 0, z0 = 0, z1 = 0;
                int   ix0 = 0, ix1 = 0, iy0 = 0, iy1 = 0, iz0 = 0, iz1 = 0;

                if (ConstantGridSpacing)
                {
                    ix0 = (int)((position.X - XCoords[0]) / GridSpacing.X);
                    ix1 = ix0 == XCoords.Length - 1 ? ix0 : ix0 + 1;
                    x0  = (float)XCoords[ix0];
                    x1  = (float)XCoords[ix1];
                    iy0 = (int)((position.Y - YCoords[0]) / GridSpacing.Y);
                    iy1 = iy0 == YCoords.Length - 1 ? iy0 : iy0 + 1;
                    y0  = (float)YCoords[iy0];
                    y1  = (float)YCoords[iy1];
                    if (GridSpacing.Z != 0)
                    {
                        iz0 = (int)((position.Z - ZCoords[0]) / GridSpacing.Z);
                        iz1 = iz0 == ZCoords.Length - 1 ? iz0 : iz0 + 1;
                        z0  = (float)ZCoords[iz0];
                        z1  = (float)ZCoords[iz1];
                    }
                    else
                    {
                        iz0 = 0; iz1 = 0;
                        z0  = (float)ZCoords[iz0];
                        z1  = (float)ZCoords[iz1];
                    }
                }
                else
                {
                    var xt = binarySearchForSurroundingCoords(position.X, XCoords);
                    x0  = (float)xt.Item1;
                    x1  = (float)xt.Item2;
                    ix0 = xt.Item3;
                    ix1 = xt.Item4;
                    var yt = binarySearchForSurroundingCoords(position.Y, YCoords);
                    y0  = (float)yt.Item1;
                    y1  = (float)yt.Item2;
                    iy0 = yt.Item3;
                    iy1 = yt.Item4;
                    var zt = binarySearchForSurroundingCoords(position.Z, ZCoords);
                    z0  = (float)zt.Item1;
                    z1  = (float)zt.Item2;
                    iz0 = zt.Item3;
                    iz1 = zt.Item4;
                }
                float xd;
                if (x1 == x0)
                {
                    xd = 0;
                }
                else
                {
                    xd = (float)(position.X - x0) / (x1 - x0);
                }
                double yd;
                if (y1 == y0)
                {
                    yd = 0;
                }
                else
                {
                    yd = (position.Y - y0) / (y1 - y0);
                }
                double zd;
                if (z1 == z0)
                {
                    zd = 0;
                }
                else
                {
                    zd = (position.Z - z0) / (z1 - z0);
                }
                float c00 = Data[ix0, iy0, iz0] * (1 - xd) + Data[ix1, iy0, iz0] * xd;
                float c01 = Data[ix0, iy0, iz1] * (1 - xd) + Data[ix1, iy0, iz1] * xd;
                float c10 = Data[ix0, iy1, iz0] * (1 - xd) + Data[ix1, iy1, iz0] * xd;
                float c11 = Data[ix0, iy1, iz1] * (1 - xd) + Data[ix1, iy1, iz1] * xd;
                float c0  = (float)(c00 * (1 - yd) + c10 * yd);
                float c1  = (float)(c01 * (1 - yd) + c11 * yd);
                float c   = (float)(c0 * (1 - zd) + c1 * zd);

                voxel.Value = c;
            }
        }