Skip to content

visualdynamics.gui.time_tools

time_tools

Settings and preview for time-history scaling and paired TRAC.

Classes:

Name Description
TimeTools

Display time tools beside the plot; the project owns the computations.

Functions:

Name Description
pair_model

The pair editor's table: one row a pair, the first and the second

Classes

TimeTools

TimeTools(window: Any)

Display time tools beside the plot; the project owns the computations.

Methods:

Name Description
hide

Put away the settings while a different view is being drawn.

add_results

Show all outputs as separate rows and select them together.

render

Offer the tools for time selections and draw a requested preview.

pick_station

Select a station's row in the score table, which plots its

Source code in src/visualdynamics/gui/time_tools.py
def __init__(self, window: Any) -> None:
    self.window: Any = window
    pane = window.data_pane
    self.group: QActionGroup = QActionGroup(pane)
    self.group.setExclusionPolicy(QActionGroup.ExclusionPolicy.ExclusiveOptional)
    self.compare_action: QAction = self._action(
        'TRAC / Overlay', 'Overlay paired responses and choose the TRAC time window')
    self.panel: QWidget = QWidget(pane)
    self.panel.setMinimumWidth(245)
    layout = QVBoxLayout(self.panel)
    self.note: QLabel = QLabel()
    self.note.setWordWrap(True)
    layout.addWidget(self.note)
    self.settings: QWidget = QWidget()
    form = QFormLayout(self.settings)
    self.start: DoubleSpinBox = self._seconds()
    self.stop: DoubleSpinBox = self._seconds()
    self.start.setToolTip('First time in seconds included in the TRAC score')
    self.stop.setToolTip('Last time in seconds included in the TRAC score')
    form.addRow('TRAC start (s)', self.start)
    form.addRow('TRAC end (s)', self.stop)
    self.manual: QPushButton = QPushButton('Edit pairs…')
    self.manual.setToolTip('Choose the two source records for each comparison station')
    form.addRow(self.manual)
    self.table: QTableWidget = QTableWidget(0, 3)
    self.table.setHorizontalHeaderLabels(['DOF', 'TRAC', 'sTRAC'])
    self.table.horizontalHeaderItem(2).setToolTip(
        'Signed gain multiplying the second trace to fit the first. Ideal: 1.')
    self.map_mode: QComboBox = QComboBox()
    self.map_mode.addItems(['Off', 'TRAC points', 'sTRAC points',
                            'TRAC contour', 'sTRAC contour',
                            'TRAC smooth contour', 'sTRAC smooth contour'])
    self.map_mode.currentIndexChanged.connect(self._edited)
    self.map_mode.setToolTip('Color the linked geometry in the 3-D view by each '
                             'station\'s score, as points or a contour')
    self.mesh_choice: QComboBox = QComboBox()
    self.mesh_choice.currentIndexChanged.connect(self._edited)
    self.mesh_choice.setToolTip('A finite element geometry to draw the contour on, under the measured stations')
    self.figures: QSplitter = QSplitter()
    self.traces: QSplitter = QSplitter(Qt.Orientation.Vertical)
    self.figures.addWidget(self.traces)
    self.trace_visible: QCheckBox = QCheckBox('Show time traces')
    self.trace_visible.setChecked(True)
    self.trace_visible.setToolTip('Show the selected pair\'s time traces')
    self.trace_visible.toggled.connect(self._edited)
    self.trace_frame: QWidget = self._figure_frame(
        'Time traces', lambda: self.trace_visible.setChecked(False))
    self.waterfall_frame: QWidget = self._figure_frame('Waterfall', self._close_waterfall)
    self.traces.addWidget(self.trace_frame)
    self.traces.addWidget(self.waterfall_frame)
    pane._time_tools_layout.insertWidget(0, self.figures, 1)
    self.figures.hide()
    form.addRow('Geometry correlation', self.map_mode)
    form.addRow('FEM overlay', self.mesh_choice)
    form.addRow(self.trace_visible)
    self.correlation_key: tuple | None = None
    self.correlation_count: int = 0
    self.mesh_source: tuple | None = None
    form.addRow(self.table)
    self.table.setEditTriggers(QTableWidget.EditTrigger.NoEditTriggers)
    self.table.setSelectionBehavior(QTableWidget.SelectionBehavior.SelectRows)
    layout.addWidget(self.settings, 1)
    self.apply: QPushButton = QPushButton('Save comparison')
    self.apply.setToolTip('Keep the previewed result and its settings in the project')
    layout.addWidget(self.apply)
    pane._time_tools_layout.addWidget(self.panel)
    self.start.valueChanged.connect(self._edited)
    self.stop.valueChanged.connect(self._edited)
    self.table.currentCellChanged.connect(self._edited)
    self.manual.clicked.connect(self._manual_pairs)
    self.apply.clicked.connect(self._apply)
    self.key: tuple | None = None
    self.series: list = []
    self.explicit: list | None = None
    self.draft: TimeHistory | None = None
    self.saved: str | None = None
    self.hide()
