From 6f6ce90a91f1b98317c08ca96b75cc03c78fc122 Mon Sep 17 00:00:00 2001 From: wangxuegang Date: Thu, 13 Jun 2024 10:26:05 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E6=96=B0=E5=A2=9E=20pointList=20=E5=88=97?= =?UTF-8?q?=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- labelme/app.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/labelme/app.py b/labelme/app.py index 9a83a3711..a09b3ef8f 100644 --- a/labelme/app.py +++ b/labelme/app.py @@ -107,6 +107,7 @@ def __init__( ) self.labelList = LabelListWidget() + self.pointList = LabelListWidget() self.lastOpenDir = None self.flag_dock = self.flag_widget = None @@ -126,6 +127,15 @@ def __init__( self.shape_dock.setObjectName("Labels") self.shape_dock.setWidget(self.labelList) + # pointList + # self.pointList.itemSelectionChanged.connect(self.labelSelectionChanged) + # self.pointList.itemDoubleClicked.connect(self.editLabel) + # self.pointList.itemChanged.connect(self.labelItemChanged) + # self.pointList.itemDropped.connect(self.labelOrderChanged) + self.shape_dock = QtWidgets.QDockWidget('坐标列表', self) + self.shape_dock.setObjectName("Labels") + self.shape_dock.setWidget(self.pointList) + self.uniqLabelList = UniqueLabelQListWidget() self.uniqLabelList.setToolTip( self.tr( @@ -987,6 +997,7 @@ def status(self, message, delay=5000): def resetState(self): self.labelList.clear() + self.pointList.clear() self.filename = None self.imagePath = None self.imageData = None @@ -1170,6 +1181,14 @@ def shapeSelectionChanged(self, selected_shapes): item = self.labelList.findItemByShape(shape) self.labelList.selectItem(item) self.labelList.scrollToItem(item) + + # pointList + self.pointList.clear() + for point_item in shape.points: + point_text = f'{point_item.x()},{point_item.y()}' + point_list_item = LabelListWidgetItem(point_text, shape) + point_list_item.setText('{}'.format(html.escape(point_text))) + self.pointList.addItem(point_list_item) self._noSelectionSlot = False n_selected = len(selected_shapes) self.actions.delete.setEnabled(n_selected) @@ -1183,6 +1202,7 @@ def addLabel(self, shape): else: text = "{} ({})".format(shape.label, shape.group_id) label_list_item = LabelListWidgetItem(text, shape) + self.labelList.addItem(label_list_item) if self.uniqLabelList.findItemByLabel(shape.label) is None: item = self.uniqLabelList.createItemFromLabel(shape.label) @@ -1200,6 +1220,7 @@ def addLabel(self, shape): ) ) + def _update_shape_color(self, shape): r, g, b = self._get_rgb_by_label(shape.label) shape.line_color = QtGui.QColor(r, g, b) From df773062916f2954b55695dec5d5bcd2074783ba Mon Sep 17 00:00:00 2001 From: wangxuegang Date: Thu, 20 Jun 2024 18:18:04 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BB=A5=E4=B8=8Bbug:?= =?UTF-8?q?=E7=BC=96=E8=BE=91=E6=9C=80=E4=B8=8B=E9=9D=A2=E6=A0=87=E7=AD=BE?= =?UTF-8?q?=E6=97=B6=EF=BC=8C=E5=BC=B9=E5=87=BA=E7=9A=84=E7=BC=96=E8=BE=91?= =?UTF-8?q?=E7=AA=97=E5=8F=A3=E6=98=BE=E7=A4=BA=E4=B8=8D=E5=AE=8C=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- labelme/app.py | 1 + labelme/widgets/label_dialog.py | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/labelme/app.py b/labelme/app.py index a09b3ef8f..5939bda5c 100644 --- a/labelme/app.py +++ b/labelme/app.py @@ -1115,6 +1115,7 @@ def editLabel(self, item=None): flags=shape.flags, group_id=shape.group_id, description=shape.description, + centralWidget=self.centralWidget() ) if text is None: return diff --git a/labelme/widgets/label_dialog.py b/labelme/widgets/label_dialog.py index 1047a5e38..ee316b746 100644 --- a/labelme/widgets/label_dialog.py +++ b/labelme/widgets/label_dialog.py @@ -199,7 +199,7 @@ def getGroupId(self): return int(group_id) return None - def popUp(self, text=None, move=True, flags=None, group_id=None, description=None): + def popUp(self, text=None, move=True, flags=None, group_id=None, description=None,centralWidget=None): if self._fit_to_content["row"]: self.labelList.setMinimumHeight( self.labelList.sizeHintForRow(0) * self.labelList.count() + 2 @@ -232,6 +232,11 @@ def popUp(self, text=None, move=True, flags=None, group_id=None, description=Non self.edit.completer().setCurrentRow(row) self.edit.setFocus(QtCore.Qt.PopupFocusReason) if move: + h = centralWidget.height() + + x = QtGui.QCursor.pos().x() + y = QtGui.QCursor.pos().y() if QtGui.QCursor.pos().y() < h else h - 200 + QtGui.QCursor.setPos(x, y) self.move(QtGui.QCursor.pos()) if self.exec_(): return ( From 0847210f1cde3b749608b18c3e9e777b1d70c207 Mon Sep 17 00:00:00 2001 From: wangxuegang Date: Thu, 20 Jun 2024 18:41:01 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E7=BC=96=E8=BE=91=E6=A0=87=E7=AD=BE?= =?UTF-8?q?=E7=AA=97=E5=8F=A3=E7=9A=84=E5=BC=B9=E5=87=BA=E4=BD=8D=E7=BD=AE?= =?UTF-8?q?=E7=94=B1=E5=9B=BA=E5=AE=9A=E5=80=BC=E6=94=B9=E4=B8=BA=E8=AF=A5?= =?UTF-8?q?=E7=AA=97=E5=8F=A3=E9=AB=98=E5=BA=A6=E7=9A=841/2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- labelme/widgets/label_dialog.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/labelme/widgets/label_dialog.py b/labelme/widgets/label_dialog.py index ee316b746..4de18ff93 100644 --- a/labelme/widgets/label_dialog.py +++ b/labelme/widgets/label_dialog.py @@ -235,7 +235,8 @@ def popUp(self, text=None, move=True, flags=None, group_id=None, description=Non h = centralWidget.height() x = QtGui.QCursor.pos().x() - y = QtGui.QCursor.pos().y() if QtGui.QCursor.pos().y() < h else h - 200 + dialog_height = self.sizeHint().height() + y = QtGui.QCursor.pos().y() if QtGui.QCursor.pos().y() < h else h - int(dialog_height / 2) QtGui.QCursor.setPos(x, y) self.move(QtGui.QCursor.pos()) if self.exec_(): From 3484bea59b139c1a379c7a1fa6b46b6fdc6741be Mon Sep 17 00:00:00 2001 From: wangxuegang Date: Fri, 21 Jun 2024 14:46:39 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=94=B1=E4=BA=8Ecentral?= =?UTF-8?q?Widget=E4=B8=BANone=E5=AF=BC=E8=87=B4=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- labelme/widgets/label_dialog.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/labelme/widgets/label_dialog.py b/labelme/widgets/label_dialog.py index 4de18ff93..beabce3ab 100644 --- a/labelme/widgets/label_dialog.py +++ b/labelme/widgets/label_dialog.py @@ -232,12 +232,13 @@ def popUp(self, text=None, move=True, flags=None, group_id=None, description=Non self.edit.completer().setCurrentRow(row) self.edit.setFocus(QtCore.Qt.PopupFocusReason) if move: - h = centralWidget.height() + if centralWidget: + h = centralWidget.height() - x = QtGui.QCursor.pos().x() - dialog_height = self.sizeHint().height() - y = QtGui.QCursor.pos().y() if QtGui.QCursor.pos().y() < h else h - int(dialog_height / 2) - QtGui.QCursor.setPos(x, y) + x = QtGui.QCursor.pos().x() + dialog_height = self.sizeHint().height() + y = QtGui.QCursor.pos().y() if QtGui.QCursor.pos().y() < h else h - int(dialog_height / 2) + QtGui.QCursor.setPos(x, y) self.move(QtGui.QCursor.pos()) if self.exec_(): return (