public static SmoothedPolyline SmoothedPolylineTranslate(SmoothedPolyline smoothedPolyline, Vector deltaVec) { GPoint delta = new GPoint(deltaVec.X, deltaVec.Y); SmoothedPolyline sm = smoothedPolyline.Clone(); for (Microsoft.Msagl.Core.Geometry.Site s = sm.HeadSite, s0 = sm.HeadSite; s != null; s = s.Next, s0 = s0.Next) { s.Point = s0.Point + delta; } return(sm); }
public static SmoothedPolyline SmoothedPolylineTransform(SmoothedPolyline smoothedPolyline, PlaneTransformation m) { //GPoint delta = new GPoint(deltaVec.X, deltaVec.Y); SmoothedPolyline sm = smoothedPolyline.Clone(); //PlaneTransformation pt = new PlaneTransformation(m.M11, m.M12,m.OffsetX,m.M21, m.M22, m.OffsetY); for (Microsoft.Msagl.Core.Geometry.Site s = sm.HeadSite, s0 = sm.HeadSite; s != null; s = s.Next, s0 = s0.Next) { s.Point = m * s0.Point; } return(sm); }
public static Site GetPreviousSite(SmoothedPolyline sm, GPoint point) { Site prevSite = sm.HeadSite; Site nextSite = prevSite.Next; do { if (BetweenSites(prevSite, nextSite, point)) { return(prevSite); } prevSite = nextSite; nextSite = nextSite.Next; } while (nextSite != null); return(null); }
internal static SmoothedPolyline CreateUnderlyingPolylineForSelfEdge(GPoint p0, double dx, double dy) { var p1 = p0 + new GPoint(0, dy); var p2 = p0 + new GPoint(dx, dy); var p3 = p0 + new GPoint(dx, -dy); var p4 = p0 + new GPoint(0, -dy); var site = new Site(p0); var polyline = new SmoothedPolyline(site); site = new Site(site, p1); site = new Site(site, p2); site = new Site(site, p3); site = new Site(site, p4); new Site(site, p0); return(polyline); }
public static Site FindCornerForEdit(SmoothedPolyline underlyingPolyline, GPoint mousePoint, double tolerance) { Site site = underlyingPolyline.HeadSite.Next; tolerance *= tolerance; //square the tolerance do { if (site.Previous == null || site.Next == null) { continue; //don't return the first and the last corners } GPoint diff = mousePoint - site.Point; if (diff * diff <= tolerance) { return(site); } site = site.Next; } while (site.Next != null); return(null); }
public static void CreateSimpleEdgeCurveWithUnderlyingPolyline(Edge edge) { //ValidateArg.IsNotNull(edge, "edge"); var a = edge.srcNode.Center; var b = edge.tarNode.Center; if (edge.srcNode == edge.tarNode) { var dx = 2.0 / 3 * edge.srcNode.borderCurve.BoundingBox.Width; var dy = edge.srcNode.borderCurve.BoundingBox.Height / 4; edge.underlying = CreateUnderlyingPolylineForSelfEdge(new GPoint(a.X, a.Y), dx, dy); edge.lineCurve = edge.underlying.CreateCurve(); } else { edge.underlying = SmoothedPolyline.FromPoints(new[] { new GPoint(a.X, a.Y), new GPoint(b.X, b.Y) }); edge.lineCurve = edge.underlying.CreateCurve(); } Edge.TrimSplineByBoundaryAndArrowhead(edge, false); //.TrimSplineAndCalculateArrowheads(edge.EdgeGeometry, // edge.Source.BoundaryCurve, // edge.Target.BoundaryCurve, // edge.Curve, false, false); }
public static Tuple <Site, PolylineCornerType> AnalyzeInsertOrDeletePolylineCorner(SmoothedPolyline sm, GPoint point, double tolerance) { //tolerance += SelectedEdge.Edge.Attr.LineWidth; Site corner = FindCornerForEdit(sm, point, tolerance); if (corner != null) { return(new Tuple <Site, PolylineCornerType>(corner, PolylineCornerType.CornerToDelete)); } corner = GetPreviousSite(sm, point); if (corner != null) { return(new Tuple <Site, PolylineCornerType>(corner, PolylineCornerType.PreviousCornerForInsertion)); } return(null); }