Example #1
0
        public static CadCursor Create()
        {
            CadCursor cc = default(CadCursor);

            cc.DirX = Vector3d.UnitX;
            cc.DirY = Vector3d.UnitY;

            return(cc);
        }
Example #2
0
        public void DrawCrossCursorScrn(CadCursor pp, DrawPen pen)
        {
            double size = Math.Max(DC.ViewWidth, DC.ViewHeight);

            Vector3d p0 = pp.Pos - (pp.DirX * size);
            Vector3d p1 = pp.Pos + (pp.DirX * size);

            DrawLineScrn(pen, p0.X, p0.Y, p1.X, p1.Y);

            p0 = pp.Pos - (pp.DirY * size);
            p1 = pp.Pos + (pp.DirY * size);

            DrawLineScrn(pen, p0.X, p0.Y, p1.X, p1.Y);
        }
Example #3
0
        public RulerInfo Capture(DrawContext dc, CadCursor cursor, double rangePixel)
        {
            RulerInfo match = default(RulerInfo);
            RulerInfo ri    = default(RulerInfo);

            double min = rangePixel;

            MatchIndex = -1;

            for (int i = 0; i < RCount; i++)
            {
                ri = Ruler[i].Capture(dc, cursor, rangePixel);

                if (ri.IsValid && ri.Distance < min)
                {
                    min        = ri.Distance;
                    match      = ri;
                    MatchIndex = i;
                }
            }

            return(match);
        }
Example #4
0
        public void DrawCrossCursorScrn(CadCursor pp, DrawPen pen)
        {
            double size = Math.Max(DC.ViewWidth, DC.ViewHeight);

            Vector3d p0 = pp.Pos - (pp.DirX * size);
            Vector3d p1 = pp.Pos + (pp.DirX * size);

            p0 = DC.DevPointToWorldPoint(p0);
            p1 = DC.DevPointToWorldPoint(p1);

            GL.Disable(EnableCap.DepthTest);

            DrawLine(pen, p0, p1);

            p0 = pp.Pos - (pp.DirY * size);
            p1 = pp.Pos + (pp.DirY * size);

            p0 = DC.DevPointToWorldPoint(p0);
            p1 = DC.DevPointToWorldPoint(p1);

            DrawLine(pen, p0, p1);

            GL.Enable(EnableCap.DepthTest);
        }
Example #5
0
        public RulerInfo Capture(DrawContext dc, CadCursor cursor, double range)
        {
            RulerInfo ret = default(RulerInfo);

            Vector3d cwp = dc.DevPointToWorldPoint(cursor.Pos);

            Vector3d xfaceNormal = dc.DevVectorToWorldVector(cursor.DirX);
            Vector3d yfaceNormal = dc.DevVectorToWorldVector(cursor.DirY);

            Vector3d cx = CadMath.CrossPlane(P0, P1, cwp, xfaceNormal);
            Vector3d cy = CadMath.CrossPlane(P0, P1, cwp, yfaceNormal);

            if (!cx.IsValid() && !cy.IsValid())
            {
                return(ret);
            }

            Vector3d p    = VectorExt.InvalidVector3d;
            double   mind = Double.MaxValue;

            StackArray <Vector3d> vtbl = default;

            vtbl[0]     = cx;
            vtbl[1]     = cy;
            vtbl.Length = 2;

            for (int i = 0; i < vtbl.Length; i++)
            {
                Vector3d v = vtbl[i];

                if (!v.IsValid())
                {
                    continue;
                }

                Vector3d devv = dc.WorldPointToDevPoint(v);

                double td = (devv - cursor.Pos).Norm();

                if (td < mind)
                {
                    mind = td;
                    p    = v;
                }
            }

            if (!p.IsValid())
            {
                return(ret);
            }

            if (mind > range)
            {
                return(ret);
            }

            ret.IsValid    = true;
            ret.CrossPoint = p;
            ret.Distance   = mind;

            ret.Ruler = this;

            return(ret);
        }
Example #6
0
 public void SetTargetPoint(CadCursor cursor)
 {
     Target = cursor;
 }