개정판 ceee3a70
line no tracing improve test
Change-Id: If74f3592e6ad813769d49dbdbd442b7aba03bbca
DTI_PID/DTI_PID/LineNoTracer.py | ||
---|---|---|
192 | 192 |
if 1 == len(configs): |
193 | 193 |
#configs = app_doc_data.getConfigs('Line No', 'Configuration') |
194 | 194 |
|
195 |
''' |
|
195 | 196 |
for line_no in self._lineNos: |
196 | 197 |
_from = line_no.prop('From') |
197 | 198 |
_to = line_no.prop('To') |
... | ... | |
224 | 225 |
line_no.set_property('To', None) |
225 | 226 |
line_no._fixed = False |
226 | 227 |
|
227 |
self.maxValue = len(self._lineNos) + 1 # line no's count + secondary line |
|
228 |
|
|
229 | 228 |
# find primary lines |
230 | 229 |
# sort line no with from,to value |
231 | 230 |
self._lineNos.sort( |
... | ... | |
235 | 234 |
if displayMessage: displayMessage.emit('{} {}'.format(lineno.text(), 'Topology Construction')) |
236 | 235 |
self.find_primary_lines(lineno, include_signal=False) |
237 | 236 |
if updateProgress: updateProgress.emit(self.maxValue) |
237 |
''' |
|
238 |
|
|
239 |
self.maxValue = len(self._lineNos) + 1 # line no's count + secondary line |
|
240 |
|
|
241 |
# find primary lines |
|
242 |
remainLineNo1 = [] |
|
243 |
remainLineNo2 = [] |
|
244 |
for line_no in self._lineNos: |
|
245 |
line_no.conns.clear() |
|
246 |
|
|
247 |
_from = line_no.prop('From') |
|
248 |
_to = line_no.prop('To') |
|
249 |
|
|
250 |
if _from and _to: |
|
251 |
_from.owner = line_no |
|
252 |
_to.owner = line_no |
|
253 |
line_no._fixed = True |
|
254 |
|
|
255 |
if displayMessage: displayMessage.emit('{} {}'.format(line_no.text(), 'Topology Construction')) |
|
256 |
self.find_primary_lines(line_no, include_signal=False) |
|
257 |
if updateProgress: updateProgress.emit(self.maxValue) |
|
258 |
else: |
|
259 |
remainLineNo1.append(line_no) |
|
260 |
|
|
261 |
for line_no in self.remainLineNo1: |
|
262 |
if _from: |
|
263 |
_from.owner = line_no |
|
264 |
line_no.set_property('To', None) |
|
265 |
line_no._fixed = True if len([conn for conn in _from.connectors if conn.connectedItem]) == 1 else False |
|
266 |
|
|
267 |
if displayMessage: displayMessage.emit('{} {}'.format(line_no.text(), 'Topology Construction')) |
|
268 |
self.find_primary_lines(line_no, include_signal=False) |
|
269 |
if updateProgress: updateProgress.emit(self.maxValue) |
|
270 |
else: |
|
271 |
remainLineNo2.append(line_no) |
|
272 |
|
|
273 |
for line_no in self.remainLineNo2: |
|
274 |
line_no.set_property('From', None) |
|
275 |
line_no.set_property('To', None) |
|
276 |
line_no._fixed = False |
|
277 |
|
|
278 |
remainVertical = [] |
|
279 |
remainVertical2 = [] |
|
280 |
remainHorizontal = [] |
|
281 |
for line_no in self.remainLineNo2: |
|
282 |
if line_no.angle == 0: |
|
283 |
remainHorizontal.append(line_no) |
|
284 |
else: |
|
285 |
remainVertical.append(line_no) |
|
286 |
|
|
287 |
while remainVertical: |
|
288 |
remainVerticalLine = [line for line in self._lines if line.owner is None and line.is_piping(strong=True) and line.isVertical()] |
|
289 |
if not remainVerticalLine: |
|
290 |
remainVertical2.extend(remainVertical) |
|
291 |
break |
|
292 |
|
|
293 |
minDist = None |
|
294 |
startLine = None |
|
295 |
vertical = None |
|
296 |
|
|
297 |
for line_no in remainVertical: |
|
298 |
point = (line_no.center().x(), line_no.center().y()) |
|
299 |
remainVerticalLine.sort(key=lambda x: x.distanceTo(point)) |
|
300 |
|
|
301 |
dist = remainVerticalLine[0].distanceTo(point) |
|
302 |
if (minDist is None) or (dist < minDist): |
|
303 |
minDist = dist |
|
304 |
startLine = remainVerticalLine[0] |
|
305 |
vertical = line_no |
|
306 |
|
|
307 |
if (startLine is not None) and (minDist < toler): |
|
308 |
vertical.conns.append(startLine) |
|
309 |
startLine.owner = vertical |
|
310 |
|
|
311 |
if displayMessage: displayMessage.emit('{} {}'.format(vertical.text(), 'Topology Construction')) |
|
312 |
self.find_primary_lines(vertical, include_signal=False) |
|
313 |
if updateProgress: updateProgress.emit(self.maxValue) |
|
314 |
else: |
|
315 |
remainVertical2.append(vertical) |
|
316 |
|
|
317 |
if vertical: |
|
318 |
remainVertical.remove(vertical) |
|
319 |
else: |
|
320 |
break |
|
321 |
|
|
322 |
while remainHorizontal: |
|
323 |
remainLine = [line for line in self._lines if line.owner is None and line.is_piping(strong=True)] |
|
324 |
if not remainLine: |
|
325 |
break |
|
326 |
|
|
327 |
minDist = None |
|
328 |
startLine = None |
|
329 |
horizontal = None |
|
330 |
|
|
331 |
for line_no in remainHorizontal: |
|
332 |
point = (line_no.center().x(), line_no.center().y()) |
|
333 |
remainLine.sort(key=lambda x: x.distanceTo(point)) |
|
334 |
|
|
335 |
dist = remainLine[0].distanceTo(point) |
|
336 |
if (minDist is None) or (dist < minDist): |
|
337 |
minDist = dist |
|
338 |
startLine = remainLine[0] |
|
339 |
horizontal = line_no |
|
340 |
|
|
341 |
if (startLine is not None) and (minDist < toler): |
|
342 |
horizontal.conns.append(startLine) |
|
343 |
startLine.owner = horizontal |
|
344 |
|
|
345 |
if displayMessage: displayMessage.emit('{} {}'.format(horizontal.text(), 'Topology Construction')) |
|
346 |
self.find_primary_lines(horizontal, include_signal=False) |
|
347 |
if updateProgress: updateProgress.emit(self.maxValue) |
|
348 |
|
|
349 |
if horizontal: |
|
350 |
remainHorizontal.remove(horizontal) |
|
351 |
else: |
|
352 |
break |
|
353 |
|
|
354 |
while remainVertical2: |
|
355 |
remainLine = [line for line in self._lines if line.owner is None and line.is_piping(strong=True)] |
|
356 |
if not remainLine: |
|
357 |
break |
|
358 |
|
|
359 |
minDist = None |
|
360 |
startLine = None |
|
361 |
remain = None |
|
362 |
|
|
363 |
for line_no in remainVertical2: |
|
364 |
point = (line_no.center().x(), line_no.center().y()) |
|
365 |
remainLine.sort(key=lambda x: x.distanceTo(point)) |
|
366 |
|
|
367 |
dist = remainLine[0].distanceTo(point) |
|
368 |
if (minDist is None) or (dist < minDist): |
|
369 |
minDist = dist |
|
370 |
startLine = remainLine[0] |
|
371 |
remain = line_no |
|
372 |
|
|
373 |
if (startLine is not None) and (minDist < toler): |
|
374 |
remain.conns.append(startLine) |
|
375 |
startLine.owner = remain |
|
376 |
|
|
377 |
if displayMessage: displayMessage.emit('{} {}'.format(remain.text(), 'Topology Construction')) |
|
378 |
self.find_primary_lines(remain, include_signal=False) |
|
379 |
if updateProgress: updateProgress.emit(self.maxValue) |
|
380 |
else: |
|
381 |
remainVertical2.append(remain) |
|
382 |
|
|
383 |
if remain: |
|
384 |
remainVertical.remove(remain) |
|
385 |
else: |
|
386 |
break |
|
387 |
# up to here |
|
238 | 388 |
|
239 | 389 |
# find secondary lines |
240 | 390 |
lines_and_symbols = self._lines + [sym for sym in self._symbols if not issubclass(type(sym), QEngineeringEquipmentItem)] |
내보내기 Unified diff