internal static void DragEdge(Point delta, GeomEdge e, EdgeRestoreData edgeRestoreData, Set<GeometryObject> objectsMarkedToDrag) { Site site = null; if (objectsMarkedToDrag.Contains(e.Source)) { if (!objectsMarkedToDrag.Contains(e.Target)) site = e.UnderlyingPolyline.HeadSite; } else site = e.UnderlyingPolyline.LastSite; if (site == null) TranslateEdge(e, delta, edgeRestoreData); else DragEdgeWithSite(delta, e, site); }
///// <summary> ///// Creates a curve by using the underlying polyline ///// </summary> ///// <param name="underlyingPoly"></param> ///// <returns></returns> // [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Polyline")] // static public Curve CreateCurveFromEdgeUnderlyingPolyline(UnderlyingPolyline underlyingPoly) { // Curve curve = new Curve(); // Site a = underlyingPoly.HeadSite;//the corner start // Site b; //the corner origin // Site c;//the corner other end // while (SmoothedPolyline.FindCorner(a, out b, out c)) { // CubicBezierSegment seg = SmoothedPolyline.CreateBezierSeg(b.bezierSegmentShrinkCoefficient, a, b, c); // if (curve.Segments.Count == 0) { // if (!ApproximateComparer.Close(a.Point, seg.Start)) // Curve.AddLineSeg(curve, a.Point, seg.Start); // } else if (!ApproximateComparer.Close(curve.End, seg.Start)) // Routing.ContinueWithLineSeg(curve, seg.Start); // curve.AddSegment(seg); // a = b; // } // System.Diagnostics.Debug.Assert(a.Next.Next == null); // if (curve.Segments.Count == 0) { // if (!ApproximateComparer.Close(a.Point, a.Next.Point)) { // Curve.AddLineSeg(curve, a.Point, a.Next.Point); // } else { // double w=5; // curve.Segments.Add(new CubicBezierSegment(a.Point, a.Point+new Point(w,w),a.Point+new Point(-w,w), b.Point)); // } // } else if (!ApproximateComparer.Close(curve.End, a.Next.Point)) // Routing.ContinueWithLineSeg(curve, a.Next.Point); // return curve; // } static void TranslateEdge(GeomEdge e, Point delta, EdgeRestoreData edgeRestoreData) { if (edgeRestoreData.Curve != null) { e.Curve = edgeRestoreData.Curve.Clone(); e.Curve.Translate(delta); } if (e.UnderlyingPolyline != null) for (Site s = e.UnderlyingPolyline.HeadSite, s0 = edgeRestoreData.UnderlyingPolyline.HeadSite; s != null; s = s.Next, s0 = s0.Next) s.Point = s0.Point + delta; if (e.EdgeGeometry.SourceArrowhead != null) e.EdgeGeometry.SourceArrowhead.TipPosition = edgeRestoreData.ArrowheadAtSourcePosition + delta; if (e.EdgeGeometry.TargetArrowhead != null) e.EdgeGeometry.TargetArrowhead.TipPosition = edgeRestoreData.ArrowheadAtTargetPosition + delta; if (e.Label != null) e.Label.Center = edgeRestoreData.LabelCenter + delta; }
internal static ICurve CreateBaseSegmentForDraggingEdgeWithSource(Point delta, GeomEdge edge, EdgeRestoreData edgeRestoreData, Dictionary<GeomEdge, double> offsets) { double offset; ICurve seg; Point a = edgeRestoreData.UnderlyingPolyline.HeadSite.Point + delta; Point b = edgeRestoreData.UnderlyingPolyline.LastSite.Point; if (offsets.TryGetValue(edge, out offset) && offset != 0) { Point ab = b - a; Point abOrtog = ab.Normalize().Rotate(Math.PI/2)*offset; seg = CreateBaseSegOnSourceTargetAndOrth(ref a, ref b, ref abOrtog); // SugiyamaLayoutSettings.Show(seg, edge.Curve, edge.Source.BoundaryCurve); } else seg = new LineSegment(a, b); return seg; }