Esempio n. 1
0
        private void DrawRect2D(Vector3d p0, Vector3d p1, DrawPen pen)
        {
            Vector3d v0 = Vector3d.Zero;
            Vector3d v1 = Vector3d.Zero;
            Vector3d v2 = Vector3d.Zero;
            Vector3d v3 = Vector3d.Zero;

            v0.X = System.Math.Max(p0.X, p1.X);
            v0.Y = System.Math.Min(p0.Y, p1.Y);

            v1.X = v0.X;
            v1.Y = System.Math.Max(p0.Y, p1.Y);

            v2.X = System.Math.Min(p0.X, p1.X);
            v2.Y = v1.Y;

            v3.X = v2.X;
            v3.Y = v0.Y;

            Start2D();

            GL.Begin(PrimitiveType.LineStrip);

            GL.Color4(pen.Color4());
            GL.Vertex3(v0);
            GL.Vertex3(v1);
            GL.Vertex3(v2);
            GL.Vertex3(v3);
            GL.Vertex3(v0);

            GL.End();

            End2D();
        }
Esempio n. 2
0
        public void DrawRectScrn(DrawPen pen, Vector3d pp0, Vector3d pp1)
        {
            Vector3d p0 = DC.DevPointToWorldPoint(pp0);
            Vector3d p1 = DC.DevPointToWorldPoint(pp1);

            DrawRect(pen, p0, p1);
        }
Esempio n. 3
0
        public void DrawCross(DrawPen pen, Vector3d p, double size)
        {
            GL.Disable(EnableCap.Lighting);
            GL.Disable(EnableCap.Light0);

            double hs = size;

            Vector3d px0 = p;

            px0.X -= hs;
            Vector3d px1 = p;

            px1.X += hs;

            Vector3d py0 = p;

            py0.Y -= hs;
            Vector3d py1 = p;

            py1.Y += hs;

            Vector3d pz0 = p;

            pz0.Z -= hs;
            Vector3d pz1 = p;

            pz1.Z += hs;

            DrawLine(pen, px0, px1);
            DrawLine(pen, py0, py1);
            DrawLine(pen, pz0, pz1);
        }
Esempio n. 4
0
        private void SetupPrinterSet(int penW)
        {
            AllocGDITbl();

            ColorSet colorSet = PrintColors.Instance;

            PenColorTbl   = colorSet.PenColorTbl;
            BrushColorTbl = colorSet.BrushColorTbl;

            for (int i = 0; i < PEN_TBL_SIZE; i++)
            {
                PenTbl[i]    = new DrawPen(new Pen(PenColorTbl[i], penW));
                PenTbl[i].ID = i;
            }

            for (int i = 0; i < BRUSH_TBL_SIZE; i++)
            {
                BrushTbl[i]    = new DrawBrush(new SolidBrush(BrushColorTbl[i]));
                BrushTbl[i].ID = i;
            }

            BrushTbl[BRUSH_BACKGROUND].Dispose();

            //FontFamily fontFamily = LoadFontFamily("/Fonts/mplus-1m-thin.ttf");
            //FontFamily fontFamily = new FontFamily("MS UI Gothic");
            FontFamily fontFamily = new FontFamily("MS ゴシック");

            FontTbl[FONT_DEFAULT] = new Font(fontFamily, FONT_SIZE_DEFAULT);
            FontTbl[FONT_SMALL]   = new Font(fontFamily, FONT_SIZE_SMALL);
        }
Esempio n. 5
0
        public static CadVertex DrawBezier3(
            CadVertex p0, CadVertex p1, CadVertex p2, int s, DrawContext dc, DrawPen pen)
        {
            double t = 0;
            double d = 1.0 / (double)s;

            t = d;

            int n = 3;

            CadVertex t0 = p0;
            CadVertex t1 = p0;

            while (t <= 1.0)
            {
                t1  = default;
                t1 += p0 * BezierFuncs.BernsteinBasisF(n - 1, 0, t);
                t1 += p1 * BezierFuncs.BernsteinBasisF(n - 1, 1, t);
                t1 += p2 * BezierFuncs.BernsteinBasisF(n - 1, 2, t);

                dc.Drawing.DrawLine(pen, t0.vector, t1.vector);

                t0 = t1;

                t += d;
            }

            return(t1);
        }
