Compare commits
2 Commits
523d1b6733
...
e7880d7c06
| Author | SHA1 | Date | |
|---|---|---|---|
| e7880d7c06 | |||
| 3c4f552d5a |
@ -2,60 +2,57 @@
|
|||||||
using Hi.Geom;
|
using Hi.Geom;
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace Sample.Disp
|
namespace Sample.Disp;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Demonstrates creation of pickable 3D geometry at the primitive level.
|
||||||
|
/// Shows how to assign picking IDs directly to geometry vertices and create interactive triangles.
|
||||||
|
/// Uses a lower-level approach than the Pickable base class for more precise control.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// ### Source Code
|
||||||
|
/// [!code-csharp[SampleCode](~/../Hi.Sample.Wpf/Disp/DemoPickable.cs)]
|
||||||
|
/// </remarks>
|
||||||
|
public class DemoPickable : IDisplayee
|
||||||
{
|
{
|
||||||
/// <summary>
|
private readonly Drawing draw;
|
||||||
/// Demonstrates creation of pickable 3D geometry at the primitive level.
|
private readonly ShowEventPickable pickable;
|
||||||
/// Shows how to assign picking IDs directly to geometry vertices and create interactive triangles.
|
|
||||||
/// Uses a lower-level approach than the Pickable base class for more precise control.
|
/// <summary>
|
||||||
/// </summary>
|
/// Initializes a new instance of DemoPickable.
|
||||||
/// <remarks>
|
/// Creates a pickable triangle with a specific picking ID for user interaction.
|
||||||
/// ### Source Code
|
/// </summary>
|
||||||
/// [!code-csharp[SampleCode](~/../Hi.Sample.Wpf/Disp/DemoPickable.cs)]
|
public DemoPickable()
|
||||||
/// </remarks>
|
|
||||||
public class DemoPickable : IDisplayee
|
|
||||||
{
|
{
|
||||||
private readonly Drawing draw;
|
pickable = new ShowEventPickable();
|
||||||
private readonly ShowEventPickable pickable;
|
double pid = pickable.PickingID;
|
||||||
|
double[] vs = new double[] {
|
||||||
/// <summary>
|
//pickID, x,y,z
|
||||||
/// Initializes a new instance of DemoPickable.
|
pid, 0,0.1,0.1,
|
||||||
/// Creates a pickable triangle with a specific picking ID for user interaction.
|
pid, 0.1,0,0,
|
||||||
/// </summary>
|
pid, 0.1,0,0.1
|
||||||
public DemoPickable()
|
};
|
||||||
{
|
draw = new Drawing(vs, Stamp.PV, GL.GL_TRIANGLES);
|
||||||
pickable = new ShowEventPickable();
|
}
|
||||||
double pid = pickable.PickingID;
|
/// <inheritdoc/>
|
||||||
double[] vs = new double[] {
|
public void Display(Bind bind)
|
||||||
//pickID, x,y,z
|
{
|
||||||
pid, 0,0.1,0.1,
|
draw.Display(bind);
|
||||||
pid, 0.1,0,0,
|
}
|
||||||
pid, 0.1,0,0.1
|
/// <inheritdoc/>
|
||||||
};
|
public void ExpandToBox3d(Box3d dst)
|
||||||
draw = new Drawing(vs, Stamp.PV, GL.GL_TRIANGLES);
|
{
|
||||||
}
|
draw.ExpandToBox3d(dst);
|
||||||
/// <inheritdoc/>
|
|
||||||
public void Display(Bind bind)
|
|
||||||
{
|
|
||||||
draw.Display(bind);
|
|
||||||
}
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public void ExpandToBox3d(Box3d dst)
|
|
||||||
{
|
|
||||||
draw.ExpandToBox3d(dst);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Entry point for the DemoPickable example.
|
|
||||||
/// Creates and displays a pickable triangle that can respond to mouse events.
|
|
||||||
/// Demonstrates integration of picking functionality with geometric primitives.
|
|
||||||
/// </summary>
|
|
||||||
[STAThread]
|
|
||||||
public static void Main()
|
|
||||||
{
|
|
||||||
DemoUtil.RunApplication("DemoPickable", new DemoPickable());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Entry point for the DemoPickable example.
|
||||||
|
/// Creates and displays a pickable triangle that can respond to mouse events.
|
||||||
|
/// Demonstrates integration of picking functionality with geometric primitives.
|
||||||
|
/// </summary>
|
||||||
|
[STAThread]
|
||||||
|
public static void Main()
|
||||||
|
{
|
||||||
|
DemoUtil.RunApplication("DemoPickable", new DemoPickable());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
119
Disp/HeidenhainCoordinateEntryDisplayee.cs
Normal file
119
Disp/HeidenhainCoordinateEntryDisplayee.cs
Normal file
@ -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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
90
Disp/IsoCoordinateEntryDisplayee.cs
Normal file
90
Disp/IsoCoordinateEntryDisplayee.cs
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
using Hi.Disp;
|
||||||
|
using Hi.Disp.Flag;
|
||||||
|
using Hi.Geom;
|
||||||
|
using Hi.Machining.MachiningEquipmentUtils;
|
||||||
|
using Hi.Mech.Topo;
|
||||||
|
using Hi.Numerical;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Sample.Disp;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Displayee for ISO coordinate entry visualization.
|
||||||
|
/// </summary>
|
||||||
|
public class IsoCoordinateEntryDisplayee : IAnchoredDisplayee
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the ISO coordinate key (e.g. "G54", "G59.2").
|
||||||
|
/// </summary>
|
||||||
|
public string IsoCoordinateId { get; set; } = "G54";
|
||||||
|
/// <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>
|
||||||
|
/// Initializes a new instance of the <see cref="IsoCoordinateEntryDisplayee"/> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="ncEnvFunc">The function that provides the NcEnv instance.</param>
|
||||||
|
/// <param name="millingEquipmentSource">The function that provides the machining equipment.</param>
|
||||||
|
public IsoCoordinateEntryDisplayee(Func<HardNcEnv> ncEnvFunc,
|
||||||
|
Func<IMachiningEquipment> millingEquipmentSource)
|
||||||
|
{
|
||||||
|
NcEnvFunc = ncEnvFunc;
|
||||||
|
MillingEquipmentFunc = millingEquipmentSource;
|
||||||
|
}
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public void Display(Bind bind)
|
||||||
|
{
|
||||||
|
HardNcEnv ncEnv = NcEnv;
|
||||||
|
if (ncEnv == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Vec3d coordinateMove;
|
||||||
|
string text;
|
||||||
|
|
||||||
|
if (ncEnv.IsoCoordinateTable?.TryGetValue(
|
||||||
|
IsoCoordinateId, out coordinateMove) != true
|
||||||
|
|| coordinateMove == null)
|
||||||
|
return;
|
||||||
|
if (coordinateMove == null)
|
||||||
|
return;
|
||||||
|
text = IsoCoordinateId ?? "";
|
||||||
|
|
||||||
|
Vec3d attacherPos = MillingEquipmentFunc?.Invoke()
|
||||||
|
?.GetIsoCoordinatePosition(coordinateMove);
|
||||||
|
|
||||||
|
bind.ModelMatStack.Push();
|
||||||
|
bind.ModelMatStack.Trans(attacherPos);
|
||||||
|
CoordinateDrawing.Display(bind, text);
|
||||||
|
bind.ModelMatStack.Pop();
|
||||||
|
}
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public void ExpandToBox3d(Box3d dst)
|
||||||
|
{
|
||||||
|
HardNcEnv ncEnv = NcEnv;
|
||||||
|
if (ncEnv == null)
|
||||||
|
return;
|
||||||
|
Vec3d coordinateMove;
|
||||||
|
if (ncEnv.IsoCoordinateTable?.TryGetValue(IsoCoordinateId, out coordinateMove) != true
|
||||||
|
|| coordinateMove == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Vec3d attacherPos = MillingEquipmentFunc?.Invoke()
|
||||||
|
?.GetIsoCoordinatePosition(coordinateMove);
|
||||||
|
if (attacherPos == null)
|
||||||
|
return;
|
||||||
|
dst.Expand(attacherPos);
|
||||||
|
}
|
||||||
|
/// <inheritdoc/>
|
||||||
|
/// <returns>Table Buckle if existed; otherwise, return null.</returns>
|
||||||
|
public Anchor GetAnchor()
|
||||||
|
{
|
||||||
|
return MillingEquipmentFunc?.Invoke()?.GetMachiningChain()?.GetAnchor();
|
||||||
|
}
|
||||||
|
}
|
||||||
239
Disp/MachiningProjectDisplayee.cs
Normal file
239
Disp/MachiningProjectDisplayee.cs
Normal file
@ -0,0 +1,239 @@
|
|||||||
|
using Hi.Coloring;
|
||||||
|
using Hi.MachiningProcs;
|
||||||
|
using Hi.Common;
|
||||||
|
using Hi.Disp;
|
||||||
|
using Hi.Disp.Flag;
|
||||||
|
using Hi.Mech.Topo;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Collections;
|
||||||
|
using Hi.Geom;
|
||||||
|
using System.Linq;
|
||||||
|
using Hi.Numerical;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Sample.Disp;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Represents a displayable wrapper for a machining project.
|
||||||
|
/// </summary>
|
||||||
|
public class MachiningProjectDisplayee : IDisplayee, IGetAnchor
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the current milling course from the host function.
|
||||||
|
/// </summary>
|
||||||
|
public MachiningProject MachiningProject => LocalProjectService.MachiningProject;
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the function that provides the machining project.
|
||||||
|
/// </summary>
|
||||||
|
public LocalProjectService LocalProjectService { get; set; }
|
||||||
|
|
||||||
|
///// <summary>
|
||||||
|
///// Initializes a new instance of the <see cref="MachiningProjectDisplayee"/> class.
|
||||||
|
///// </summary>
|
||||||
|
///// <param name="machiningProject">The machining project to display.</param>
|
||||||
|
///// <param name="renderingFlagBitArray">The bit array controlling rendering flags.</param>
|
||||||
|
//public MachiningProjectDisplayee(MachiningProject machiningProject,
|
||||||
|
// BitArray renderingFlagBitArray)
|
||||||
|
// {
|
||||||
|
// RenderingFlagBitArray = renderingFlagBitArray;
|
||||||
|
// }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="MachiningProjectDisplayee"/> class with default rendering flags.
|
||||||
|
/// </summary>
|
||||||
|
public MachiningProjectDisplayee(LocalProjectService localProjectService)
|
||||||
|
{ LocalProjectService = localProjectService; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the bit array that controls which elements are rendered.
|
||||||
|
/// </summary>
|
||||||
|
public BitArray RenderingFlagBitArray { get; set; } = new BitArray(EnumUtil.GetEnumBitArrayCap<RenderingFlag>())
|
||||||
|
{
|
||||||
|
[(int)RenderingFlag.DimensionBar] = true,
|
||||||
|
[(int)RenderingFlag.WorkpieceGeom] = true,
|
||||||
|
[(int)RenderingFlag.Fixture] = true,
|
||||||
|
[(int)RenderingFlag.ClStrip] = true,
|
||||||
|
//[(int)RenderingFlag.Mech] = true,
|
||||||
|
};
|
||||||
|
IsoCoordinateEntryDisplayee isoCoordinateEntryDisplayee;
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the ISO coordinate entry displayee for ISO-based coordinate systems.
|
||||||
|
/// </summary>
|
||||||
|
public IsoCoordinateEntryDisplayee IsoCoordinateEntryDisplayee =>
|
||||||
|
isoCoordinateEntryDisplayee ??= new IsoCoordinateEntryDisplayee(
|
||||||
|
() => MachiningProject.NcEnv,
|
||||||
|
() => LocalProjectService.MachiningEquipment);
|
||||||
|
HeidenhainCoordinateEntryDisplayee heidenhainCoordinateEntryDisplayee;
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the Heidenhain coordinate entry displayee for Heidenhain-based coordinate systems.
|
||||||
|
/// </summary>
|
||||||
|
public HeidenhainCoordinateEntryDisplayee HeidenhainCoordinateEntryDisplayee =>
|
||||||
|
heidenhainCoordinateEntryDisplayee ??= new HeidenhainCoordinateEntryDisplayee(
|
||||||
|
() => MachiningProject.NcEnv,
|
||||||
|
() => LocalProjectService.MachiningEquipment);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets a list of anchored displayees based on current rendering flags.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>A list of anchored displayees for rendering</returns>
|
||||||
|
List<IAnchoredDisplayee> GetAnchoredDisplayeeList()
|
||||||
|
{
|
||||||
|
List<IAnchoredDisplayee> dst = new List<IAnchoredDisplayee>();
|
||||||
|
MachiningProject machiningProject = MachiningProject;
|
||||||
|
if (machiningProject == null)
|
||||||
|
return dst;
|
||||||
|
|
||||||
|
LocalProjectService localProjectService = LocalProjectService;
|
||||||
|
HardNcEnv ncEnv = machiningProject.NcEnv;
|
||||||
|
var workpiece = localProjectService.Workpiece;
|
||||||
|
var machiningEquipment = localProjectService.MachiningEquipment;
|
||||||
|
|
||||||
|
if (RenderingFlagBitArray[(int)RenderingFlag.ClStrip])
|
||||||
|
{
|
||||||
|
localProjectService.ClStrip.IsKeepingDispAlive = true;
|
||||||
|
dst.Add(new AnchoredDisplayee(
|
||||||
|
localProjectService.MachiningEquipment?.Workpiece?.ProgramZeroAnchor,
|
||||||
|
localProjectService.ClStrip));
|
||||||
|
}
|
||||||
|
if (RenderingFlagBitArray[(int)RenderingFlag.Mech])
|
||||||
|
{
|
||||||
|
if (localProjectService.MachiningEquipment != null)
|
||||||
|
{
|
||||||
|
List<IAnchoredDisplayee> machAncDisplayees = localProjectService
|
||||||
|
?.MachiningEquipment?.GetAnchoredDisplayeeList() ?? [];
|
||||||
|
HashSet<Anchor> exclusiveAnchorSet = new([
|
||||||
|
.. localProjectService.Workpiece?.Asmb.GetDescendantAnchors()??[],
|
||||||
|
.. localProjectService.MachiningTool?.GetAsmb().GetDescendantAnchors()??[],
|
||||||
|
.. localProjectService.Fixture?.Asmb.GetDescendantAnchors()??[],
|
||||||
|
]);
|
||||||
|
dst.AddRange(machAncDisplayees.Where(ad =>
|
||||||
|
!exclusiveAnchorSet.Contains(ad.GetAnchor())));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (RenderingFlagBitArray[(int)RenderingFlag.WorkpieceGeom])
|
||||||
|
{
|
||||||
|
if (workpiece != null)
|
||||||
|
dst.AddRange(localProjectService.WorkpieceService
|
||||||
|
.GetAnchoredDisplayeeList());
|
||||||
|
}
|
||||||
|
if (RenderingFlagBitArray[(int)RenderingFlag.Tool])
|
||||||
|
{
|
||||||
|
if (localProjectService.MachiningEquipment != null
|
||||||
|
&& localProjectService.MachiningTool != null)
|
||||||
|
dst.Add(new AnchoredDisplayee(
|
||||||
|
localProjectService.MachiningTool?.GetAnchor(),
|
||||||
|
localProjectService.MachiningTool));
|
||||||
|
}
|
||||||
|
if (RenderingFlagBitArray[(int)RenderingFlag.Fixture])
|
||||||
|
{
|
||||||
|
if (localProjectService.MachiningEquipment != null
|
||||||
|
&& localProjectService.Fixture != null)
|
||||||
|
dst.Add(new AnchoredDisplayee(
|
||||||
|
localProjectService.Fixture?.GeomAnchor,
|
||||||
|
localProjectService.Fixture));
|
||||||
|
}
|
||||||
|
if (RenderingFlagBitArray[(int)RenderingFlag.ProgramZero])
|
||||||
|
{
|
||||||
|
if (workpiece != null)
|
||||||
|
dst.Add(workpiece.ProgramZeroAnchor);
|
||||||
|
}
|
||||||
|
if (RenderingFlagBitArray[(int)RenderingFlag.IsoCoordinate])
|
||||||
|
{
|
||||||
|
dst.Add(IsoCoordinateEntryDisplayee);
|
||||||
|
}
|
||||||
|
if (RenderingFlagBitArray[(int)RenderingFlag.HeidenhainCoordinate]
|
||||||
|
&& ncEnv.CncBrand == CncBrand.Heidenhain)
|
||||||
|
{
|
||||||
|
dst.Add(HeidenhainCoordinateEntryDisplayee);
|
||||||
|
}
|
||||||
|
return dst;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the root anchor for the display hierarchy based on current rendering flags.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The root anchor to use for rendering</returns>
|
||||||
|
internal static Anchor GetRootAnchor(
|
||||||
|
LocalProjectService localProjectService, BitArray renderingFlagBitArray)
|
||||||
|
{
|
||||||
|
if (renderingFlagBitArray[(int)RenderingFlag.Mech])
|
||||||
|
return localProjectService?.MachiningEquipment?.GetAnchor();
|
||||||
|
else if (renderingFlagBitArray[(int)RenderingFlag.WorkpieceGeom])
|
||||||
|
return localProjectService.Workpiece?.GetAnchor();
|
||||||
|
else if (renderingFlagBitArray[(int)RenderingFlag.Fixture])
|
||||||
|
return localProjectService.Fixture?.GetAnchor();
|
||||||
|
else if (renderingFlagBitArray[(int)RenderingFlag.Tool])
|
||||||
|
return localProjectService.MachiningTool?.GetAnchor();
|
||||||
|
else
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public Anchor GetAnchor() => GetRootAnchor(LocalProjectService, RenderingFlagBitArray);
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public void Display(Bind bind)
|
||||||
|
{
|
||||||
|
//Console.WriteLine($"RB: {string.Join(',', Enumerable.Range(0,
|
||||||
|
// RenderingFlagBitArray.Length).Select(RenderingFlagBitArray.Get))}");
|
||||||
|
|
||||||
|
//ClStrip pos has to be update by ClStrip.
|
||||||
|
if (RenderingFlagBitArray[(int)RenderingFlag.WorkpieceGeom]
|
||||||
|
&& !RenderingFlagBitArray[(int)RenderingFlag.ClStrip]
|
||||||
|
&& LocalProjectService?.ClStrip.CallRefreshDrawing == true)
|
||||||
|
LocalProjectService?.ClStrip.RefreshDrawingInRendering(false);
|
||||||
|
|
||||||
|
bind.PushCoveringPixelMode();
|
||||||
|
double offsetHOnCover = 0;
|
||||||
|
if (RenderingFlagBitArray[(int)RenderingFlag.DimensionBar])
|
||||||
|
{
|
||||||
|
bind.ModelMatStack.Push();
|
||||||
|
bind.ModelMatStack.Trans(0, offsetHOnCover, 0);
|
||||||
|
DimensionBar.Display(bind, "mm");
|
||||||
|
bind.ModelMatStack.Pop();
|
||||||
|
offsetHOnCover += DimensionBar.OffsetH;
|
||||||
|
}
|
||||||
|
if (RenderingFlagBitArray[(int)RenderingFlag.ColorScaleBar]
|
||||||
|
&& MachiningProject?.MillingGuide?.DictionaryColorGuide?.SelectedColorGuide
|
||||||
|
is IGetRangeColorRule getRangeColorRule)
|
||||||
|
{
|
||||||
|
var rangeColorRule = getRangeColorRule.GetRangeColorRule();
|
||||||
|
if (rangeColorRule != null)
|
||||||
|
{
|
||||||
|
bind.ModelMatStack.Push();
|
||||||
|
bind.ModelMatStack.Trans(0, offsetHOnCover, 0);
|
||||||
|
|
||||||
|
ColorScaleBar.Display(bind,
|
||||||
|
rangeColorRule.Floor, rangeColorRule.Ceiling,
|
||||||
|
rangeColorRule.GetRgb, "L.", "");
|
||||||
|
bind.ModelMatStack.Pop();
|
||||||
|
offsetHOnCover += ColorScaleBar.OffsetH;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (LocalProjectService?.WorkpieceService?.HasDiff == true)
|
||||||
|
{
|
||||||
|
bind.ModelMatStack.Push();
|
||||||
|
bind.ModelMatStack.Trans(0, offsetHOnCover, 0);
|
||||||
|
|
||||||
|
var rangeColorRule = LocalProjectService.WorkpieceService.DiffRangeColorRule;
|
||||||
|
ColorScaleBar.Display(bind,
|
||||||
|
rangeColorRule.Floor, rangeColorRule.Ceiling,
|
||||||
|
rangeColorRule.GetRgb, "Df.", "");
|
||||||
|
bind.ModelMatStack.Pop();
|
||||||
|
offsetHOnCover += ColorScaleBar.OffsetH;
|
||||||
|
}
|
||||||
|
bind.ModelMatStack.Pop();
|
||||||
|
|
||||||
|
bind.PushColorByRgb(1, 1, 1);
|
||||||
|
LocalProjectService?.MachiningEquipment?.GetAsmb()?.Display(bind,
|
||||||
|
GetAnchor(),
|
||||||
|
GetAnchoredDisplayeeList().ToArray());
|
||||||
|
bind.PopColor();
|
||||||
|
}
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public void ExpandToBox3d(Box3d dst)
|
||||||
|
{
|
||||||
|
//Console.WriteLine($"dst.A: {dst}");
|
||||||
|
LocalProjectService?.MachiningEquipment?.GetAsmb()?.ExpandToBox3d(dst,
|
||||||
|
GetAnchor(),
|
||||||
|
GetAnchoredDisplayeeList().ToArray());
|
||||||
|
//Console.WriteLine($"dst.B: {dst}");
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -12,6 +12,7 @@ using System;
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
|
using Sample.Disp;
|
||||||
|
|
||||||
namespace Sample.Machining
|
namespace Sample.Machining
|
||||||
{
|
{
|
||||||
|
|||||||
@ -6,6 +6,7 @@ using System.Windows;
|
|||||||
using Hi.MachiningSteps;
|
using Hi.MachiningSteps;
|
||||||
using Hi.HiNcKits;
|
using Hi.HiNcKits;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Sample.Disp;
|
||||||
|
|
||||||
namespace Sample.Machining
|
namespace Sample.Machining
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user