MCPcopy Create free account
hub / github.com/SLiCAP/SLiCAP_python / draw_subckt_pin_names

Function draw_subckt_pin_names

SLiCAP/schematic/component_item.py:42–69  ·  view source on GitHub ↗

Draw subcircuit pin names just inside the outline, one per pin. Each name is counter-transformed so it stays horizontal and unmirrored under any rotation/flip, and anchored to grow inward from its box edge so it never pokes out. Shared by ComponentItem.paint and the Place Subcircuit pr

(painter, nodes, pins, rotation=0.0,
                          h_flip=False, v_flip=False)

Source from the content-addressed store, hash-verified

40
41
42def draw_subckt_pin_names(painter, nodes, pins, rotation=0.0,
43 h_flip=False, v_flip=False) -> None:
44 """Draw subcircuit pin names just inside the outline, one per pin.
45
46 Each name is counter-transformed so it stays horizontal and unmirrored under
47 any rotation/flip, and anchored to grow inward from its box edge so it never
48 pokes out. Shared by ComponentItem.paint and the Place Subcircuit preview.
49 """
50 ct = _counter_transform(rotation, h_flip, v_flip)
51 fm = QFontMetricsF(_PIN_NAME_FONT)
52 painter.save()
53 painter.setPen(config.SYMBOL_TEXT_COLOR)
54 painter.setFont(_PIN_NAME_FONT)
55 for (px, py), name in zip(pins, nodes):
56 if abs(px) >= abs(py): # left / right pin
57 edge = px - _sign(px) * _SUBCKT_STUB
58 ax = edge - _sign(px) * (fm.horizontalAdvance(name) / 2 + _PIN_LABEL_MARGIN)
59 ay = py
60 else: # top / bottom pin
61 edge = py - _sign(py) * _SUBCKT_STUB
62 ax = px
63 ay = edge - _sign(py) * (fm.height() / 2 + _PIN_LABEL_MARGIN)
64 painter.save()
65 painter.translate(ax, ay)
66 painter.setTransform(ct, True)
67 painter.drawText(QRectF(-100, -20, 200, 40), Qt.AlignCenter, name)
68 painter.restore()
69 painter.restore()
70
71
72def _counter_transform(rotation: float, h_flip: bool, v_flip: bool) -> "QTransform":

Callers 2

paintMethod · 0.85
paintEventMethod · 0.85

Calls 3

_counter_transformFunction · 0.85
_signFunction · 0.85
saveMethod · 0.45

Tested by

no test coverage detected