Esempio n. 6
0
 public void DrawExtSnapPoints(Vector3dList pointList, DrawPen pen)
 {
     pointList.ForEach(v =>
     {
         DrawHighlightPoint(v, pen);
     });
 }
Esempio n. 7
0
        public void DrawCross(DrawPen pen, Vector3d p, double size)
        {
            double hs = size;

            Vector3d px0 = p;

            px0.X -= hs;
            Vector3d px1 = p;

            px1.X += hs;

            Vector3d py0 = p;

            py0.Y -= hs;
            Vector3d py1 = p;

            py1.Y += hs;

            Vector3d pz0 = p;

            pz0.Z -= hs;
            Vector3d pz1 = p;

            pz1.Z += hs;

            DrawLine(pen, px0, px1);
            DrawLine(pen, py0, py1);
            DrawLine(pen, pz0, pz1);
        }
Esempio n. 8
0
        private void drawCircle(DrawContext dc, DrawPen pen)
        {
            if (PointList.Count == 0)
            {
                return;
            }

            if (PointList.Count == 1)
            {
                dc.Drawing.DrawCross(pen, PointList[0].vector, 2);
                if (PointList[0].Selected)
                {
                    dc.Drawing.DrawSelectedPoint(PointList[0].vector, dc.GetPen(DrawTools.PEN_SELECT_POINT));
                }
                return;
            }

            Vector3d normal = CadMath.Normal(PointList[0].vector, PointList[2].vector, PointList[1].vector);

            CircleExpander.Draw(PointList[0], PointList[1], PointList[2], 32, dc, pen);

            double size = dc.DevSizeToWoldSize(4);

            dc.Drawing.DrawCross(pen, PointList[0].vector, size);
        }
Esempio n. 9
0
        protected void DrawRectangleScrn(DrawPen pen, double x0, double y0, double x1, double y1)
        {
            if (pen.GdiPen == null)
            {
                return;
            }

            int lx = (int)x0;
            int rx = (int)x1;

            int ty = (int)y0;
            int by = (int)y1;

            if (x0 > x1)
            {
                lx = (int)x1;
                rx = (int)x0;
            }

            if (y0 > y1)
            {
                ty = (int)y1;
                by = (int)y0;
            }

            int dx = rx - lx;
            int dy = by - ty;

            DC.GdiGraphics.DrawRectangle(pen.GdiPen, lx, ty, dx, dy);
        }
Esempio n. 10
0
        public void DrawBouncingBox(DrawPen pen, MinMax3D mm)
        {
            Vector3d p0 = new Vector3d(mm.Min.X, mm.Min.Y, mm.Min.Z);
            Vector3d p1 = new Vector3d(mm.Min.X, mm.Min.Y, mm.Max.Z);
            Vector3d p2 = new Vector3d(mm.Max.X, mm.Min.Y, mm.Max.Z);
            Vector3d p3 = new Vector3d(mm.Max.X, mm.Min.Y, mm.Min.Z);

            Vector3d p4 = new Vector3d(mm.Min.X, mm.Max.Y, mm.Min.Z);
            Vector3d p5 = new Vector3d(mm.Min.X, mm.Max.Y, mm.Max.Z);
            Vector3d p6 = new Vector3d(mm.Max.X, mm.Max.Y, mm.Max.Z);
            Vector3d p7 = new Vector3d(mm.Max.X, mm.Max.Y, mm.Min.Z);

            DC.Drawing.DrawLine(pen, p0, p1);
            DC.Drawing.DrawLine(pen, p1, p2);
            DC.Drawing.DrawLine(pen, p2, p3);
            DC.Drawing.DrawLine(pen, p3, p0);

            DC.Drawing.DrawLine(pen, p4, p5);
            DC.Drawing.DrawLine(pen, p5, p6);
            DC.Drawing.DrawLine(pen, p6, p7);
            DC.Drawing.DrawLine(pen, p7, p4);

            DC.Drawing.DrawLine(pen, p0, p4);
            DC.Drawing.DrawLine(pen, p1, p5);
            DC.Drawing.DrawLine(pen, p2, p6);
            DC.Drawing.DrawLine(pen, p3, p7);
        }
