MCPcopy Index your code
hub / github.com/SLiCAP/SLiCAP_python / draw_symbol_texts

Function draw_symbol_texts

SLiCAP/schematic/component_item.py:124–151  ·  view source on GitHub ↗

Draw a symbol's embedded text labels upright and unmirrored under any rotation/flip (companion to draw_subckt_pin_names; used by ComponentItem and the SVG/PDF exporter via the same text list).

(painter, texts, rotation: float,
                      h_flip: bool, v_flip: bool)

Source from the content-addressed store, hash-verified

122
123
124def draw_symbol_texts(painter, texts, rotation: float,
125 h_flip: bool, v_flip: bool) -> None:
126 """Draw a symbol's embedded text labels upright and unmirrored under any
127 rotation/flip (companion to draw_subckt_pin_names; used by ComponentItem and
128 the SVG/PDF exporter via the same text list)."""
129 if not texts:
130 return
131 ct = _counter_transform(rotation, h_flip, v_flip)
132 painter.save()
133 painter.setPen(config.SYMBOL_TEXT_COLOR)
134 for t in texts:
135 content = t["content"]
136 if not content:
137 continue
138 f = QFont(_PARAM_FONT)
139 f.setPixelSize(max(1, round(t["size"])))
140 painter.setFont(f)
141 painter.save()
142 painter.translate(t["x"], t["y"])
143 painter.setTransform(ct, True)
144 # Centred horizontally AND vertically on the anchor point, so the counter
145 # transform pivots on the glyph centre — the text stays put (just upright)
146 # under any rotation/mirror. The previews render through the same path
147 # (paint_symbol) so the canvas and previews match exactly.
148 painter.drawText(QRectF(-100.0, -100.0, 200.0, 200.0),
149 Qt.AlignCenter, content)
150 painter.restore()
151 painter.restore()
152
153
154def paint_symbol(painter, svg_bytes: bytes, rect: QRectF) -> None:

Callers 2

paint_symbolFunction · 0.85
paintMethod · 0.85

Calls 2

_counter_transformFunction · 0.85
saveMethod · 0.45

Tested by

no test coverage detected