[cleanup]

This commit is contained in:
Jan Grewe 2025-02-21 08:01:45 +01:00
parent 104be6e15f
commit 2c62ee28a9
3 changed files with 20 additions and 19 deletions

View File

@ -1,4 +1,3 @@
import enum
import logging import logging
import numpy as np import numpy as np
@ -8,13 +7,7 @@ from PySide6.QtGui import QPixmap, QBrush, QColor, QImage
from fixtracks.info import PACKAGE_ROOT from fixtracks.info import PACKAGE_ROOT
from fixtracks.utils.signals import DetectionSignals, DetectionViewSignals, DetectionSceneSignals from fixtracks.utils.signals import DetectionSignals, DetectionViewSignals, DetectionSceneSignals
from ..utils.enums import DetectionData
class DetectionData(enum.Enum):
ID = 0
FRAME = 1
COORDINATES = 2
TRACK_ID = 3
class Detection(QGraphicsEllipseItem): class Detection(QGraphicsEllipseItem):

View File

@ -6,6 +6,7 @@ from PySide6.QtGui import QFont
from PySide6.QtWidgets import QWidget, QLabel, QPushButton, QSizePolicy from PySide6.QtWidgets import QWidget, QLabel, QPushButton, QSizePolicy
from PySide6.QtWidgets import QGridLayout, QVBoxLayout from PySide6.QtWidgets import QGridLayout, QVBoxLayout
from fixtracks.utils.styles import pushBtnStyle
class SelectionControls(QWidget): class SelectionControls(QWidget):
fwd = Signal(float) fwd = Signal(float)
@ -23,6 +24,7 @@ class SelectionControls(QWidget):
font = QFont() font = QFont()
font.setBold(True) font.setBold(True)
font.setPointSize(10) font.setPointSize(10)
fullstep = 1.0 fullstep = 1.0
halfstep = 0.5 halfstep = 0.5
quarterstep = 0.25 quarterstep = 0.25
@ -32,19 +34,22 @@ class SelectionControls(QWidget):
backBtn.setShortcut(Qt.Key.Key_Left) backBtn.setShortcut(Qt.Key.Key_Left)
backBtn.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Expanding) backBtn.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Expanding)
backBtn.setToolTip(f"Go back to previous window ({backBtn.shortcut().toString()})") backBtn.setToolTip(f"Go back to previous window ({backBtn.shortcut().toString()})")
backBtn.setStyleSheet(pushBtnStyle("darkgray"))
backBtn.clicked.connect(lambda: self.on_Back(fullstep)) backBtn.clicked.connect(lambda: self.on_Back(fullstep))
halfstepBackBtn = QPushButton("<<") halfstepBackBtn = QPushButton("<<")
halfstepBackBtn.setFont(font) halfstepBackBtn.setFont(font)
halfstepBackBtn.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Expanding) halfstepBackBtn.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Expanding)
halfstepBackBtn.setShortcut(Qt.KeyboardModifier.AltModifier | Qt.Key.Key_Left) halfstepBackBtn.setShortcut(Qt.KeyboardModifier.AltModifier | Qt.Key.Key_Left)
halfstepBackBtn.setToolTip(f"Go back by half a window ({halfstepBackBtn.shortcut().toString()})") halfstepBackBtn.setToolTip(f"Go back by half a window ({halfstepBackBtn.shortcut().toString()})")
halfstepBackBtn.setStyleSheet(pushBtnStyle("darkgray"))
halfstepBackBtn.clicked.connect(lambda: self.on_Back(halfstep)) halfstepBackBtn.clicked.connect(lambda: self.on_Back(halfstep))
quarterstepBackBtn = QPushButton("<") quarterstepBackBtn = QPushButton("<")
quarterstepBackBtn.setFont(font) quarterstepBackBtn.setFont(font)
quarterstepBackBtn.setShortcut(Qt.KeyboardModifier.ShiftModifier | Qt.Key.Key_Left) quarterstepBackBtn.setShortcut(Qt.KeyboardModifier.ShiftModifier | Qt.Key.Key_Left)
quarterstepBackBtn.setToolTip(f"Go back by a quarter window ({quarterstepBackBtn.shortcut().toString()})") quarterstepBackBtn.setToolTip(f"Go back by a quarter window ({quarterstepBackBtn.shortcut().toString()})")
quarterstepBackBtn.clicked.connect(lambda: self.on_Back(quarterstep))
quarterstepBackBtn.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Expanding) quarterstepBackBtn.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Expanding)
quarterstepBackBtn.setStyleSheet(pushBtnStyle("darkgray"))
quarterstepBackBtn.clicked.connect(lambda: self.on_Back(quarterstep))
fwdBtn = QPushButton(">>|") fwdBtn = QPushButton(">>|")
@ -52,23 +57,26 @@ class SelectionControls(QWidget):
fwdBtn.setShortcut(Qt.Key.Key_Right) fwdBtn.setShortcut(Qt.Key.Key_Right)
fwdBtn.setFont(font) fwdBtn.setFont(font)
fwdBtn.setToolTip(f"Proceed to next window ({fwdBtn.shortcut().toString()})") fwdBtn.setToolTip(f"Proceed to next window ({fwdBtn.shortcut().toString()})")
fwdBtn.setStyleSheet(pushBtnStyle("darkgray"))
fwdBtn.clicked.connect(lambda: self.on_Fwd(fullstep)) fwdBtn.clicked.connect(lambda: self.on_Fwd(fullstep))
halfstepFwdBtn = QPushButton(">>") halfstepFwdBtn = QPushButton(">>")
halfstepFwdBtn.setFont(font) halfstepFwdBtn.setFont(font)
halfstepFwdBtn.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Expanding) halfstepFwdBtn.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Expanding)
halfstepFwdBtn.setShortcut(Qt.KeyboardModifier.AltModifier | Qt.Key.Key_Right) halfstepFwdBtn.setShortcut(Qt.KeyboardModifier.AltModifier | Qt.Key.Key_Right)
halfstepFwdBtn.setToolTip(f"Proceed by half a window ({halfstepFwdBtn.shortcut().toString()})") halfstepFwdBtn.setToolTip(f"Proceed by half a window ({halfstepFwdBtn.shortcut().toString()})")
halfstepFwdBtn.setStyleSheet(pushBtnStyle("darkgray"))
halfstepFwdBtn.clicked.connect(lambda: self.on_Fwd(halfstep)) halfstepFwdBtn.clicked.connect(lambda: self.on_Fwd(halfstep))
quarterstepFwdBtn = QPushButton(">") quarterstepFwdBtn = QPushButton(">")
quarterstepFwdBtn.setFont(font) quarterstepFwdBtn.setFont(font)
quarterstepFwdBtn.setShortcut(Qt.KeyboardModifier.ShiftModifier | Qt.Key.Key_Right) quarterstepFwdBtn.setShortcut(Qt.KeyboardModifier.ShiftModifier | Qt.Key.Key_Right)
quarterstepFwdBtn.setToolTip(f"Proceed by a quarter window ({quarterstepFwdBtn.shortcut().toString()})") quarterstepFwdBtn.setToolTip(f"Proceed by a quarter window ({quarterstepFwdBtn.shortcut().toString()})")
quarterstepFwdBtn.clicked.connect(lambda: self.on_Fwd(quarterstep))
quarterstepFwdBtn.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Expanding) quarterstepFwdBtn.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Expanding)
quarterstepFwdBtn.setStyleSheet(pushBtnStyle("darkgray"))
quarterstepFwdBtn.clicked.connect(lambda: self.on_Fwd(quarterstep))
assignOneBtn = QPushButton("Track One") assignOneBtn = QPushButton("Track One")
assignOneBtn.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Expanding) assignOneBtn.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Expanding)
assignOneBtn.setStyleSheet("QPushButton { background-color: orange; }") assignOneBtn.setStyleSheet(pushBtnStyle("orange"))
assignOneBtn.setShortcut("Ctrl+1") assignOneBtn.setShortcut("Ctrl+1")
assignOneBtn.setToolTip(f"Assign current selection to Track One ({assignOneBtn.shortcut().toString()})") assignOneBtn.setToolTip(f"Assign current selection to Track One ({assignOneBtn.shortcut().toString()})")
assignOneBtn.setFont(font) assignOneBtn.setFont(font)
@ -77,7 +85,7 @@ class SelectionControls(QWidget):
assignTwoBtn = QPushButton("Track Two") assignTwoBtn = QPushButton("Track Two")
assignTwoBtn.setShortcut("Ctrl+2") assignTwoBtn.setShortcut("Ctrl+2")
assignTwoBtn.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Expanding) assignTwoBtn.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Expanding)
assignTwoBtn.setStyleSheet("QPushButton { background-color: green; }") assignTwoBtn.setStyleSheet(pushBtnStyle("green"))
assignTwoBtn.setToolTip(f"Assign current selection to Track Two ({assignTwoBtn.shortcut().toString()})") assignTwoBtn.setToolTip(f"Assign current selection to Track Two ({assignTwoBtn.shortcut().toString()})")
assignTwoBtn.setFont(font) assignTwoBtn.setFont(font)
assignTwoBtn.clicked.connect(self.on_TrackTwo) assignTwoBtn.clicked.connect(self.on_TrackTwo)
@ -86,35 +94,35 @@ class SelectionControls(QWidget):
assignOtherBtn.setShortcut("Ctrl+0") assignOtherBtn.setShortcut("Ctrl+0")
assignOtherBtn.setFont(font) assignOtherBtn.setFont(font)
assignOtherBtn.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Expanding) assignOtherBtn.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Expanding)
# assignOtherBtn.setStyleSheet("QPushButton { background-color: gray; }") assignOtherBtn.setStyleSheet(pushBtnStyle("gray"))
assignOtherBtn.setToolTip(f"Assign current selection to Unassigned ({assignOtherBtn.shortcut().toString()})") assignOtherBtn.setToolTip(f"Assign current selection to Unassigned ({assignOtherBtn.shortcut().toString()})")
assignOtherBtn.clicked.connect(self.on_TrackOther) assignOtherBtn.clicked.connect(self.on_TrackOther)
acceptBtn = QPushButton("accept") acceptBtn = QPushButton("accept")
acceptBtn.setFont(font) acceptBtn.setFont(font)
acceptBtn.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Expanding) acceptBtn.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Expanding)
# acceptBtn.setStyleSheet("QPushButton { background-color: red; }") acceptBtn.setStyleSheet(pushBtnStyle("darkgray"))
acceptBtn.setToolTip(f"Accept assignments of current selection as TRUE") acceptBtn.setToolTip(f"Accept assignments of current selection as TRUE")
acceptBtn.clicked.connect(self.on_Accept) acceptBtn.clicked.connect(self.on_Accept)
unacceptBtn = QPushButton("un-accept") unacceptBtn = QPushButton("un-accept")
unacceptBtn.setFont(font) unacceptBtn.setFont(font)
unacceptBtn.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Expanding) unacceptBtn.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Expanding)
# acceptBtn.setStyleSheet("QPushButton { background-color: red; }") unacceptBtn.setStyleSheet(pushBtnStyle("darkgray"))
unacceptBtn.setToolTip(f"Revoke current selection TRUE status") unacceptBtn.setToolTip(f"Revoke current selection TRUE status")
unacceptBtn.clicked.connect(self.on_Unaccept) unacceptBtn.clicked.connect(self.on_Unaccept)
deleteBtn = QPushButton("delete") deleteBtn = QPushButton("delete")
deleteBtn.setFont(font) deleteBtn.setFont(font)
deleteBtn.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Expanding) deleteBtn.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Expanding)
deleteBtn.setStyleSheet("QPushButton { background-color: red; }") deleteBtn.setStyleSheet(pushBtnStyle("red"))
deleteBtn.setToolTip(f"DANGERZONE! Delete current selection of detections!") deleteBtn.setToolTip(f"DANGERZONE! Delete current selection of detections!")
deleteBtn.clicked.connect(self.on_Delete) deleteBtn.clicked.connect(self.on_Delete)
revertBtn = QPushButton("revert assignments") revertBtn = QPushButton("revert assignments")
revertBtn.setFont(font) revertBtn.setFont(font)
revertBtn.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Expanding) revertBtn.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Expanding)
revertBtn.setStyleSheet("QPushButton { background-color: red; }") revertBtn.setStyleSheet(pushBtnStyle("red"))
revertBtn.setToolTip(f"DANGERZONE! Remove ALL assignments!") revertBtn.setToolTip(f"DANGERZONE! Remove ALL assignments!")
revertBtn.clicked.connect(self.on_RevertAll) revertBtn.clicked.connect(self.on_RevertAll)
@ -162,7 +170,7 @@ class SelectionControls(QWidget):
grid.setColumnStretch(0, 1) grid.setColumnStretch(0, 1)
grid.setColumnStretch(7, 1) grid.setColumnStretch(7, 1)
self.setLayout(grid) self.setLayout(grid)
self.setMaximumSize(QSize(400, 300)) self.setMaximumSize(QSize(500, 500))
def setWindow(self, start:int=0, end:int=0): def setWindow(self, start:int=0, end:int=0):
self.startframe.setText(f"{start:.0f}") self.startframe.setText(f"{start:.0f}")

View File

@ -6,7 +6,7 @@ from PySide6.QtWidgets import QGraphicsScene, QGraphicsEllipseItem, QGraphicsRec
from PySide6.QtCore import Qt from PySide6.QtCore import Qt
from PySide6.QtGui import QBrush, QColor, QPen, QPainter, QFont from PySide6.QtGui import QBrush, QColor, QPen, QPainter, QFont
from fixtracks.widgets.detectionview import DetectionData from fixtracks.utils.enums import DetectionData
class Skeleton(QGraphicsRectItem): class Skeleton(QGraphicsRectItem):
skeleton_grid = [(0, 1), (1, 2), (1, 3), (1, 4), (2, 5)] skeleton_grid = [(0, 1), (1, 2), (1, 3), (1, 4), (2, 5)]