diff --git a/fixtracks/widgets/detectionview.py b/fixtracks/widgets/detectionview.py index b79e5eb..80f9486 100644 --- a/fixtracks/widgets/detectionview.py +++ b/fixtracks/widgets/detectionview.py @@ -1,4 +1,3 @@ -import enum import logging import numpy as np @@ -8,13 +7,7 @@ from PySide6.QtGui import QPixmap, QBrush, QColor, QImage from fixtracks.info import PACKAGE_ROOT from fixtracks.utils.signals import DetectionSignals, DetectionViewSignals, DetectionSceneSignals - - -class DetectionData(enum.Enum): - ID = 0 - FRAME = 1 - COORDINATES = 2 - TRACK_ID = 3 +from ..utils.enums import DetectionData class Detection(QGraphicsEllipseItem): diff --git a/fixtracks/widgets/selection_control.py b/fixtracks/widgets/selection_control.py index 19e75f8..ecf3d6b 100644 --- a/fixtracks/widgets/selection_control.py +++ b/fixtracks/widgets/selection_control.py @@ -6,6 +6,7 @@ from PySide6.QtGui import QFont from PySide6.QtWidgets import QWidget, QLabel, QPushButton, QSizePolicy from PySide6.QtWidgets import QGridLayout, QVBoxLayout +from fixtracks.utils.styles import pushBtnStyle class SelectionControls(QWidget): fwd = Signal(float) @@ -23,6 +24,7 @@ class SelectionControls(QWidget): font = QFont() font.setBold(True) font.setPointSize(10) + fullstep = 1.0 halfstep = 0.5 quarterstep = 0.25 @@ -32,19 +34,22 @@ class SelectionControls(QWidget): backBtn.setShortcut(Qt.Key.Key_Left) backBtn.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Expanding) backBtn.setToolTip(f"Go back to previous window ({backBtn.shortcut().toString()})") + backBtn.setStyleSheet(pushBtnStyle("darkgray")) backBtn.clicked.connect(lambda: self.on_Back(fullstep)) halfstepBackBtn = QPushButton("<<") halfstepBackBtn.setFont(font) halfstepBackBtn.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Expanding) halfstepBackBtn.setShortcut(Qt.KeyboardModifier.AltModifier | Qt.Key.Key_Left) halfstepBackBtn.setToolTip(f"Go back by half a window ({halfstepBackBtn.shortcut().toString()})") + halfstepBackBtn.setStyleSheet(pushBtnStyle("darkgray")) halfstepBackBtn.clicked.connect(lambda: self.on_Back(halfstep)) quarterstepBackBtn = QPushButton("<") quarterstepBackBtn.setFont(font) quarterstepBackBtn.setShortcut(Qt.KeyboardModifier.ShiftModifier | Qt.Key.Key_Left) 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.setStyleSheet(pushBtnStyle("darkgray")) + quarterstepBackBtn.clicked.connect(lambda: self.on_Back(quarterstep)) fwdBtn = QPushButton(">>|") @@ -52,23 +57,26 @@ class SelectionControls(QWidget): fwdBtn.setShortcut(Qt.Key.Key_Right) fwdBtn.setFont(font) fwdBtn.setToolTip(f"Proceed to next window ({fwdBtn.shortcut().toString()})") + fwdBtn.setStyleSheet(pushBtnStyle("darkgray")) fwdBtn.clicked.connect(lambda: self.on_Fwd(fullstep)) halfstepFwdBtn = QPushButton(">>") halfstepFwdBtn.setFont(font) halfstepFwdBtn.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Expanding) halfstepFwdBtn.setShortcut(Qt.KeyboardModifier.AltModifier | Qt.Key.Key_Right) halfstepFwdBtn.setToolTip(f"Proceed by half a window ({halfstepFwdBtn.shortcut().toString()})") + halfstepFwdBtn.setStyleSheet(pushBtnStyle("darkgray")) halfstepFwdBtn.clicked.connect(lambda: self.on_Fwd(halfstep)) quarterstepFwdBtn = QPushButton(">") quarterstepFwdBtn.setFont(font) quarterstepFwdBtn.setShortcut(Qt.KeyboardModifier.ShiftModifier | Qt.Key.Key_Right) 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.setStyleSheet(pushBtnStyle("darkgray")) + quarterstepFwdBtn.clicked.connect(lambda: self.on_Fwd(quarterstep)) assignOneBtn = QPushButton("Track One") assignOneBtn.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Expanding) - assignOneBtn.setStyleSheet("QPushButton { background-color: orange; }") + assignOneBtn.setStyleSheet(pushBtnStyle("orange")) assignOneBtn.setShortcut("Ctrl+1") assignOneBtn.setToolTip(f"Assign current selection to Track One ({assignOneBtn.shortcut().toString()})") assignOneBtn.setFont(font) @@ -77,7 +85,7 @@ class SelectionControls(QWidget): assignTwoBtn = QPushButton("Track Two") assignTwoBtn.setShortcut("Ctrl+2") 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.setFont(font) assignTwoBtn.clicked.connect(self.on_TrackTwo) @@ -86,35 +94,35 @@ class SelectionControls(QWidget): assignOtherBtn.setShortcut("Ctrl+0") assignOtherBtn.setFont(font) 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.clicked.connect(self.on_TrackOther) acceptBtn = QPushButton("accept") acceptBtn.setFont(font) 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.clicked.connect(self.on_Accept) unacceptBtn = QPushButton("un-accept") unacceptBtn.setFont(font) 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.clicked.connect(self.on_Unaccept) deleteBtn = QPushButton("delete") deleteBtn.setFont(font) 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.clicked.connect(self.on_Delete) revertBtn = QPushButton("revert assignments") revertBtn.setFont(font) 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.clicked.connect(self.on_RevertAll) @@ -162,7 +170,7 @@ class SelectionControls(QWidget): grid.setColumnStretch(0, 1) grid.setColumnStretch(7, 1) self.setLayout(grid) - self.setMaximumSize(QSize(400, 300)) + self.setMaximumSize(QSize(500, 500)) def setWindow(self, start:int=0, end:int=0): self.startframe.setText(f"{start:.0f}") diff --git a/fixtracks/widgets/skeleton.py b/fixtracks/widgets/skeleton.py index 406fde8..59a9822 100644 --- a/fixtracks/widgets/skeleton.py +++ b/fixtracks/widgets/skeleton.py @@ -6,7 +6,7 @@ from PySide6.QtWidgets import QGraphicsScene, QGraphicsEllipseItem, QGraphicsRec from PySide6.QtCore import Qt from PySide6.QtGui import QBrush, QColor, QPen, QPainter, QFont -from fixtracks.widgets.detectionview import DetectionData +from fixtracks.utils.enums import DetectionData class Skeleton(QGraphicsRectItem): skeleton_grid = [(0, 1), (1, 2), (1, 3), (1, 4), (2, 5)]