개정판 4006e1f8
LineNoTracer 중 SecondaryLine 검출 부분을 중첩 루프를 이용하여 적용
DTI_PID/DTI_PID/LineNoTracer.py | ||
---|---|---|
33 | 33 |
humkyung 2018.05.08 add flow arrow |
34 | 34 |
Jeongwoo 2018.05.14 Add [runs] on Primary/Secondary Line - Need to modify Secondary Line |
35 | 35 |
Jeongwoo 2018.05.15 Make Comments [lineno.conns[0].owner = lineno] |
36 |
Jeongwoo 2018.05.17 Modify find secondary lines with 'while' |
|
36 | 37 |
''' |
37 | 38 |
def execute(self, toler=50): |
38 | 39 |
from QEngineeringLineItem import QEngineeringLineItem |
... | ... | |
84 | 85 |
if maxLengthItem is not None: maxLengthItem.addFlowArrow() # TODO: check error scene() returns None |
85 | 86 |
|
86 | 87 |
# find secondary lines |
87 |
for line in self._lines: |
|
88 |
if line.owner is not None: continue |
|
88 |
foundCount = 1 |
|
89 |
while foundCount: |
|
90 |
foundCount = 0 |
|
91 |
for line in self._lines: |
|
92 |
if line.owner is not None: continue |
|
89 | 93 |
|
90 |
matches = [x for x in self._lines if x.owner is not None and x.isConnectable(line)] |
|
91 |
if matches: |
|
92 |
connectedItems = self.findConnectedObjects(line, toler=10) |
|
93 |
for item in connectedItems: item.owner = matches[0].owner # set item's owner |
|
94 |
matches = [x for x in self._lines if x.owner is not None and x.isConnectable(line)] |
|
95 |
if matches: |
|
96 |
foundCount += 1 |
|
97 |
connectedItems = self.findConnectedObjects(line, toler=10) |
|
98 |
for item in connectedItems: item.owner = matches[0].owner # set item's owner |
|
94 | 99 |
|
95 |
pipeRun = QEngineeringRunItem() |
|
96 |
pipeRun.items = connectedItems |
|
97 |
if pipeRun.items is not None and len(pipeRun.items) > 0: |
|
98 |
matches[0].owner.runs.append(pipeRun) |
|
100 |
pipeRun = QEngineeringRunItem()
|
|
101 |
pipeRun.items = connectedItems
|
|
102 |
if pipeRun.items is not None and len(pipeRun.items) > 0:
|
|
103 |
matches[0].owner.runs.append(pipeRun)
|
|
99 | 104 |
|
100 |
connectedLines = [item for item in connectedItems if type(item) is QEngineeringLineItem] |
|
105 |
connectedLines = [item for item in connectedItems if type(item) is QEngineeringLineItem]
|
|
101 | 106 |
|
102 |
maxLength = None |
|
103 |
maxLengthItem = None |
|
104 |
for line in connectedLines: |
|
105 |
length = line.length() |
|
106 |
if maxLength is None or maxLength < length: |
|
107 |
maxLength = length |
|
108 |
maxLengthItem = line |
|
109 |
|
|
110 |
if maxLengthItem is not None: maxLengthItem.addFlowArrow() # TODO: check error scene() returns None |
|
107 |
maxLength = None
|
|
108 |
maxLengthItem = None
|
|
109 |
for line in connectedLines:
|
|
110 |
length = line.length()
|
|
111 |
if maxLength is None or maxLength < length:
|
|
112 |
maxLength = length
|
|
113 |
maxLengthItem = line
|
|
114 |
|
|
115 |
if maxLengthItem is not None: maxLengthItem.addFlowArrow() # TODO: check error scene() returns None
|
|
111 | 116 |
except Exception as ex: |
112 | 117 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
113 | 118 |
|
내보내기 Unified diff