diff --git a/Cad/BlockRawFreeForgeNoRoundHeadDrawer.cs b/Cad/BlockRawFreeForgeNoRoundHeadDrawer.cs
index f6555c4..8b7401d 100644
--- a/Cad/BlockRawFreeForgeNoRoundHeadDrawer.cs
+++ b/Cad/BlockRawFreeForgeNoRoundHeadDrawer.cs
@@ -637,7 +637,7 @@ namespace CadParamPluging.Cad
// 尺寸参数微调
SetDimDouble(dim, "Dimtxt", 3.5); // 文字高度
- SetDimDouble(dim, "Dimasz", 2.5); // 箭头大小
+ SetDimDouble(dim, "Dimasz", FeatureDrivenDrawer.DimensionArrowSize); // 箭头大小
SetDimDouble(dim, "Dimgap", 1.0); // 文字偏移
SetDimDouble(dim, "Dimexe", 1.0); // 延伸超出量
SetDimDouble(dim, "Dimexo", 0.0); // 原点偏移
@@ -840,12 +840,13 @@ namespace CadParamPluging.Cad
leader.AppendVertex(p1);
leader.AppendVertex(p2);
leader.AppendVertex(p3);
- leader.HasArrowHead = true;
+ leader.HasArrowHead = false;
leader.ColorIndex = 7;
leader.Layer = "0";
ctx.Btr.AppendEntity(leader);
ctx.Tr.AddNewlyCreatedDBObject(leader, true);
+ FeatureDrivenDrawer.DrawLeaderArrowHead(ctx, p1, p2, 7);
var text = new DBText();
text.TextString = textContent;
diff --git a/Cad/BlockRawFreeForgeRoundHeadDrawer.cs b/Cad/BlockRawFreeForgeRoundHeadDrawer.cs
index 9d51426..dae65f8 100644
--- a/Cad/BlockRawFreeForgeRoundHeadDrawer.cs
+++ b/Cad/BlockRawFreeForgeRoundHeadDrawer.cs
@@ -769,12 +769,13 @@ namespace CadParamPluging.Cad
leader.AppendVertex(p1);
leader.AppendVertex(p2);
leader.AppendVertex(p3);
- leader.HasArrowHead = true;
+ leader.HasArrowHead = false;
leader.ColorIndex = 7; // 白色
leader.Layer = "0";
ctx.Btr.AppendEntity(leader);
ctx.Tr.AddNewlyCreatedDBObject(leader, true);
+ FeatureDrivenDrawer.DrawLeaderArrowHead(ctx, p1, p2, 7);
var text = new DBText();
text.TextString = textContent;
@@ -837,7 +838,7 @@ namespace CadParamPluging.Cad
{
if (dim == null) return;
TrySetDimProp(dim, "Dimtxt", 3.5);
- TrySetDimProp(dim, "Dimasz", 2.5);
+ TrySetDimProp(dim, "Dimasz", FeatureDrivenDrawer.DimensionArrowSize);
TrySetDimProp(dim, "Dimgap", 1.0);
TrySetDimProp(dim, "Dimexe", 1.0);
TrySetDimProp(dim, "Dimexo", 0.0);
diff --git a/Cad/DiskRawFreeForgeDrawer.cs b/Cad/DiskRawFreeForgeDrawer.cs
index 4e369df..35903a4 100644
--- a/Cad/DiskRawFreeForgeDrawer.cs
+++ b/Cad/DiskRawFreeForgeDrawer.cs
@@ -326,7 +326,7 @@ namespace CadParamPluging.Cad
{
if (dim == null) return;
TrySetDimProp(dim, "Dimtxt", 3.5);
- TrySetDimProp(dim, "Dimasz", 2.5);
+ TrySetDimProp(dim, "Dimasz", FeatureDrivenDrawer.DimensionArrowSize);
TrySetDimProp(dim, "Dimgap", 1.0);
TrySetDimProp(dim, "Dimexe", 1.0);
TrySetDimProp(dim, "Dimexo", 0.0);
diff --git a/Cad/DrawingStyleManager.cs b/Cad/DrawingStyleManager.cs
index a576eda..81d647f 100644
--- a/Cad/DrawingStyleManager.cs
+++ b/Cad/DrawingStyleManager.cs
@@ -12,7 +12,7 @@ namespace CadParamPluging.Cad
OutlineBold,
OutlineThin,
PartContour,
- BreakLine, // 截断线(白色双点划线)
+ BreakLine, // 截断线
Centerline,
Hidden,
Hatch,
@@ -66,7 +66,7 @@ namespace CadParamPluging.Cad
case Role.PartContour:
return new LayerSpec { LayerName = "双点划线", DefaultLinetypeName = "PHANTOM", DefaultLineWeight = LineWeight.LineWeight015, DefaultColorIndex = 7 };
case Role.BreakLine:
- return new LayerSpec { LayerName = "截断线", DefaultLinetypeName = BreakLineLinetypeName, DefaultLineWeight = LineWeight.LineWeight015, DefaultColorIndex = 7 };
+ return new LayerSpec { LayerName = "截断线", DefaultLinetypeName = BreakLineLinetypeName, DefaultLineWeight = LineWeight.LineWeight015, DefaultColorIndex = 4 };
case Role.Centerline:
return new LayerSpec { LayerName = "中心线", DefaultLinetypeName = "CENTER", DefaultLineWeight = LineWeight.LineWeight015, DefaultColorIndex = 7 };
case Role.Hidden:
diff --git a/Cad/FeatureDrivenDrawer.cs b/Cad/FeatureDrivenDrawer.cs
index 4efd434..fba6e40 100644
--- a/Cad/FeatureDrivenDrawer.cs
+++ b/Cad/FeatureDrivenDrawer.cs
@@ -88,6 +88,8 @@ namespace CadParamPluging.Cad
public const string KeyHardness = "Hardness"; // 硬度
public const string KeyMarkingContent = "MarkingContent"; // 标刻内容
+ public const double DimensionArrowSize = 2.5;
+ private const double LeaderArrowWidthRatio = 0.6;
#endregion
@@ -129,6 +131,46 @@ namespace CadParamPluging.Cad
#endregion
+ public const double BreakLineAmplitude = 1.2;
+
+ public static void DrawSBreakLinePair(DrawingContext ctx, double x, double y0, double y1, double secondLineOffset)
+ {
+ const int segments = 24;
+ const double amplitude = BreakLineAmplitude;
+
+ DrawSBreakLine(ctx, x, y0, y1, amplitude, segments);
+ DrawSBreakLine(ctx, x + secondLineOffset, y0, y1, amplitude, segments);
+ }
+
+ public static double GetSBreakLineXAtY(double x, double y, double y0, double y1)
+ {
+ if (Math.Abs(y1 - y0) <= 1e-9)
+ {
+ return x;
+ }
+
+ var t = (y - y0) / (y1 - y0);
+ return x + BreakLineAmplitude * Math.Sin(Math.PI * 2.0 * t);
+ }
+
+ private static void DrawSBreakLine(DrawingContext ctx, double x, double y0, double y1, double amplitude, int segments)
+ {
+ var poly = new Polyline();
+ for (var i = 0; i <= segments; i++)
+ {
+ var t = (double)i / segments;
+ var y = y0 + (y1 - y0) * t;
+ var waveX = x + amplitude * Math.Sin(Math.PI * 2.0 * t);
+ poly.AddVertexAt(i, new Point2d(waveX, y), 0, 0, 0);
+ }
+
+ ctx.Style?.Apply(poly, DrawingStyleManager.Role.BreakLine);
+ try { poly.Linetype = "Continuous"; } catch { }
+ poly.LinetypeScale = 5.0;
+ ctx.Btr.AppendEntity(poly);
+ ctx.Tr.AddNewlyCreatedDBObject(poly, true);
+ }
+
#region 预期图形尺寸计算
///
@@ -190,13 +232,14 @@ namespace CadParamPluging.Cad
if (isMachined && isRolling)
{
- var minWallThickness = bag.GetDoubleOrNull(KeyMinWallThickness);
+ var innerDia = bag.GetDoubleOrNull(KeyInnerDiameter2) ?? 0;
+ var nominalWallThickness = (outerDia - innerDia) / 2.0;
- if (minWallThickness.HasValue && minWallThickness.Value > 0)
+ if (innerDia > 0 && nominalWallThickness > 0)
{
- // 示意图模式:视觉宽度 = 最小壁厚 * 3(不是物理外径)
+ // 示意图模式:视觉宽度 = 名义壁厚 * 3(不是公差后的 Tmin)
// 比例 2:1 内孔:实体
- activeWidth = minWallThickness.Value * 3.0;
+ activeWidth = nominalWallThickness * 3.0;
}
else
{
@@ -1103,48 +1146,9 @@ namespace CadParamPluging.Cad
///
private static void DrawRingSymmetryAxis(DrawingContext ctx, double ox, double oy, double height)
{
- const double extend = 5.0; // 截断线在轮廓上下各延长一点
- const double frameMargin = 5.0; // 避免越过图框边界
const double lineSpacing = 3.0; // 两根截断线间距3mm
- var y0 = oy - extend;
- var y1 = oy + height + extend;
-
- // 若能检测到白色外框,则把截断线端点夹在图框内(留出少量安全边距)。
- try
- {
- var frameExtents = TemplateDrawingService.ComputeWhiteFrameExtents(ctx?.Ctx);
- if (frameExtents.HasValue)
- {
- var frame = frameExtents.Value;
- y0 = Math.Max(y0, frame.MinPoint.Y + frameMargin);
- y1 = Math.Min(y1, frame.MaxPoint.Y - frameMargin);
- }
- }
- catch
- {
- // ignore
- }
-
- // 极端情况下(图框过小/检测异常导致端点反转)退回到原始高度。
- if (y1 <= y0)
- {
- y0 = oy;
- y1 = oy + height;
- }
-
- // 绘制两根双点划线,间距 lineSpacing
- // 第一根在 ox 位置
- var line1 = new Line(new Point3d(ox, y0, 0), new Point3d(ox, y1, 0));
- ctx.Style?.Apply(line1, DrawingStyleManager.Role.BreakLine); // 使用截断线样式(白色双点划线)
- ctx.Btr.AppendEntity(line1);
- ctx.Tr.AddNewlyCreatedDBObject(line1, true);
-
- // 第二根在 ox - lineSpacing 位置
- var line2 = new Line(new Point3d(ox - lineSpacing, y0, 0), new Point3d(ox - lineSpacing, y1, 0));
- ctx.Style?.Apply(line2, DrawingStyleManager.Role.BreakLine); // 使用截断线样式(白色双点划线)
- ctx.Btr.AppendEntity(line2);
- ctx.Tr.AddNewlyCreatedDBObject(line2, true);
+ DrawSBreakLinePair(ctx, ox, oy, oy + height, -lineSpacing);
}
///
@@ -2439,7 +2443,7 @@ namespace CadParamPluging.Cad
// Template dimstyle may have very small DIMTXT; apply per-dimension overrides to keep it readable.
// Values are in drawing units (typically mm).
TrySetDimProp(dim, "Dimtxt", 3.5);
- TrySetDimProp(dim, "Dimasz", 2.5);
+ TrySetDimProp(dim, "Dimasz", DimensionArrowSize);
TrySetDimProp(dim, "Dimgap", 1.0);
TrySetDimProp(dim, "Dimexe", 1.0);
TrySetDimProp(dim, "Dimexo", 0.0);
@@ -2780,6 +2784,40 @@ namespace CadParamPluging.Cad
}
#endregion
+ public static void DrawLeaderArrowHead(DrawingContext ctx, Point3d tip, Point3d nextPoint, int colorIndex)
+ {
+ try
+ {
+ var dx = nextPoint.X - tip.X;
+ var dy = nextPoint.Y - tip.Y;
+ var len = Math.Sqrt(dx * dx + dy * dy);
+ if (len <= 0.001)
+ {
+ return;
+ }
+
+ var ux = dx / len;
+ var uy = dy / len;
+ var arrowWidth = DimensionArrowSize * LeaderArrowWidthRatio;
+ var baseX = tip.X + DimensionArrowSize * ux;
+ var baseY = tip.Y + DimensionArrowSize * uy;
+ var perpX = -uy;
+ var perpY = ux;
+
+ var arrow = new Solid(
+ tip,
+ new Point3d(baseX + arrowWidth / 2.0 * perpX, baseY + arrowWidth / 2.0 * perpY, 0),
+ new Point3d(baseX - arrowWidth / 2.0 * perpX, baseY - arrowWidth / 2.0 * perpY, 0));
+ arrow.ColorIndex = colorIndex;
+ ctx.Btr.AppendEntity(arrow);
+ ctx.Tr.AddNewlyCreatedDBObject(arrow, true);
+ }
+ catch
+ {
+ // ignore
+ }
+ }
+
public static void DrawSpecialInnerHoleLeader(DrawingContext ctx, double ox, double oy, double height, double innerDia)
{
try
@@ -2803,12 +2841,13 @@ namespace CadParamPluging.Cad
leader.AppendVertex(p1);
leader.AppendVertex(p2);
leader.AppendVertex(p3);
- leader.HasArrowHead = true;
+ leader.HasArrowHead = false;
leader.ColorIndex = 7; // 白色
leader.Layer = "0";
ctx.Btr.AppendEntity(leader);
ctx.Tr.AddNewlyCreatedDBObject(leader, true);
+ DrawLeaderArrowHead(ctx, p1, p2, 7);
// 绘制文字
var text = new DBText();
@@ -2856,12 +2895,13 @@ namespace CadParamPluging.Cad
leader.AppendVertex(p1);
leader.AppendVertex(p2);
leader.AppendVertex(p3);
- leader.HasArrowHead = true;
+ leader.HasArrowHead = false;
leader.ColorIndex = 7; // 白色
leader.Layer = "0";
ctx.Btr.AppendEntity(leader);
ctx.Tr.AddNewlyCreatedDBObject(leader, true);
+ DrawLeaderArrowHead(ctx, p1, p2, 7);
// 绘制文字
var text = new DBText();
@@ -2898,18 +2938,21 @@ namespace CadParamPluging.Cad
var p2 = new Point3d(xStart + 15, yStart - 15, 0);
var p3 = new Point3d(p2.X + 10, p2.Y, 0); // 这里的p3是直线的终点,短线接在这里
- // 绘制引线
- var poly = new Polyline();
- poly.AddVertexAt(0, new Point2d(p1.X, p1.Y), 0, 0, 0);
- poly.AddVertexAt(1, new Point2d(p2.X, p2.Y), 0, 0, 0);
- poly.AddVertexAt(2, new Point2d(p3.X, p3.Y), 0, 0, 0);
-
- ctx.Style?.Apply(poly, DrawingStyleManager.Role.Dimension); // 使用 Dimension 角色
- // 修改为青色 (ColorIndex 4)
- poly.ColorIndex = 4;
+ // 绘制带箭头的引线
+ var leader = new Leader();
+ leader.SetDatabaseDefaults();
+ leader.AppendVertex(p1);
+ leader.AppendVertex(p2);
+ leader.AppendVertex(p3);
+ leader.HasArrowHead = false;
- ctx.Btr.AppendEntity(poly);
- ctx.Tr.AddNewlyCreatedDBObject(poly, true);
+ ctx.Style?.Apply(leader, DrawingStyleManager.Role.Dimension); // 使用 Dimension 角色
+ // 修改为青色 (ColorIndex 4)
+ leader.ColorIndex = 4;
+
+ ctx.Btr.AppendEntity(leader);
+ ctx.Tr.AddNewlyCreatedDBObject(leader, true);
+ DrawLeaderArrowHead(ctx, p1, p2, 4);
// 2. 文字和外围圆圈 (无论硬度值是什么,只显示固定的"HB"符号)
string displayTxt = "HB";
diff --git a/Cad/RingMachinedRollingDrawer.cs b/Cad/RingMachinedRollingDrawer.cs
index 00b43dd..d241d53 100644
--- a/Cad/RingMachinedRollingDrawer.cs
+++ b/Cad/RingMachinedRollingDrawer.cs
@@ -101,15 +101,14 @@ namespace CadParamPluging.Cad
double visualOuterR = physicalOuterR;
double visualInnerR = physicalInnerR;
- // 轧制+车加工(示意图模式)特殊处理
+ // 轧制示意图几何按名义壁厚画;Tmin 标注文字仍使用考虑公差后的 MinWallThickness。
if (ctx.IsMachined)
{
- var minWallThkParam = bag.GetDoubleOrNull(KeyMinWallThickness);
-
- if (minWallThkParam.HasValue && minWallThkParam.Value > 0)
+ var nominalWallThickness = (physicalOuterR - physicalInnerR);
+ if (physicalInnerR > 0 && nominalWallThickness > 0)
{
- visualInnerR = minWallThkParam.Value * 2.0;
- visualOuterR = minWallThkParam.Value * 3.0;
+ visualInnerR = nominalWallThickness * 2.0;
+ visualOuterR = nominalWallThickness * 3.0;
}
else
{
@@ -392,12 +391,13 @@ namespace CadParamPluging.Cad
leader.AppendVertex(p1);
leader.AppendVertex(p2);
leader.AppendVertex(p3);
- leader.HasArrowHead = true;
+ leader.HasArrowHead = false;
leader.ColorIndex = 7; // 白色
leader.Layer = "0";
ctx.Btr.AppendEntity(leader);
ctx.Tr.AddNewlyCreatedDBObject(leader, true);
+ FeatureDrivenDrawer.DrawLeaderArrowHead(ctx, p1, p2, 7);
// 绘制文字
var text = new DBText();
@@ -455,42 +455,9 @@ namespace CadParamPluging.Cad
private static void DrawRingSymmetryAxis(FeatureDrivenDrawer.DrawingContext ctx, double ox, double oy, double height)
{
- const double extend = 5.0;
- const double frameMargin = 5.0;
const double lineSpacing = 3.0;
- var y0 = oy - extend;
- var y1 = oy + height + extend;
-
- try
- {
- var frameExtents = TemplateDrawingService.ComputeWhiteFrameExtents(ctx?.Ctx);
- if (frameExtents.HasValue)
- {
- var frame = frameExtents.Value;
- y0 = Math.Max(y0, frame.MinPoint.Y + frameMargin);
- y1 = Math.Min(y1, frame.MaxPoint.Y - frameMargin);
- }
- }
- catch { }
-
- if (y1 <= y0)
- {
- y0 = oy;
- y1 = oy + height;
- }
-
- var line1 = new Line(new Point3d(ox, y0, 0), new Point3d(ox, y1, 0));
- ctx.Style?.Apply(line1, DrawingStyleManager.Role.BreakLine);
- line1.LinetypeScale = 5.0;
- ctx.Btr.AppendEntity(line1);
- ctx.Tr.AddNewlyCreatedDBObject(line1, true);
-
- var line2 = new Line(new Point3d(ox - lineSpacing, y0, 0), new Point3d(ox - lineSpacing, y1, 0));
- ctx.Style?.Apply(line2, DrawingStyleManager.Role.BreakLine);
- line2.LinetypeScale = 5.0;
- ctx.Btr.AppendEntity(line2);
- ctx.Tr.AddNewlyCreatedDBObject(line2, true);
+ FeatureDrivenDrawer.DrawSBreakLinePair(ctx, ox, oy, oy + height, -lineSpacing);
}
@@ -776,7 +743,7 @@ namespace CadParamPluging.Cad
{
if (dim == null) return;
TrySetDimProp(dim, "Dimtxt", 3.5);
- TrySetDimProp(dim, "Dimasz", 2.5);
+ TrySetDimProp(dim, "Dimasz", FeatureDrivenDrawer.DimensionArrowSize);
TrySetDimProp(dim, "Dimgap", 1.0);
TrySetDimProp(dim, "Dimexe", 1.0);
TrySetDimProp(dim, "Dimexo", 0.0);
diff --git a/Cad/RingRawRollingDrawer.cs b/Cad/RingRawRollingDrawer.cs
index 50b2736..27a2ec6 100644
--- a/Cad/RingRawRollingDrawer.cs
+++ b/Cad/RingRawRollingDrawer.cs
@@ -109,16 +109,14 @@ namespace CadParamPluging.Cad
double visualOuterR = physicalOuterR;
double visualInnerR = physicalInnerR;
- // 强制启用"示意图模式"逻辑 (原 IsMachined 判断)
- // 因为在 RingRawRollingGenerator 中被强制设置了 "车加工"
+ // 轧制示意图几何按名义壁厚画;Tmin 标注文字仍使用考虑公差后的 MinWallThickness。
if (true)
{
- var minWallThkParam = bag.GetDoubleOrNull(KeyMinWallThickness);
-
- if (minWallThkParam.HasValue && minWallThkParam.Value > 0)
+ var nominalWallThickness = (physicalOuterR - physicalInnerR);
+ if (physicalInnerR > 0 && nominalWallThickness > 0)
{
- visualInnerR = minWallThkParam.Value * 2.0;
- visualOuterR = minWallThkParam.Value * 3.0;
+ visualInnerR = nominalWallThickness * 2.0;
+ visualOuterR = nominalWallThickness * 3.0;
}
else
{
@@ -346,42 +344,9 @@ namespace CadParamPluging.Cad
private static void DrawRingSymmetryAxis(FeatureDrivenDrawer.DrawingContext ctx, double ox, double oy, double height)
{
- const double extend = 5.0;
- const double frameMargin = 5.0;
const double lineSpacing = 3.0;
- var y0 = oy - extend;
- var y1 = oy + height + extend;
-
- try
- {
- var frameExtents = TemplateDrawingService.ComputeWhiteFrameExtents(ctx?.Ctx);
- if (frameExtents.HasValue)
- {
- var frame = frameExtents.Value;
- y0 = Math.Max(y0, frame.MinPoint.Y + frameMargin);
- y1 = Math.Min(y1, frame.MaxPoint.Y - frameMargin);
- }
- }
- catch { }
-
- if (y1 <= y0)
- {
- y0 = oy;
- y1 = oy + height;
- }
-
- var line1 = new Line(new Point3d(ox, y0, 0), new Point3d(ox, y1, 0));
- ctx.Style?.Apply(line1, DrawingStyleManager.Role.BreakLine);
- line1.LinetypeScale = 5.0;
- ctx.Btr.AppendEntity(line1);
- ctx.Tr.AddNewlyCreatedDBObject(line1, true);
-
- var line2 = new Line(new Point3d(ox - lineSpacing, y0, 0), new Point3d(ox - lineSpacing, y1, 0));
- ctx.Style?.Apply(line2, DrawingStyleManager.Role.BreakLine);
- line2.LinetypeScale = 5.0;
- ctx.Btr.AppendEntity(line2);
- ctx.Tr.AddNewlyCreatedDBObject(line2, true);
+ FeatureDrivenDrawer.DrawSBreakLinePair(ctx, ox, oy, oy + height, -lineSpacing);
}
@@ -663,7 +628,7 @@ namespace CadParamPluging.Cad
{
if (dim == null) return;
TrySetDimProp(dim, "Dimtxt", 3.5);
- TrySetDimProp(dim, "Dimasz", 2.5);
+ TrySetDimProp(dim, "Dimasz", FeatureDrivenDrawer.DimensionArrowSize);
TrySetDimProp(dim, "Dimgap", 1.0);
TrySetDimProp(dim, "Dimexe", 1.0);
TrySetDimProp(dim, "Dimexo", 0.0);
diff --git a/Cad/ShaftRawFreeForgeRoundShaftDrawer.cs b/Cad/ShaftRawFreeForgeRoundShaftDrawer.cs
index a99e7cc..5361ae9 100644
--- a/Cad/ShaftRawFreeForgeRoundShaftDrawer.cs
+++ b/Cad/ShaftRawFreeForgeRoundShaftDrawer.cs
@@ -115,7 +115,7 @@ namespace CadParamPluging.Cad
DrawShaftRoundHeadUnifiedOutline(ctx, ox, oy, W, H, w, r, xf_left, xf_right, fx_L_tangTop, fy_L_tangTop, fx_L_tang, fy_L_tangBot, fx_R_tangTop, fy_R_tangTop, fx_R_tang, fy_R_tangBot, needBreakLines, xBreak, lineSpacing);
// 3. 绘制中心线 (横向,在中间位置)
- DrawHorizontalCenterLine(ctx, ctx.Center.Y, ox, ox + W, needBreakLines, xBreak, lineSpacing);
+ DrawHorizontalCenterLine(ctx, ctx.Center.Y, ox, ox + W, needBreakLines, xBreak, lineSpacing, oy, oy + H);
// 4. 绘制断线 (如果需要)
if (needBreakLines)
@@ -169,14 +169,6 @@ namespace CadParamPluging.Cad
FeatureDrivenDrawer.AddLinearDim(ctx, new Point3d(xf_right, oy, 0), new Point3d(xf_right, oy + H, 0), new Point3d(dimX, ctx.Center.Y, 0), 90, dimText);
}
- // 3.3 补加未注侧倒角标注指示
- if (filletR > 0)
- {
- double cxRight = xf_right;
- double cyTop = oy + H - filletR;
- DrawHeadFilletRadiusLeader(ctx, cxRight, cyTop, filletR);
- }
-
// 4. 硬度和标刻
var hardnessVal = bag.GetString(FeatureDrivenDrawer.KeyHardness);
if (!string.IsNullOrWhiteSpace(hardnessVal) && hardnessVal != "空")
@@ -211,7 +203,7 @@ namespace CadParamPluging.Cad
{
// 使用与锻件相同的断线X坐标和间距
// double xBreak = ox + W / 4.0; // variable is already declared in outer scope
- DrawRectOutlineWithBreak(ctx, pOx, pOy, pW, pH, xBreak, lineSpacing, DrawingStyleManager.Role.PartContour);
+ DrawRectOutlineWithBreak(ctx, pOx, pOy, pW, pH, xBreak, lineSpacing, oy, oy + H, DrawingStyleManager.Role.PartContour);
}
else
{
@@ -352,10 +344,14 @@ namespace CadParamPluging.Cad
}
else
{
- var tL = new Line(new Point3d(xf_left, oy + H, 0), new Point3d(xBreak, oy + H, 0));
- var tR = new Line(new Point3d(xBreak + breakWidth, oy + H, 0), new Point3d(xf_right, oy + H, 0));
- var bL = new Line(new Point3d(xf_left, oy, 0), new Point3d(xBreak, oy, 0));
- var bR = new Line(new Point3d(xBreak + breakWidth, oy, 0), new Point3d(xf_right, oy, 0));
+ var topBreakLeft = FeatureDrivenDrawer.GetSBreakLineXAtY(xBreak, oy + H, oy, oy + H);
+ var topBreakRight = FeatureDrivenDrawer.GetSBreakLineXAtY(xBreak + breakWidth, oy + H, oy, oy + H);
+ var bottomBreakLeft = FeatureDrivenDrawer.GetSBreakLineXAtY(xBreak, oy, oy, oy + H);
+ var bottomBreakRight = FeatureDrivenDrawer.GetSBreakLineXAtY(xBreak + breakWidth, oy, oy, oy + H);
+ var tL = new Line(new Point3d(xf_left, oy + H, 0), new Point3d(topBreakLeft, oy + H, 0));
+ var tR = new Line(new Point3d(topBreakRight, oy + H, 0), new Point3d(xf_right, oy + H, 0));
+ var bL = new Line(new Point3d(xf_left, oy, 0), new Point3d(bottomBreakLeft, oy, 0));
+ var bR = new Line(new Point3d(bottomBreakRight, oy, 0), new Point3d(xf_right, oy, 0));
ctx.Style?.Apply(tL, DrawingStyleManager.Role.OutlineBold);
ctx.Style?.Apply(tR, DrawingStyleManager.Role.OutlineBold);
ctx.Style?.Apply(bL, DrawingStyleManager.Role.OutlineBold);
@@ -446,7 +442,7 @@ namespace CadParamPluging.Cad
catch { }
}
- private static void DrawHorizontalCenterLine(FeatureDrivenDrawer.DrawingContext ctx, double centerY, double xLeft, double xRight, bool hasBreak = false, double xBreak = 0, double breakWidth = 0)
+ private static void DrawHorizontalCenterLine(FeatureDrivenDrawer.DrawingContext ctx, double centerY, double xLeft, double xRight, bool hasBreak = false, double xBreak = 0, double breakWidth = 0, double breakY0 = 0, double breakY1 = 0)
{
const double extend = 5.0;
@@ -460,13 +456,15 @@ namespace CadParamPluging.Cad
else
{
// Left segment
- var line1 = new Line(new Point3d(xLeft - extend, centerY, 0), new Point3d(xBreak, centerY, 0));
+ var breakLeft = FeatureDrivenDrawer.GetSBreakLineXAtY(xBreak, centerY, breakY0, breakY1);
+ var breakRight = FeatureDrivenDrawer.GetSBreakLineXAtY(xBreak + breakWidth, centerY, breakY0, breakY1);
+ var line1 = new Line(new Point3d(xLeft - extend, centerY, 0), new Point3d(breakLeft, centerY, 0));
ctx.Style?.Apply(line1, DrawingStyleManager.Role.Centerline);
ctx.Btr.AppendEntity(line1);
ctx.Tr.AddNewlyCreatedDBObject(line1, true);
// Right segment
- var line2 = new Line(new Point3d(xBreak + breakWidth, centerY, 0), new Point3d(xRight + extend, centerY, 0));
+ var line2 = new Line(new Point3d(breakRight, centerY, 0), new Point3d(xRight + extend, centerY, 0));
ctx.Style?.Apply(line2, DrawingStyleManager.Role.Centerline);
ctx.Btr.AppendEntity(line2);
ctx.Tr.AddNewlyCreatedDBObject(line2, true);
@@ -507,24 +505,12 @@ namespace CadParamPluging.Cad
private static void DrawBreakLines(FeatureDrivenDrawer.DrawingContext ctx, double ox, double oy, double width, double height)
{
const double lineSpacing = 3.0;
- const double extend = 5.0;
-
double xBreak = ox + width / 4.0;
- double y0 = oy - extend;
- double y1 = oy + height + extend;
+ double y0 = oy;
+ double y1 = oy + height;
- var line1 = new Line(new Point3d(xBreak, y0, 0), new Point3d(xBreak, y1, 0));
- ctx.Style?.Apply(line1, DrawingStyleManager.Role.BreakLine);
- line1.LinetypeScale = 5.0;
- ctx.Btr.AppendEntity(line1);
- ctx.Tr.AddNewlyCreatedDBObject(line1, true);
-
- var line2 = new Line(new Point3d(xBreak + lineSpacing, y0, 0), new Point3d(xBreak + lineSpacing, y1, 0));
- ctx.Style?.Apply(line2, DrawingStyleManager.Role.BreakLine);
- line2.LinetypeScale = 5.0;
- ctx.Btr.AppendEntity(line2);
- ctx.Tr.AddNewlyCreatedDBObject(line2, true);
+ FeatureDrivenDrawer.DrawSBreakLinePair(ctx, xBreak, y0, y1, lineSpacing);
}
@@ -534,7 +520,7 @@ namespace CadParamPluging.Cad
/// 绘制带断口的零件轮廓(在断线位置打断上下横线)
/// 支持自定义 Role (通常为 PartContour)
///
- private static void DrawRectOutlineWithBreak(FeatureDrivenDrawer.DrawingContext ctx, double x, double y, double w, double h, double xBreak, double breakWidth, DrawingStyleManager.Role role)
+ private static void DrawRectOutlineWithBreak(FeatureDrivenDrawer.DrawingContext ctx, double x, double y, double w, double h, double xBreak, double breakWidth, double breakY0, double breakY1, DrawingStyleManager.Role role)
{
// 左边竖线
var leftLine = new Line(new Point3d(x, y, 0), new Point3d(x, y + h, 0));
@@ -556,16 +542,18 @@ namespace CadParamPluging.Cad
// 左段
if (xBreak > x)
{
- var bottomLeft = new Line(new Point3d(x, y, 0), new Point3d(Math.Min(xBreak, x + w), y, 0));
+ var bottomBreakLeft = FeatureDrivenDrawer.GetSBreakLineXAtY(xBreak, y, breakY0, breakY1);
+ var bottomLeft = new Line(new Point3d(x, y, 0), new Point3d(Math.Min(bottomBreakLeft, x + w), y, 0));
ctx.Style?.Apply(bottomLeft, role);
ctx.Btr.AppendEntity(bottomLeft);
ctx.Tr.AddNewlyCreatedDBObject(bottomLeft, true);
}
// 右段
- if (xBreak + breakWidth < x + w)
+ var bottomBreakRight = FeatureDrivenDrawer.GetSBreakLineXAtY(xBreak + breakWidth, y, breakY0, breakY1);
+ if (bottomBreakRight < x + w)
{
- var bottomRight = new Line(new Point3d(Math.Max(xBreak + breakWidth, x), y, 0), new Point3d(x + w, y, 0));
+ var bottomRight = new Line(new Point3d(Math.Max(bottomBreakRight, x), y, 0), new Point3d(x + w, y, 0));
ctx.Style?.Apply(bottomRight, role);
ctx.Btr.AppendEntity(bottomRight);
ctx.Tr.AddNewlyCreatedDBObject(bottomRight, true);
@@ -575,15 +563,17 @@ namespace CadParamPluging.Cad
// 左段
if (xBreak > x)
{
- var topLeft = new Line(new Point3d(x, y + h, 0), new Point3d(Math.Min(xBreak, x + w), y + h, 0));
+ var topBreakLeft = FeatureDrivenDrawer.GetSBreakLineXAtY(xBreak, y + h, breakY0, breakY1);
+ var topLeft = new Line(new Point3d(x, y + h, 0), new Point3d(Math.Min(topBreakLeft, x + w), y + h, 0));
ctx.Style?.Apply(topLeft, role);
ctx.Btr.AppendEntity(topLeft);
ctx.Tr.AddNewlyCreatedDBObject(topLeft, true);
}
// 右段
- if (xBreak + breakWidth < x + w)
+ var topBreakRight = FeatureDrivenDrawer.GetSBreakLineXAtY(xBreak + breakWidth, y + h, breakY0, breakY1);
+ if (topBreakRight < x + w)
{
- var topRight = new Line(new Point3d(Math.Max(xBreak + breakWidth, x), y + h, 0), new Point3d(x + w, y + h, 0));
+ var topRight = new Line(new Point3d(Math.Max(topBreakRight, x), y + h, 0), new Point3d(x + w, y + h, 0));
ctx.Style?.Apply(topRight, role);
ctx.Btr.AppendEntity(topRight);
ctx.Tr.AddNewlyCreatedDBObject(topRight, true);
diff --git a/Cad/ShaftRawFreeForgeSquareShaftDrawer.cs b/Cad/ShaftRawFreeForgeSquareShaftDrawer.cs
index 9534ed1..f193be1 100644
--- a/Cad/ShaftRawFreeForgeSquareShaftDrawer.cs
+++ b/Cad/ShaftRawFreeForgeSquareShaftDrawer.cs
@@ -119,12 +119,9 @@ namespace CadParamPluging.Cad
double sectionWArg = S3;
DrawShaftRoundHeadUnifiedOutline(ctx, ox, oy, S1, S2, w, r, xf_left, xf_right, fx_L_tangTop, fy_L_tangTop, fx_L_tang, fy_L_tangBot, fx_R_tangTop, fy_R_tangTop, fx_R_tang, fy_R_tangBot, needBreakLines, xBreak, lineSpacing, sectionOxArg, sectionWArg);
- // 2. 中心线 (贯穿左右水平方向)
+ // 2. 中心线(断线区域不穿线)
double clY = oy + S2 / 2.0;
- var centerLine = new Line(new Point3d(ox - 10, clY, 0), new Point3d(ox + S1 + 10, clY, 0));
- ctx.Style?.Apply(centerLine, DrawingStyleManager.Role.Centerline);
- ctx.Btr.AppendEntity(centerLine);
- ctx.Tr.AddNewlyCreatedDBObject(centerLine, true);
+ DrawHorizontalCenterLine(ctx, clY, ox, ox + S1, needBreakLines, xBreak, lineSpacing, oy, oy + S2);
// 4. Draw Break Lines if needed
if (needBreakLines)
@@ -195,14 +192,6 @@ namespace CadParamPluging.Cad
FeatureDrivenDrawer.AddLinearDim(ctx, new Point3d(xf_right, oy, 0), new Point3d(xf_right, oy + S2, 0), new Point3d(dimX, ctx.Center.Y, 0), 90, dimText);
}
- // 补加未注侧倒角标注指示
- if (filletR > 0)
- {
- double cxRight = xf_right;
- double cyTop = oy + S2 - filletR;
- DrawHeadFilletRadiusLeader(ctx, cxRight, cyTop, filletR);
- }
-
if (S3 > 0)
{
var val = ctx.OriginalBag?.GetDoubleOrNull(FeatureDrivenDrawer.KeySquareShaftSize3) ?? S3;
@@ -255,7 +244,7 @@ namespace CadParamPluging.Cad
if (needBreakLines)
{
- DrawRectOutlineWithBreak(ctx, pOx, pOy, pL, pH, xBreak, lineSpacing, DrawingStyleManager.Role.PartContour);
+ DrawRectOutlineWithBreak(ctx, pOx, pOy, pL, pH, xBreak, lineSpacing, oy, oy + S2, DrawingStyleManager.Role.PartContour);
}
else
{
@@ -270,25 +259,39 @@ namespace CadParamPluging.Cad
private static void DrawBreakLines(FeatureDrivenDrawer.DrawingContext ctx, double ox, double oy, double width, double height)
{
const double lineSpacing = 3.0;
- const double extend = 5.0;
-
double xBreak = ox + width / 4.0;
- double y0 = oy - extend;
- double y1 = oy + height + extend;
+ double y0 = oy;
+ double y1 = oy + height;
- var line1 = new Line(new Point3d(xBreak, y0, 0), new Point3d(xBreak, y1, 0));
- ctx.Style?.Apply(line1, DrawingStyleManager.Role.BreakLine);
- line1.LinetypeScale = 5.0;
+ FeatureDrivenDrawer.DrawSBreakLinePair(ctx, xBreak, y0, y1, lineSpacing);
+
+ }
+
+ private static void DrawHorizontalCenterLine(FeatureDrivenDrawer.DrawingContext ctx, double centerY, double xLeft, double xRight, bool hasBreak = false, double xBreak = 0, double breakWidth = 0, double breakY0 = 0, double breakY1 = 0)
+ {
+ const double extend = 5.0;
+
+ if (!hasBreak)
+ {
+ var line = new Line(new Point3d(xLeft - extend, centerY, 0), new Point3d(xRight + extend, centerY, 0));
+ ctx.Style?.Apply(line, DrawingStyleManager.Role.Centerline);
+ ctx.Btr.AppendEntity(line);
+ ctx.Tr.AddNewlyCreatedDBObject(line, true);
+ return;
+ }
+
+ var breakLeft = FeatureDrivenDrawer.GetSBreakLineXAtY(xBreak, centerY, breakY0, breakY1);
+ var breakRight = FeatureDrivenDrawer.GetSBreakLineXAtY(xBreak + breakWidth, centerY, breakY0, breakY1);
+ var line1 = new Line(new Point3d(xLeft - extend, centerY, 0), new Point3d(breakLeft, centerY, 0));
+ ctx.Style?.Apply(line1, DrawingStyleManager.Role.Centerline);
ctx.Btr.AppendEntity(line1);
ctx.Tr.AddNewlyCreatedDBObject(line1, true);
- var line2 = new Line(new Point3d(xBreak + lineSpacing, y0, 0), new Point3d(xBreak + lineSpacing, y1, 0));
- ctx.Style?.Apply(line2, DrawingStyleManager.Role.BreakLine);
- line2.LinetypeScale = 5.0;
+ var line2 = new Line(new Point3d(breakRight, centerY, 0), new Point3d(xRight + extend, centerY, 0));
+ ctx.Style?.Apply(line2, DrawingStyleManager.Role.Centerline);
ctx.Btr.AppendEntity(line2);
ctx.Tr.AddNewlyCreatedDBObject(line2, true);
-
}
private static void DrawShaftRoundHeadUnifiedOutline(FeatureDrivenDrawer.DrawingContext ctx, double ox, double oy, double W, double H, double w, double r, double xf_left, double xf_right, double fx_L_tangTop, double fy_L_tangTop, double fx_L_tangBotX, double fy_L_tangBot, double fx_R_tangTop, double fy_R_tangTop, double fx_R_tangBotX, double fy_R_tangBot, bool needBreakLines, double xBreak, double breakWidth, double sectionOx, double sectionW)
@@ -422,8 +425,10 @@ namespace CadParamPluging.Cad
{
if (xBreak > seg.Item1 && (xBreak + breakWidth) < seg.Item2)
{
- newSegs.Add(Tuple.Create(seg.Item1, xBreak));
- newSegs.Add(Tuple.Create(xBreak + breakWidth, seg.Item2));
+ var breakLeft = FeatureDrivenDrawer.GetSBreakLineXAtY(xBreak, yLine, oy, oy + H);
+ var breakRight = FeatureDrivenDrawer.GetSBreakLineXAtY(xBreak + breakWidth, yLine, oy, oy + H);
+ newSegs.Add(Tuple.Create(seg.Item1, breakLeft));
+ newSegs.Add(Tuple.Create(breakRight, seg.Item2));
}
else newSegs.Add(seg);
}
@@ -641,7 +646,7 @@ namespace CadParamPluging.Cad
/// 绘制带断口的零件轮廓(在断线位置打断上下横线)
/// 支持自定义 Role (通常为 PartContour)
///
- private static void DrawRectOutlineWithBreak(FeatureDrivenDrawer.DrawingContext ctx, double x, double y, double w, double h, double xBreak, double breakWidth, DrawingStyleManager.Role role)
+ private static void DrawRectOutlineWithBreak(FeatureDrivenDrawer.DrawingContext ctx, double x, double y, double w, double h, double xBreak, double breakWidth, double breakY0, double breakY1, DrawingStyleManager.Role role)
{
// 左边竖线
var leftLine = new Line(new Point3d(x, y, 0), new Point3d(x, y + h, 0));
@@ -659,16 +664,18 @@ namespace CadParamPluging.Cad
// 左段
if (xBreak > x)
{
- var bottomLeft = new Line(new Point3d(x, y, 0), new Point3d(Math.Min(xBreak, x + w), y, 0));
+ var bottomBreakLeft = FeatureDrivenDrawer.GetSBreakLineXAtY(xBreak, y, breakY0, breakY1);
+ var bottomLeft = new Line(new Point3d(x, y, 0), new Point3d(Math.Min(bottomBreakLeft, x + w), y, 0));
ctx.Style?.Apply(bottomLeft, role);
ctx.Btr.AppendEntity(bottomLeft);
ctx.Tr.AddNewlyCreatedDBObject(bottomLeft, true);
}
// 右段
- if (xBreak + breakWidth < x + w)
+ var bottomBreakRight = FeatureDrivenDrawer.GetSBreakLineXAtY(xBreak + breakWidth, y, breakY0, breakY1);
+ if (bottomBreakRight < x + w)
{
- var bottomRight = new Line(new Point3d(Math.Max(xBreak + breakWidth, x), y, 0), new Point3d(x + w, y, 0));
+ var bottomRight = new Line(new Point3d(Math.Max(bottomBreakRight, x), y, 0), new Point3d(x + w, y, 0));
ctx.Style?.Apply(bottomRight, role);
ctx.Btr.AppendEntity(bottomRight);
ctx.Tr.AddNewlyCreatedDBObject(bottomRight, true);
@@ -678,15 +685,17 @@ namespace CadParamPluging.Cad
// 左段
if (xBreak > x)
{
- var topLeft = new Line(new Point3d(x, y + h, 0), new Point3d(Math.Min(xBreak, x + w), y + h, 0));
+ var topBreakLeft = FeatureDrivenDrawer.GetSBreakLineXAtY(xBreak, y + h, breakY0, breakY1);
+ var topLeft = new Line(new Point3d(x, y + h, 0), new Point3d(Math.Min(topBreakLeft, x + w), y + h, 0));
ctx.Style?.Apply(topLeft, role);
ctx.Btr.AppendEntity(topLeft);
ctx.Tr.AddNewlyCreatedDBObject(topLeft, true);
}
// 右段
- if (xBreak + breakWidth < x + w)
+ var topBreakRight = FeatureDrivenDrawer.GetSBreakLineXAtY(xBreak + breakWidth, y + h, breakY0, breakY1);
+ if (topBreakRight < x + w)
{
- var topRight = new Line(new Point3d(Math.Max(xBreak + breakWidth, x), y + h, 0), new Point3d(x + w, y + h, 0));
+ var topRight = new Line(new Point3d(Math.Max(topBreakRight, x), y + h, 0), new Point3d(x + w, y + h, 0));
ctx.Style?.Apply(topRight, role);
ctx.Btr.AppendEntity(topRight);
ctx.Tr.AddNewlyCreatedDBObject(topRight, true);
diff --git a/Cad/TemplateDrawingService.cs b/Cad/TemplateDrawingService.cs
index 2df2774..bf55007 100644
--- a/Cad/TemplateDrawingService.cs
+++ b/Cad/TemplateDrawingService.cs
@@ -480,7 +480,7 @@ namespace CadParamPluging.Cad
Func getValueW = (k) =>
{
var val = bag.GetString(k);
- if (k != null && k.StartsWith("MarkingContent", StringComparison.OrdinalIgnoreCase))
+ if (IsNoteVisibilityControlledKey(k))
{
if (bag.GetString(k + "_ShowInNote") == "0") return "__SKIP_NOTE__";
}
@@ -722,6 +722,13 @@ namespace CadParamPluging.Cad
};
}
+ private static bool IsNoteVisibilityControlledKey(string key)
+ {
+ return key != null
+ && (key.StartsWith("MarkingContent", StringComparison.OrdinalIgnoreCase)
+ || key.StartsWith("SurfaceRoughness", StringComparison.OrdinalIgnoreCase));
+ }
+
private static BlockTableRecord GetTargetSpace(Transaction tr, Database db, string layoutName, bool scanModelSpace)
{
if (tr == null || db == null)
diff --git a/Tests/HardnessSymbolArrowTests.cs b/Tests/HardnessSymbolArrowTests.cs
new file mode 100644
index 0000000..59ab412
--- /dev/null
+++ b/Tests/HardnessSymbolArrowTests.cs
@@ -0,0 +1,120 @@
+using System;
+using System.IO;
+
+public static class HardnessSymbolArrowTests
+{
+ public static int Main()
+ {
+ try
+ {
+ AnnotationArrowsUseDimensionArrowSize();
+ Console.WriteLine("Annotation arrow size tests passed.");
+ return 0;
+ }
+ catch (Exception ex)
+ {
+ Console.Error.WriteLine(ex.Message);
+ return 1;
+ }
+ }
+
+ private static void AnnotationArrowsUseDimensionArrowSize()
+ {
+ var sourcePath = Path.Combine("Cad", "FeatureDrivenDrawer.cs");
+ var source = File.ReadAllText(sourcePath);
+
+ if (!source.Contains("public const double DimensionArrowSize = 2.5;"))
+ {
+ throw new InvalidOperationException(sourcePath + ": dimension arrow size must be controlled by one shared 2.5 variable.");
+ }
+
+ if (!source.Contains("TrySetDimProp(dim, \"Dimasz\", DimensionArrowSize);"))
+ {
+ throw new InvalidOperationException(sourcePath + ": dimension Dimasz must use DimensionArrowSize.");
+ }
+
+ var methodStart = source.IndexOf("public static void DrawHardnessSymbol", StringComparison.Ordinal);
+ if (methodStart < 0)
+ {
+ throw new InvalidOperationException(sourcePath + ": DrawHardnessSymbol method was not found.");
+ }
+
+ var methodEnd = source.IndexOf("/// ", methodStart, StringComparison.Ordinal);
+ if (methodEnd < 0)
+ {
+ methodEnd = source.Length;
+ }
+
+ var method = source.Substring(methodStart, methodEnd - methodStart);
+ if (!method.Contains("var leader = new Leader()") ||
+ !method.Contains("ctx.Style?.Apply(leader, DrawingStyleManager.Role.Dimension)") ||
+ !method.Contains("DrawLeaderArrowHead(ctx, p1, p2, 4)") ||
+ method.Contains("double arrowLength = 5.0") ||
+ method.Contains("double arrowWidth = 1.5"))
+ {
+ throw new InvalidOperationException(sourcePath + ": hardness symbol arrow must use the shared dimension arrow size.");
+ }
+
+ RequireMethodUsesSharedArrow(source, sourcePath, "public static void DrawSpecialInnerHoleLeader");
+ RequireMethodUsesSharedArrow(source, sourcePath, "public static void DrawSpecialHBLeaderToTop");
+ RequireFileMethodUsesSharedArrow(
+ Path.Combine("Cad", "BlockRawFreeForgeNoRoundHeadDrawer.cs"),
+ "private static void DrawSpecialHBLeaderToTop",
+ "FeatureDrivenDrawer.DrawLeaderArrowHead(ctx, p1, p2, 7)");
+ RequireFileMethodUsesSharedArrow(
+ Path.Combine("Cad", "BlockRawFreeForgeRoundHeadDrawer.cs"),
+ "private static void DrawSpecialHBLeaderToTop",
+ "FeatureDrivenDrawer.DrawLeaderArrowHead(ctx, p1, p2, 7)");
+ RequireFileMethodUsesSharedArrow(
+ Path.Combine("Cad", "RingMachinedRollingDrawer.cs"),
+ "private static void DrawSpecialInnerHoleLeader",
+ "FeatureDrivenDrawer.DrawLeaderArrowHead(ctx, p1, p2, 7)");
+ }
+
+ private static void RequireMethodUsesSharedArrow(string source, string sourcePath, string signature)
+ {
+ var methodStart = source.IndexOf(signature, StringComparison.Ordinal);
+ if (methodStart < 0)
+ {
+ throw new InvalidOperationException(sourcePath + ": " + signature + " method was not found.");
+ }
+
+ var methodEnd = source.IndexOf("public static void", methodStart + signature.Length, StringComparison.Ordinal);
+ if (methodEnd < 0)
+ {
+ methodEnd = source.IndexOf("private static void", methodStart + signature.Length, StringComparison.Ordinal);
+ }
+ if (methodEnd < 0)
+ {
+ methodEnd = source.Length;
+ }
+
+ var method = source.Substring(methodStart, methodEnd - methodStart);
+ if (!method.Contains("DrawLeaderArrowHead(ctx, p1, p2, 7)"))
+ {
+ throw new InvalidOperationException(sourcePath + ": " + signature + " must draw its arrow with DimensionArrowSize.");
+ }
+ }
+
+ private static void RequireFileMethodUsesSharedArrow(string sourcePath, string signature, string expectedCall)
+ {
+ var source = File.ReadAllText(sourcePath);
+ var methodStart = source.IndexOf(signature, StringComparison.Ordinal);
+ if (methodStart < 0)
+ {
+ throw new InvalidOperationException(sourcePath + ": " + signature + " method was not found.");
+ }
+
+ var methodEnd = source.IndexOf("private static void", methodStart + signature.Length, StringComparison.Ordinal);
+ if (methodEnd < 0)
+ {
+ methodEnd = source.Length;
+ }
+
+ var method = source.Substring(methodStart, methodEnd - methodStart);
+ if (!method.Contains(expectedCall))
+ {
+ throw new InvalidOperationException(sourcePath + ": " + signature + " must draw its arrow with DimensionArrowSize.");
+ }
+ }
+}
diff --git a/Tests/MinWallThicknessAutoCalcTests.cs b/Tests/MinWallThicknessAutoCalcTests.cs
new file mode 100644
index 0000000..00ebac9
--- /dev/null
+++ b/Tests/MinWallThicknessAutoCalcTests.cs
@@ -0,0 +1,50 @@
+using System;
+using System.IO;
+
+public static class MinWallThicknessAutoCalcTests
+{
+ public static int Main()
+ {
+ try
+ {
+ AutoCalculationUsesToleranceWorstCase();
+ Console.WriteLine("Min wall thickness auto calculation tests passed.");
+ return 0;
+ }
+ catch (Exception ex)
+ {
+ Console.Error.WriteLine(ex.Message);
+ return 1;
+ }
+ }
+
+ private static void AutoCalculationUsesToleranceWorstCase()
+ {
+ var sourcePath = Path.Combine("UI", "DrawingParamsForm.cs");
+ var source = File.ReadAllText(sourcePath);
+
+ if (!source.Contains("private const string KeyOuterDiameter1TolMinus = \"OuterDiameter1TolMinus\";") ||
+ !source.Contains("private const string KeyInnerDiameter2TolPlus = \"InnerDiameter2TolPlus\";"))
+ {
+ throw new InvalidOperationException(sourcePath + ": min wall thickness auto calculation must know outer lower tolerance and inner upper tolerance keys.");
+ }
+
+ if (!source.Contains("string.Equals(key, KeyOuterDiameter1TolMinus, StringComparison.OrdinalIgnoreCase)") ||
+ !source.Contains("string.Equals(key, KeyInnerDiameter2TolPlus, StringComparison.OrdinalIgnoreCase)"))
+ {
+ throw new InvalidOperationException(sourcePath + ": tolerance input changes must update min wall thickness.");
+ }
+
+ if (!source.Contains("var outerLower = GetNumericValue(KeyOuterDiameter1TolMinus);") ||
+ !source.Contains("var innerUpper = GetNumericValue(KeyInnerDiameter2TolPlus);") ||
+ !source.Contains("var t = ((phi1 + outerLower) - (phi2 + innerUpper)) / 2.0;"))
+ {
+ throw new InvalidOperationException(sourcePath + ": min wall thickness must be calculated as ((outer diameter + lower tolerance) - (inner diameter + upper tolerance)) / 2.");
+ }
+
+ if (source.Contains("var t = (phi1 - phi2) / 2.0;"))
+ {
+ throw new InvalidOperationException(sourcePath + ": nominal-only min wall thickness formula must not remain.");
+ }
+ }
+}
diff --git a/Tests/RingRollingNominalWallGeometryTests.cs b/Tests/RingRollingNominalWallGeometryTests.cs
new file mode 100644
index 0000000..ca92b05
--- /dev/null
+++ b/Tests/RingRollingNominalWallGeometryTests.cs
@@ -0,0 +1,49 @@
+using System;
+using System.IO;
+
+public static class RingRollingNominalWallGeometryTests
+{
+ public static int Main()
+ {
+ try
+ {
+ RollingDrawerUsesNominalWallForGeometry("Cad", "RingMachinedRollingDrawer.cs");
+ RollingDrawerUsesNominalWallForGeometry("Cad", "RingRawRollingDrawer.cs");
+ Console.WriteLine("Ring rolling nominal wall geometry tests passed.");
+ return 0;
+ }
+ catch (Exception ex)
+ {
+ Console.Error.WriteLine(ex.Message);
+ return 1;
+ }
+ }
+
+ private static void RollingDrawerUsesNominalWallForGeometry(params string[] pathParts)
+ {
+ var sourcePath = Path.Combine(pathParts);
+ var source = File.ReadAllText(sourcePath);
+
+ if (!source.Contains("var nominalWallThickness = (physicalOuterR - physicalInnerR);"))
+ {
+ throw new InvalidOperationException(sourcePath + ": rolling geometry must derive wall width from nominal outer/inner diameters.");
+ }
+
+ if (!source.Contains("visualInnerR = nominalWallThickness * 2.0;") ||
+ !source.Contains("visualOuterR = nominalWallThickness * 3.0;"))
+ {
+ throw new InvalidOperationException(sourcePath + ": rolling schematic geometry must use nominal wall thickness for 2:1 hole/wall visual ratio.");
+ }
+
+ if (source.Contains("visualInnerR = minWallThkParam.Value * 2.0;") ||
+ source.Contains("visualOuterR = minWallThkParam.Value * 3.0;"))
+ {
+ throw new InvalidOperationException(sourcePath + ": rolling geometry must not use tolerance-adjusted MinWallThickness.");
+ }
+
+ if (!source.Contains("FeatureDrivenDrawer.DrawMinWallThicknessNote(ctx, xInnerRight.Value, ox + visualOuterR, oy, minWallThickness.Value"))
+ {
+ throw new InvalidOperationException(sourcePath + ": rolling Tmin annotation must continue to display MinWallThickness.");
+ }
+ }
+}
diff --git a/Tests/ShaftBreakCenterLineTests.cs b/Tests/ShaftBreakCenterLineTests.cs
new file mode 100644
index 0000000..4411f3c
--- /dev/null
+++ b/Tests/ShaftBreakCenterLineTests.cs
@@ -0,0 +1,36 @@
+using System;
+using System.IO;
+
+public static class ShaftBreakCenterLineTests
+{
+ public static int Main()
+ {
+ try
+ {
+ SquareShaftCenterLineSkipsBreakGap();
+ Console.WriteLine("Shaft break centerline tests passed.");
+ return 0;
+ }
+ catch (Exception ex)
+ {
+ Console.Error.WriteLine(ex.Message);
+ return 1;
+ }
+ }
+
+ private static void SquareShaftCenterLineSkipsBreakGap()
+ {
+ var sourcePath = Path.Combine("Cad", "ShaftRawFreeForgeSquareShaftDrawer.cs");
+ var source = File.ReadAllText(sourcePath);
+
+ if (source.Contains("var centerLine = new Line(new Point3d(ox - 10, clY, 0), new Point3d(ox + S1 + 10, clY, 0));"))
+ {
+ throw new InvalidOperationException(sourcePath + ": square shaft centerline must not pass through the break gap.");
+ }
+
+ if (!source.Contains("DrawHorizontalCenterLine(ctx, clY, ox, ox + S1, needBreakLines, xBreak, lineSpacing, oy, oy + S2);"))
+ {
+ throw new InvalidOperationException(sourcePath + ": square shaft centerline must reuse the break-aware centerline drawing.");
+ }
+ }
+}
diff --git a/Tests/ShaftBreakLineClearanceTests.cs b/Tests/ShaftBreakLineClearanceTests.cs
new file mode 100644
index 0000000..7b4dea9
--- /dev/null
+++ b/Tests/ShaftBreakLineClearanceTests.cs
@@ -0,0 +1,38 @@
+using System;
+using System.IO;
+
+public static class ShaftBreakLineClearanceTests
+{
+ public static int Main()
+ {
+ try
+ {
+ ShaftDrawerUsesClearanceAroundBreakLines("Cad", "ShaftRawFreeForgeRoundShaftDrawer.cs");
+ ShaftDrawerUsesClearanceAroundBreakLines("Cad", "ShaftRawFreeForgeSquareShaftDrawer.cs");
+ Console.WriteLine("Shaft break-line clearance tests passed.");
+ return 0;
+ }
+ catch (Exception ex)
+ {
+ Console.Error.WriteLine(ex.Message);
+ return 1;
+ }
+ }
+
+ private static void ShaftDrawerUsesClearanceAroundBreakLines(params string[] pathParts)
+ {
+ var sourcePath = Path.Combine(pathParts);
+ var source = File.ReadAllText(sourcePath);
+
+ if (!source.Contains("FeatureDrivenDrawer.GetSBreakLineXAtY("))
+ {
+ throw new InvalidOperationException(sourcePath + ": shaft break gaps must calculate the exact S break-line intersection at each horizontal line Y.");
+ }
+
+ if (source.Contains("xBreak - breakClearance") ||
+ source.Contains("xBreak + breakWidth + breakClearance"))
+ {
+ throw new InvalidOperationException(sourcePath + ": shaft break gaps must not use fixed clearance offsets.");
+ }
+ }
+}
diff --git a/Tests/ShaftRightTopRadiusLeaderTests.cs b/Tests/ShaftRightTopRadiusLeaderTests.cs
new file mode 100644
index 0000000..42a2e93
--- /dev/null
+++ b/Tests/ShaftRightTopRadiusLeaderTests.cs
@@ -0,0 +1,40 @@
+using System;
+using System.IO;
+
+public static class ShaftRightTopRadiusLeaderTests
+{
+ public static int Main()
+ {
+ try
+ {
+ ShaftDrawersDoNotDrawRightTopRadiusLeader("Cad", "ShaftRawFreeForgeRoundShaftDrawer.cs");
+ ShaftDrawersDoNotDrawRightTopRadiusLeader("Cad", "ShaftRawFreeForgeSquareShaftDrawer.cs");
+ Console.WriteLine("Shaft right-top radius leader tests passed.");
+ return 0;
+ }
+ catch (Exception ex)
+ {
+ Console.Error.WriteLine(ex.Message);
+ return 1;
+ }
+ }
+
+ private static void ShaftDrawersDoNotDrawRightTopRadiusLeader(params string[] pathParts)
+ {
+ var sourcePath = Path.Combine(pathParts);
+ var source = File.ReadAllText(sourcePath);
+
+ if (!source.Contains("private static void DrawHeadFilletRadiusLeader"))
+ {
+ throw new InvalidOperationException(sourcePath + ": radius leader helper should remain available for local history and narrow changes.");
+ }
+
+ var helperStart = source.IndexOf("private static void DrawHeadFilletRadiusLeader", StringComparison.Ordinal);
+ var mainFlow = source.Substring(0, helperStart);
+
+ if (mainFlow.Contains("DrawHeadFilletRadiusLeader(ctx,"))
+ {
+ throw new InvalidOperationException(sourcePath + ": shaft templates must not draw the right-top R radius leader.");
+ }
+ }
+}
diff --git a/UI/DrawingParamsForm.cs b/UI/DrawingParamsForm.cs
index 026bf24..d3d0282 100644
--- a/UI/DrawingParamsForm.cs
+++ b/UI/DrawingParamsForm.cs
@@ -436,7 +436,7 @@ namespace CadParamPluging.UI
}
Control finalCtrl = ctrl;
- if (string.Equals(def.Key, "MarkingContent", StringComparison.OrdinalIgnoreCase))
+ if (ShouldShowNoteVisibilityOption(def.Key))
{
var flow = new FlowLayoutPanel
{
@@ -550,27 +550,27 @@ namespace CadParamPluging.UI
_ctrlMinWallThickness = _controlsByKey[KeyMinWallThickness];
var hasOuter = _controlsByKey.ContainsKey(KeyOuterDiameter1);
- var hasOuterTol = _controlsByKey.ContainsKey(KeyOuterDiameter1TolMinus);
+ var hasOuterLower = _controlsByKey.ContainsKey(KeyOuterDiameter1TolMinus);
var hasInner = _controlsByKey.ContainsKey(KeyInnerDiameter2);
- var hasInnerTol = _controlsByKey.ContainsKey(KeyInnerDiameter2TolPlus);
+ var hasInnerUpper = _controlsByKey.ContainsKey(KeyInnerDiameter2TolPlus);
- if (hasOuter && hasOuterTol && hasInner && hasInnerTol)
+ if (hasOuter && hasOuterLower && hasInner && hasInnerUpper)
{
_canAutoCalcMinWallThickness = true;
UpdateMinWallThickness();
if (_ctrlMinWallThickness != null)
{
- _toolTip.SetToolTip(_ctrlMinWallThickness, "自动计算: T=((Φ1+b1)-(Φ2+a2))/2\n(根据外径Φ1、外径下差b1、内径Φ2、内径上差a2)");
+ _toolTip.SetToolTip(_ctrlMinWallThickness, "自动计算: T=((Φ1+b1)-(Φ2+a2))/2\n(根据外径下差、内径上差取最小壁厚)");
}
}
else
{
var missing = new List();
if (!hasOuter) missing.Add("外径Φ1");
- if (!hasOuterTol) missing.Add("外径下差b1");
+ if (!hasOuterLower) missing.Add("外径下差b1");
if (!hasInner) missing.Add("内径Φ2");
- if (!hasInnerTol) missing.Add("内径上差a2");
+ if (!hasInnerUpper) missing.Add("内径上差a2");
if (_ctrlMinWallThickness != null && missing.Count > 0)
{
@@ -590,15 +590,11 @@ namespace CadParamPluging.UI
try
{
var phi1 = GetNumericValue(KeyOuterDiameter1);
- var b1 = GetNumericValue(KeyOuterDiameter1TolMinus);
+ var outerLower = GetNumericValue(KeyOuterDiameter1TolMinus);
var phi2 = GetNumericValue(KeyInnerDiameter2);
- var a2 = GetNumericValue(KeyInnerDiameter2TolPlus);
+ var innerUpper = GetNumericValue(KeyInnerDiameter2TolPlus);
- // 注意:b1通常为负数(如-0.5),a2通常为正数(如0.5)
- // 最小壁厚(径向):T = ((外径最小) - (内径最大)) / 2
- // 外径最小 = Φ1 + b1,内径最大 = Φ2 + a2
- // T = ((Φ1 + b1) - (Φ2 + a2)) / 2
- var t = ((phi1 + b1) - (phi2 + a2)) / 2.0;
+ var t = ((phi1 + outerLower) - (phi2 + innerUpper)) / 2.0;
if (_ctrlMinWallThickness is NumericUpDown num)
{
@@ -665,7 +661,7 @@ namespace CadParamPluging.UI
Func getValueW = (k) =>
{
var val = tempBag.GetString(k);
- if (k != null && k.StartsWith("MarkingContent", StringComparison.OrdinalIgnoreCase))
+ if (IsNoteVisibilityControlledKey(k))
{
if (tempBag.GetString(k + "_ShowInNote") == "0") return "__SKIP_NOTE__";
}
@@ -708,6 +704,35 @@ namespace CadParamPluging.UI
return bag;
}
+ private bool ShouldShowNoteVisibilityOption(string key)
+ {
+ if (string.IsNullOrWhiteSpace(key))
+ {
+ return false;
+ }
+
+ if (key.StartsWith("MarkingContent", StringComparison.OrdinalIgnoreCase))
+ {
+ return true;
+ }
+
+ if (!key.StartsWith("SurfaceRoughness", StringComparison.OrdinalIgnoreCase))
+ {
+ return false;
+ }
+
+ return string.Equals(_schema?.ProjectType, "车加工", StringComparison.OrdinalIgnoreCase)
+ && string.Equals(_schema?.DrawingType, "轧制", StringComparison.OrdinalIgnoreCase)
+ && string.Equals(_schema?.SheetSize, "环形", StringComparison.OrdinalIgnoreCase);
+ }
+
+ private static bool IsNoteVisibilityControlledKey(string key)
+ {
+ return key != null
+ && (key.StartsWith("MarkingContent", StringComparison.OrdinalIgnoreCase)
+ || key.StartsWith("SurfaceRoughness", StringComparison.OrdinalIgnoreCase));
+ }
+
private Control CreateControl(ParamDefinition def, string valueKey)
{
var initialValue = def.DefaultValue;