/// <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); } } } }
private void RenderPoints(Graphics g) { int i, k, n; PointF pt; float[] pts = data.Points; // Draw input points n = data.NumberOfInputPoints; for (i = 0; i < n; i++) { k = 2 * i; if (ignoreBounds || zoom.ViewportContains(pts[k], pts[k + 1])) { pt = zoom.WorldToScreen(pts[k], pts[k + 1]); g.FillEllipse(renderColors.Point, pt.X - 1.5f, pt.Y - 1.5f, 3, 3); } } // Draw Steiner points n = pts.Length / 2; for (; i < n; i++) { k = 2 * i; if (ignoreBounds || zoom.ViewportContains(pts[k], pts[k + 1])) { pt = zoom.WorldToScreen(pts[k], pts[k + 1]); g.FillEllipse(renderColors.SteinerPoint, pt.X - 1.5f, pt.Y - 1.5f, 3, 3); } } }
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); } } } }
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); } }
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); }
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); }
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); }
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); } }
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); } } }
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); } }