|
|
|
@ -108,6 +108,20 @@ def _line_width_value(wire_style):
|
|
|
|
return max(0.1, min(20.0, value))
|
|
|
|
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):
|
|
|
|
def _geometry_style_fields(wire_style):
|
|
|
|
return {
|
|
|
|
return {
|
|
|
|
key: _style_text(wire_style, key)
|
|
|
|
key: _style_text(wire_style, key)
|
|
|
|
@ -336,10 +350,30 @@ def _apply_wire_style_view(obj, wire_style):
|
|
|
|
return changed
|
|
|
|
return changed
|
|
|
|
|
|
|
|
|
|
|
|
color = _parse_line_color(_style_text(wire_style, "line_color"))
|
|
|
|
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:
|
|
|
|
try:
|
|
|
|
if tuple(getattr(view, "LineColor", ())) != tuple(color):
|
|
|
|
if str(getattr(view, "DisplayMode", "") or "") != "Wireframe":
|
|
|
|
view.LineColor = color
|
|
|
|
view.DisplayMode = "Wireframe"
|
|
|
|
changed = True
|
|
|
|
changed = True
|
|
|
|
except Exception:
|
|
|
|
except Exception:
|
|
|
|
pass
|
|
|
|
pass
|
|
|
|
@ -353,6 +387,39 @@ def _apply_wire_style_view(obj, wire_style):
|
|
|
|
except Exception:
|
|
|
|
except Exception:
|
|
|
|
pass
|
|
|
|
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
|
|
|
|
return changed
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -495,6 +562,7 @@ def apply_wire_styles_from_payload(payload, doc=None):
|
|
|
|
"routed_wires_matched": 0,
|
|
|
|
"routed_wires_matched": 0,
|
|
|
|
"updated_properties": 0,
|
|
|
|
"updated_properties": 0,
|
|
|
|
"updated_view": 0,
|
|
|
|
"updated_view": 0,
|
|
|
|
|
|
|
|
"updated_samples": [],
|
|
|
|
"warnings": [],
|
|
|
|
"warnings": [],
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -515,5 +583,14 @@ def apply_wire_styles_from_payload(payload, doc=None):
|
|
|
|
report["updated_properties"] += 1
|
|
|
|
report["updated_properties"] += 1
|
|
|
|
if view_changed:
|
|
|
|
if view_changed:
|
|
|
|
report["updated_view"] += 1
|
|
|
|
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
|
|
|
|
return report
|
|
|
|
|