[tracks] minor cleanup

This commit is contained in:
Jan Grewe 2025-02-03 20:53:42 +01:00
parent ee97382bbe
commit e2ac4f3551
2 changed files with 4 additions and 12 deletions

View File

@ -19,12 +19,6 @@ class Detection(QGraphicsEllipseItem):
def mousePressEvent(self, event): def mousePressEvent(self, event):
self.signals.clicked.emit(self.data(0), QPointF(event.scenePos().x(), event.scenePos().y())) self.signals.clicked.emit(self.data(0), QPointF(event.scenePos().x(), event.scenePos().y()))
# item = self.scene().itemAt(event.scenePos(), self.views()[0].transform())
# if item:
# item.setSelected(True)
# print(f"Rectangle clicked at: {event.scenePos().x()}, {event.scenePos().y()}")
def hoverEnterEvent(self, event): def hoverEnterEvent(self, event):
self.signals.hover.emit(self.data(0), QPointF(event.scenePos().x(), event.scenePos().y())) self.signals.hover.emit(self.data(0), QPointF(event.scenePos().x(), event.scenePos().y()))
@ -53,7 +47,6 @@ class DetectionScene(QGraphicsScene):
def mouseMoveEvent(self, event): def mouseMoveEvent(self, event):
if self.selection_rect is not None: if self.selection_rect is not None:
# Update the selection rectangle as the mouse moves
rect = QRectF(self.start_point, event.scenePos()).normalized() rect = QRectF(self.start_point, event.scenePos()).normalized()
self.selection_rect.setRect(rect) self.selection_rect.setRect(rect)
super().mouseMoveEvent(event) super().mouseMoveEvent(event)
@ -64,7 +57,6 @@ class DetectionScene(QGraphicsScene):
self.removeItem(self.selection_rect) self.removeItem(self.selection_rect)
self.selection_rect = None self.selection_rect = None
if rect.width() > 0.0: if rect.width() > 0.0:
# Find all items that intersect with the selection rectangle
selected_items = self.items(rect, Qt.IntersectsItemShape) selected_items = self.items(rect, Qt.IntersectsItemShape)
for item in selected_items: for item in selected_items:
if not isinstance(item, Detection): if not isinstance(item, Detection):
@ -158,7 +150,7 @@ class DetectionView(QWidget):
def main(): def main():
def items_selected(items): def items_selected(items):
print("items selected", items) print("items selected")
import pickle import pickle
import numpy as np import numpy as np