Exemplo n.º 1
0
 public void RenderSnapPoints(Graphics g, ScreenTrans zoom, List <SnapMode> SModes)
 {
     try
     {
         if (data.objSnap.Geo2D_Entities.Count == 0 || data.objSnap.Geo2D_Entities == null)
         {
             return;
         }
     }
     catch { }
     /////
     if (SModes.Contains(SnapMode.Geo2DPoint))
     {
         if (data.objSnap.Geo2D_Entities.Count != 0)
         {
             for (int i = 0; i < data.objSnap.Geo2D_Entities.Count; i++)
             {
                 Numt = data.objSnap.Geo2D_Entities[i];
                 p0   = new PointF((float)data.PsList[Numt].X, (float)data.PsList[Numt].Y);
                 p0   = zoom.WorldToScreen(p0.X, p0.Y);
                 G.FillEllipse(RParas.BrushSnapP, p0.X - RParas.RSnapP / 2, p0.Y - RParas.RSnapP / 2, RParas.RSnapP, RParas.RSnapP);
             }
         }
     }
 }
Exemplo n.º 2
0
 public void Render(Graphics g, ScreenTrans zoom, RenderParameter RParas)
 {
     if (RParas.Show_WRim2D == false)
     {
         return;
     }
     try
     {
         if (data.Rims == null || data.Rims.Count == 0)
         {
             return;
         }
     }
     catch { }
     /////
     for (int i = 0; i < data.Rims.Count; i++)
     {
         RenderRim(g, zoom, RParas, data.Rims[i]);
     }
     if (RParas.SwitchSnap == false)
     {
         return;                              /////如果对象捕捉没有打开则直接返回
     }
     RenderSnap(g, zoom, RParas, RParas.SModes);
 }
Exemplo n.º 3
0
 public void RenderSnap(Graphics g, ScreenTrans zoom, RenderParameter RParas, List <SnapMode> SModes)
 {
     /////渲染捕捉到的几何体
     if (!(SModes.Contains(SnapMode.Geo2DRim)))
     {
         return;
     }
     try
     {
         if (data.objSnap.Geo2D_Rims == null || data.objSnap.Geo2D_Rims.Count == 0)
         {
             return;
         }
     }
     catch { }
     /////
     for (int i = 0; i < data.objSnap.Geo2D_Rims.Count; i++)
     {
         RimT = data.Rims[data.objSnap.Geo2D_Rims[i]];
         if (RimT.Count == 0)
         {
             continue;
         }
         Ps = new PointF[RimT.Shape.Count];
         for (int j = 0; j < RimT.Shape.Count; j++)
         {
             Ps[j] = zoom.WorldToScreen((float)(RimT.Shape[j].X), (float)(RimT.Shape[j].Y));
         }
         g.DrawPolygon(RParas.SnapGeo2DPen, Ps);
     }
 }
Exemplo n.º 4
0
        /// <summary>
        /// Renders the voronoi diagram.
        /// </summary>
        public void Render(Graphics g, ScreenTrans zoom, RenderParameter renderColors)
        {
            this.renderColors = renderColors;

            var points = data.VoronoiPoints;
            var edges  = data.VoronoiEdges;

            if (points != null && edges != null)
            {
                uint   k;
                PointF p0, p1;
                int    n = edges.Length / 2;

                for (int i = 0; i < n; i++)
                {
                    // First endpoint of voronoi edge
                    k  = edges[2 * i];
                    p0 = new PointF(points[2 * k], points[2 * k + 1]);

                    // Second endpoint of voronoi edge
                    k  = edges[2 * i + 1];
                    p1 = new PointF(points[2 * k], points[2 * k + 1]);

                    // Render the edge
                    if (zoom.ViewportContains(p0.X, p0.Y) ||
                        zoom.ViewportContains(p1.X, p1.Y))
                    {
                        p0 = zoom.WorldToScreen(p0.X, p0.Y);
                        p1 = zoom.WorldToScreen(p1.X, p1.Y);

                        g.DrawLine(renderColors.VoronoiLine, p0, p1);
                    }
                }
            }
        }
Exemplo n.º 5
0
        float Rate2ViewPort;         /////图形到ViewPort的比例
        #endregion

        #region Initialize
        /// <summary>
        /// Initializes a new instance of the <see cref="RenderControl" /> class.
        /// </summary>
        public RenderControl(IWRender_GUI Father)
        {
            this.Father = Father;
            SetStyle(ControlStyles.ResizeRedraw, true);

            trans   = new ScreenTrans(true);
            context = new BufferedGraphicsContext();
            data    = new RenderData();
        }
