自动布局完成

This commit is contained in:
艾竹
2023-12-21 22:20:38 +08:00
parent 467bec839a
commit 6e917a2107
5 changed files with 340 additions and 320 deletions

View File

@@ -1,69 +1,72 @@
//using System;
using System;
//namespace AIStudio.Wpf.DiagramDesigner.Layout
//{
// public class Configuration
// {
// /// <summary>
// /// The network whose nodes are to be repositioned.
// /// </summary>
// public DiagramViewModel Network { get; set; }
namespace AIStudio.Wpf.DiagramDesigner.Layout
{
public class Configuration
{
/// <summary>
/// The network whose nodes are to be repositioned.
/// </summary>
public DiagramViewModel Network
{
get; set;
}
// /// <summary>
// /// A time modifier that is used to speed up, or slow down, time during the simulation.
// /// A greater time modifier speeds up the physics simulation, at the cost of accuracy and stability.
// /// </summary>
// public float TimeModifier { get; set; } = 3.5f;
// /// <summary>
// /// Number of updates per iteration.
// /// Increasing this number increases the accuracy of the physics simulation at the cost of performance.
// /// </summary>
// public int UpdatesPerIteration { get; set; } = 1;
/// <summary>
/// A time modifier that is used to speed up, or slow down, time during the simulation.
/// A greater time modifier speeds up the physics simulation, at the cost of accuracy and stability.
/// </summary>
public float TimeModifier { get; set; } = 3.5f;
// /// <summary>
// /// How strongly should nodes push eachother away?
// /// A greater NodeRepulsionForce increases the distance between nodes.
// /// </summary>
// public float NodeRepulsionForce { get; set; } = 100;
/// <summary>
/// Number of updates per iteration.
/// Increasing this number increases the accuracy of the physics simulation at the cost of performance.
/// </summary>
public int UpdatesPerIteration { get; set; } = 1;
// /// <summary>
// /// A function that maps each connection onto the equilibrium distance of its corresponding spring.
// /// A greater equilibrium distance increases the distance between the two connected endpoints.
// /// </summary>
// public Func<ConnectionViewModel, double> EquilibriumDistance { get; set; } = conn => 100;
/// <summary>
/// How strongly should nodes push eachother away?
/// A greater NodeRepulsionForce increases the distance between nodes.
/// </summary>
public float NodeRepulsionForce { get; set; } = 100;
// /// <summary>
// /// A function that maps each connection onto the springiness/stiffness constant of its corresponding spring.
// /// (c.f. Hooke's law)
// /// </summary>
// public Func<ConnectionViewModel, double> SpringConstant { get; set; } = conn => 1;
/// <summary>
/// A function that maps each connection onto the equilibrium distance of its corresponding spring.
/// A greater equilibrium distance increases the distance between the two connected endpoints.
/// </summary>
public Func<ConnectionViewModel, double> EquilibriumDistance { get; set; } = conn => 100;
// /// <summary>
// /// A function that maps each connection onto the strength of its row force.
// /// Since inputs/outputs are on the left/right of a node, networks tend to be layed out horizontally.
// /// The row force is added onto the endpoints of the connection to make the nodes end up in a more horizontal layout.
// /// </summary>
// public Func<ConnectionViewModel, double> RowForce { get; set; } = conn => 100;
/// <summary>
/// A function that maps each connection onto the springiness/stiffness constant of its corresponding spring.
/// (c.f. Hooke's law)
/// </summary>
public Func<ConnectionViewModel, double> SpringConstant { get; set; } = conn => 1;
// /// <summary>
// /// A function that maps each node onto its mass in the physics simulation.
// /// Greater mass makes the node harder to move.
// /// </summary>
// public Func<DesignerItemViewModelBase, float> NodeMass { get; set; } = node => 10;
/// <summary>
/// A function that maps each connection onto the strength of its row force.
/// Since inputs/outputs are on the left/right of a node, networks tend to be layed out horizontally.
/// The row force is added onto the endpoints of the connection to make the nodes end up in a more horizontal layout.
/// </summary>
public Func<ConnectionViewModel, double> RowForce { get; set; } = conn => 100;
// /// <summary>
// /// The friction coefficient is used to control friction forces in the simulation.
// /// Greater friction makes the simulation converge faster, as it slows nodes down when
// /// they are swinging around. If the friction is too high, the nodes will stop moving before
// /// they reach their optimal position or might not even move at all.
// /// </summary>
// public Func<DesignerItemViewModelBase, float> FrictionCoefficient { get; set; } = node => 2.5f;
/// <summary>
/// A function that maps each node onto its mass in the physics simulation.
/// Greater mass makes the node harder to move.
/// </summary>
public Func<DesignerItemViewModelBase, float> NodeMass { get; set; } = node => 10;
// /// <summary>
// /// A predicate function that specifies whether or not a node is fixed.
// /// Fixed nodes do not get moved in the simulation.
// /// </summary>
// public Func<DesignerItemViewModelBase, bool> IsFixedNode { get; set; } = node => false;
// }
//}
/// <summary>
/// The friction coefficient is used to control friction forces in the simulation.
/// Greater friction makes the simulation converge faster, as it slows nodes down when
/// they are swinging around. If the friction is too high, the nodes will stop moving before
/// they reach their optimal position or might not even move at all.
/// </summary>
public Func<DesignerItemViewModelBase, float> FrictionCoefficient { get; set; } = node => 2.5f;
/// <summary>
/// A predicate function that specifies whether or not a node is fixed.
/// Fixed nodes do not get moved in the simulation.
/// </summary>
public Func<DesignerItemViewModelBase, bool> IsFixedNode { get; set; } = node => false;
}
}