개정판 149967a7
issue #000: now label find owner symbol itself and valve oper code find in-line item as owner
Change-Id: Iea2d60f1d48c2e49c2c1a212049479deb28c7aa1
DTI_PID/DTI_PID/LineNoTracer.py | ||
---|---|---|
377 | 377 |
from EngineeringValveOperCodeTextItem import QEngineeringValveOperCodeTextItem |
378 | 378 |
from QEngineeringTrimLineNoTextItem import QEngineeringTrimLineNoTextItem |
379 | 379 |
from QEngineeringTagNoTextItem import QEngineeringTagNoTextItem |
380 |
from EngineeringErrorItem import QEngineeringErrorItem |
|
380 | 381 |
|
381 | 382 |
try: |
382 | 383 |
worker.displayMessage.emit('Initiating...') |
... | ... | |
410 | 411 |
for item in worker.graphicsView.scene.items(): |
411 | 412 |
if type(item) is QEngineeringSpecBreakItem: |
412 | 413 |
specBreak.append(item) |
413 |
elif issubclass(type(item), SymbolSvgItem) and not (type(item) is QEngineeringUnknownItem) and item.type != 'Notes': |
|
414 |
elif issubclass(type(item), SymbolSvgItem) and not (type(item) is QEngineeringErrorItem) and not (type(item) is QEngineeringUnknownItem) and item.type != 'Notes':
|
|
414 | 415 |
matches = [vendor_package for vendor_package in vendor_packages if vendor_package.includes(item)] |
415 | 416 |
if matches: |
416 | 417 |
item.set_property('Supplied By', vendorTag) |
... | ... | |
464 | 465 |
""" try to connect label to valve """ |
465 | 466 |
labels = [symbol for symbol in symbols if type(symbol) is QEngineeringInstrumentItem and not symbol.has_connection] |
466 | 467 |
#print(labels[0]) |
467 |
valves = [symbol for symbol in symbols if (type(symbol) is QEngineeringInstrumentItem and symbol.has_connection) and type(symbol) is not QEngineeringReducerItem and type(symbol) is not QEngineeringEquipmentItem \ |
|
468 |
and type(symbol) is not QEngineeringOPCItem and type(symbol) is not QEngineeringSpecBreakItem] |
|
468 |
valves = [symbol for symbol in symbols if symbol.type == 'Specialty Components' or symbol.type == 'In-Line' or symbol.type == 'Relief Devices'] |
|
469 | 469 |
#print(valves[0]) |
470 |
for valve in valves:
|
|
471 |
valve.connectAttribute(labels, clear=False)
|
|
470 |
for label in labels:
|
|
471 |
label.connectAttribute(valves, clear=False)
|
|
472 | 472 |
|
473 | 473 |
for symbol in symbols: |
474 | 474 |
for assoc in symbol.associations(): |
... | ... | |
484 | 484 |
texts = [item for item in worker.graphicsView.scene.items() if type(item) is QEngineeringReservedWordTextItem] |
485 | 485 |
for text in texts: |
486 | 486 |
text.findOwner(lines) |
487 |
texts = [item for item in worker.graphicsView.scene.items() if type(item) is QEngineeringSizeTextItem or type(item) is QEngineeringValveOperCodeTextItem or type(item) is QEngineeringTagNoTextItem] |
|
488 |
for text in texts: |
|
487 |
|
|
488 |
# restore and save manual edited attr's text item |
|
489 |
texts = [item for item in worker.graphicsView.scene.items() if type(item) is QEngineeringSizeTextItem or type(item) is QEngineeringValveOperCodeTextItem or type(item) is QEngineeringTagNoTextItem] |
|
490 |
targetText = [] |
|
491 |
for symbol in symbols: |
|
492 |
for attr in list(symbol.attrs.keys()): |
|
493 |
for text in texts: |
|
494 |
# skip freezed attr or already consumed by symbol |
|
495 |
if attr.AssocItem == text: |
|
496 |
text.owner = symbol |
|
497 |
else: |
|
498 |
targetText.append(text) |
|
499 |
|
|
500 |
for text in targetText: |
|
489 | 501 |
text.findOwner(symbols) |
490 | 502 |
|
491 | 503 |
""" update line type """ |
DTI_PID/DTI_PID/Shapes/EngineeringInstrumentItem.py | ||
---|---|---|
155 | 155 |
@date 2018.05.06 |
156 | 156 |
''' |
157 | 157 |
def connectAttribute(self, attributes, clear=True): |
158 |
from AppDocData import AppDocData |
|
159 |
|
|
158 | 160 |
try: |
159 | 161 |
if clear: |
160 | 162 |
self.clear_attr_and_assoc_item() |
161 | 163 |
|
162 | 164 |
rect = self.sceneBoundingRect() |
165 |
|
|
166 |
minDist = None |
|
167 |
selected = None |
|
168 |
|
|
169 |
configs = AppDocData.instance().getConfigs('Range', 'Detection Ratio') |
|
170 |
ratio = float(configs[0].value) if 1 == len(configs) else 1.5 |
|
171 |
|
|
172 |
dist = (self.sceneBoundingRect().height() + self.sceneBoundingRect().width()) * ratio / 2 |
|
173 |
center = self.sceneBoundingRect().center() |
|
174 |
|
|
163 | 175 |
for attr in attributes: |
164 |
if rect.contains(attr.center()): |
|
165 |
if issubclass(type(attr), QEngineeringTextItem): |
|
166 |
if self.add_assoc_item(attr): |
|
167 |
attr.owner = self # set owner of text |
|
168 |
elif issubclass(type(attr), SymbolSvgItem): |
|
176 |
if issubclass(type(attr), QEngineeringTextItem): |
|
177 |
if rect.contains(attr.center()): |
|
169 | 178 |
if self.add_assoc_item(attr): |
170 | 179 |
attr.owner = self # set owner of text |
180 |
|
|
181 |
elif issubclass(type(attr), SymbolSvgItem): |
|
182 |
dx = attr.center().x() - center.x() |
|
183 |
dy = attr.center().y() - center.y() |
|
184 |
|
|
185 |
offset = (attr.sceneBoundingRect().width() + attr.sceneBoundingRect().height()) / 4 |
|
186 |
length = math.sqrt(dx*dx + dy*dy) - offset |
|
187 |
|
|
188 |
if (length < dist) and (minDist is None or length < minDist): |
|
189 |
minDist = length |
|
190 |
selected = attr |
|
191 |
|
|
192 |
if selected is not None: |
|
193 |
self.add_assoc_item(selected) |
|
194 |
|
|
171 | 195 |
except Exception as ex: |
172 | 196 |
from App import App |
173 | 197 |
from AppDocData import MessageType |
DTI_PID/DTI_PID/Shapes/EngineeringValveOperCodeTextItem.py | ||
---|---|---|
35 | 35 |
|
36 | 36 |
def findOwner(self, symbols): |
37 | 37 |
import math |
38 |
from EngineeringInstrumentItem import QEngineeringInstrumentItem |
|
38 | 39 |
|
39 | 40 |
try: |
40 | 41 |
minDist = None |
... | ... | |
47 | 48 |
center = self.sceneBoundingRect().center() |
48 | 49 |
|
49 | 50 |
for symbol in symbols: |
50 |
if type(symbol) is SymbolSvgItem: |
|
51 |
if type(symbol) is SymbolSvgItem or type(symbol) is QEngineeringInstrumentItem:
|
|
51 | 52 |
dx = symbol.center().x() - center.x() |
52 |
dy = symbol.center().y() - center.y() |
|
53 |
length = math.sqrt(dx*dx + dy*dy) |
|
53 |
dy = symbol.center().y() - center.y() |
|
54 |
|
|
55 |
offset = (symbol.sceneBoundingRect().width() + symbol.sceneBoundingRect().height()) / 4 |
|
56 |
length = math.sqrt(dx*dx + dy*dy) - offset |
|
57 |
|
|
54 | 58 |
if (length < dist) and (minDist is None or length < minDist): |
55 | 59 |
minDist = length |
56 | 60 |
selected = symbol |
DTI_PID/DTI_PID/TextItemFactory.py | ||
---|---|---|
276 | 276 |
if 1 == len(configs) and configs[0].value: |
277 | 277 |
symbol_names = configs[0].value.split(',') |
278 | 278 |
for symbol in appDocData.symbols: |
279 |
if symbol.name in symbol_names and symbol.includes(textInfo.center) and '"' not in textInfo._text:
|
|
279 |
if symbol.name in symbol_names and symbol.includes(textInfo.center) and '"' not in textInfo.getText():
|
|
280 | 280 |
item = QEngineeringNoteItem(symbol=symbol) |
281 | 281 |
item.owner = symbol |
282 | 282 |
symbol.add_assoc_item(item, 0) |
내보내기 Unified diff