Exemplo n.º 6
0
        private void RenderText(ScreenTrans zoom, WText2D Text)
        {
            p0 = Ps[Text.Position.Num];

            float H = (float)Text.Height;

            H = zoom.WorldToScreen(H);

            G.DrawString(Text.Text, new Font("宋体", H), Brushes.White, p0);
        }
Exemplo n.º 7
0
 private void RenderRim(Graphics g, ScreenTrans zoom, RenderParameter RParas, WRim2D Rim)
 {
     tB   = new SolidBrush(Rim.Color);
     tPen = new Pen(Rim.Color_Shape, 2);
     Ps   = new PointF[Rim.Shape.Count];
     for (int i = 0; i < Rim.Shape.Count; i++)
     {
         Ps[i] = zoom.WorldToScreen((float)(Rim.Shape[i].X), (float)(Rim.Shape[i].Y));
     }
     g.FillPolygon(tB, Ps);
     g.DrawPolygon(tPen, Ps);
 }
Exemplo n.º 8
0
        /// <summary>
        /// Renders only the mesh edges (no points or segments).
        /// </summary>
        public void RenderMesh(Graphics g, ScreenTrans zoom)
        {
            this.zoom = zoom;

            if (data.MeshEdges != null)
            {
                this.RenderEdges(g);
            }
            else if (data.Triangles != null)
            {
                this.RenderTriangles(g, false);
            }
        }
Exemplo n.º 9
0
        /// <summary>
        /// Renders only points and segments (no mesh triangles).
        /// </summary>
        public void RenderGeometry(Graphics g, ScreenTrans zoom)
        {
            this.zoom = zoom;

            if (data.Segments != null)
            {
                this.RenderSegments(g);
            }

            if (data.Points != null)
            {
                this.RenderPoints(g);
            }
        }
Exemplo n.º 10
0
        private void RenderLines(ScreenTrans zoom, WLine2D Line, bool SnapCheck)
        {
            if (SnapCheck == false)
            {
                tPen = new Pen(Line.Color, Line.LineWidth);
            }
            else
            {
                tPen = RParas.SnapGeo2DPen;
            }
            p0 = Ps[Line.StartPoint.Num];
            p1 = Ps[Line.EndPoint.Num];

            G.DrawLine(tPen, p0, p1);
        }
Exemplo n.º 11
0
        private void RenderPolyLines(ScreenTrans zoom, WPolyLine2D PL, bool SnapCheck)
        {
            if (SnapCheck == false)
            {
                tPen = new Pen(PL.Color, PL.LineWidth);
            }
            else
            {
                tPen = RParas.SnapGeo2DPen;
            }

            for (int j = 0; j < PL.Count - 1; j++)
            {
                p0 = Ps[PL[j].Num];
                p1 = Ps[PL[j + 1].Num];

                G.DrawLine(tPen, p0, p1);
            }
        }
Exemplo n.º 12
0
 public void Render(Graphics g, ScreenTrans zoom, RenderParameter RParas)
 {
     if (RParas.Show_WMesh2D == false)
     {
         return;
     }
     try
     {
         if (data.Meshs == null || data.Meshs.Count == 0)
         {
             return;
         }
     }
     catch { }
     /////
     for (int i = 0; i < data.Meshs.Count; i++)
     {
         RenderSingleMesh(g, zoom, RParas, data.Meshs[i]);
     }
 }
Exemplo n.º 13
0
 private void RenderHighLights(Graphics g, ScreenTrans zoom, RenderParameter RParas, ref List <WShapeRim2D> HighLights)
 {
     if (HighLights == null || HighLights.Count == 0)
     {
         return;
     }
     for (int i = 0; i < HighLights.Count; i++)
     {
         if (HighLights[i].Count == 0)
         {
             continue;
         }
         Ps = new PointF[HighLights[i].Count];
         for (int j = 0; j < HighLights[i].Count; j++)
         {
             Ps[j] = zoom.WorldToScreen((float)(HighLights[i][j].X), (float)(HighLights[i][j].Y));
         }
         g.DrawPolygon(RParas.SnapGeo2DPen, Ps);
     }
 }
