[tracs, timeline] pass window width to timeline

This commit is contained in:
Jan Grewe 2025-01-29 23:04:58 +01:00
parent 4a95f48c95
commit 8317e61de6
2 changed files with 16 additions and 6 deletions

View File

@ -26,6 +26,11 @@ class Window(QGraphicsRectItem):
)
self._y = y
def setWindowWidth(self, newwidth):
self._width = newwidth
r = self.rect()
self.setRect(r.x(), r.y(), newwidth, r.height())
def mouseMoveEvent(self, event):
# print(event.scenePos())
super().mouseMoveEvent(event)
@ -164,6 +169,7 @@ class DetectionTimeline(QWidget):
def fit_scene_to_view(self):
"""Scale the image to fit the QGraphicsView."""
logging.debug("Call to fit_scene_to_view")
self._view.fitInView(self._scene.sceneRect(), Qt.KeepAspectRatio)
def resizeEvent(self, event):
@ -180,6 +186,9 @@ class DetectionTimeline(QWidget):
self._rangeStop = np.round(end_pos / scene_width, 3)
self.signals.windowMoved.emit(self._rangeStart, self._rangeStop)
def setWindowWidth(self, width):
self._window.setWindowWidth(width)
# TODO add method to change window size
def main():

View File

@ -58,6 +58,7 @@ class PoseTableModel(QAbstractTableModel):
return -1
return row[0]
class FilterProxyModel(QSortFilterProxyModel):
def __init__(self, parent=None):
super().__init__(parent)
@ -109,12 +110,12 @@ class SelectionControls(QWidget):
halfstepBackBtn = QPushButton("<<")
halfstepBackBtn.setFont(font)
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.clicked.connect(lambda: self.on_Back(halfstep))
quarterstepBackBtn = QPushButton("<")
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.clicked.connect(lambda: self.on_Fwd(quarterstep))
@ -127,12 +128,12 @@ class SelectionControls(QWidget):
halfstepFwdBtn = QPushButton(">>")
halfstepFwdBtn.setFont(font)
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.clicked.connect(lambda: self.on_Fwd(halfstep))
quarterstepFwdBtn = QPushButton(">")
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.clicked.connect(lambda: self.on_Fwd(quarterstep))
@ -529,10 +530,10 @@ class FixTracks(QWidget):
self.update()
def on_forward(self, stepsize):
logging.debug("Tracks: recieve forward command with stepsize: %.2f", stepsize)
logging.debug("Tracks: receive forward command with step-size: %.2f", stepsize)
def on_backward(self, stepsize):
logging.debug("Tracks: recieve backward command with stepsize: %.2f", stepsize)
logging.debug("Tracks: receive backward command with step-size: %.2f", stepsize)
def main():
from PySide6.QtWidgets import QApplication