개정판 18fb962a
issue #000: improve attr link
Change-Id: I6293a083526c1f1fca29be74b7ca621631b1b1e2
DTI_PID/DTI_PID/Shapes/SymbolSvgItem.py | ||
---|---|---|
1085 | 1085 |
|
1086 | 1086 |
minDist = None |
1087 | 1087 |
selected = None |
1088 |
|
|
1089 |
contain_texts = [] |
|
1088 | 1090 |
for attr in attributes: |
1089 | 1091 |
# size text and operation code text will find owner themselves in findowner method |
1090 | 1092 |
if False: # type(attr) is QEngineeringSizeTextItem or type(attr) is QEngineeringValveOperCodeTextItem: |
... | ... | |
1103 | 1105 |
attr.owner = self |
1104 | 1106 |
elif issubclass(type(attr), QEngineeringTextItem): |
1105 | 1107 |
if rect.contains(attr.center()): |
1106 |
if self.add_assoc_item(attr): |
|
1107 |
attr.owner = self # set owner of text |
|
1108 |
dx = attr.center().x() - center.x() |
|
1109 |
dy = attr.center().y() - center.y() |
|
1110 |
length = math.sqrt(dx * dx + dy * dy) |
|
1111 |
contain_texts.append([length, attr]) |
|
1108 | 1112 |
elif type(attr) is QEngineeringLineItem: |
1109 | 1113 |
length = attr.distanceTo([center.x(), center.y()]) |
1110 | 1114 |
if (length < dist) and (minDist is None or length < minDist): |
1111 | 1115 |
minDist = length |
1112 | 1116 |
selected = attr |
1113 | 1117 |
|
1118 |
if contain_texts: |
|
1119 |
num = len([_attr for _attr in self.getAttributes(findOwner=True) if _attr.AttributeType == 'Text Item']) |
|
1120 |
contain_texts = sorted(contain_texts, key=lambda param: param[0]) |
|
1121 |
index = 0 |
|
1122 |
for _, attr in contain_texts: |
|
1123 |
if index >= num: |
|
1124 |
break |
|
1125 |
if self.add_assoc_item(attr): |
|
1126 |
attr.owner = self # set owner of text |
|
1127 |
index += 1 |
|
1128 |
|
|
1114 | 1129 |
if selected is not None: |
1115 | 1130 |
self.add_assoc_item(selected) |
1116 | 1131 |
|
내보내기 Unified diff