Exemplo n.º 14
0
        private void RenderCircles(ScreenTrans zoom, WCircle2D Circle, bool SnapCheck)
        {
            if (SnapCheck == false)
            {
                tPen = new Pen(Circle.Color, Circle.LineWidth);
            }
            else
            {
                tPen = RParas.SnapGeo2DPen;
            }

            float R;

            p0 = Ps[Circle.Center.Num];

            R = (float)Circle.R;
            R = zoom.WorldToScreen(R);

            G.DrawArc(tPen, new Rectangle((int)(p0.X - R), (int)(p0.Y - R), (int)(R * 2), (int)(R * 2)), 0, 360);
        }
Exemplo n.º 15
0
 public void RenderSnapEntities(Graphics g, ScreenTrans zoom, List <SnapMode> SModes)
 {
     try
     {
         if (data.objSnap.Geo2D_Entities.Count == 0 || data.objSnap.Geo2D_Entities == null)
         {
             return;
         }
     }
     catch { }
     /////渲染捕捉到的几何体
     if (SModes.Contains(SnapMode.Geo2DEntity))
     {
         if (data.objSnap.Geo2D_Entities.Count != 0)
         {
             for (int i = 0; i < data.objSnap.Geo2D_Entities.Count; i++)
             {
                 RenderSingleEntity(zoom, data.Entities[data.objSnap.Geo2D_Entities[i]], true);
             }
         }
     }
 }
Exemplo n.º 16
0
        private void RenderPoints(ScreenTrans zoom, WGeos2D_PsList PsList)
        {
            Ps = new PointF[PsList.Count + 1];
            for (int i = 1; i <= PsList.Count; i++)
            {
                if (PsList[i] == null)
                {
                    Ps[i] = new PointF(float.MaxValue, float.MaxValue);
                }
                Ps[i] = new PointF((float)PsList[i].X, (float)PsList[i].Y);
                Ps[i] = zoom.WorldToScreen(Ps[i].X, Ps[i].Y);

                if (RParas.SwitchHP == true && PsList[i].HardCheck == true)
                {
                    G.FillEllipse(RParas.BrushHP, Ps[i].X - RParas.Rhp / 2, Ps[i].Y - RParas.Rhp / 2, RParas.Rhp, RParas.Rhp);
                }
                if (RParas.SwitchSP == true && PsList[i].HardCheck == false)
                {
                    G.FillEllipse(RParas.BrushSP, Ps[i].X - RParas.Rsp / 2, Ps[i].Y - RParas.Rsp / 2, RParas.Rsp, RParas.Rsp);
                }
            }
        }
Exemplo n.º 17
0
        /// <summary>
        /// Renders the mesh.
        /// </summary>
        public void Render(Graphics g, ScreenTrans zoom, bool fillTriangles)
        {
            this.zoom = zoom;

            if (data.MeshEdges != null && !fillTriangles)
            {
                this.RenderEdges(g);
            }

            if (fillTriangles && data.Triangles != null)
            {
                this.RenderTriangles(g, fillTriangles && (data.NumberOfRegions > 0));
            }

            if (data.Segments != null)
            {
                this.RenderSegments(g);
            }

            if (data.Points != null)
            {
                this.RenderPoints(g);
            }
        }
Exemplo n.º 18
0
 /// <summary>
 /// Render
 /// </summary>
 public void Render(Graphics g, ScreenTrans zoom)
 {
     this.G = g;
     try
     {
         if (data.Entities.Count == 0 || data.Entities == null)
         {
             return;
         }
     }
     catch { }
     //////
     RenderPoints(zoom, data.PsList);
     for (int i = 0; i < data.Entities.Count; i++)
     {
         RenderSingleEntity(zoom, data.Entities[i], false);
     }
     if (RParas.SwitchSnap == false)
     {
         return;                              /////如果对象捕捉没有打开则直接返回
     }
     RenderSnapEntities(g, zoom, RParas.SModes);
     RenderSnapPoints(g, zoom, RParas.SModes);
 }
Exemplo n.º 19
0
        private void RenderSingleEntity(ScreenTrans zoom, WEntity2D E, bool SnapCheck)
        {
            switch (E.Kind)
            {
            case GeoKind.Line:
                RenderLines(zoom, (WLine2D)E, SnapCheck);
                break;

            case GeoKind.PolyLine:
                RenderPolyLines(zoom, (WPolyLine2D)E, SnapCheck);
                break;

            case GeoKind.Circle:
                RenderCircles(zoom, (WCircle2D)E, SnapCheck);
                break;

            case GeoKind.DText:
                RenderText(zoom, (WText2D)E);
                break;

            default:
                break;
            }
        }
Exemplo n.º 20
0
        public void RenderSingleMesh(Graphics g, ScreenTrans zoom, RenderParameter RParas, WMesh2D_Mesh Mesh)
        {
            PointF P;

            PointF[] Ps;

            Brush tB = new SolidBrush(Mesh.Color);

            int Num;
            int Kind;

            /////节点转换
            PointF[] Ns = new PointF[Mesh.QNs + 1];
            for (int i = 1; i <= Mesh.QNs; i++)
            {
                Ns[i] = new PointF((float)Mesh.Nodes[i].X, (float)Mesh.Nodes[i].Y);
                Ns[i] = zoom.WorldToScreen(Ns[i].X, Ns[i].Y);
            }
            /////使用Shape输出
            bool Check_Fill = false;
            //if (Mesh.Shapes != null && Mesh.Shapes.Count != 0)
            //{
            //    for (int i = 0; i < Mesh.Shapes.Count; i++)
            //    {
            //        Ps = new PointF[Mesh.Shapes[i].Count];
            //        for (int j = 0; j < Mesh.Shapes[i].Count; j++)
            //        {
            //            Ps[j] = new PointF((float)Mesh.Shapes[i][j].X, (float)Mesh.Shapes[i][j].Y);
            //            Ps[j] = zoom.WorldToScreen(Ps[j].X, Ps[j].Y);
            //        }
            //        g.FillPolygon(tB, Ps);
            //    }
            //    Check_Fill = true;
            //}
            /////
            bool Check_Frame = false;

            if (Mesh.NsPairs != null && Mesh.NsPairs.Length > 0)
            {
                Ps = new PointF[2];
                for (int i = 0; i < Mesh.NsPairs.Length; i++)
                {
                    g.DrawLine(RParas.PenES, Ns[Mesh.NsPairs[i].N1], Ns[Mesh.NsPairs[i].N2]);
                }
                Check_Frame = true;
            }
            /////单元输出
            if (Check_Fill == false || Check_Frame == false)
            {
                for (int i = 0; i < Mesh.QEs; i++)
                {
                    Kind = Mesh.Elements[i].Kind;
                    if (Kind < 3)
                    {
                        continue;
                    }
                    /////
                    Ps = new PointF[Kind + 1];

                    Num = Mesh.Elements[i].N1;
                    if (Num < 0)
                    {
                        continue;
                    }
                    Ps[0] = Ns[Num];
                    Num   = Mesh.Elements[i].N2;
                    if (Num < 0)
                    {
                        continue;
                    }
                    Ps[1] = Ns[Num];
                    Num   = Mesh.Elements[i].N3;
                    if (Num < 0)
                    {
                        continue;
                    }
                    Ps[2] = Ns[Num];
                    if (Kind == 4)
                    {
                        Num = Mesh.Elements[i].N4;
                        if (Num < 0)
                        {
                            continue;
                        }
                        Ps[3] = Ns[Num];
                    }
                    Ps[Kind] = Ps[0];
                    /////
                    if (Check_Fill == false)
                    {
                        g.FillPolygon(tB, Ps);
                    }
                    if (Check_Frame == false)
                    {
                        g.DrawPolygon(RParas.PenES, Ps);
                    }
                }
            }
            /////
            for (int i = 0; i < Mesh.Elements.Count; i++)
            {
                Kind = Mesh.Elements[i].Kind;
                if (Kind == 2)
                {
                    Ps    = new PointF[2];
                    Num   = Mesh.Elements[i].N1;
                    Ps[0] = Ns[Num];
                    Num   = Mesh.Elements[i].N2;
                    Ps[1] = Ns[Num];
                    g.DrawLine(RParas.PenEB, Ps[0], Ps[1]);
                    continue;
                }
            }

            if (RParas.SwitchN == false)
            {
                return;
            }
            for (int i = 1; i < Mesh.Nodes.Count; i++)
            {
                P = new PointF((float)Mesh.Nodes[i].X, (float)Mesh.Nodes[i].Y);
                P = zoom.WorldToScreen(P.X, P.Y);
                g.FillEllipse(RParas.BrushN, P.X - RParas.Rn / 2, P.Y - RParas.Rn / 2, RParas.Rn, RParas.Rn);
            }
        }
Exemplo n.º 21
0
 /// <summary>
 /// Renders the mesh.
 /// </summary>
 public void Render(Graphics g, ScreenTrans zoom)
 {
     Render(g, zoom, false);
 }