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

Method paint

SLiCAP/schematic/component_item.py:784–841  ·  view source on GitHub ↗
(self, painter, option, widget=None)

Source from the content-addressed store, hash-verified

782 wire.move_points(idxs, delta)
783
784 def paint(self, painter, option, widget=None):
785 super().paint(painter, option, widget)
786
787 # Embedded symbol text (+/- markers, noise labels …) — drawn on top of the
788 # artwork and kept upright/unmirrored under any rotation/flip.
789 draw_symbol_texts(painter, self.symbol_texts,
790 self.rotation(), self.h_flip, self.v_flip)
791
792 # Pin markers — small grey squares on UNCONNECTED pins; they disappear as
793 # soon as a wire or another pin connects to the pin (the scene keeps
794 # _unconnected_pins in sync). Drawn here so they sit on top of the symbol.
795 if self._unconnected_pins:
796 pins = PIN_POSITIONS.get(self.symbol_name, [])
797 size = config.HANDLE_SIZE
798 h = size / 2.0
799 painter.save()
800 painter.setPen(Qt.NoPen)
801 painter.setBrush(config.CONNECTION_COLOR)
802 for i in self._unconnected_pins:
803 if i < len(pins):
804 lx, ly = pins[i]
805 painter.drawRect(QRectF(lx - h, ly - h, size, size))
806 painter.restore()
807
808 # Pin names — only for symbols that opt in via data-show-pinnames (the
809 # auto-generated subcircuit boxes, whose shape carries no pin meaning).
810 # Each name is counter-transformed so it stays horizontal and unmirrored
811 # under any rotation/flip of the block.
812 if SYMBOL_SHOW_PINNAMES.get(self.symbol_name, False):
813 draw_subckt_pin_names(
814 painter,
815 SYMBOL_NODES.get(self.symbol_name, []),
816 PIN_POSITIONS.get(self.symbol_name, []),
817 self.rotation(), self.h_flip, self.v_flip,
818 )
819
820 # Dashed leader lines from the symbol centre to its attribute labels,
821 # drawn while the component is selected. A clicked attribute shows only
822 # its own leader; selecting the body (no active label) shows them all.
823 if self._labels and (option.state & QStyle.State_Selected):
824 active = self._labels.get(self._active_label_key)
825 painter.save()
826 painter.setPen(QPen(COMP_LABEL_COLOR, 0.5, Qt.DashLine))
827 painter.setBrush(Qt.NoBrush)
828 origin = QPointF(0.0, 0.0)
829 targets = [active] if active is not None else list(self._labels.values())
830 for lbl in targets:
831 painter.drawLine(origin, lbl.pos())
832 painter.restore()
833
834 if option.state & QStyle.State_Selected:
835 painter.save()
836 painter.setPen(QPen(QColor(0, 120, 215), 1.0))
837 painter.setBrush(Qt.NoBrush)
838 tight = SYMBOL_TIGHT_RECT.get(self.symbol_name)
839 rect = QRectF(*tight) if tight else super().boundingRect()
840 painter.drawRect(rect)
841 painter.restore()

Callers

nothing calls this directly

Calls 4

draw_symbol_textsFunction · 0.85
draw_subckt_pin_namesFunction · 0.85
saveMethod · 0.45
boundingRectMethod · 0.45

Tested by

no test coverage detected