개정판 e78ba6c9
issue #640: add connection point index correctly
Change-Id: I7864047f63e42245aae3789190efb549ce5fe8a5
DTI_PID/DTI_PID/Commands/ConnectionPointCommand.py | ||
---|---|---|
18 | 18 |
|
19 | 19 |
onSuccess = pyqtSignal(QGraphicsItem) |
20 | 20 |
|
21 |
def __init__(self, imageViewer, connectionPointLineEdit): |
|
21 |
def __init__(self, imageViewer, connectionPointLineEdit, index=-1):
|
|
22 | 22 |
super(ConnectionPointCommand, self).__init__(imageViewer) |
23 | 23 |
self.name = 'ConnectionPoint' |
24 | 24 |
self.connectionPointLineEdit = connectionPointLineEdit |
... | ... | |
27 | 27 |
self.imageHeight = self.imageViewer.image().height() |
28 | 28 |
self.initMinPoint = QPointF(self.imageWidth * -1, self.imageHeight * -1) |
29 | 29 |
self.connectionPointLineEdit.setText("") |
30 |
self.index = index |
|
30 | 31 |
|
31 | 32 |
''' |
32 | 33 |
@brief pan image by left click and drag |
... | ... | |
62 | 63 |
if event.button() == Qt.LeftButton: |
63 | 64 |
if self.isOnImage(newScenePos.x(), newScenePos.y()): |
64 | 65 |
## drawCircle Method is static |
65 |
conn = ConnectionPointCommand.drawCircle(self.imageViewer, newScenePos.x(), newScenePos.y()) |
|
66 |
conn = ConnectionPointCommand.drawCircle(self.imageViewer, newScenePos.x(), newScenePos.y(), self.index)
|
|
66 | 67 |
text = "{},{}".format(newScenePos.x(), newScenePos.y()) |
67 | 68 |
self.connectionPointLineEdit.setText(text) |
69 |
self.index += 1 |
|
68 | 70 |
self.onSuccess.emit(conn) |
69 | 71 |
else: |
70 | 72 |
QMessageBox.about(self.imageViewer, self.tr('Notice'), self.tr('Please select inside of the symbol.')) |
... | ... | |
84 | 86 |
humkyung 2018.08.28 add connector item instead of QGraphicsEllipse |
85 | 87 |
''' |
86 | 88 |
@staticmethod |
87 |
def drawCircle(imageViewer, x, y): |
|
89 |
def drawCircle(imageViewer, x, y, index=-1):
|
|
88 | 90 |
from EngineeringConnectorItem import QEngineeringConnectorItem |
89 | 91 |
|
90 |
connector = QEngineeringConnectorItem() |
|
92 |
connector = QEngineeringConnectorItem(index=index)
|
|
91 | 93 |
connector.setPos((float(x), float(y))) |
92 | 94 |
imageViewer.scene.addItem(connector) |
93 | 95 |
|
DTI_PID/DTI_PID/Shapes/EngineeringConnectorItem.py | ||
---|---|---|
66 | 66 |
self._label.setFont(font) |
67 | 67 |
|
68 | 68 |
@property |
69 |
def label(self): |
|
70 |
return self._label.text() |
|
71 |
|
|
72 |
@label.setter |
|
73 |
def label(self, value): |
|
74 |
self._label.setPlainText(value) |
|
75 |
|
|
76 |
@property |
|
69 | 77 |
def connectedItem(self): |
70 | 78 |
""" getter of connectedItem """ |
71 | 79 |
import uuid |
DTI_PID/DTI_PID/SymbolEditorDialog.py | ||
---|---|---|
48 | 48 |
self.ui.tableWidgetConnList.horizontalHeaderItem(0).setSizeHint(QSize(25, 25)) |
49 | 49 |
self.ui.tableWidgetConnList.itemPressed.connect(self.onConnPtPressed) |
50 | 50 |
|
51 |
self.conn_index = 1 |
|
52 |
|
|
51 | 53 |
self.setupImageViewer() |
52 | 54 |
self.setupTools() |
53 | 55 |
self.initForms() |
... | ... | |
55 | 57 |
self.isAccepted = False |
56 | 58 |
self.offsetX = 0 |
57 | 59 |
self.offsetY = 0 |
58 |
self.newSym = None |
|
60 |
self.newSym = None
|
|
59 | 61 |
|
60 | 62 |
# for display image |
61 | 63 |
if display: |
... | ... | |
313 | 315 |
x = tokens[0] |
314 | 316 |
y = tokens[1] |
315 | 317 |
|
316 |
conn = ConnectionPointCommand.ConnectionPointCommand.drawCircle(self.ui.imageView, x, y) |
|
318 |
conn = ConnectionPointCommand.ConnectionPointCommand.drawCircle(self.ui.imageView, x, y, self.conn_index) |
|
319 |
self.conn_index += 1 |
|
317 | 320 |
|
318 | 321 |
item = QTableWidgetItem('{},{}'.format(x, y)) |
319 | 322 |
item.setFlags(Qt.ItemIsEnabled) |
... | ... | |
629 | 632 |
def keyPressEvent(self, event): |
630 | 633 |
if event.key() == QtCore.Qt.Key_Delete: |
631 | 634 |
if self.ui.tableWidgetConnList.hasFocus(): |
635 |
self.ui.imageView.command = None |
|
632 | 636 |
model = self.ui.tableWidgetConnList.model() |
633 | 637 |
|
634 | 638 |
item = self.ui.tableWidgetConnList.currentItem() |
... | ... | |
638 | 642 |
if data is not None: |
639 | 643 |
self.ui.imageView.scene.removeItem(data) |
640 | 644 |
model.removeRow(item.row()) |
645 |
self.conn_index -= 1 |
|
646 |
|
|
647 |
for index in range(self.ui.tableWidgetConnList.rowCount()): |
|
648 |
item = self.ui.tableWidgetConnList.item(index, 0) |
|
649 |
data = item.data(Qt.UserRole) |
|
650 |
if data is not None: |
|
651 |
data.label = str(index + 1) |
|
641 | 652 |
elif self.ui.additionalSymbolListWidget.hasFocus(): |
642 | 653 |
selectedItems = self.ui.additionalSymbolListWidget.selectedItems() |
643 | 654 |
if selectedItems is not None: |
... | ... | |
798 | 809 |
self.ui.tableWidgetConnList.setCellWidget(rows, 2, symbol_idx_combobox) |
799 | 810 |
# up to here |
800 | 811 |
|
812 |
self.conn_index += 1 |
|
813 |
|
|
801 | 814 |
''' |
802 | 815 |
@brief Original Point Tool Button Clicked |
803 | 816 |
''' |
... | ... | |
810 | 823 |
@brief Connection Point Tool Button Clicked |
811 | 824 |
''' |
812 | 825 |
def addConnectionPoint(self, event): |
813 |
cmd = ConnectionPointCommand.ConnectionPointCommand(self.ui.imageView, self.ui.connectionPointLineEdit) |
|
826 |
cmd = ConnectionPointCommand.ConnectionPointCommand(self.ui.imageView, self.ui.connectionPointLineEdit, self.conn_index)
|
|
814 | 827 |
cmd.onSuccess.connect(self.onCommandSuccess) |
815 | 828 |
self.ui.imageView.command = cmd |
816 | 829 |
|
... | ... | |
821 | 834 |
''' |
822 | 835 |
def onDeleteConnPt(self): |
823 | 836 |
try: |
837 |
self.ui.imageView.command = None |
|
824 | 838 |
model = self.ui.tableWidgetConnList.model() |
825 | 839 |
|
826 | 840 |
item = self.ui.tableWidgetConnList.currentItem() |
... | ... | |
830 | 844 |
if data is not None: |
831 | 845 |
self.ui.imageView.scene.removeItem(data) |
832 | 846 |
model.removeRow(item.row()) |
847 |
self.conn_index -= 1 |
|
848 |
|
|
849 |
for index in range(self.ui.tableWidgetConnList.rowCount()): |
|
850 |
item = self.ui.tableWidgetConnList.item(index, 0) |
|
851 |
data = item.data(Qt.UserRole) |
|
852 |
if data is not None: |
|
853 |
data.label = str(index + 1) |
|
833 | 854 |
except Exception as ex: |
834 | 855 |
from App import App |
835 | 856 |
from AppDocData import MessageType |
... | ... | |
896 | 917 |
self.ui.imageView.command = FlipImageCommand.FlipImageCommand(self.ui.imageView, horizontal = False, vertical = True) |
897 | 918 |
self.guidelineStateChangedEvent(None) |
898 | 919 |
|
920 |
''' |
|
899 | 921 |
def adjustOriginalPoint(self, adjustX, adjustY): |
900 | 922 |
originalPoint = self.ui.originalPointLineEdit.text() |
901 | 923 |
if originalPoint and self.ui.imageView.isOriginalPointSelected: |
... | ... | |
906 | 928 |
y = y - adjustY |
907 | 929 |
self.ui.originalPointLineEdit.setText(str(x)+","+str(y)) |
908 | 930 |
OriginalPointCommand.OriginalPointCommand.drawCircle(self.ui.imageView, x, y) |
909 |
|
|
931 |
''' |
|
932 |
''' |
|
910 | 933 |
def adjustConnectionPoint(self, adjustX, adjustY): |
911 | 934 |
itemCount = self.ui.connectionPointList.count() |
912 | 935 |
for index in range(itemCount): |
... | ... | |
918 | 941 |
x = x - adjustX |
919 | 942 |
y = y - adjustY |
920 | 943 |
item.setText(str(x)+","+str(y)) |
921 |
ConnectionPointCommand.ConnectionPointCommand.drawCircle(self.ui.imageView, x, y) |
|
944 |
ConnectionPointCommand.ConnectionPointCommand.drawCircle(self.ui.imageView, x, y, self.conn_index) |
|
945 |
self.conn_index += 1 |
|
946 |
''' |
|
922 | 947 |
|
923 | 948 |
''' |
924 | 949 |
@brief Validation Check |
내보내기 Unified diff