refactor(Hi.Sample): follow HiGeom's Box3d struct -- the demo displayees take ref Box3d and expand through Expanded, DemoSatellite scales its boxes with ScaledFromCenter, and MachiningProjectDisplayee forwards ref dst to the assembly

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
2026-09-24 13:05:35 +08:00
co-authored by Claude Fable 5.1
parent 060fb66029
commit 7d79db5685
9 changed files with 23 additions and 23 deletions
+3 -3
View File
@@ -29,10 +29,10 @@ namespace Sample.Disp
new Box3d(2, 0, 0, 3, 1, 1).ToDraw_Face().Display(bind); new Box3d(2, 0, 0, 3, 1, 1).ToDraw_Face().Display(bind);
} }
/// <inheritdoc/> /// <inheritdoc/>
public void ExpandToBox3d(Box3d dst) public void ExpandToBox3d(ref Box3d dst)
{ {
dst.Expand(new vec3d_t(0, 0, 0)); dst = dst.Expanded(new vec3d_t(0, 0, 0));
dst.Expand(new vec3d_t(3, 1, 1)); dst = dst.Expanded(new vec3d_t(3, 1, 1));
} }
static void Main() static void Main()
+3 -3
View File
@@ -25,10 +25,10 @@ namespace Sample.Disp
bind.PickID = 0; bind.PickID = 0;
} }
/// <inheritdoc/> /// <inheritdoc/>
public void ExpandToBox3d(Box3d dst) public void ExpandToBox3d(ref Box3d dst)
{ {
dst.Expand(new vec3d_t(0, 0, 0)); dst = dst.Expanded(new vec3d_t(0, 0, 0));
dst.Expand(new vec3d_t(1, 1, 1)); dst = dst.Expanded(new vec3d_t(1, 1, 1));
} }
/// <inheritdoc/> /// <inheritdoc/>
public override void OnMouseEnter(ui_event_type e, DispEngine dispEngine) public override void OnMouseEnter(ui_event_type e, DispEngine dispEngine)
+3 -3
View File
@@ -37,10 +37,10 @@ namespace Sample.Disp
bind.PickID = 0; bind.PickID = 0;
} }
/// <inheritdoc/> /// <inheritdoc/>
public void ExpandToBox3d(Box3d dst) public void ExpandToBox3d(ref Box3d dst)
{ {
dst.Expand(new vec3d_t(0, 0, 0)); dst = dst.Expanded(new vec3d_t(0, 0, 0));
dst.Expand(new vec3d_t(1, 1, 3)); dst = dst.Expanded(new vec3d_t(1, 1, 3));
} }
#region IDisposable Support #region IDisposable Support
private bool disposedValue = false; // To detect redundant calls private bool disposedValue = false; // To detect redundant calls
+2 -2
View File
@@ -40,9 +40,9 @@ public class DemoPickable : IDisplayee
draw.Display(bind); draw.Display(bind);
} }
/// <inheritdoc/> /// <inheritdoc/>
public void ExpandToBox3d(Box3d dst) public void ExpandToBox3d(ref Box3d dst)
{ {
draw.ExpandToBox3d(dst); draw.ExpandToBox3d(ref dst);
} }
/// <summary> /// <summary>
+5 -5
View File
@@ -21,8 +21,8 @@ namespace Sample.Disp
double angle_moon; double angle_moon;
DemoSatellite() DemoSatellite()
{ {
sun = Box3d.CenterUnitBox.ScaleFromCenter(4).ToDraw_Face(); sun = Box3d.CenterUnitBox.ScaledFromCenter(4).ToDraw_Face();
earth = Box3d.CenterUnitBox.ScaleFromCenter(2).ToDraw_Face(); earth = Box3d.CenterUnitBox.ScaledFromCenter(2).ToDraw_Face();
moon = Box3d.CenterUnitBox.ToDraw_Face(); moon = Box3d.CenterUnitBox.ToDraw_Face();
} }
/// <inheritdoc/> /// <inheritdoc/>
@@ -41,10 +41,10 @@ namespace Sample.Disp
bind.ModelMatStack.Pop(); bind.ModelMatStack.Pop();
} }
/// <inheritdoc/> /// <inheritdoc/>
public void ExpandToBox3d(Box3d dst) public void ExpandToBox3d(ref Box3d dst)
{ {
dst.Expand(new vec3d_t(-14, -14, -2)); dst = dst.Expanded(new vec3d_t(-14, -14, -2));
dst.Expand(new vec3d_t(14, 14, 2)); dst = dst.Expanded(new vec3d_t(14, 14, 2));
} }
static void Main() static void Main()
+1 -1
View File
@@ -33,7 +33,7 @@ public static class DemoUtil
try try
{ {
Box3d box = new Box3d(); Box3d box = new Box3d();
displayee.ExpandToBox3d(box); displayee.ExpandToBox3d(ref box);
Console.WriteLine($"{title}: {displayee.GetType().Name} bounding {box}"); Console.WriteLine($"{title}: {displayee.GetType().Name} bounding {box}");
Console.WriteLine("Assign it to your canvas' DispEngine.Displayee to see it."); Console.WriteLine("Assign it to your canvas' DispEngine.Displayee to see it.");
} }
+2 -2
View File
@@ -90,7 +90,7 @@ namespace Sample.Disp
bind.ModelMatStack.Pop(); bind.ModelMatStack.Pop();
} }
/// <inheritdoc/> /// <inheritdoc/>
public void ExpandToBox3d(Box3d dst) public void ExpandToBox3d(ref Box3d dst)
{ {
HardNcEnv ncEnv = NcEnv; HardNcEnv ncEnv = NcEnv;
if (ncEnv == null || NcEnv.CncBrand != CncBrand.Heidenhain) if (ncEnv == null || NcEnv.CncBrand != CncBrand.Heidenhain)
@@ -107,7 +107,7 @@ namespace Sample.Disp
HeidenhainCycleDef247Q339, HeidenhainCycleDef7Arg, ncEnv); HeidenhainCycleDef247Q339, HeidenhainCycleDef7Arg, ncEnv);
dst.Expand(-mcXyz_AttacherAtTableMountZero + coordinateMove); dst = dst.Expanded(-mcXyz_AttacherAtTableMountZero + coordinateMove);
} }
/// <inheritdoc/> /// <inheritdoc/>
public Anchor GetAnchor() public Anchor GetAnchor()
+2 -2
View File
@@ -59,7 +59,7 @@ public class IsoCoordinateEntryDisplayee : IAnchoredDisplayee
bind.ModelMatStack.Pop(); bind.ModelMatStack.Pop();
} }
/// <inheritdoc/> /// <inheritdoc/>
public void ExpandToBox3d(Box3d dst) public void ExpandToBox3d(ref Box3d dst)
{ {
HardNcEnv ncEnv = NcEnv; HardNcEnv ncEnv = NcEnv;
if (ncEnv == null) if (ncEnv == null)
@@ -70,7 +70,7 @@ public class IsoCoordinateEntryDisplayee : IAnchoredDisplayee
IMachiningEquipment equipment = MillingEquipmentFunc?.Invoke(); IMachiningEquipment equipment = MillingEquipmentFunc?.Invoke();
if (equipment == null || !equipment.TryGetIsoCoordinatePosition(coordinateMove, out vec3d_t attacherPos)) if (equipment == null || !equipment.TryGetIsoCoordinatePosition(coordinateMove, out vec3d_t attacherPos))
return; return;
dst.Expand(attacherPos); dst = dst.Expanded(attacherPos);
} }
/// <inheritdoc/> /// <inheritdoc/>
/// <returns>Table Mount if existed; otherwise, return null.</returns> /// <returns>Table Mount if existed; otherwise, return null.</returns>
+2 -2
View File
@@ -239,10 +239,10 @@ public class MachiningProjectDisplayee : IDisplayee, IGetAnchor
bind.PopColor(); bind.PopColor();
} }
/// <inheritdoc/> /// <inheritdoc/>
public void ExpandToBox3d(Box3d dst) public void ExpandToBox3d(ref Box3d dst)
{ {
//Console.WriteLine($"dst.A: {dst}"); //Console.WriteLine($"dst.A: {dst}");
LocalProjectService?.MachiningEquipment?.GetAsmb()?.ExpandToBox3d(dst, LocalProjectService?.MachiningEquipment?.GetAsmb()?.ExpandToBox3d(ref dst,
GetAnchor(), GetAnchor(),
GetAnchoredDisplayeeList().ToArray()); GetAnchoredDisplayeeList().ToArray());
//Console.WriteLine($"dst.B: {dst}"); //Console.WriteLine($"dst.B: {dst}");