Пример #1
0
        protected void FillRectangleScrn(DrawBrush brush, double x0, double y0, double x1, double y1)
        {
            if (brush.GdiBrush == 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.FillRectangle(brush.GdiBrush, lx, ty, dx, dy);
        }
Пример #2
0
        public void DrawText(int font, DrawBrush brush, Vector3d a, Vector3d xdir, Vector3d ydir, DrawTextOption opt, string s)
        {
            Vector3d pa = DC.WorldPointToDevPoint(a);
            Vector3d d  = DC.WorldVectorToDevVector(xdir);

            DrawTextScrn(font, brush, pa, d, opt, s);
        }
Пример #3
0
        private void DrawTextScrn(int font, DrawBrush brush, Vector3d a, Vector3d xdir, Vector3d ydir, string s, double imgScale, DrawTextOption opt)
        {
            Start2D();

            FontTex tex = mFontFaceW.CreateTexture(s);

            Vector3d xv = xdir.UnitVector() * tex.ImgW * imgScale;
            Vector3d yv = ydir.UnitVector() * tex.ImgH * imgScale;

            if ((opt.Option & DrawTextOption.H_CENTER) != 0)
            {
                a -= (xv / 2);
            }

            if (xv.IsZero() || yv.IsZero())
            {
                return;
            }

            GL.Color4(brush.Color4());

            mFontRenderer.Render(tex, a, xv, yv);

            End2D();
        }
Пример #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);
        }
Пример #5
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);
            }
        }
Пример #6
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;
                    }
                }
            }
        }
Пример #7
0
        private void DrawTextScrn(int font, DrawBrush brush, Vector3d a, Vector3d dir, DrawTextOption opt, string s)
        {
            if (brush.GdiBrush == null)
            {
                return;
            }
            if (DC.Font(font) == null)
            {
                return;
            }

            if (opt.Option != 0)
            {
                Vector3d sz = MeasureText(font, s);

                if ((opt.Option | DrawTextOption.H_CENTER) != 0)
                {
                    double slen = sz.X / 2;

                    Vector3d ud = Vector3d.UnitX;

                    if (!dir.IsZero())
                    {
                        ud = dir.UnitVector();
                    }

                    a = a - (ud * slen);
                }
            }

            double angle = 0;

            if (!(dir.X == 0 && dir.Y == 0))
            {
                angle = CadMath.Angle2D(dir);
            }

            angle = CadMath.Rad2Deg(angle);

            DC.GdiGraphics.TranslateTransform((int)a.X, (int)a.Y);

            DC.GdiGraphics.RotateTransform((float)angle);

            Font  f = DC.Font(font);
            Brush b = brush.GdiBrush;

            DC.GdiGraphics.DrawString(s, f, b, 0, 0);

            DC.GdiGraphics.ResetTransform();
        }
Пример #8
0
        private void DrawHeFaces(DrawBrush brush, HeModel model)
        {
            if (brush.IsNullBrush)
            {
                return;
            }

            EnableLight();

            for (int i = 0; i < model.FaceStore.Count; i++)
            {
                HeFace f = model.FaceStore[i];

                HalfEdge head = f.Head;

                HalfEdge c = head;

                GL.Begin(PrimitiveType.Polygon);
                GL.Color4(brush.Color4());

                if (f.Normal != HeModel.INVALID_INDEX)
                {
                    Vector3d nv = model.NormalStore[f.Normal];
                    GL.Normal3(nv);
                }

                for (; ;)
                {
                    GL.Vertex3((model.VertexStore.Ref(c.Vertex).vector *DC.WorldScale));

                    c = c.Next;

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

                GL.End();
            }

            DisableLight();
        }
Пример #9
0
        public void DrawText(int font, DrawBrush brush, Vector3d a, Vector3d xdir, Vector3d ydir, DrawTextOption opt, string s)
        {
            a *= DC.WorldScale;

            FontTex tex = mFontFaceW.CreateTexture(s);

            Vector3d xv = xdir.UnitVector() * tex.ImgW * 0.15;
            Vector3d yv = ydir.UnitVector() * tex.ImgH * 0.15;

            if (xv.IsZero() || yv.IsZero())
            {
                return;
            }

            if ((opt.Option & DrawTextOption.H_CENTER) != 0)
            {
                a -= (xv / 2);
            }

            GL.Color4(brush.Color4());

            mFontRenderer.Render(tex, a, xv, yv);
        }
Пример #10
0
 public void Clear(DrawBrush brush)
 {
     FillRectangleScrn(
         brush,
         0, 0, (int)DC.ViewWidth, (int)DC.ViewHeight);
 }
Пример #11
0
        private void DrawDim(DrawContext dc, DrawPen linePen, DrawBrush textBrush)
        {
            dc.Drawing.DrawLine(linePen, PointList[0].vector, PointList[3].vector);
            dc.Drawing.DrawLine(linePen, PointList[1].vector, PointList[2].vector);

            Vector3d cp = CadMath.CenterPoint(PointList[3].vector, PointList[2].vector);

            double arrowW = ARROW_W;
            double arrowL = ARROW_LEN;

            double ww = (PointList[1] - PointList[0]).Norm() / 4.0;

            if (ww > arrowL)
            {
                dc.Drawing.DrawArrow(linePen, cp, PointList[3].vector, ArrowTypes.CROSS, ArrowPos.END, arrowL, arrowW);
                dc.Drawing.DrawArrow(linePen, cp, PointList[2].vector, ArrowTypes.CROSS, ArrowPos.END, arrowL, arrowW);
            }
            else
            {
                Vector3d v0 = cp - PointList[3].vector;
                Vector3d v1 = cp - PointList[2].vector;

                v0 = -(v0.Normalized() * (arrowL * 1.5)) / dc.WorldScale + PointList[3].vector;
                v1 = -(v1.Normalized() * (arrowL * 1.5)) / dc.WorldScale + PointList[2].vector;

                dc.Drawing.DrawArrow(linePen, v0, PointList[3].vector, ArrowTypes.CROSS, ArrowPos.END, arrowL, arrowW);
                dc.Drawing.DrawArrow(linePen, v1, PointList[2].vector, ArrowTypes.CROSS, ArrowPos.END, arrowL, arrowW);

                dc.Drawing.DrawLine(linePen, PointList[2].vector, PointList[3].vector);
            }

            CadVertex lineV = PointList[2] - PointList[3];

            double len = lineV.Norm();

            string lenStr = CadUtil.ValToString(len);

            CadVertex p = PointList[3] + (lineV / 2);

            p += (PointList[3] - PointList[0]).UnitVector() * (arrowW);

            CadVertex up = PointList[3] - PointList[0];

            // 裏返しになる場合は、反転する
            // If it turns over, reverse it
            Vector3d normal = CadMath.Normal(lineV.vector, up.vector);

            double scala = CadMath.InnerProduct(normal, dc.ViewDir);

            if (scala > 0)
            {
                lineV = -lineV;
            }

            //             --- lineV --->
            //    3<------------ p ----------->2
            // ^  |                            |
            // |  |                            |
            // up 0                            1
            //
            dc.Drawing.DrawText(FontID, textBrush, p.vector, lineV.vector, up.vector,
                                new DrawTextOption(DrawTextOption.H_CENTER),
                                lenStr);
        }
Пример #12
0
 public void Clear(DrawBrush brush)
 {
     GL.ClearColor(brush.Color4());
     GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
 }