개정판 7f7cdbd5
fixed issue #486: fixed connected item when line is created
Change-Id: I682826c8c1011a5180dc3a39544ff5fe6df70e89
DTI_PID/DTI_PID/Commands/PlaceLineCommand.py | ||
---|---|---|
1 |
# coding: utf-8 |
|
2 |
""" |
|
3 |
This is place line module |
|
4 |
""" |
|
5 | ||
1 | 6 |
import os.path |
2 | 7 |
import AbstractCommand |
3 | 8 |
try: |
... | ... | |
12 | 17 |
raise ImportError("ImageViewerQt: Requires PyQt5 or PyQt4.") |
13 | 18 | |
14 | 19 |
class PlaceLineCommand(AbstractCommand.AbstractCommand): |
20 |
""" |
|
21 |
This is place line class |
|
22 |
""" |
|
23 | ||
15 | 24 |
onSuccess = pyqtSignal() |
16 | 25 |
onRejected = pyqtSignal(AbstractCommand.AbstractCommand) |
17 | 26 |
DTI_PID/DTI_PID/MainWindow.py | ||
---|---|---|
1200 | 1200 |
lineItem.connectIfPossible(items[-1], 5) |
1201 | 1201 |
else: |
1202 | 1202 |
pt = lineItem.startPoint() |
1203 |
selected = self.graphicsView.scene.itemAt(QPointF(pt[0], pt[1]), QTransform())
|
|
1204 |
if selected is not None and type(selected) is QEngineeringConnectorItem:
|
|
1205 |
lineItem.connectIfPossible(selected.parent, 5)
|
|
1203 |
selected = [item for item in self.graphicsView.scene.items(QPointF(pt[0], pt[1])) if type(item) is QEngineeringConnectorItem or type(item) is QEngineeringLineItem]
|
|
1204 |
if selected: |
|
1205 |
lineItem.connectIfPossible(selected[0].parent if type(selected[0]) is QEngineeringConnectorItem else selected[0], 5)
|
|
1206 | 1206 |
|
1207 | 1207 |
items.append(lineItem) |
1208 | 1208 |
self.graphicsView.scene.addItem(lineItem) |
1209 | 1209 | |
1210 | 1210 |
pt = items[-1].endPoint() |
1211 |
selected = self.graphicsView.scene.itemAt(QPointF(pt[0], pt[1]), QTransform())
|
|
1212 |
if selected is not None and type(selected) is QEngineeringConnectorItem:
|
|
1213 |
items[-1].connectIfPossible(selected.parent, 5) |
|
1211 |
selected = [item for item in self.graphicsView.scene.items(QPointF(pt[0], pt[1])) if type(item) is QEngineeringConnectorItem and item.parent is not items[-1]]
|
|
1212 |
if selected: |
|
1213 |
items[-1].connectIfPossible(selected[0].parent, 5)
|
|
1214 | 1214 |
finally: |
1215 | 1215 |
self.graphicsView.scene.removeItem(self.actionLine.tag._polyline) |
1216 | 1216 |
self.actionLine.tag.reset() |
내보내기 Unified diff