using OpenTK.Graphics.ES20;
namespace Yw.WinFrmUI.Hydro
{
///
///
///
internal static class Network2dExtensions
{
///
/// 绘制2d
///
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();
}
});
}
///
/// 悬停2d
///
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;
}
}
///
/// 选择2d
///
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;
}
}
}
}