개정판 41703338
issue #000: fix symbol b command
Change-Id: Idad1ebf45f0504ea0b6c6bdea7c6e8848c566166
DTI_PID/DTI_PID/Shapes/SymbolSvgItem.py | ||
---|---|---|
737 | 737 |
res.append(startPt) |
738 | 738 |
res.append(self.connectors[i].center()) |
739 | 739 |
elif issubclass(type(obj), SymbolSvgItem): |
740 |
selected = None |
|
740 | 741 |
for i in range(len(self.connectors)): |
741 | 742 |
if i > 3: break |
743 |
_pt1 = Point(self.connectors[i].center()[0], self.connectors[i].center()[1]) |
|
742 | 744 |
for j in range(len(obj.connectors)): |
743 | 745 |
if j > 3: break |
744 |
_pt = Point(obj.connectors[j].center()[0], obj.connectors[j].center()[1]) |
|
745 |
if (_pt.distance(Point(self.connectors[i].center()[0],
|
|
746 |
self.connectors[i].center()[1])) < toler):
|
|
747 |
if self.connectors[i].connectedItem is None:
|
|
748 |
self.connectors[i].connect(obj) |
|
749 |
if obj.connectors[j].connectedItem is None:
|
|
750 |
obj.connectors[j].connect(self)
|
|
751 | ||
752 |
res.append(obj)
|
|
746 |
_pt2 = Point(obj.connectors[j].center()[0], obj.connectors[j].center()[1])
|
|
747 |
length = _pt1.distance(_pt2)
|
|
748 |
if (length < toler) and (selected is None or length < selected[0]):
|
|
749 |
selected = [length, self.connectors[i], obj.connectors[j]]
|
|
750 | ||
751 |
if selected and selected[1].connectedItem is None and selected[2].connectedItem is None:
|
|
752 |
selected[1].connect(selected[2].parent)
|
|
753 |
selected[2].connect(selected[1].parent) |
|
754 |
res.append(obj) |
|
753 | 755 |
except Exception as ex: |
754 | 756 |
from App import App |
755 | 757 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
... | ... | |
1031 | 1033 |
def bind_close_items(self): |
1032 | 1034 |
""" connect close item by pressing B """ |
1033 | 1035 |
from EngineeringLineItem import QEngineeringLineItem |
1036 |
from shapely.geometry import Point |
|
1034 | 1037 | |
1035 | 1038 |
scene = self.scene() |
1036 | 1039 |
if scene: |
1037 | 1040 |
configs = AppDocData.instance().getConfigs('Line Detector', 'Length to connect line') |
1038 | 1041 |
toler = int(configs[0].value) if configs else 20 |
1039 |
for item in [item for item in scene.items() if hasattr(item, 'connectors')]: |
|
1040 |
if item is not self: |
|
1041 |
res = self.connect_if_possible(item, toler) |
|
1042 | ||
1043 |
items = [item for item in scene.items() if hasattr(item, 'connectors') and item is not self] |
|
1044 | ||
1045 |
for s_connector in self.connectors: |
|
1046 |
if s_connector.connectedItem: |
|
1047 |
continue |
|
1048 | ||
1049 |
_pt1 = Point(s_connector.center()[0], s_connector.center()[1]) |
|
1050 |
dist = sys.maxsize |
|
1051 |
selected = None |
|
1052 | ||
1053 |
for item in items: |
|
1054 |
for i_connector in item.connectors: |
|
1055 |
if i_connector.connectedItem: |
|
1056 |
continue |
|
1057 | ||
1058 |
_pt2 = Point(i_connector.center()[0], i_connector.center()[1]) |
|
1059 |
length = _pt1.distance(_pt2) |
|
1060 |
if length < toler and length < dist: |
|
1061 |
selected = item |
|
1062 | ||
1063 |
if selected is not self: |
|
1064 |
res = self.connect_if_possible(selected, toler) |
|
1042 | 1065 |
if res and type(item) is QEngineeringLineItem: |
1043 | 1066 |
item.set_line([res[1], res[2]]) |
1044 | 1067 |
내보내기 Unified diff