显示 3.175 外围孔间距
This commit is contained in:
17
App.xaml.cs
17
App.xaml.cs
@@ -54,8 +54,23 @@ namespace DrillTools
|
|||||||
bool isPpDrillTape = viewModel.IsPpDrillTape;
|
bool isPpDrillTape = viewModel.IsPpDrillTape;
|
||||||
double ppXSpacing = viewModel.PpXSpacing;
|
double ppXSpacing = viewModel.PpXSpacing;
|
||||||
double ppYSpacing = viewModel.PpYSpacing;
|
double ppYSpacing = viewModel.PpYSpacing;
|
||||||
|
bool hasOuter3175Spacing = viewModel.HasOuter3175Spacing;
|
||||||
|
double outer3175XSpacing = viewModel.Outer3175XSpacing;
|
||||||
|
double outer3175YSpacing = viewModel.Outer3175YSpacing;
|
||||||
|
|
||||||
var selectionWindow = new StartupSelectionWindow(filePath, canClearParameters, canGeneratePpDrillTape, minDrill, minSlot, minEA, isPpDrillTape, ppXSpacing, ppYSpacing);
|
var selectionWindow = new StartupSelectionWindow(
|
||||||
|
filePath,
|
||||||
|
canClearParameters,
|
||||||
|
canGeneratePpDrillTape,
|
||||||
|
minDrill,
|
||||||
|
minSlot,
|
||||||
|
minEA,
|
||||||
|
isPpDrillTape,
|
||||||
|
ppXSpacing,
|
||||||
|
ppYSpacing,
|
||||||
|
hasOuter3175Spacing,
|
||||||
|
outer3175XSpacing,
|
||||||
|
outer3175YSpacing);
|
||||||
selectionWindow.ShowDialog();
|
selectionWindow.ShowDialog();
|
||||||
|
|
||||||
switch (selectionWindow.SelectedAction)
|
switch (selectionWindow.SelectedAction)
|
||||||
|
|||||||
@@ -205,6 +205,7 @@
|
|||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="Auto" />
|
<RowDefinition Height="Auto" />
|
||||||
<RowDefinition Height="Auto" />
|
<RowDefinition Height="Auto" />
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
|
|
||||||
<!-- 文件名单独一行 -->
|
<!-- 文件名单独一行 -->
|
||||||
@@ -259,6 +260,21 @@
|
|||||||
Text="{Binding MinEADiameter, StringFormat=F3}" />
|
Text="{Binding MinEADiameter, StringFormat=F3}" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
|
<StackPanel
|
||||||
|
Grid.Row="2"
|
||||||
|
Margin="0,5,0,0"
|
||||||
|
Orientation="Horizontal"
|
||||||
|
Visibility="{Binding HasOuter3175Spacing, Converter={StaticResource BooleanToVisibilityConverter}}">
|
||||||
|
<TextBlock VerticalAlignment="Center" Text="3.175外围孔 " />
|
||||||
|
<TextBlock
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
Text="{Binding Outer3175XSpacing, StringFormat=X间距: {0:F3}}" />
|
||||||
|
<TextBlock
|
||||||
|
Margin="10,0,0,0"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
Text="{Binding Outer3175YSpacing, StringFormat=Y间距: {0:F3}}" />
|
||||||
|
</StackPanel>
|
||||||
</Grid>
|
</Grid>
|
||||||
</GroupBox>
|
</GroupBox>
|
||||||
|
|
||||||
|
|||||||
@@ -36,6 +36,9 @@ namespace DrillTools
|
|||||||
private bool _isPpDrillTape;
|
private bool _isPpDrillTape;
|
||||||
private double _ppXSpacing;
|
private double _ppXSpacing;
|
||||||
private double _ppYSpacing;
|
private double _ppYSpacing;
|
||||||
|
private bool _hasOuter3175Spacing;
|
||||||
|
private double _outer3175XSpacing;
|
||||||
|
private double _outer3175YSpacing;
|
||||||
|
|
||||||
private const int SwRestore = 9;
|
private const int SwRestore = 9;
|
||||||
private const int SvsiSelect = 0x1;
|
private const int SvsiSelect = 0x1;
|
||||||
@@ -239,6 +242,33 @@ namespace DrillTools
|
|||||||
set => SetProperty(ref _ppYSpacing, value);
|
set => SetProperty(ref _ppYSpacing, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否存在3.175外围孔间距信息
|
||||||
|
/// </summary>
|
||||||
|
public bool HasOuter3175Spacing
|
||||||
|
{
|
||||||
|
get => _hasOuter3175Spacing;
|
||||||
|
set => SetProperty(ref _hasOuter3175Spacing, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 3.175外围孔X间距(单位mm)
|
||||||
|
/// </summary>
|
||||||
|
public double Outer3175XSpacing
|
||||||
|
{
|
||||||
|
get => _outer3175XSpacing;
|
||||||
|
set => SetProperty(ref _outer3175XSpacing, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 3.175外围孔Y间距(单位mm)
|
||||||
|
/// </summary>
|
||||||
|
public double Outer3175YSpacing
|
||||||
|
{
|
||||||
|
get => _outer3175YSpacing;
|
||||||
|
set => SetProperty(ref _outer3175YSpacing, value);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 从钻带内容加载刀具信息
|
/// 从钻带内容加载刀具信息
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -248,6 +278,7 @@ namespace DrillTools
|
|||||||
DrillTapeContent = drillTapeContent;
|
DrillTapeContent = drillTapeContent;
|
||||||
Tools.Clear();
|
Tools.Clear();
|
||||||
OriginalTools.Clear(); // 清空原始刀具顺序
|
OriginalTools.Clear(); // 清空原始刀具顺序
|
||||||
|
UpdateOuter3175SpacingInfo();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -348,6 +379,7 @@ namespace DrillTools
|
|||||||
|
|
||||||
// 计算PP钻带间距
|
// 计算PP钻带间距
|
||||||
UpdatePpSpacingInfo();
|
UpdatePpSpacingInfo();
|
||||||
|
UpdateOuter3175SpacingInfo();
|
||||||
|
|
||||||
// 启动菜单的预检查和非调整刀序动作会关闭此开关,避免排序提示抢在菜单前弹出。
|
// 启动菜单的预检查和非调整刀序动作会关闭此开关,避免排序提示抢在菜单前弹出。
|
||||||
if (ShouldCheckSortFileOnLoad && !string.IsNullOrEmpty(OriginalFilePath))
|
if (ShouldCheckSortFileOnLoad && !string.IsNullOrEmpty(OriginalFilePath))
|
||||||
@@ -888,6 +920,9 @@ namespace DrillTools
|
|||||||
// 计算并更新最小直径信息
|
// 计算并更新最小直径信息
|
||||||
UpdateMinDiameterInfo();
|
UpdateMinDiameterInfo();
|
||||||
|
|
||||||
|
// 计算3.175外围孔间距
|
||||||
|
UpdateOuter3175SpacingInfo();
|
||||||
|
|
||||||
// 加载示例钻带内容
|
// 加载示例钻带内容
|
||||||
DrillTapeContent = @"M48
|
DrillTapeContent = @"M48
|
||||||
;厚铜板参数-镀膜-EA-250618
|
;厚铜板参数-镀膜-EA-250618
|
||||||
@@ -1742,6 +1777,63 @@ M30";
|
|||||||
System.Diagnostics.Debug.WriteLine($"=== 计算完成 ===");
|
System.Diagnostics.Debug.WriteLine($"=== 计算完成 ===");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 更新3.175外围孔间距信息
|
||||||
|
/// </summary>
|
||||||
|
private void UpdateOuter3175SpacingInfo()
|
||||||
|
{
|
||||||
|
HasOuter3175Spacing = false;
|
||||||
|
Outer3175XSpacing = 0;
|
||||||
|
Outer3175YSpacing = 0;
|
||||||
|
|
||||||
|
var targetTool = Tools.FirstOrDefault(tool => Math.Abs(tool.Diameter - 3.175) < 0.001);
|
||||||
|
if (targetTool?.HoleLocations == null || targetTool.HoleLocations.Count == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var points = ExtractCoordinatePoints(targetTool.HoleLocations);
|
||||||
|
if (points.Count < 4)
|
||||||
|
return;
|
||||||
|
|
||||||
|
double topY = points.Max(point => point.Y);
|
||||||
|
double bottomY = points.Min(point => point.Y);
|
||||||
|
|
||||||
|
var topRowPoints = points.Where(point => Math.Abs(point.Y - topY) < 0.0001).ToList();
|
||||||
|
var bottomRowPoints = points.Where(point => Math.Abs(point.Y - bottomY) < 0.0001).ToList();
|
||||||
|
|
||||||
|
if (topRowPoints.Count < 2 || bottomRowPoints.Count < 2)
|
||||||
|
return;
|
||||||
|
|
||||||
|
double leftX = Math.Min(topRowPoints.Min(point => point.X), bottomRowPoints.Min(point => point.X));
|
||||||
|
double rightX = Math.Max(topRowPoints.Max(point => point.X), bottomRowPoints.Max(point => point.X));
|
||||||
|
|
||||||
|
Outer3175XSpacing = Math.Round(rightX - leftX, 3, MidpointRounding.AwayFromZero);
|
||||||
|
Outer3175YSpacing = Math.Round(topY - bottomY, 3, MidpointRounding.AwayFromZero);
|
||||||
|
HasOuter3175Spacing = true;
|
||||||
|
|
||||||
|
Debug.WriteLine($"[3.175外围孔] X间距={Outer3175XSpacing:F3}, Y间距={Outer3175YSpacing:F3}");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 从孔位文本中提取坐标点,统一转换为毫米
|
||||||
|
/// </summary>
|
||||||
|
private static List<(double X, double Y)> ExtractCoordinatePoints(IEnumerable<string> holeLocations)
|
||||||
|
{
|
||||||
|
var points = new List<(double X, double Y)>();
|
||||||
|
|
||||||
|
foreach (var location in holeLocations)
|
||||||
|
{
|
||||||
|
var match = Regex.Match(location, @"X([+-]?\d+)Y([+-]?\d+)");
|
||||||
|
if (!match.Success)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
double x = double.Parse(match.Groups[1].Value) / 1000.0;
|
||||||
|
double y = double.Parse(match.Groups[2].Value) / 1000.0;
|
||||||
|
points.Add((x, y));
|
||||||
|
}
|
||||||
|
|
||||||
|
return points;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 更新PP钻带间距信息
|
/// 更新PP钻带间距信息
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -1767,18 +1859,7 @@ M30";
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// 解析孔位坐标
|
// 解析孔位坐标
|
||||||
var points = new List<(double X, double Y)>();
|
var points = ExtractCoordinatePoints(tool.HoleLocations);
|
||||||
|
|
||||||
foreach (var location in tool.HoleLocations)
|
|
||||||
{
|
|
||||||
var match = System.Text.RegularExpressions.Regex.Match(location, @"X([+-]?\d+)Y([+-]?\d+)");
|
|
||||||
if (match.Success)
|
|
||||||
{
|
|
||||||
double x = double.Parse(match.Groups[1].Value) / 1000.0;
|
|
||||||
double y = double.Parse(match.Groups[2].Value) / 1000.0;
|
|
||||||
points.Add((x, y));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (points.Count != 4)
|
if (points.Count != 4)
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="Auto" />
|
<RowDefinition Height="Auto" />
|
||||||
<RowDefinition Height="Auto" />
|
<RowDefinition Height="Auto" />
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
|
|
||||||
<StackPanel Grid.Row="0" Orientation="Horizontal">
|
<StackPanel Grid.Row="0" Orientation="Horizontal">
|
||||||
@@ -71,6 +72,21 @@
|
|||||||
Text="{Binding MinEADiameter, StringFormat=F3}" />
|
Text="{Binding MinEADiameter, StringFormat=F3}" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
|
<StackPanel
|
||||||
|
Grid.Row="2"
|
||||||
|
Margin="0,5,0,0"
|
||||||
|
Orientation="Horizontal"
|
||||||
|
Visibility="{Binding HasOuter3175Spacing, Converter={StaticResource BooleanToVisibilityConverter}}">
|
||||||
|
<TextBlock VerticalAlignment="Center" Text="3.175外围孔 " />
|
||||||
|
<TextBlock
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
Text="{Binding Outer3175XSpacing, StringFormat=X间距: {0:F3}}" />
|
||||||
|
<TextBlock
|
||||||
|
Margin="10,0,0,0"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
Text="{Binding Outer3175YSpacing, StringFormat=Y间距: {0:F3}}" />
|
||||||
|
</StackPanel>
|
||||||
</Grid>
|
</Grid>
|
||||||
</GroupBox>
|
</GroupBox>
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,8 @@ namespace DrillTools
|
|||||||
|
|
||||||
public StartupSelectionWindow(string filePath, bool canClearParameters = false, bool canGeneratePpDrillTape = false,
|
public StartupSelectionWindow(string filePath, bool canClearParameters = false, bool canGeneratePpDrillTape = false,
|
||||||
double minDrillDiameter = 0, double minSlotDiameter = 0, double minEADiameter = 0,
|
double minDrillDiameter = 0, double minSlotDiameter = 0, double minEADiameter = 0,
|
||||||
bool isPpDrillTape = false, double ppXSpacing = 0, double ppYSpacing = 0)
|
bool isPpDrillTape = false, double ppXSpacing = 0, double ppYSpacing = 0,
|
||||||
|
bool hasOuter3175Spacing = false, double outer3175XSpacing = 0, double outer3175YSpacing = 0)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
DataContext = new
|
DataContext = new
|
||||||
@@ -29,7 +30,10 @@ namespace DrillTools
|
|||||||
MinEADiameter = minEADiameter,
|
MinEADiameter = minEADiameter,
|
||||||
IsPpDrillTape = isPpDrillTape,
|
IsPpDrillTape = isPpDrillTape,
|
||||||
PpXSpacing = ppXSpacing,
|
PpXSpacing = ppXSpacing,
|
||||||
PpYSpacing = ppYSpacing
|
PpYSpacing = ppYSpacing,
|
||||||
|
HasOuter3175Spacing = hasOuter3175Spacing,
|
||||||
|
Outer3175XSpacing = outer3175XSpacing,
|
||||||
|
Outer3175YSpacing = outer3175YSpacing
|
||||||
};
|
};
|
||||||
ClearParametersButton.Visibility = canClearParameters ? Visibility.Visible : Visibility.Collapsed;
|
ClearParametersButton.Visibility = canClearParameters ? Visibility.Visible : Visibility.Collapsed;
|
||||||
GeneratePpDrillTapeButton.Visibility = canGeneratePpDrillTape ? Visibility.Visible : Visibility.Collapsed;
|
GeneratePpDrillTapeButton.Visibility = canGeneratePpDrillTape ? Visibility.Visible : Visibility.Collapsed;
|
||||||
|
|||||||
Reference in New Issue
Block a user