개정판 e8fc933f
issue #563: fix line tracer
Change-Id: I5819615f7d1f30da42cda2524ae071ad987882dd
DTI_PID/DTI_PID/LineNoTracer.py | ||
---|---|---|
481 | 481 |
QApplication.processEvents() |
482 | 482 |
|
483 | 483 |
symbols = [] |
484 |
lines = docdata.lines
|
|
484 |
lines = [item for item in worker.scene.items() if type(item) is QEngineeringLineItem]
|
|
485 | 485 |
lineNos = [] |
486 | 486 |
spec_breaks = [] |
487 | 487 |
lineIndicator = [] |
DTI_PID/DTI_PID/Shapes/EngineeringLineItem.py | ||
---|---|---|
644 | 644 |
return self._lineType == 'Primary' or self._lineType == 'Secondary' or \ |
645 | 645 |
self._lineType == 'Connect To Process' |
646 | 646 |
|
647 |
def next_connected(self, lhs, rhs): |
|
648 |
""" check given two item's are next connected(ex: 0-1) """ |
|
649 |
|
|
650 |
lhs_matches = [at for at in range(len(self.connectors)) if self.connectors[at].connectedItem == lhs] |
|
651 |
rhs_matches = [at for at in range(len(self.connectors)) if self.connectors[at].connectedItem == rhs] |
|
652 |
if lhs_matches and rhs_matches: |
|
653 |
return (lhs_matches[0] in [0, 1] and rhs_matches[0] in [0, 1]) |
|
654 |
|
|
655 |
return False |
|
656 |
|
|
647 | 657 |
@staticmethod |
648 | 658 |
def check_piping(lineType, strong=False): |
649 | 659 |
""" return true if piping line """ |
DTI_PID/DTI_PID/Shapes/EngineeringLineNoTextItem.py | ||
---|---|---|
847 | 847 |
from_found = False |
848 | 848 |
to_found = False |
849 | 849 |
|
850 |
while pool: |
|
851 |
lineNo = pool.pop() |
|
852 |
if lineNo not in visited: |
|
853 |
visited.append(lineNo) |
|
854 |
else: |
|
855 |
continue |
|
856 |
|
|
857 |
if lineNo.runs and lineNo.runs[0]: |
|
858 |
items = lineNo.runs[0].items |
|
859 |
if len(items) > 2: |
|
860 |
if type(items[0]) is QEngineeringNozzleItem and not from_found: |
|
861 |
for connector in items[0].connectors: |
|
862 |
# From |
|
863 |
if (type(connector.connectedItem) is QEngineeringVendorItem or type( |
|
864 |
connector.connectedItem) is QEngineeringEquipmentItem) and \ |
|
865 |
connector.connectedItem not in items: |
|
866 |
for _attr in _attrs: |
|
867 |
if _attr.Attribute == 'From_eq' and self.add_assoc_item(connector.connectedItem, |
|
850 |
|
|
851 |
try: |
|
852 |
while pool: |
|
853 |
lineNo = pool.pop() |
|
854 |
if lineNo not in visited: |
|
855 |
visited.append(lineNo) |
|
856 |
else: |
|
857 |
continue |
|
858 |
|
|
859 |
if lineNo.runs and lineNo.runs[0]: |
|
860 |
items = lineNo.runs[0].items |
|
861 |
if len(items) > 2: |
|
862 |
if type(items[0]) is QEngineeringNozzleItem and not from_found: |
|
863 |
for connector in items[0].connectors: |
|
864 |
# From |
|
865 |
if (type(connector.connectedItem) is QEngineeringVendorItem or type( |
|
866 |
connector.connectedItem) is QEngineeringEquipmentItem) and \ |
|
867 |
connector.connectedItem not in items: |
|
868 |
for _attr in _attrs: |
|
869 |
if _attr.Attribute == 'From_eq' and self.add_assoc_item(connector.connectedItem, |
|
870 |
at=_attr.AttrAt): |
|
871 |
_attr.AssocItem = connector.connectedItem |
|
872 |
from_found = True |
|
873 |
break |
|
874 |
break |
|
875 |
elif not from_found: |
|
876 |
if type(items[0]) is QEngineeringLineItem and items[0].connectors[0].connectedItem and items[0].connectors[0].connectedItem.owner: |
|
877 |
pool.append(items[0].connectors[0].connectedItem.owner) |
|
878 |
else: |
|
879 |
next_items = [connector.connectedItem for connector in items[0].connectors if connector.connectedItem and \ |
|
880 |
connector.connectedItem is not items[1] and items[0].next_connected(items[1], connector.connectedItem)] |
|
881 |
if next_items and next_items[0].owner: |
|
882 |
pool.append(next_items[0].owner) |
|
883 |
|
|
884 |
if type(items[-1]) is QEngineeringNozzleItem and not to_found: |
|
885 |
for connector in items[-1].connectors: |
|
886 |
# To |
|
887 |
if (type(connector.connectedItem) is QEngineeringVendorItem or type( |
|
888 |
connector.connectedItem) is QEngineeringEquipmentItem) and \ |
|
889 |
connector.connectedItem not in items: |
|
890 |
for _attr in _attrs: |
|
891 |
if _attr.Attribute == 'To_eq' and self.add_assoc_item(connector.connectedItem, |
|
868 | 892 |
at=_attr.AttrAt): |
869 |
_attr.AssocItem = connector.connectedItem |
|
870 |
from_found = True |
|
871 |
break |
|
872 |
break |
|
873 |
elif not from_found: |
|
874 |
if type(items[0]) is QEngineeringLineItem and items[0].connectors[0].connectedItem and items[0].connectors[0].connectedItem.owner: |
|
875 |
pool.append(items[0].connectors[0].connectedItem.owner) |
|
876 |
else: |
|
877 |
next_items = [connector.connectedItem for connector in items[0].connectors if connector.connectedItem and \ |
|
878 |
connector.connectedItem is not items[1] and items[0].next_connected(items[1], connector.connectedItem)] |
|
879 |
if next_items and next_items[0].owner: |
|
880 |
pool.append(next_items[0].owner) |
|
881 |
|
|
882 |
if type(items[-1]) is QEngineeringNozzleItem and not to_found: |
|
883 |
for connector in items[-1].connectors: |
|
884 |
# To |
|
885 |
if (type(connector.connectedItem) is QEngineeringVendorItem or type( |
|
886 |
connector.connectedItem) is QEngineeringEquipmentItem) and \ |
|
887 |
connector.connectedItem not in items: |
|
888 |
for _attr in _attrs: |
|
889 |
if _attr.Attribute == 'To_eq' and self.add_assoc_item(connector.connectedItem, |
|
890 |
at=_attr.AttrAt): |
|
891 |
_attr.AssocItem = connector.connectedItem |
|
892 |
to_found = True |
|
893 |
break |
|
894 |
break |
|
895 |
elif not to_found: |
|
896 |
if type(items[-1]) is QEngineeringLineItem and items[-1].connectors[1].connectedItem and items[-1].connectors[1].connectedItem.owner: |
|
897 |
pool.append(items[-1].connectors[1].connectedItem.owner) |
|
898 |
else: |
|
899 |
next_items = [connector.connectedItem for connector in items[-1].connectors if connector.connectedItem and \ |
|
900 |
connector.connectedItem is not items[-2] and items[-1].next_connected(items[-2], connector.connectedItem)] |
|
901 |
if next_items and next_items[0].owner: |
|
902 |
pool.append(next_items[0].owner) |
|
893 |
_attr.AssocItem = connector.connectedItem |
|
894 |
to_found = True |
|
895 |
break |
|
896 |
break |
|
897 |
elif not to_found: |
|
898 |
if type(items[-1]) is QEngineeringLineItem and items[-1].connectors[1].connectedItem and items[-1].connectors[1].connectedItem.owner: |
|
899 |
pool.append(items[-1].connectors[1].connectedItem.owner) |
|
900 |
else: |
|
901 |
next_items = [connector.connectedItem for connector in items[-1].connectors if connector.connectedItem and \ |
|
902 |
connector.connectedItem is not items[-2] and items[-1].next_connected(items[-2], connector.connectedItem)] |
|
903 |
if next_items and next_items[0].owner: |
|
904 |
pool.append(next_items[0].owner) |
|
905 |
except Exception as ex: |
|
906 |
from App import App |
|
907 |
from AppDocData import MessageType |
|
908 |
|
|
909 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
910 |
sys.exc_info()[-1].tb_lineno) |
|
911 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
내보내기 Unified diff