修复比例错误
This commit is contained in:
parent
5da28a3d31
commit
839e100231
@ -166,7 +166,8 @@ namespace CadParamPluging.Cad
|
||||
bool isRolling = !string.IsNullOrWhiteSpace(processMethod) && processMethod.Contains("轧制");
|
||||
|
||||
double activeWidth = outerDia;
|
||||
var extraMargin = 40.0; // Default margin
|
||||
double activeHeight = height;
|
||||
var extraMargin = 50.0; // 标注和文字的默认边距(双侧共100)
|
||||
|
||||
if (isMachined && isRolling)
|
||||
{
|
||||
@ -174,28 +175,27 @@ namespace CadParamPluging.Cad
|
||||
|
||||
if (minWallThickness.HasValue && minWallThickness.Value > 0)
|
||||
{
|
||||
// Width is controlled by min wall thickness (Width = 3 * Wall)
|
||||
// Schematic mode: 2/3 hole, 1/3 wall
|
||||
// 示意图模式:视觉宽度 = 最小壁厚 * 3(不是物理外径)
|
||||
// 比例 2:1 内孔:实体
|
||||
activeWidth = minWallThickness.Value * 3.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Fallback: visual width is fixed to 3.0 * Height
|
||||
// 降级:视觉宽度 = 高度 * 3
|
||||
activeWidth = height * 3.0;
|
||||
}
|
||||
|
||||
// Increase margin significantly for schematic mode to avoid "Too Small" detection
|
||||
// leading to unnecessary zoom-in suggestions (e.g. 1:1.35).
|
||||
// Effectively claims a larger safe zone around the small schematic.
|
||||
extraMargin = 120;
|
||||
// 示意图模式下,图形较小,标注边距也相应调整
|
||||
// 但不要过大,否则会错误触发"超出边框"检测
|
||||
extraMargin = 60.0; // 示意图的边距稍大于默认值
|
||||
}
|
||||
|
||||
// 环形图形:宽度=外径(X方向),高度=高度参数(Y方向)
|
||||
// 加上标注的额外空间
|
||||
// 环形图形:宽度=视觉宽度(X方向),高度=高度参数(Y方向)
|
||||
// 加上标注的额外空间(双侧)
|
||||
return new ExpectedDrawingSize
|
||||
{
|
||||
Width = activeWidth + extraMargin * 2,
|
||||
Height = height + extraMargin * 2
|
||||
Height = activeHeight + extraMargin * 2
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -353,6 +353,15 @@ namespace CadParamPluging.UI
|
||||
// 1. 获取预估图形尺寸 (不含标注的纯几何尺寸 + 预留边距)
|
||||
var expectedSize = FeatureDrivenDrawer.CalculateExpectedSize(bag, tplParams.SheetSize);
|
||||
|
||||
// 调试:输出关键参数以排查比例建议错误
|
||||
var debugDelivery = bag.GetString("DeliveryStatus");
|
||||
var debugProcess = bag.GetString("ProcessMethod");
|
||||
var debugMinWall = bag.GetDoubleOrNull("MinWallThickness");
|
||||
var debugHeight = bag.GetDoubleOrNull("Height1");
|
||||
var debugOuterDia = bag.GetDoubleOrNull("OuterDiameter1");
|
||||
AppendLog($"[调试] 交付状态={debugDelivery}, 工艺方法={debugProcess}");
|
||||
AppendLog($"[调试] 外径D1={debugOuterDia}, 高度H1={debugHeight}, 最小壁厚={debugMinWall}, 结构={tplParams.SheetSize}");
|
||||
|
||||
if (expectedSize.IsValid)
|
||||
{
|
||||
var currentDrawW = expectedSize.Width * scaleFactor;
|
||||
@ -364,6 +373,7 @@ namespace CadParamPluging.UI
|
||||
// 调试日志
|
||||
AppendLog($"[尺寸检查] 白框尺寸: {frameWidth:F0}x{frameHeight:F0}, 预期图形(原始): {expectedSize.Width:F0}x{expectedSize.Height:F0}, 当前比例: 1:{(1/scaleFactor):F1}");
|
||||
AppendLog($"[尺寸检查] 预期图形(缩放后): {currentDrawW:F0}x{currentDrawH:F0}, 超出={isOverflow}, 过小={isTooSmall}");
|
||||
AppendLog($"[尺寸检查] 判断阈值: 超出条件(W>{frameWidth:F0} || H>{frameHeight:F0}), 过小条件(W<{frameWidth*0.3:F0} && H<{frameHeight*0.3:F0})");
|
||||
|
||||
if (isOverflow || isTooSmall)
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user