개정판 92d67345
fix line grid
Change-Id: I085c0e1deb6ba068ce7f5e6658aa7cc52e78fadf
DTI_PID/DTI_PID/Shapes/EngineeringConnectorItem.py | ||
---|---|---|
94 | 94 |
def center(self): |
95 | 95 |
"""return the position of connector in scene""" |
96 | 96 |
|
97 |
from AppDocData import AppDocData |
|
98 |
|
|
99 |
configs = AppDocData.instance().getConfigs('Data', 'Grid') |
|
100 |
grid = int(configs[0].value) if 1 == len(configs) else -1 |
|
101 |
|
|
97 | 102 |
if self.scene(): |
98 |
return self.sceneBoundingRect().center().x(), self.sceneBoundingRect().center().y() |
|
103 |
if grid == 1: |
|
104 |
return round(self.sceneBoundingRect().center().x()), round(self.sceneBoundingRect().center().y()) |
|
105 |
else: |
|
106 |
return self.sceneBoundingRect().center().x(), self.sceneBoundingRect().center().y() |
|
99 | 107 |
else: |
100 | 108 |
return self.recognized_pt |
101 | 109 |
|
DTI_PID/DTI_PID/Shapes/EngineeringLineItem.py | ||
---|---|---|
297 | 297 |
@date 2018.04.16 |
298 | 298 |
''' |
299 | 299 |
def start_point(self): |
300 |
from AppDocData import AppDocData |
|
301 |
|
|
302 |
configs = AppDocData.instance().getConfigs('Data', 'Grid') |
|
303 |
grid = int(configs[0].value) if 1 == len(configs) else -1 |
|
304 |
|
|
300 | 305 |
at = self.line().p1() |
301 |
return (at.x(), at.y()) |
|
306 |
|
|
307 |
if grid == 1: |
|
308 |
return (round(at.x()), round(at.y())) |
|
309 |
else: |
|
310 |
return (at.x(), at.y()) |
|
302 | 311 |
|
303 | 312 |
''' |
304 | 313 |
@brief return last point |
... | ... | |
306 | 315 |
@date 2018.04.16 |
307 | 316 |
''' |
308 | 317 |
def end_point(self): |
318 |
from AppDocData import AppDocData |
|
319 |
|
|
320 |
configs = AppDocData.instance().getConfigs('Data', 'Grid') |
|
321 |
grid = int(configs[0].value) if 1 == len(configs) else -1 |
|
322 |
|
|
309 | 323 |
at = self.line().p2() |
310 |
return (at.x(), at.y()) |
|
324 |
|
|
325 |
if grid == 1: |
|
326 |
return (round(at.x()), round(at.y())) |
|
327 |
else: |
|
328 |
return (at.x(), at.y()) |
|
311 | 329 |
|
312 | 330 |
''' |
313 | 331 |
@brief dot product of given two vectors |
... | ... | |
723 | 741 |
|
724 | 742 |
try: |
725 | 743 |
if issubclass(type(obj), SymbolSvgItem): |
744 |
configs = AppDocData.instance().getConfigs('Data', 'Grid') |
|
745 |
grid = int(configs[0].value) if 1 == len(configs) else -1 |
|
746 |
|
|
726 | 747 |
for i in range(len(obj.connectors)): |
727 | 748 |
if not self.is_connectable(obj.connectors[i]): |
728 | 749 |
continue |
... | ... | |
749 | 770 |
obj.connectors[i].connect(self) |
750 | 771 |
# line, start, end |
751 | 772 |
res.append(obj) |
752 |
res.append(obj.connectors[i].center()) |
|
753 |
res.append(end_pt) |
|
773 |
if grid == 1: |
|
774 |
res.append((round(obj.connectors[i].center()[0]), round(obj.connectors[i].center()[1]))) |
|
775 |
res.append((round(end_pt[0]), round(end_pt[1]))) |
|
776 |
else: |
|
777 |
res.append(obj.connectors[i].center()) |
|
778 |
res.append(end_pt) |
|
754 | 779 |
elif Point(end_pt[0], end_pt[1]).distance(Point(pt[0], pt[1])) < toler: |
755 | 780 |
if self.connectors[1].connectedItem is None and obj.connectors[i].connectedItem is None: |
756 | 781 |
self.connectors[1].connect(obj) |
757 | 782 |
obj.connectors[i].connect(self) |
758 | 783 |
# line, start, end |
759 | 784 |
res.append(obj) |
760 |
res.append(start_pt) |
|
761 |
res.append(obj.connectors[i].center()) |
|
785 |
if grid == 1: |
|
786 |
res.append((round(start_pt[0]), round(start_pt[1]))) |
|
787 |
res.append((round(obj.connectors[i].center()[0]), round(obj.connectors[i].center()[1]))) |
|
788 |
else: |
|
789 |
res.append(start_pt) |
|
790 |
res.append(obj.connectors[i].center()) |
|
762 | 791 |
elif type(obj) is QEngineeringLineItem: |
763 | 792 |
_startPt = obj.start_point() |
764 | 793 |
_endPt = obj.end_point() |
DTI_PID/DTI_PID/Shapes/SymbolSvgItem.py | ||
---|---|---|
870 | 870 |
res = [] |
871 | 871 |
try: |
872 | 872 |
if type(obj) is QEngineeringLineItem: |
873 |
configs = AppDocData.instance().getConfigs('Data', 'Grid') |
|
874 |
grid = int(configs[0].value) if 1 == len(configs) else -1 |
|
875 |
|
|
873 | 876 |
startPt = obj.start_point() |
874 | 877 |
endPt = obj.end_point() |
875 | 878 |
conns = [] |
... | ... | |
901 | 904 |
conns[0][2].connect(self) |
902 | 905 |
# line, start, end |
903 | 906 |
res.append(obj) |
904 |
res.append(conns[0][3]) |
|
905 |
res.append(conns[0][4]) |
|
907 |
if grid == 1: |
|
908 |
res.append((round(conns[0][3][0]), round(conns[0][3][1]))) |
|
909 |
res.append((round(conns[0][4][0]), round(conns[0][4][1]))) |
|
910 |
else: |
|
911 |
res.append(conns[0][3]) |
|
912 |
res.append(conns[0][4]) |
|
906 | 913 |
|
907 | 914 |
elif issubclass(type(obj), SymbolSvgItem): |
908 | 915 |
selected = None |
내보내기 Unified diff