using OpenTK.Graphics.ES20;
|
|
namespace Yw.WinFrmUI.Hydro
|
{
|
/// <summary>
|
///
|
/// </summary>
|
internal static class Network2dExtensions
|
{
|
/// <summary>
|
/// 绘制2d
|
/// </summary>
|
public static void Draw2d(this NetworkL3d nw, float zoom)
|
{
|
if (nw == null)
|
{
|
return;
|
}
|
nw.Links.ForEach(x =>
|
{
|
if (x is PumpL3d pump)
|
{
|
pump.Draw2d(zoom);
|
}
|
else
|
{
|
x.Draw2d();
|
}
|
|
});
|
|
nw.Nodes.ForEach(x =>
|
{
|
if (x is SourceL3d source)
|
{
|
source.Draw2d(zoom);
|
}
|
else
|
{
|
x.Draw2d();
|
}
|
|
});
|
}
|
|
/// <summary>
|
/// 悬停2d
|
/// </summary>
|
public static void Hover2d(this NetworkL3d nw, Ray3 ray, float zoom, Vector3CacheHelper vecache)
|
{
|
nw.Visuals.ForEach(x => x.IsHovered = false);
|
var visual = ray.CastingClosest(zoom, nw, vecache);
|
if (visual != null)
|
{
|
visual.IsHovered = true;
|
}
|
}
|
|
/// <summary>
|
/// 选择2d
|
/// </summary>
|
public static void Select2d(this NetworkL3d nw, Ray3 ray, float zoom, Vector3CacheHelper vecache)
|
{
|
nw.Visuals.ForEach(x => x.IsSelected = false);
|
var visual = ray.CastingClosest(zoom, nw, vecache);
|
if (visual != null)
|
{
|
visual.IsSelected = true;
|
return;
|
}
|
}
|
|
|
}
|
}
|