Example #1
0
        public void DrawGrid(Gridding grid)
        {
            GL.PointSize(1);

            if (DC is DrawContextGLOrtho)
            {
                DrawGridOrtho(grid);
            }
            else if (DC is DrawContextGL)
            {
                DrawGridPerse(grid);
            }
        }
Example #2
0
        public virtual void DrawGrid(Gridding grid)
        {
            Vector3d lt = Vector3d.Zero;
            Vector3d rb = new Vector3d(DC.ViewWidth, DC.ViewHeight, 0);

            Vector3d ltw = DC.DevPointToWorldPoint(lt);
            Vector3d rbw = DC.DevPointToWorldPoint(rb);

            double minx = Math.Min(ltw.X, rbw.X);
            double maxx = Math.Max(ltw.X, rbw.X);

            double miny = Math.Min(ltw.Y, rbw.Y);
            double maxy = Math.Max(ltw.Y, rbw.Y);

            double minz = Math.Min(ltw.Z, rbw.Z);
            double maxz = Math.Max(ltw.Z, rbw.Z);


            DrawPen pen = DC.GetPen(DrawTools.PEN_GRID);

            Vector3d p = default(Vector3d);


            double n = grid.Decimate(DC, grid, 8);

            double x, y, z;
            double sx, sy, sz;
            double szx = grid.GridSize.X * n;
            double szy = grid.GridSize.Y * n;
            double szz = grid.GridSize.Z * n;

            sx = Math.Round(minx / szx) * szx;
            sy = Math.Round(miny / szy) * szy;
            sz = Math.Round(minz / szz) * szz;

            x = sx;
            while (x < maxx)
            {
                p.X = x;
                p.Z = 0;

                y = sy;

                while (y < maxy)
                {
                    p.Y = y;
                    DrawDot(pen, p);
                    y += szy;
                }

                x += szx;
            }

            z = sz;
            y = sy;

            while (z < maxz)
            {
                p.Z = z;
                p.X = 0;

                y = sy;

                while (y < maxy)
                {
                    p.Y = y;
                    DrawDot(pen, p);
                    y += szy;
                }

                z += szz;
            }

            z = sz;
            x = sx;

            while (x < maxx)
            {
                p.X = x;
                p.Y = 0;

                z = sz;

                while (z < maxz)
                {
                    p.Z = z;
                    DrawDot(pen, p);
                    z += szz;
                }

                x += szx;
            }
        }
Example #3
0
        /**
         * 画面上での間隔が min より大きくなるように間引く為のサイズの
         * 倍率を求める
         */
        public double Decimate(DrawContext dc, Gridding grid, double min)
        {
            double scaleX = 1.0;
            double scaleY = 1.0;
            double scaleZ = 1.0;

            double gridSizeX = grid.GridSize.X;
            double gridSizeY = grid.GridSize.Y;
            double gridSizeZ = grid.GridSize.Z;

            Vector3d devLen;
            double   t = 1;
            double   d;

            double devLenX;
            double devLenY;
            double devLenZ;

            // X axis
            devLen = dc.WorldVectorToDevVector(new Vector3d(gridSizeX, 0, 0));

            devLenX = Math.Max(Math.Abs(devLen.X), Math.Abs(devLen.Y));
            if (devLenX != 0 && devLenX < min)
            {
                d = Math.Ceiling(min / devLenX) * devLenX;
                t = d / devLenX;
            }

            if (t > scaleX)
            {
                scaleX = t;
            }


            // Y axis
            devLen = dc.WorldVectorToDevVector(new Vector3d(0, gridSizeY, 0));

            devLenY = Math.Max(Math.Abs(devLen.X), Math.Abs(devLen.Y));
            if (devLenY != 0 && devLenY < min)
            {
                d = Math.Ceiling(min / devLenY) * devLenY;
                t = d / devLenY;
            }

            if (t > scaleY)
            {
                scaleY = t;
            }


            // Z axis
            devLen = dc.WorldVectorToDevVector(new Vector3d(0, 0, gridSizeZ));

            devLenZ = Math.Max(Math.Abs(devLen.X), Math.Abs(devLen.Y));

            if (devLenZ != 0 && devLenZ < min)
            {
                d = Math.Ceiling(min / devLenZ) * devLenZ;
                t = d / devLenZ;
            }

            if (t > scaleZ)
            {
                scaleZ = t;
            }

            return(Math.Max(Math.Max(scaleX, scaleY), scaleZ));
        }
Example #4
0
 public void CopyFrom(Gridding g)
 {
     mGridSize = g.mGridSize;
     Range     = g.Range;
 }
Example #5
0
        protected void DrawGridPerse(Gridding grid)
        {
            //double minx = -100;
            //double maxx = 100;

            //double miny = -100;
            //double maxy = 100;

            //double minz = -100;
            //double maxz = 100;

            //DrawPen pen = DC.GetPen(DrawTools.PEN_GRID);

            //Vector3d p = default;

            //double x, y, z;
            //double sx, sy, sz;
            //double szx = grid.GridSize.X;
            //double szy = grid.GridSize.Y;
            //double szz = grid.GridSize.Z;

            //sx = Math.Round(minx / szx) * szx;
            //sy = Math.Round(miny / szy) * szy;
            //sz = Math.Round(minz / szz) * szz;

            //x = sx;
            //while (x < maxx)
            //{
            //    p.X = x;
            //    p.Z = 0;

            //    y = sy;

            //    while (y < maxy)
            //    {
            //        p.Y = y;
            //        DrawDot(pen, p);
            //        y += szy;
            //    }

            //    x += szx;
            //}

            //z = sz;
            //y = sy;

            //while (z < maxz)
            //{
            //    p.Z = z;
            //    p.X = 0;

            //    y = sy;

            //    while (y < maxy)
            //    {
            //        p.Y = y;
            //        DrawDot(pen, p);
            //        y += szy;
            //    }

            //    z += szz;
            //}

            //z = sz;
            //x = sx;

            //while (x < maxx)
            //{
            //    p.X = x;
            //    p.Y = 0;

            //    z = sz;

            //    while (z < maxz)
            //    {
            //        p.Z = z;
            //        DrawDot(pen, p);
            //        z += szz;
            //    }

            //    x += szx;
            //}
        }