80 lines
3.0 KiB
C#
80 lines
3.0 KiB
C#
using Hi.Wpf.Disp;
|
|
using System;
|
|
using Hi.MongoUtils;
|
|
using Hi.Licenses;
|
|
using Hi.MachiningProcs;
|
|
using Hi.Common.FileLines;
|
|
using Hi.MillingSteps;
|
|
using System.Windows;
|
|
using Hi.Disp;
|
|
|
|
namespace Sample.Machining
|
|
{
|
|
/// <summary>
|
|
/// Demonstrates integration of machining process visualization with interactive strip position selection.
|
|
/// Shows how to load a machining project, configure rendering options, and implement user interaction.
|
|
/// Provides a complete example of a 3D visualization application with HiAPI and WPF.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// ### Source Code
|
|
/// [!code-csharp[SampleCode](~/../Hi.Sample.Wpf/Machining/DemoRenderingMachiningProcessAndStripPosSelection.cs)]
|
|
/// </remarks>
|
|
public static class DemoRenderingMachiningProcessAndStripPosSelection
|
|
{
|
|
[STAThread]
|
|
static void Main(string[] args)
|
|
{
|
|
#region Initialize Environment
|
|
License.LogInAll();
|
|
DispEngine.Init();
|
|
MongoServer.Default = MongoServer.Run(new MongoRunnerOptions()
|
|
{
|
|
MongoPort = 28100
|
|
});
|
|
#endregion
|
|
|
|
#region Load Machining Project
|
|
var projectPath = "C:/HiNC-Projects/DemoStandardPath/Main.hincproj";
|
|
Console.WriteLine($"Load Project: {projectPath}");
|
|
MachiningProject machiningProject = MachiningProject.LoadFile(projectPath);
|
|
|
|
machiningProject.ShellApi.MillingStepSelected += (MachiningStep step) =>
|
|
{
|
|
var sourceCommand = step.SourceCommand;
|
|
Console.WriteLine($"Step Selected: MRR = {step.Mrr_mm3ds} At \"{sourceCommand?.FilePath}\" (Line {sourceCommand?.GetLineNo()}) \"{sourceCommand?.Line}\"");
|
|
};
|
|
machiningProject.PacePlayer.Start();
|
|
#endregion
|
|
|
|
#region Configure Rendering Options
|
|
var projectDisplayee = new MachiningProjectDisplayee(machiningProject);
|
|
projectDisplayee.RenderingFlagBitArray[(int)RenderingFlag.Mech] = true;
|
|
projectDisplayee.RenderingFlagBitArray[(int)RenderingFlag.Fixture] = true;
|
|
projectDisplayee.RenderingFlagBitArray[(int)RenderingFlag.WorkpieceGeom] = false;
|
|
projectDisplayee.RenderingFlagBitArray[(int)RenderingFlag.ClStrip] = true;
|
|
projectDisplayee.RenderingFlagBitArray[(int)RenderingFlag.DimensionBar] = true;
|
|
#endregion
|
|
|
|
#region Create and Run WPF Application
|
|
Application app = new Application
|
|
{
|
|
ShutdownMode = ShutdownMode.OnMainWindowClose
|
|
};
|
|
app.Exit += (o, e) =>
|
|
{
|
|
machiningProject.Dispose();
|
|
MongoServer.Default.Dispose();
|
|
DispEngine.FinishDisp();
|
|
License.LogOutAll();
|
|
Console.WriteLine($"App exit.");
|
|
};
|
|
app.Run(new RenderingWindow()
|
|
{
|
|
Title = "Demo",
|
|
Displayee = projectDisplayee
|
|
});
|
|
#endregion
|
|
}
|
|
}
|
|
}
|