From 8555197bed76590d53157fe67fe25211c7dedc77 Mon Sep 17 00:00:00 2001 From: zhanghao <2024138486@qq.com> Date: Wed, 24 Jun 2026 10:47:47 +0800 Subject: [PATCH] =?UTF-8?q?feature/2d=20to=203d=E5=AF=BC=E7=BA=BF=E5=AE=9E?= =?UTF-8?q?=E6=97=B6=E5=90=8C=E6=AD=A5-zh-0624?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Mod/FreeCADExchange/ExchangeBootstrap.py | 3 +- src/Mod/FreeCADExchange/WiringImport.py | 83 +++++++++++++++++++- 2 files changed, 82 insertions(+), 4 deletions(-) diff --git a/src/Mod/FreeCADExchange/ExchangeBootstrap.py b/src/Mod/FreeCADExchange/ExchangeBootstrap.py index 9f46459..a514677 100644 --- a/src/Mod/FreeCADExchange/ExchangeBootstrap.py +++ b/src/Mod/FreeCADExchange/ExchangeBootstrap.py @@ -1060,11 +1060,12 @@ def reload_exchange_payload_from_signal(json_path, signal_payload): revision = _signal_revision(signal_payload) _append_debug_log( - "exchange signal reload complete: revision={0}, tasks_updated={1}, routed_matched={2}, view_updates={3}".format( + "exchange signal reload complete: revision={0}, tasks_updated={1}, routed_matched={2}, view_updates={3}, samples={4}".format( revision, wiring_report.get("updated_tasks", 0) if isinstance(wiring_report, dict) else 0, style_report.get("routed_wires_matched", 0) if isinstance(style_report, dict) else 0, style_report.get("updated_view", 0) if isinstance(style_report, dict) else 0, + style_report.get("updated_samples", []) if isinstance(style_report, dict) else [], ) ) App.Console.PrintMessage( diff --git a/src/Mod/FreeCADExchange/WiringImport.py b/src/Mod/FreeCADExchange/WiringImport.py index 32703fa..be4c915 100644 --- a/src/Mod/FreeCADExchange/WiringImport.py +++ b/src/Mod/FreeCADExchange/WiringImport.py @@ -108,6 +108,20 @@ def _line_width_value(wire_style): return max(0.1, min(20.0, value)) +def _draw_style_value(wire_style): + text = _style_text(wire_style, "line_type").lower() + if not text: + return "Solid" + normalized = text.replace("_", "").replace("-", "").replace(" ", "") + if normalized in {"dashline", "dashed", "dash", "dashes", "虚线"}: + return "Dashed" + if normalized in {"dotline", "dotted", "dot", "dots", "点线"}: + return "Dotted" + if normalized in {"dashdotline", "dashdot", "点划线"}: + return "Dashdot" + return "Solid" + + def _geometry_style_fields(wire_style): return { key: _style_text(wire_style, key) @@ -336,10 +350,30 @@ def _apply_wire_style_view(obj, wire_style): return changed color = _parse_line_color(_style_text(wire_style, "line_color")) - if color is not None and hasattr(view, "LineColor"): + if color is not None: + for prop_name in ("LineColor", "ShapeColor", "PointColor"): + if not hasattr(view, prop_name): + continue + try: + if tuple(getattr(view, prop_name, ())) != tuple(color): + setattr(view, prop_name, color) + changed = True + except Exception: + pass + + draw_style = _draw_style_value(wire_style) + if hasattr(view, "DrawStyle"): + try: + if str(getattr(view, "DrawStyle", "") or "") != draw_style: + view.DrawStyle = draw_style + changed = True + except Exception: + pass + + if hasattr(view, "DisplayMode"): try: - if tuple(getattr(view, "LineColor", ())) != tuple(color): - view.LineColor = color + if str(getattr(view, "DisplayMode", "") or "") != "Wireframe": + view.DisplayMode = "Wireframe" changed = True except Exception: pass @@ -353,6 +387,39 @@ def _apply_wire_style_view(obj, wire_style): except Exception: pass + _ensure_bool_property( + obj, + "QetWireStyleApplied", + bool(isinstance(wire_style, dict) and wire_style), + "Whether the QET wire style has been applied to the visible 3D wire", + ) + _ensure_string_property( + obj, + "QetAppliedWireLineColor", + _style_text(wire_style, "line_color"), + "Applied QET wire line color text", + ) + _ensure_string_property( + obj, + "QetAppliedWireDrawStyle", + draw_style, + "Applied QET wire draw style", + ) + if color is not None: + _ensure_string_property( + obj, + "QetAppliedWireLineColorRgb", + ",".join(str(value) for value in color), + "Applied QET wire RGB color", + ) + if width is not None: + _ensure_string_property( + obj, + "QetAppliedWireLineWidth", + str(width), + "Applied QET wire line width", + ) + return changed @@ -495,6 +562,7 @@ def apply_wire_styles_from_payload(payload, doc=None): "routed_wires_matched": 0, "updated_properties": 0, "updated_view": 0, + "updated_samples": [], "warnings": [], } @@ -515,5 +583,14 @@ def apply_wire_styles_from_payload(payload, doc=None): report["updated_properties"] += 1 if view_changed: report["updated_view"] += 1 + if len(report["updated_samples"]) < 8: + report["updated_samples"].append( + { + "wire_uuid": wire_uuid, + "line_color": _style_text(entry["wire_style"], "line_color"), + "line_width": _style_text(entry["wire_style"], "line_width"), + "view_changed": bool(view_changed), + } + ) return report