Methods:
hide
hide() -> None

Put away the settings while a different view is being drawn.

Source code in src/visualdynamics/gui/time_tools.py
def hide(self) -> None:
    """Put away the settings while a different view is being drawn."""
    pane = self.window.data_pane
    if not self.figures.isHidden():
        pane.author_split.insertWidget(0, pane.graphics)
        if pane._waterfall_page is not None:
            pane.author_split.insertWidget(1, pane._waterfall_page)
        pane.author_split.show()
        self.figures.hide()
    self.panel.hide()
    self.compare_action.setVisible(False)
add_results
add_results(names: list[str]) -> None

Show all outputs as separate rows and select them together.

Source code in src/visualdynamics/gui/time_tools.py
def add_results(self, names: list[str]) -> None:
    """Show all outputs as separate rows and select them together."""
    if not names:
        return
    window = self.window
    with QSignalBlocker(window.tree):
        for name in names:
            window.show_object(name, select=False)
        window.tree.setCurrentItem(window._item_for_object(names[0]))
        window.tree.clearSelection()
        for name in names:
            window._item_for_object(name).setSelected(True)
    window._selection_changed()
render
render(series: list, *, compare_sections: bool = False) -> str | None

Offer the tools for time selections and draw a requested preview.

Source code in src/visualdynamics/gui/time_tools.py
def render(self, series: list, *, compare_sections: bool = False) -> str | None:
    """Offer the tools for time selections and draw a requested preview."""
    self.hide()
    if not series or not all(isinstance(d, TimeHistory) for _n, d, _r in series):
        self.key = None
        return None
    key = tuple((n, id(d), tuple(r) if r is not None else None) for n, d, r in series)
    if key != self.key:
        if compare_sections:
            self.window.data_pane.waterfall_action.setChecked(False)
        self.compare_action.setChecked(compare_sections)
        self.explicit = self.draft = None
        self.key = key
    self.series = series
    name, data, _ = series[0]
    self.saved = name if len(series) == 1 and getattr(data, 'time_comparison', None) else None
    comparable = (len(series) > 1 or self.saved is not None
                  or (series[0][2] is not None and len(series[0][2]) > 1))
    self.compare_action.setVisible(comparable)
    if not (self.saved or self.compare_action.isChecked()):
        return None
    if self.saved:
        self.compare_action.setChecked(True)
    pane = self.window.data_pane
    pane.show_controls(map_wanted=None, diagonal=None, cmif=False,
                       complex_data=False, pair=False)
    pane.toolbar.show()
    self.panel.show()
    return self._preview()
pick_station
pick_station(rows: list[int]) -> None

Select a station's row in the score table, which plots its traces. A node scored by more than one row steps through them on each click.

Source code in src/visualdynamics/gui/time_tools.py
def pick_station(self, rows: list[int]) -> None:
    """Select a station's row in the score table, which plots its
    traces. A node scored by more than one row steps through them
    on each click."""
    # Callum Hammill's, 2026-11: a station clicked on the geometry
    # selects its traces. Brought back onto the main 3-D view when
    # the map moved there (Brandon, 2026-11-24)
    if not self.panel.isVisible() or not rows:
        return
    current = self.table.currentRow()
    row = rows[(rows.index(current) + 1) % len(rows)] if current in rows else rows[0]
    if 0 <= row < self.table.rowCount():
        self.table.setCurrentCell(row, 0)
        self.table.scrollToItem(self.table.item(row, 0))

Functions:

pair_model

pair_model(pairs: list[list[int]], labels: list[str], parent: Any = None) -> TableModel

The pair editor's table: one row a pair, the first and the second response each picked from labels. pairs holds indices into labels and is edited in place; the comparison the pairs are given to is what the journal records, so the columns journal elsewhere.

Source code in src/visualdynamics/gui/time_tools.py
def pair_model(pairs: list[list[int]], labels: list[str],
               parent: Any = None) -> TableModel:
    """The pair editor's table: one row a pair, the first and the second
    response each picked from `labels`. `pairs` holds indices into
    `labels` and is edited in place; the comparison the pairs are given
    to is what the journal records, so the columns journal elsewhere."""

    def getter(side: int):
        return lambda obj, row: labels[obj[row][side]]

    def setter(side: int):
        def put(obj, row, text):
            text = str(text).strip()
            if text not in labels:
                raise ValueError(f'{text!r} is not one of the picked responses')
            obj[row][side] = labels.index(text)
        return put

    columns = [Column(title, getter(side), set=setter(side), choices=list(labels),
                      journal=_elsewhere,
                      alignment=int(Qt.AlignmentFlag.AlignLeft | Qt.AlignmentFlag.AlignVCenter))
               for side, title in enumerate(('First (colored)', 'Second (gray)'))]
    return TableModel(pairs, columns, len, parent)