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

Class AnalysisItem

SLiCAP/schematic/analysis_item.py:7–51  ·  view source on GitHub ↗

SLiCAP analysis setup block: .source / .detector / .lgref commands. Stores structured data; double-click reopens the dialog for editing.

Source from the content-addressed store, hash-verified

5
6
7class AnalysisItem(QGraphicsTextItem):
8 """
9 SLiCAP analysis setup block: .source / .detector / .lgref commands.
10 Stores structured data; double-click reopens the dialog for editing.
11 """
12
13 def __init__(self,
14 source: list, # 0-2 independent source refdes strings
15 detector: list, # 0-2 [type, ref] pairs; type = "V" or "I"
16 lgref: list, # 0-2 dependent source refdes strings
17 pos: QPointF = QPointF(0, 0)):
18 super().__init__()
19 self.source = list(source)
20 self.detector = [list(d) for d in detector]
21 self.lgref = list(lgref)
22 self.setPos(pos)
23 self.setFont(COMMAND_FONT)
24 self.setDefaultTextColor(COMMAND_COLOR)
25 self.setFlag(QGraphicsItem.ItemIsSelectable)
26 self.setFlag(QGraphicsItem.ItemIsMovable)
27 self.setFlag(QGraphicsItem.ItemSendsGeometryChanges)
28 self.setTextInteractionFlags(Qt.NoTextInteraction)
29 self.update_text()
30
31 def update_text(self):
32 lines = self.commands()
33 self.setPlainText("\n".join(lines) if lines else ".source\n.detector\n.lgref")
34
35 def commands(self) -> list:
36 result = []
37 src_refs = [r.strip() for r in self.source if r.strip()]
38 if src_refs:
39 result.append(".source " + " ".join(src_refs))
40 det_parts = [f"{t}_{r.strip()}" for t, r in self.detector if r.strip()]
41 if det_parts:
42 result.append(".detector " + " ".join(det_parts))
43 lg_refs = [r.strip() for r in self.lgref if r.strip()]
44 if lg_refs:
45 result.append(".lgref " + " ".join(lg_refs))
46 return result
47
48 def itemChange(self, change, value):
49 if change == QGraphicsItem.ItemPositionChange:
50 return snap(value)
51 return super().itemChange(change, value)

Callers 3

_commit_pasteMethod · 0.85
from_dataMethod · 0.85
mousePressEventMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected