개정판 e35755a0
issue #480: short line detection, fix symbol connection direction for line
Change-Id: I47b145a617ca5eb3f363885f152848655f3e769e
DTI_PID/DTI_PID/RecognitionDialog.py | ||
---|---|---|
1244 | 1244 |
|
1245 | 1245 |
# detect flange |
1246 | 1246 |
flange_list = [] |
1247 |
|
|
1247 | 1248 |
print('flag3.9') |
1248 | 1249 |
configs = app_doc_data.getConfigs('Project', 'Operation') |
1249 | 1250 |
instrument = int(configs[0].value) if configs else 1 |
... | ... | |
1469 | 1470 |
else: |
1470 | 1471 |
horizontals.append(line) |
1471 | 1472 |
|
1473 |
# symbol to line |
|
1472 | 1474 |
for connector in connectors: |
1473 | 1475 |
direction = connector.dir() |
1474 | 1476 |
symbol = connector.parentItem() |
... | ... | |
1525 | 1527 |
new_line.connectors[1].connect(symbol) |
1526 | 1528 |
new_lines.append(new_line) |
1527 | 1529 |
|
1530 |
# symbol to symbol |
|
1531 |
connectors = [conn for conn in connectors if conn.connectedItem is None] |
|
1532 |
for connector1 in connectors: |
|
1533 |
if connector1.connectedItem: |
|
1534 |
continue |
|
1535 |
|
|
1536 |
selected = None |
|
1537 |
min_dist = sys.maxsize |
|
1538 |
|
|
1539 |
for connector2 in connectors: |
|
1540 |
if connector2.connectedItem or connector1 is connector2: |
|
1541 |
continue |
|
1542 |
|
|
1543 |
dx = connector1.center()[0] - connector2.center()[0] |
|
1544 |
dy = connector1.center()[1] - connector2.center()[1] |
|
1545 |
dist = math.sqrt(dx * dx + dy * dy) |
|
1546 |
if dist < lineMaxLength and dist < min_dist and min(abs(dx), abs(dy)) < thickness: |
|
1547 |
selected = connector2 |
|
1548 |
min_dist = dist |
|
1549 |
|
|
1550 |
if selected: |
|
1551 |
new_line = QEngineeringLineItem(vertices=[connector1.center(), selected.center()], thickness=thickness) |
|
1552 |
new_line.area = 'Drawing' |
|
1553 |
|
|
1554 |
connector1.connect(new_line) |
|
1555 |
selected.connect(new_line) |
|
1556 |
new_line.connectors[0].connect(connector1.parentItem()) |
|
1557 |
new_line.connectors[1].connect(selected.parentItem()) |
|
1558 |
new_lines.append(new_line) |
|
1559 |
|
|
1528 | 1560 |
app_doc_data.lines.extend(new_lines) |
1529 | 1561 |
app_doc_data.allItems.extend(new_lines) |
1530 | 1562 |
|
... | ... | |
2685 | 2717 |
cpx = originalSymbolWidth - float(tokens[0]) |
2686 | 2718 |
cpy = float(tokens[1]) |
2687 | 2719 |
elif len(tokens) == 3: |
2688 |
direction = converted[tokens[0]] |
|
2720 |
#direction = converted[tokens[0]] |
|
2721 |
direction = tokens[0] |
|
2689 | 2722 |
cpx = originalSymbolWidth - float(tokens[1]) |
2690 | 2723 |
cpy = float(tokens[2]) |
2691 | 2724 |
elif len(tokens) >= 4: |
2692 |
direction = converted[tokens[0]] |
|
2725 |
#direction = converted[tokens[0]] |
|
2726 |
direction = tokens[0] |
|
2693 | 2727 |
cpx = originalSymbolWidth - float(tokens[1]) |
2694 | 2728 |
cpy = float(tokens[2]) |
2695 | 2729 |
symbol_idx = tokens[3] |
... | ... | |
2730 | 2764 |
|
2731 | 2765 |
# calculate rotated direction |
2732 | 2766 |
direction = connPt[0] |
2767 |
''' |
|
2733 | 2768 |
if direction == 'LEFT': |
2734 | 2769 |
direction = 'DOWN' if angle == 90 else 'RIGHT' if angle == 180 else 'UP' if angle == 270 else direction |
2735 | 2770 |
elif direction == 'RIGHT': |
... | ... | |
2738 | 2773 |
direction = 'LEFT' if angle == 90 else 'DOWN' if angle == 180 else 'RIGHT' if angle == 270 else direction |
2739 | 2774 |
elif direction == 'DOWN': |
2740 | 2775 |
direction = 'RIGHT' if angle == 90 else 'UP' if angle == 180 else 'LEFT' if angle == 270 else direction |
2776 |
''' |
|
2741 | 2777 |
# up to here |
2742 | 2778 |
|
2743 | 2779 |
''' |
내보내기 Unified diff