Esempio n. 11
0
        public void DrawRect(DrawPen pen, Vector3d p0, Vector3d p1)
        {
            GL.Disable(EnableCap.DepthTest);

            Vector3d pp0 = DC.WorldPointToDevPoint(p0);
            Vector3d pp2 = DC.WorldPointToDevPoint(p1);

            Vector3d pp1 = pp0;

            pp1.Y = pp2.Y;

            Vector3d pp3 = pp0;

            pp3.X = pp2.X;

            pp0 = DC.DevPointToWorldPoint(pp0);
            pp1 = DC.DevPointToWorldPoint(pp1);
            pp2 = DC.DevPointToWorldPoint(pp2);
            pp3 = DC.DevPointToWorldPoint(pp3);

            DrawLine(pen, pp0, pp1);
            DrawLine(pen, pp1, pp2);
            DrawLine(pen, pp2, pp3);
            DrawLine(pen, pp3, pp0);

            GL.Enable(EnableCap.DepthTest);
        }
Esempio n. 12
0
        public void DrawRect(DrawPen pen, Vector3d p0, Vector3d p1)
        {
            Vector3d pp0 = DC.WorldPointToDevPoint(p0);
            Vector3d pp1 = DC.WorldPointToDevPoint(p1);

            DrawRectangleScrn(pen, pp0.X, pp0.Y, pp1.X, pp1.Y);
        }
Esempio n. 13
0
        public override void DrawSeg(DrawContext dc, DrawPen pen, int idxA, int idxB)
        {
            CadVertex a = PointList[idxA];
            CadVertex b = PointList[idxB];

            dc.Drawing.DrawLine(pen, a.vector, b.vector);
        }
Esempio n. 14
0
        public void DrawHighlightPoint(Vector3d pt, DrawPen pen)
        {
            Vector3d pp = DC.WorldPointToDevPoint(pt);

            //DrawCircleScrn(pen, pp, 3);

            DrawCrossScrn(pen, pp, 4);
        }
Esempio n. 15
0
            public override void DrawTemp(DrawContext dc, CadVertex tp, DrawPen pen)
            {
                if (Figure.PointList.Count <= 0)
                {
                    return;
                }

                dc.Drawing.DrawRect(pen, Figure.PointList[0].vector, tp.vector);
            }
Esempio n. 16
0
        protected void DrawLineScrn(DrawPen pen, Vector3d a, Vector3d b)
        {
            if (pen.GdiPen == null)
            {
                return;
            }

            DC.GdiGraphics.DrawLine(pen.GdiPen, (int)a.X, (int)a.Y, (int)b.X, (int)b.Y);
        }
Esempio n. 17
0
        protected void DrawLineScrn(DrawPen pen, double x1, double y1, double x2, double y2)
        {
            if (pen.GdiPen == null)
            {
                return;
            }

            DC.GdiGraphics.DrawLine(pen.GdiPen, (int)x1, (int)y1, (int)x2, (int)y2);
        }
Esempio n. 18
0
        public void DrawDot(DrawPen pen, Vector3d p)
        {
            GL.Color4(pen.Color4());

            GL.Begin(PrimitiveType.Points);

            GL.Vertex3(p);

            GL.End();
        }
Esempio n. 19
0
 public void DrawSelectedPoints(VertexList pointList, DrawPen pen)
 {
     foreach (CadVertex p in pointList)
     {
         if (p.Selected)
         {
             DrawSelectedPoint(p.vector, pen);
         }
     }
 }
Esempio n. 20
0
        public virtual void DrawDot(DrawPen pen, Vector3d p)
        {
            Vector3d p0 = DC.WorldPointToDevPoint(p);
            Vector3d p1 = p0;

            p0.X = (int)p0.X;
            p1.X = p0.X + 0.1;

            DC.GdiGraphics.DrawLine(pen.GdiPen, (float)p0.X, (float)p0.Y, (float)p1.X, (float)p1.Y);
        }
Esempio n. 21
0
        protected void DrawCircleScrn(DrawPen pen, Vector3d cp, double r)
        {
            if (pen.GdiPen == null)
            {
                return;
            }

            DC.GdiGraphics.DrawEllipse(
                pen.GdiPen, (int)(cp.X - r), (int)(cp.Y - r), (int)(r * 2), (int)(r * 2));
        }
