public override void Do() { if (IsDone) { throw new Exception("CBuildLineAction already was done (new line id: " + createdLineView.Model.Id + ")"); } bool isAnjoinedLine = IsBuildToLine ? point1.Value.Model.Contains(segment.Value.Owner.Model) : point1.Value.Model.GetCommonLine(point2.Value.Model) != null; if (isAnjoinedLine) // выйти, если новая линия будет совпадать с какой-либо существующей { return; } // если были выбраны точка и отрезок, создать вторую точку if (IsBuildToLine) { divideAction.Do(); var newPoint = segment.Value.Owner.PointAt(segment.Value.IndexInLine + 1); point2 = new CVPointWrap(Owner, newPoint); } CMLine line = Owner.model.CreateLine(point1.Id, point2.Id); var lineView = Owner.lineViewDict[line.Id]; createdLineView = lineView; }
public CBuildLineAction(CVShape owner, CVPoint point, CVLineSegment segment, Vector3 hitPos) : base(owner) { point1 = new CVPointWrap(owner, point); this.segment = new CVSegmentWrap(owner, segment); this.hitPos = segment.Owner.CalcHitPosition(this.segment.Index, hitPos); divideAction = new CDivideLineAction(Owner, segment.Owner, this.segment.Index, this.hitPos); }