mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-04-01 22:56:35 +08:00
mind 有点样子了
This commit is contained in:
@@ -6,7 +6,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
public static partial class PathGenerators
|
||||
{
|
||||
private const double _margin = 125;
|
||||
|
||||
|
||||
public static PathGeneratorResult Smooth(IDiagramViewModel _, ConnectionViewModel link, PointBase[] route, PointBase source, PointBase target)
|
||||
{
|
||||
@@ -74,17 +74,39 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
if (sourceOrientation == ConnectorOrientation.None)//按照线条的四象限来处理。
|
||||
{
|
||||
var slope = (route[1].Y - route[0].Y) / (route[1].X - route[0].X);
|
||||
if (Math.Abs(slope) < link.SmoothAutoSlope)
|
||||
{
|
||||
if (route[1].X > route[0].X)
|
||||
{
|
||||
sourceOrientation = ConnectorOrientation.Right;
|
||||
}
|
||||
else
|
||||
{
|
||||
sourceOrientation = ConnectorOrientation.Left;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (route[1].Y > route[0].Y)//Y轴方向是反的
|
||||
{
|
||||
sourceOrientation = ConnectorOrientation.Bottom;
|
||||
}
|
||||
else
|
||||
{
|
||||
sourceOrientation = ConnectorOrientation.Top;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
var curvePointA = GetCurvePoint(route[0].X, route[0].Y, cX, cY, sourceOrientation);
|
||||
var curvePointB = GetCurvePoint(route[1].X, route[1].Y, cX, cY, link.SinkConnectorInfo?.Orientation);
|
||||
var curvePointA = GetCurvePoint(route[0].X, route[0].Y, cX, cY, link.SmoothMargin, sourceOrientation);
|
||||
var curvePointB = GetCurvePoint(route[1].X, route[1].Y, cX, cY, link.SmoothMargin, link.SinkConnectorInfo?.Orientation);
|
||||
return new[] { route[0], curvePointA, curvePointB, route[1] };
|
||||
}
|
||||
}
|
||||
|
||||
private static PointBase GetCurvePoint(double pX, double pY, double cX, double cY, ConnectorOrientation? alignment)
|
||||
private static PointBase GetCurvePoint(double pX, double pY, double cX, double cY, double smoothMargin, ConnectorOrientation? alignment)
|
||||
{
|
||||
var margin = Math.Min(_margin, Math.Pow(Math.Pow(pX - cX, 2) + Math.Pow(pY - cY, 2), .5));
|
||||
var margin = Math.Min(smoothMargin, Math.Pow(Math.Pow(pX - cX, 2) + Math.Pow(pY - cY, 2), .5));
|
||||
switch (alignment)
|
||||
{
|
||||
case ConnectorOrientation.Top: return new PointBase(pX, Math.Min(pY - margin, cY));
|
||||
|
||||
Reference in New Issue
Block a user