Esempio n. 22
0
        private void DrawLineRaw(DrawPen pen, Vector3d a, Vector3d b)
        {
            GL.Color4(pen.Color4());

            GL.Begin(PrimitiveType.LineStrip);

            GL.Vertex3(a);
            GL.Vertex3(b);

            GL.End();
        }
Esempio n. 23
0
        public void DrawHarfEdgeModel(
            DrawBrush brush, DrawPen pen, DrawPen edgePen, double edgeThreshold, HeModel model)
        {
            DrawHeFaces(brush, model);
            DrawHeEdges(pen, edgePen, edgeThreshold, model);

            if (SettingsHolder.Settings.DrawNormal)
            {
                DrawHeFacesNormal(model);
            }
        }
Esempio n. 24
0
        private void drawPoint(DrawContext dc, DrawPen pen)
        {
            if (PointList.Count == 0)
            {
                return;
            }

            double size = dc.DevSizeToWoldSize(4);

            dc.Drawing.DrawCross(pen, PointList[0].vector, size);
        }
Esempio n. 25
0
            public override void DrawTemp(DrawContext dc, CadVertex tp, DrawPen pen)
            {
                if (Figure.PointCount == 0)
                {
                    return;
                }

                CadVertex lastPt = Figure.PointList[Figure.PointCount - 1];

                dc.Drawing.DrawLine(pen, lastPt.vector, tp.vector);
            }
Esempio n. 26
0
        private void DrawNurbs(DrawContext dc, DrawPen pen)
        {
            if (PointList.Count < 2)
            {
                return;
            }

            DrawSurfaces(dc, pen);

            DrawControlPoints(dc,
                              dc.GetPen(DrawTools.PEN_NURBS_CTRL_LINE));
        }
Esempio n. 27
0
        public void DrawLine(DrawPen pen, Vector3d a, Vector3d b)
        {
            if (pen.GdiPen == null)
            {
                return;
            }

            Vector3d pa = DC.WorldPointToDevPoint(a);
            Vector3d pb = DC.WorldPointToDevPoint(b);

            DC.GdiGraphics.DrawLine(pen.GdiPen, (int)pa.X, (int)pa.Y, (int)pb.X, (int)pb.Y);
        }
Esempio n. 28
0
        public void DrawSelectedPoint(Vector3d pt, DrawPen pen)
        {
            Vector3d pp = DC.WorldPointToDevPoint(pt);

            int size = 2;

            DrawRectangleScrn(
                pen,
                (int)pp.X - size, (int)pp.Y - size,
                (int)pp.X + size, (int)pp.Y + size
                );
        }
Esempio n. 29
0
        public void DrawMarkCursor(DrawPen pen, Vector3d p, double pix_size)
        {
            GL.Disable(EnableCap.DepthTest);

            //Vector3d size = DC.DevVectorToWorldVector(Vector3d.UnitX * pix_size);
            //DrawCross(pen, p, size.Norm());

            double size = DC.DevSizeToWoldSize(pix_size);

            DrawCross(pen, p, size);

            GL.Enable(EnableCap.DepthTest);
        }
Esempio n. 30
0
        public void DrawHarfEdgeModel(
            DrawBrush brush, DrawPen pen, DrawPen edgePen, double edgeThreshold, HeModel model)
        {
            for (int i = 0; i < model.FaceStore.Count; i++)
            {
                HeFace f = model.FaceStore[i];

                HalfEdge head = f.Head;

                HalfEdge c = head;

                HalfEdge pair;

                for (; ;)
                {
                    bool edge = false;

                    pair = c.Pair;

                    if (pair == null)
                    {
                        edge = true;
                    }
                    else
                    {
                        double s = CadMath.InnerProduct(model.NormalStore[c.Normal], model.NormalStore[pair.Normal]);

                        if (Math.Abs(s) < edgeThreshold)
                        {
                            edge = true;
                        }
                    }

                    HalfEdge next = c.Next;

                    DrawPen dpen = edge ? edgePen : pen;

                    DrawLine(dpen,
                             model.VertexStore.Ref(c.Vertex).vector,
                             model.VertexStore.Ref(next.Vertex).vector
                             );

                    c = next;

                    if (c == head)
                    {
                        break;
                    }
                }
            }
        }