개정판 bab64619
issue #000: improve connection func
Change-Id: I51b5301ee4e006ec477dc49f5d717d200158275a
DTI_PID/DTI_PID/AppDocData.py | ||
---|---|---|
86 | 86 |
self._activeDrawing = None |
87 | 87 |
self._hmbTable = None |
88 | 88 |
self._hmbColors = {} |
89 |
self._streamLineListModelDatas = None
|
|
89 |
self._streamLineListModelDatas = []
|
|
90 | 90 |
self._titleBlockProperties = None |
91 | 91 |
self.needReOpening = None |
92 | 92 |
|
... | ... | |
171 | 171 |
self._activeDrawing = None |
172 | 172 |
self._hmbTable = None |
173 | 173 |
self._hmbColors = {} |
174 |
self._streamLineListModelDatas = None
|
|
174 |
self._streamLineListModelDatas = []
|
|
175 | 175 |
self._titleBlockProperties = None |
176 | 176 |
|
177 | 177 |
self._configs = None |
DTI_PID/DTI_PID/MainWindow.py | ||
---|---|---|
648 | 648 |
def on_connect_line_to_symbol(self): |
649 | 649 |
"""connect line to symbol""" |
650 | 650 |
from LineDetector import LineDetector |
651 |
from RecognitionDialog import Worker |
|
651 | 652 |
|
652 | 653 |
if not self.graphicsView.hasImage(): |
653 | 654 |
self.showImageSelectionMessageBox() |
... | ... | |
659 | 660 |
toler = int(configs[0].value) if configs else 20 |
660 | 661 |
detector = LineDetector(app_doc_data.imgSrc) |
661 | 662 |
|
662 |
lines = [item for item in self.graphicsView.scene().items() if type(item) is QEngineeringLineItem] |
|
663 |
lines = [item for item in self.graphicsView.scene().items() if type(item) is QEngineeringLineItem if item.length() > 50] |
|
664 |
lines_short = [item for item in self.graphicsView.scene().items() if type(item) is QEngineeringLineItem if item.length() <= 50] |
|
665 |
unknowns = [item for item in self.graphicsView.scene().items() if type(item) is QEngineeringUnknownItem] |
|
663 | 666 |
symbols = [item for item in self.graphicsView.scene().items() if issubclass(type(item), SymbolSvgItem)] |
667 |
|
|
668 |
for item in lines_short + unknowns: |
|
669 |
item.transfer.onRemoved.emit(item) |
|
670 |
|
|
664 | 671 |
if lines: |
672 |
try: |
|
673 |
conns = [] |
|
674 |
for sym in symbols: |
|
675 |
if sym.conn_type: |
|
676 |
for index in range(len(sym.conn_type)): |
|
677 |
if sym.conn_type[index] == 'Secondary' or sym.conn_type[index] == 'Primary': |
|
678 |
item = sym.connectors[index].connectedItem |
|
679 |
if item is None: |
|
680 |
conns.append(sym.connectors[index]) |
|
681 |
|
|
682 |
Worker.make_short_lines_sts(conns, None) |
|
683 |
|
|
684 |
conns = [] |
|
685 |
for sym in symbols: |
|
686 |
if sym.conn_type: |
|
687 |
for index in range(len(sym.conn_type)): |
|
688 |
if sym.conn_type[index] == 'Secondary' or sym.conn_type[index] == 'Primary': |
|
689 |
item = sym.connectors[index].connectedItem |
|
690 |
if item is None and sym.connectors[index]: |
|
691 |
conns.append(sym.connectors[index]) |
|
692 |
|
|
693 |
Worker.make_short_lines_stl(lines, conns, None) |
|
694 |
except Exception as ex: |
|
695 |
message = f"error occurred({repr(ex)}) in {sys.exc_info()[-1].tb_frame.f_code.co_filename}:" \ |
|
696 |
f"{sys.exc_info()[-1].tb_lineno}" |
|
697 |
self.addMessage.emit(MessageType.Error, message) |
|
698 |
|
|
665 | 699 |
# connect line to symbol |
666 | 700 |
try: |
667 | 701 |
for line in lines: |
DTI_PID/DTI_PID/RecognitionDialog.py | ||
---|---|---|
1499 | 1499 |
pass |
1500 | 1500 |
|
1501 | 1501 |
@staticmethod |
1502 |
def make_short_lines_sts(connectors, worker): |
|
1502 |
def make_short_lines_sts(connectors, worker=None):
|
|
1503 | 1503 |
""" make short lines logically, symbol to symbol """ |
1504 | 1504 |
|
1505 | 1505 |
import math |
... | ... | |
1549 | 1549 |
app_doc_data.allItems.extend(new_lines) |
1550 | 1550 |
|
1551 | 1551 |
except Exception as ex: |
1552 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
1553 |
sys.exc_info()[-1].tb_lineno) |
|
1554 |
worker.displayLog.emit(MessageType.Error, message) |
|
1552 |
if worker: |
|
1553 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
1554 |
sys.exc_info()[-1].tb_lineno) |
|
1555 |
worker.displayLog.emit(MessageType.Error, message) |
|
1556 |
else: |
|
1557 |
from App import App |
|
1558 |
from AppDocData import MessageType |
|
1559 |
|
|
1560 |
message = f"error occurred({repr(ex)}) in {sys.exc_info()[-1].tb_frame.f_code.co_filename}:" \ |
|
1561 |
f"{sys.exc_info()[-1].tb_lineno}" |
|
1562 |
QMessageBox.warning(self, self._tr('Warning'), message) |
|
1555 | 1563 |
|
1556 | 1564 |
@staticmethod |
1557 |
def make_short_lines_stl(lines, connectors, worker): |
|
1565 |
def make_short_lines_stl(lines, connectors, worker=None):
|
|
1558 | 1566 |
""" make short lines logically, symbol to line """ |
1559 | 1567 |
|
1560 | 1568 |
import math |
... | ... | |
1638 | 1646 |
app_doc_data.allItems.extend(new_lines) |
1639 | 1647 |
|
1640 | 1648 |
except Exception as ex: |
1641 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
1642 |
sys.exc_info()[-1].tb_lineno) |
|
1643 |
worker.displayLog.emit(MessageType.Error, message) |
|
1649 |
if worker: |
|
1650 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
1651 |
sys.exc_info()[-1].tb_lineno) |
|
1652 |
worker.displayLog.emit(MessageType.Error, message) |
|
1653 |
else: |
|
1654 |
from App import App |
|
1655 |
from AppDocData import MessageType |
|
1656 |
|
|
1657 |
message = f"error occurred({repr(ex)}) in {sys.exc_info()[-1].tb_frame.f_code.co_filename}:" \ |
|
1658 |
f"{sys.exc_info()[-1].tb_lineno}" |
|
1659 |
QMessageBox.warning(self, self._tr('Warning'), message) |
|
1644 | 1660 |
|
1645 | 1661 |
@staticmethod |
1646 | 1662 |
def changeVisualLineType(all_lines, worker): |
내보내기 Unified diff