feat(demos): take over the ten framework-independent samples from Hi.Sample.Wpf
Hi.WinForm and Hi.WpfPlus are being retired, and Hi.Sample.Wpf existed only to demonstrate Hi.WpfPlus -- but ten of its fourteen files never touched WPF at all. Those move here rather than leaving with it: - The three displayees upgrading-to-3.2/breaking-changes.md tells callers to copy -- MachiningProjectDisplayee, IsoCoordinateEntryDisplayee, HeidenhainCoordinateEntryDisplayee. They compose only public API over LocalProjectService, which is the point of shipping them as a starting sample; that doc now points at Hi.Sample/Disp/. - Seven display demos -- Cylindroid, DiscreteRgb, Drawing, Pick1, Pick2, Pickable, Satellite. Their only WPF coupling was the closing DemoUtil.RunApplication call. DemoUtil is rewritten for a project with no canvas. HiAPI ships none any more, so a sample cannot end by opening a window; Present() initializes the app, reports the displayee's type and bounding box, and shuts down, which makes the samples runnable and checkable headlessly and puts the handover where it actually is -- the application assigns the composed IDisplayee to its own canvas' DispEngine. The four files that genuinely need WPF (DemoStl, the old DemoUtil, and the two Machining demos) stay behind and retire with Hi.Sample.Wpf. Each moved file's own [!code-csharp] doc-comment path was repointed from ~/../Hi.Sample.Wpf/Disp/ to ~/../Hi.Sample/Disp/. Builds clean at x64: 0 warnings, 0 errors. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,119 @@
|
||||
using Hi.Disp.Flag;
|
||||
using Hi.Disp;
|
||||
using Hi.Machining.MachiningEquipmentUtils;
|
||||
using Hi.Mech.Topo;
|
||||
using Hi.Numerical;
|
||||
using Hi.Numerical.NcArgs;
|
||||
using System.Collections;
|
||||
using System;
|
||||
using Hi.Geom;
|
||||
using System.Linq;
|
||||
|
||||
namespace Sample.Disp
|
||||
{
|
||||
/// <summary>
|
||||
/// Displayee for Heidenhain coordinate entry visualization.
|
||||
/// </summary>
|
||||
public class HeidenhainCoordinateEntryDisplayee : IAnchoredDisplayee
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets whether to show Heidenhain datum preset information.
|
||||
/// </summary>
|
||||
public bool ShowHeidenhainDatumPreset { get; set; } = true;
|
||||
/// <summary>
|
||||
/// Gets or sets whether to show Heidenhain datum shift information.
|
||||
/// </summary>
|
||||
public bool ShowHeidenhainDatumShift { get; set; } = true;
|
||||
/// <summary>
|
||||
/// Gets or sets the function that provides the NcEnv instance.
|
||||
/// </summary>
|
||||
public Func<HardNcEnv> NcEnvFunc { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or sets the function that provides the machining equipment.
|
||||
/// </summary>
|
||||
public Func<IMachiningEquipment> MillingEquipmentFunc { get; set; }
|
||||
HardNcEnv NcEnv => NcEnvFunc?.Invoke();
|
||||
/// <summary>
|
||||
/// Gets or sets the Heidenhain Cycle Def 247 Q339 value.
|
||||
/// </summary>
|
||||
public int HeidenhainCycleDef247Q339 { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or sets the Heidenhain Cycle Def 7 arguments.
|
||||
/// </summary>
|
||||
public HeidenhainCycleDef7Arg HeidenhainCycleDef7Arg { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance.
|
||||
/// </summary>
|
||||
/// <param name="ncEnvFunc">The function that provides the NcEnv instance.</param>
|
||||
/// <param name="millingEquipmentSource">The function that provides the machining equipment.</param>
|
||||
public HeidenhainCoordinateEntryDisplayee(Func<HardNcEnv> ncEnvFunc, Func<IMachiningEquipment> millingEquipmentSource)
|
||||
{
|
||||
NcEnvFunc = ncEnvFunc;
|
||||
MillingEquipmentFunc = millingEquipmentSource;
|
||||
}
|
||||
/// <inheritdoc/>
|
||||
public void Display(Bind bind)
|
||||
{
|
||||
HardNcEnv ncEnv = NcEnv;
|
||||
if (ncEnv == null || NcEnv.CncBrand != CncBrand.Heidenhain)
|
||||
return;
|
||||
|
||||
////Console.WriteLine($"B: {CoordinateIndex}; {coordinateMove}");
|
||||
Vec3d mcXyz_AttacherAtTableBuckleZero = MillingEquipmentFunc?.Invoke()
|
||||
?.GetMachinePositionAtTableBuckleZero();
|
||||
if (mcXyz_AttacherAtTableBuckleZero == null)
|
||||
return;
|
||||
|
||||
Vec3d coordinateMove;
|
||||
string text;
|
||||
if (HeidenhainCycleDef247Q339 == 0 && HeidenhainCycleDef7Arg == null)
|
||||
return;
|
||||
coordinateMove = NcFlagUtil.GetHeidenhainCoordinateOffset(
|
||||
HeidenhainCycleDef247Q339, HeidenhainCycleDef7Arg, ncEnv);
|
||||
//Console.WriteLine($"HeidenhainCycleDef7Arg: {HeidenhainCycleDef7Arg==null}");
|
||||
string datumPresetText = null;
|
||||
if (HeidenhainCycleDef247Q339 != 0 && ShowHeidenhainDatumPreset)
|
||||
datumPresetText = $"Datum Preset Q339={HeidenhainCycleDef247Q339}";
|
||||
string datumShiftText = null;
|
||||
if (HeidenhainCycleDef7Arg != null && ShowHeidenhainDatumShift)
|
||||
datumShiftText = $"Datum Shift: {HeidenhainCycleDef7Arg?.ToString() ?? "None"}";
|
||||
text = string.Join(", ",
|
||||
(new string[] { datumPresetText, datumShiftText }).
|
||||
Where(v => v != null));
|
||||
//text = $"Datum Preset Q339={HeidenhainCycleDef247Q339}, Datum Shift: #1";
|
||||
//Console.WriteLine($"text: [{text}]");
|
||||
|
||||
bind.ModelMatStack.Push();
|
||||
bind.ModelMatStack.Trans(coordinateMove - mcXyz_AttacherAtTableBuckleZero);
|
||||
CoordinateDrawing.Display(bind, text);
|
||||
bind.ModelMatStack.Pop();
|
||||
}
|
||||
/// <inheritdoc/>
|
||||
public void ExpandToBox3d(Box3d dst)
|
||||
{
|
||||
HardNcEnv ncEnv = NcEnv;
|
||||
if (ncEnv == null || NcEnv.CncBrand != CncBrand.Heidenhain)
|
||||
return;
|
||||
|
||||
Vec3d mcXyz_AttacherAtTableBuckleZero = MillingEquipmentFunc?.Invoke()
|
||||
?.GetMachinePositionAtTableBuckleZero();
|
||||
if (mcXyz_AttacherAtTableBuckleZero == null)
|
||||
return;
|
||||
Vec3d coordinateMove;
|
||||
if (HeidenhainCycleDef247Q339 == 0 && HeidenhainCycleDef7Arg == null)
|
||||
return;
|
||||
coordinateMove = NcFlagUtil.GetHeidenhainCoordinateOffset(
|
||||
HeidenhainCycleDef247Q339, HeidenhainCycleDef7Arg, ncEnv);
|
||||
|
||||
|
||||
dst.Expand(-mcXyz_AttacherAtTableBuckleZero + coordinateMove);
|
||||
}
|
||||
/// <inheritdoc/>
|
||||
public Anchor GetAnchor()
|
||||
{
|
||||
return MillingEquipmentFunc?.Invoke()?.GetMachiningChain()
|
||||
?.GetTableBuckle()?.GetAnchor();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user