개정판 5d145f1a
issue #663: line type test
Change-Id: If8a8f878fe4f55faf274cf608d0b209b26854d39
DTI_PID/DTI_PID/RecognitionDialog.py | ||
---|---|---|
1427 | 1427 |
@staticmethod |
1428 | 1428 |
def changeVisualLineType(all_lines, worker): |
1429 | 1429 |
from LineDetector import LineDetector |
1430 |
from EngineeringAbstractItem import QEngineeringAbstractItem |
|
1430 | 1431 |
|
1431 | 1432 |
try: |
1432 | 1433 |
app_doc_data = AppDocData.instance() |
... | ... | |
1649 | 1650 |
''' |
1650 | 1651 |
|
1651 | 1652 |
line_runs = [] |
1652 |
items = [item for item in app_doc_data.lines] |
|
1653 |
while items: |
|
1654 |
connected_items_list = [items[0]] |
|
1655 |
connected_items_count = 0 |
|
1656 |
while True: |
|
1657 |
if connected_items_count == len(connected_items_list): |
|
1653 |
for line_found in lines_found: |
|
1654 |
inserted = False |
|
1655 |
for line_run in line_runs: |
|
1656 |
if line_found[0] in line_run: |
|
1657 |
inserted = True |
|
1658 | 1658 |
break |
1659 |
else: |
|
1660 |
connected_items_count = len(connected_items_list) |
|
1661 |
|
|
1662 |
for item in items: |
|
1663 |
if item in connected_items_list: |
|
1664 |
matches = [conn.connectedItem for conn in item.connectors if conn.connectedItem and type(conn.connectedItem) is QEngineeringLineItem \ |
|
1665 |
and conn.connectedItem not in connected_items_list] |
|
1666 |
if matches: |
|
1667 |
connected_items_list.extend(matches) |
|
1668 |
break |
|
1669 |
else: |
|
1670 |
matches = [conn for conn in item.connectors if conn.connectedItem and conn.connectedItem in connected_items_list] |
|
1671 |
if matches and type(item) is QEngineeringLineItem: |
|
1672 |
connected_items_list.append(item) |
|
1673 |
break |
|
1674 | 1659 |
|
1675 |
for item in connected_items_list: |
|
1676 |
items.remove(item) |
|
1677 |
|
|
1678 |
line_runs.append(connected_items_list) |
|
1660 |
if inserted: |
|
1661 |
continue |
|
1662 |
else: |
|
1663 |
run = [line_found[0]] |
|
1664 |
Worker.find_connected_line(run, line_found[0]) |
|
1665 |
line_runs.append(run) |
|
1679 | 1666 |
|
1680 | 1667 |
for line_run in line_runs: |
1681 | 1668 |
_lines_found = [] |
1682 |
_line_found = None |
|
1683 | 1669 |
for _line in line_run: |
1684 | 1670 |
_lines = [line_found[0] for line_found in lines_found] |
1685 | 1671 |
if _line in _lines: |
1686 | 1672 |
index = _lines.index(_line) |
1687 | 1673 |
_lines_found.append(lines_found[index]) |
1688 |
if _lines_found: |
|
1689 |
_line_found = sorted(_lines_found, key=lambda param:param[1][1])[0] |
|
1674 |
_line_found = sorted(_lines_found, key=lambda param:param[1][1])[0] |
|
1675 |
Worker.changeConnectedLineType(_line_found[0], _line_found[1][0], visual_marker=True) |
|
1676 |
|
|
1677 |
# change line type: connected at body |
|
1678 |
remains = [line for line in app_doc_data.lines if not hasattr(line, 'visual_marker')] |
|
1679 |
while True: |
|
1680 |
remains_count = len(remains) |
|
1681 |
|
|
1682 |
for _line in remains: |
|
1683 |
matches = [conn for conn in _line.connectors if conn.connectedItem and \ |
|
1684 |
conn._connected_at == QEngineeringAbstractItem.CONNECTED_AT_BODY and hasattr(conn.connectedItem, 'visual_marker')] |
|
1685 |
if matches: |
|
1686 |
Worker.changeConnectedLineType(_line, matches[0].connectedItem.lineType, visual_marker=True) |
|
1687 |
break |
|
1688 |
|
|
1689 |
remains = [line for line in app_doc_data.lines if not hasattr(line, 'visual_marker')] |
|
1690 |
if remains_count == len(remains): |
|
1691 |
break |
|
1690 | 1692 |
|
1691 |
if _line_found: |
|
1692 |
for _line in line_run: |
|
1693 |
_line.lineType = _line_found[1][0] |
|
1694 | 1693 |
except Exception as ex: |
1695 | 1694 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
1696 | 1695 |
sys.exc_info()[-1].tb_lineno) |
... | ... | |
1714 | 1713 |
Worker.find_connected_line(lines, current_line) |
1715 | 1714 |
|
1716 | 1715 |
@staticmethod |
1717 |
def changeConnectedLineType(line, lineType): |
|
1716 |
def changeConnectedLineType(line, lineType, visual_marker=False): |
|
1717 |
# for visual line type detection |
|
1718 |
if visual_marker: |
|
1719 |
line.visual_marker = visual_marker |
|
1720 |
|
|
1718 | 1721 |
line.lineType = lineType |
1719 | 1722 |
if type(line.connectors[0].connectedItem) is QEngineeringLineItem and \ |
1720 | 1723 |
(line.connectors[0].connectedItem.connectors[0].connectedItem is line or |
1721 | 1724 |
line.connectors[0].connectedItem.connectors[1].connectedItem is line) and \ |
1722 | 1725 |
line.connectors[0].connectedItem.lineType is not lineType: |
1723 |
Worker.changeConnectedLineType(line.connectors[0].connectedItem, lineType) |
|
1726 |
Worker.changeConnectedLineType(line.connectors[0].connectedItem, lineType, visual_marker=visual_marker)
|
|
1724 | 1727 |
|
1725 | 1728 |
if type(line.connectors[1].connectedItem) is QEngineeringLineItem and \ |
1726 | 1729 |
(line.connectors[1].connectedItem.connectors[0].connectedItem is line or |
1727 | 1730 |
line.connectors[1].connectedItem.connectors[1].connectedItem is line) and \ |
1728 | 1731 |
line.connectors[1].connectedItem.lineType is not lineType: |
1729 |
Worker.changeConnectedLineType(line.connectors[1].connectedItem, lineType) |
|
1732 |
Worker.changeConnectedLineType(line.connectors[1].connectedItem, lineType, visual_marker=visual_marker)
|
|
1730 | 1733 |
|
1731 | 1734 |
''' |
1732 | 1735 |
@history 2018.05.25 Jeongwoo Moved from MainWindow |
내보내기 Unified diff