public static void SetArcOverCut(ArcBase arc) { float pos = arc.LeadOut.Pos; if (Math.Abs(arc.LeadOut.Pos) < 0.000001)//封口 { } else if (pos < 0)//缺口,从圆弧尾部去掉pos长的距离 { arc.AngleSweep -= (float)(Math.Abs(pos) / arc.SizeLength) * arc.AngleSweep; arc.Update(); } else//过切/多圈 { } }
/// <summary> /// 添加到显示画布 /// </summary> /// <param name="canvas"></param> /// <param name="figures"></param> public static void AddToDrawObject(UCCanvas canvas, List <FigureBaseModel> figures, bool isClear = false) { if (canvas == null) { return; } if (figures != null && figures.Count > 0) { if (isClear) { canvas.Model.Clear(); } List <IDrawObject> objects = new List <IDrawObject>(); foreach (FigureBaseModel figure in figures) { switch (figure.Type) { case FigureTypes.Point: { var fig = figure as PointModel; SingleDot singleDot = new SingleDot() { LayerId = fig.LayerId, IsSelected = fig.IsSelected, P1 = fig.Point, GroupParam = fig.GroupParam, LeadIn = fig.LeadIn, LeadOut = fig.LeadOut, MicroConnParams = figure.MicroConnects, CornerRingParam = figure.CornerRingParam, IsInnerCut = figure.IsInnerCut }; singleDot.Update(); objects.Add(singleDot); } break; case FigureTypes.Arc: { var fig = figure as ArcModel; ArcBase arcBase = new ArcBase() { LayerId = fig.LayerId, IsSelected = fig.IsSelected, AngleSweep = fig.AngleSweep, Center = fig.Center, Radius = (float)fig.Radius, StartAngle = (float)fig.StartAngle, GroupParam = fig.GroupParam, LeadIn = fig.LeadIn, LeadOut = fig.LeadOut, MicroConnParams = figure.MicroConnects, CompensationParam = figure.CompensationParam, CornerRingParam = figure.CornerRingParam, IsInnerCut = figure.IsInnerCut }; arcBase.Update(); objects.Add(arcBase); } break; case FigureTypes.Circle: { var fig = figure as CircleModel; Circle circle = new Circle() { LayerId = fig.LayerId, IsSelected = fig.IsSelected, IsClockwise = fig.IsClockwise, Center = fig.Center, Radius = (float)fig.Radius, StartAngle = (float)fig.StartAngle, GroupParam = fig.GroupParam, LeadIn = fig.LeadIn, LeadOut = fig.LeadOut, MicroConnParams = figure.MicroConnects, CompensationParam = figure.CompensationParam, CornerRingParam = figure.CornerRingParam, IsInnerCut = figure.IsInnerCut, IsFlyingCut = fig.IsFlyingCut, IsFlyingCutScatter = fig.IsFlyingCutScatter, FlyingCutLeadOut = fig.FlyingCutLeadOut, }; circle.Update(); objects.Add(circle); } break; case FigureTypes.LwPolyline: { var fig = figure as LwPolylineModel; MultiSegmentLineBase multiSegmentLineBase = new MultiSegmentLineBase() { LayerId = fig.LayerId, IsSelected = fig.IsSelected, IsCloseFigure = fig.IsFill, Points = fig.Points, GroupParam = fig.GroupParam, LeadIn = fig.LeadIn, LeadOut = fig.LeadOut, PathStartParm = fig.PathStartParm, MicroConnParams = figure.MicroConnects, CompensationParam = figure.CompensationParam, CornerRingParam = figure.CornerRingParam, IsInnerCut = figure.IsInnerCut, BezierParam = fig.BezierParam }; multiSegmentLineBase.Update(); objects.Add(multiSegmentLineBase); } break; case FigureTypes.Ellipse: { } break; case FigureTypes.PolyBezier: { } break; default: break; } } canvas.Model.DrawingLayer.AddObjectOnDrawing(objects); canvas.Model.DrawingLayer.UpdateSN(); GlobalData.Model.GlobalModel.TotalDrawObjectCount = canvas.Model.DrawingLayer.Objects.Count; canvas.DoInvalidate(true); } }