개정판 d05240df
issue #000: 1129 validate line to line and recognitnion line to line connection check on going
Change-Id: I5fd6d8d41a812cd106f09dedd78cff9e0e762514
DTI_PID/DTI_PID/LineDetector.py | ||
---|---|---|
347 | 347 |
|
348 | 348 |
res = line.connect_if_possible(symbol, toler) |
349 | 349 |
if res: |
350 |
line.set_line([res[1], endPt])
|
|
350 |
line.set_line([res[1], res[2]])
|
|
351 | 351 |
else: |
352 | 352 |
dx = distEnd[0][1][0] - endPt[0] |
353 | 353 |
dy = distEnd[0][1][1] - endPt[1] |
... | ... | |
359 | 359 |
|
360 | 360 |
res = line.connect_if_possible(symbol, toler) |
361 | 361 |
if res: |
362 |
line.set_line([startPt, res[1]])
|
|
362 |
line.set_line([res[1], res[2]])
|
|
363 | 363 |
''' |
364 | 364 |
@brief extend line to intersection point |
365 | 365 |
@author humkyung |
... | ... | |
367 | 367 |
''' |
368 | 368 |
def connectLineToLine(self, lhs, rhs, toler=20): |
369 | 369 |
try: |
370 |
res = lhs.connect_if_possible(rhs, toler) |
|
371 |
if not res: |
|
372 |
return |
|
373 |
|
|
370 | 374 |
lhs_start = list(lhs.startPoint()) |
371 | 375 |
lhs_end = list(lhs.endPoint()) |
372 | 376 |
rhs_start = list(rhs.startPoint()) |
... | ... | |
430 | 434 |
rhs_end[1] = pt.y |
431 | 435 |
|
432 | 436 |
rhs.set_line([rhs_start, rhs_end]) |
433 |
|
|
434 |
lhs.connect_if_possible(rhs, toler=1) |
|
435 | 437 |
except Exception as ex: |
436 | 438 |
from App import App |
437 | 439 |
from AppDocData import MessageType |
DTI_PID/DTI_PID/Shapes/EngineeringLineItem.py | ||
---|---|---|
668 | 668 |
if self.connectors[0].connectedItem is None and obj.connectors[i].connectedItem is None: |
669 | 669 |
self.connectors[0].connect(obj) |
670 | 670 |
obj.connectors[i].connect(self) |
671 |
# line, start, end |
|
671 | 672 |
res.append(obj) |
672 | 673 |
res.append(obj.connectors[i].sceneConnectPoint) |
674 |
res.append(endPt) |
|
673 | 675 |
elif (Point(endPt[0], endPt[1]).distance(Point(pt[0], pt[1])) < toler): |
674 | 676 |
if self.connectors[1].connectedItem is None and obj.connectors[i].connectedItem is None: |
675 | 677 |
self.connectors[1].connect(obj) |
676 | 678 |
obj.connectors[i].connect(self) |
679 |
# line, start, end |
|
677 | 680 |
res.append(obj) |
681 |
res.append(startPt) |
|
678 | 682 |
res.append(obj.connectors[i].sceneConnectPoint) |
679 | 683 |
elif type(obj) is QEngineeringLineItem: |
680 | 684 |
_startPt = obj.startPoint() |
681 | 685 |
_endPt = obj.endPoint() |
682 |
if self.distanceTo(_startPt) < toler: |
|
683 |
if ((Point(startPt[0], startPt[1]).distance(Point(_startPt[0], _startPt[1])) < toler)): |
|
686 |
if obj.connectors[0].connectedItem is None and self.distanceTo(_startPt) < toler:
|
|
687 |
if self.connectors[0].connectedItem is None and ((Point(startPt[0], startPt[1]).distance(Point(_startPt[0], _startPt[1])) < toler)):
|
|
684 | 688 |
self.connectors[0].connect(obj) |
685 | 689 |
obj.connectors[0].connect(self) |
686 | 690 |
res.append(obj) |
687 |
elif ((Point(endPt[0], endPt[1]).distance(Point(_startPt[0], _startPt[1])) < toler)): |
|
691 |
elif self.connectors[1].connectedItem is None and ((Point(endPt[0], endPt[1]).distance(Point(_startPt[0], _startPt[1])) < toler)):
|
|
688 | 692 |
self.connectors[1].connect(obj) |
689 | 693 |
obj.connectors[0].connect(self) |
690 | 694 |
res.append(obj) |
691 |
else:
|
|
695 |
elif obj.connectors[0].connectedItem is None:
|
|
692 | 696 |
obj.connectors[0].connect(self, at=QEngineeringAbstractItem.CONNECTED_AT_BODY) |
697 |
res.append(obj) |
|
693 | 698 |
|
694 |
elif self.distanceTo(_endPt) < toler: |
|
695 |
if ((Point(startPt[0], startPt[1]).distance(Point(_endPt[0], _endPt[1])) < toler)): |
|
699 |
elif obj.connectors[1].connectedItem is None and self.distanceTo(_endPt) < toler:
|
|
700 |
if self.connectors[0].connectedItem is None and ((Point(startPt[0], startPt[1]).distance(Point(_endPt[0], _endPt[1])) < toler)):
|
|
696 | 701 |
self.connectors[0].connect(obj) |
697 | 702 |
obj.connectors[1].connect(self) |
698 | 703 |
res.append(obj) |
699 |
elif ((Point(endPt[0], endPt[1]).distance(Point(_endPt[0], _endPt[1])) < toler)): |
|
704 |
elif self.connectors[1].connectedItem is None and ((Point(endPt[0], endPt[1]).distance(Point(_endPt[0], _endPt[1])) < toler)):
|
|
700 | 705 |
self.connectors[1].connect(obj) |
701 | 706 |
obj.connectors[1].connect(self) |
702 | 707 |
res.append(obj) |
703 |
else:
|
|
708 |
elif obj.connectors[1].connectedItem is None:
|
|
704 | 709 |
obj.connectors[1].connect(self, at=QEngineeringAbstractItem.CONNECTED_AT_BODY) |
710 |
res.append(obj) |
|
705 | 711 |
except Exception as ex: |
706 | 712 |
from App import App |
707 | 713 |
from AppDocData import MessageType |
DTI_PID/DTI_PID/Shapes/SymbolSvgItem.py | ||
---|---|---|
350 | 350 |
if connector.connectedItem and issubclass(type(connector.connectedItem), QEngineeringAbstractItem): |
351 | 351 |
connectedUid.append(str(connector.connectedItem.uid)) |
352 | 352 |
|
353 |
if issubclass(type(connector.connectedItem), SymbolSvgItem) and type( |
|
354 |
connector.connectedItem) is not QEngineeringEquipmentItem: |
|
353 |
if (issubclass(type(connector.connectedItem), SymbolSvgItem) and \ |
|
354 |
type(connector.connectedItem) is not QEngineeringEquipmentItem) or \ |
|
355 |
type(connector.connectedItem) is QEngineeringLineItem: |
|
355 | 356 |
matches = [conn for conn in connector.connectedItem.connectors if conn.connectedItem is self] |
356 | 357 |
# check if two items are connected each other |
357 | 358 |
if not matches: |
... | ... | |
748 | 749 |
if self.connectors[i].connectedItem is None and obj.connectors[0].connectedItem is None: |
749 | 750 |
self.connectors[i].connect(obj) |
750 | 751 |
obj.connectors[0].connect(self) |
752 |
# line, start, end |
|
751 | 753 |
res.append(obj) |
752 | 754 |
res.append(self.connectors[i].sceneConnectPoint) |
755 |
res.append(endPt) |
|
753 | 756 |
if (Point(endPt[0], endPt[1]).distance(Point(self.connectors[i].sceneConnectPoint[0], |
754 | 757 |
self.connectors[i].sceneConnectPoint[1])) < toler): |
755 | 758 |
if self.connectors[i].connectedItem is None and obj.connectors[1].connectedItem is None: |
756 | 759 |
self.connectors[i].connect(obj) |
757 | 760 |
obj.connectors[1].connect(self) |
761 |
# line, start, end |
|
758 | 762 |
res.append(obj) |
763 |
res.append(startPt) |
|
759 | 764 |
res.append(self.connectors[i].sceneConnectPoint) |
760 | 765 |
elif issubclass(type(obj), SymbolSvgItem): |
761 | 766 |
for i in range(len(self.connectors)): |
... | ... | |
987 | 992 |
return |
988 | 993 |
if event.key() == Qt.Key_Delete: |
989 | 994 |
self.deleteSvgItemFromScene() |
995 |
elif event.key() == Qt.Key_B: |
|
996 |
self.bind_close_items() |
|
990 | 997 |
elif event.key() == Qt.Key_R and type(self) is not QEngineeringErrorItem: |
991 | 998 |
self.rotateSymbol() |
992 | 999 |
elif event.key() == Qt.Key_O and type(self) is not QEngineeringErrorItem: |
993 |
self.changeStandardPoint() |
|
1000 |
pass |
|
1001 |
#self.changeStandardPoint() |
|
994 | 1002 |
elif event.key() == Qt.Key_C and type(self) is not QEngineeringErrorItem: |
995 | 1003 |
self.changeConnPoint() |
996 | 1004 |
elif event.key() == Qt.Key_F and type(self) is not QEngineeringErrorItem: |
... | ... | |
1036 | 1044 |
self.origin[0] = self.origin[0] + 1 |
1037 | 1045 |
self.rotate(self.getCurrentPoint(), self.angle) |
1038 | 1046 |
|
1047 |
def bind_close_items(self): |
|
1048 |
from EngineeringLineItem import QEngineeringLineItem |
|
1049 |
|
|
1050 |
scene = self.scene() |
|
1051 |
if scene: |
|
1052 |
configs = AppDocData.instance().getConfigs('Line Detector', 'Length to connect line') |
|
1053 |
toler = int(configs[0].value) if configs else 20 |
|
1054 |
for item in [item for item in scene.items() if hasattr(item, 'connectors')]: |
|
1055 |
if item is not self: |
|
1056 |
res = self.connect_if_possible(item, toler) |
|
1057 |
if res and type(item) is QEngineeringLineItem: |
|
1058 |
item.set_line([res[1], res[2]]) |
|
1059 |
|
|
1039 | 1060 |
''' |
1040 | 1061 |
@brief connect attribute |
1041 | 1062 |
@author humkyung |
1042 | 1063 |
@date 2018.05.02 |
1043 | 1064 |
@history humkyung 2018.05.09 append only nearest size attribute |
1044 | 1065 |
''' |
1045 |
|
|
1046 | 1066 |
def connectAttribute(self, attributes, clear=True): |
1047 | 1067 |
import math |
1048 | 1068 |
from EngineeringTextItem import QEngineeringTextItem |
내보내기 Unified diff