Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions trace/widgets/axis_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ def __init__(self, parent: QWidget, plot: PyDMArchiverTimePlot, axis: BasePlotAx

log_checkbox = QCheckBox(self)
log_checkbox.setChecked(self.axis.log_mode)
log_checkbox.checkStateChanged.connect(self.set_axis_log_mode)
log_checkbox.stateChanged.connect(self.set_axis_log_mode)
log_mode_row = SettingsRowItem(self, "Log Mode", log_checkbox)
main_layout.addLayout(log_mode_row)

self.grid_checkbox = QCheckBox(self)
self.grid_checkbox.setChecked(bool(self.axis.grid))
self.grid_checkbox.checkStateChanged.connect(self.show_grid)
self.grid_checkbox.stateChanged.connect(self.show_grid)
y_grid_row = SettingsRowItem(self, "Y Axis Gridline", self.grid_checkbox)
main_layout.addLayout(y_grid_row)

Expand Down Expand Up @@ -68,12 +68,16 @@ def set_axis_orientation(self, orientation: str):
self.axis.show()

@Slot(int)
def set_axis_log_mode(self, checked: int):
self.axis.log_mode = bool(checked)
@Slot(Qt.CheckState)
def set_axis_log_mode(self, state: int | Qt.CheckState):
checked = Qt.CheckState(state) == Qt.Checked
self.axis.log_mode = checked

@Slot(int)
def show_grid(self, visible: int):
if not visible:
@Slot(Qt.CheckState)
def show_grid(self, state: int | Qt.CheckState):
checked = Qt.CheckState(state) == Qt.Checked
if not checked:
self.axis.setGrid(False)
else:
try:
Expand Down
35 changes: 19 additions & 16 deletions trace/widgets/control_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import qtawesome as qta
from qtpy import QtGui, QtCore, QtWidgets
from qtpy.QtCore import QTimer
from qtpy.QtCore import Qt, Slot, QTimer
from services.theme_manager import Theme, IconColors, ThemeManager

from pydm.widgets.baseplot import BasePlotAxisItem
Expand Down Expand Up @@ -368,7 +368,7 @@ def __init__(self, plot_axis_item: BasePlotAxisItem, control_panel=None, theme_m
layout.addLayout(self.bottom_settings_layout)
self.auto_range_checkbox = QtWidgets.QCheckBox("Auto")
self.auto_range_checkbox.setCheckState(QtCore.Qt.Checked if self.source.auto_range else QtCore.Qt.Unchecked)
self.auto_range_checkbox.checkStateChanged.connect(self.set_auto_range)
self.auto_range_checkbox.stateChanged.connect(self.set_auto_range)
self.source.linkedView().sigRangeChangedManually.connect(self.disable_auto_range)
self.bottom_settings_layout.addWidget(self.auto_range_checkbox)
self.bottom_settings_layout.addWidget(QtWidgets.QLabel("min, max"))
Expand All @@ -387,7 +387,7 @@ def __init__(self, plot_axis_item: BasePlotAxisItem, control_panel=None, theme_m

self.active_toggle = ToggleSwitch("Active")
self.active_toggle.setCheckState(QtCore.Qt.Checked if self.source.isVisible() else QtCore.Qt.Unchecked)
self.active_toggle.checkStateChanged.connect(self.set_active)
self.active_toggle.stateChanged.connect(self.set_active)
self.header_layout.addWidget(self.active_toggle)

self.placeholder = QtWidgets.QWidget(self)
Expand Down Expand Up @@ -543,16 +543,19 @@ def toggle_expand(self):
self.layout().itemAt(index).widget().show()
self._expanded = not self._expanded

def set_active(self, state: QtCore.Qt.CheckState):
if state == QtCore.Qt.Unchecked:
self.source.hide()
else:
self.source.show()
@Slot(int)
@Slot(Qt.CheckState)
def set_active(self, state: int | Qt.CheckState):
checked = Qt.CheckState(state) == Qt.Checked
self.source.setVisible(checked)
for i in range(1, self.layout().count()):
self.layout().itemAt(i).widget().active_toggle.setCheckState(state)

def set_auto_range(self, state: QtCore.Qt.CheckState):
self.source.auto_range = state == QtCore.Qt.Checked
@Slot(int)
@Slot(Qt.CheckState)
def set_auto_range(self, state: int | Qt.CheckState):
checked = Qt.CheckState(state) == Qt.Checked
self.source.auto_range = checked

def disable_auto_range(self):
self.auto_range_checkbox.setCheckState(QtCore.Qt.Unchecked)
Expand Down Expand Up @@ -753,7 +756,7 @@ def __init__(

self.active_toggle = ToggleSwitch("Active", color=self.source.color_string)
self.active_toggle.setCheckState(QtCore.Qt.Checked if self.source.isVisible() else QtCore.Qt.Unchecked)
self.active_toggle.checkStateChanged.connect(self.set_active)
self.active_toggle.stateChanged.connect(self.set_active)
self.layout().addWidget(self.active_toggle)

second_layout = QtWidgets.QVBoxLayout()
Expand Down Expand Up @@ -878,11 +881,11 @@ def axis_item(self):
parent = parent.parent()
return parent

def set_active(self, state: QtCore.Qt.CheckState):
if state == QtCore.Qt.Unchecked:
self.source.hide()
else:
self.source.show()
@Slot(int)
@Slot(Qt.CheckState)
def set_active(self, state: int | Qt.CheckState):
checked = Qt.CheckState(state) == Qt.Checked
self.source.setVisible(checked)

def update_live_icon(self, connected: bool) -> None:
self.live_connection_status.setVisible(not connected)
Expand Down
25 changes: 14 additions & 11 deletions trace/widgets/curve_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ def __init__(self, parent: QWidget, plot: PyDMArchiverTimePlot, curve: TimePlotC
width_row = SettingsRowItem(self, " Width", width_combo)
main_layout.addLayout(width_row)

extention_option = QCheckBox(self)
extention_option.checkStateChanged.connect(lambda check: self.set_extension_option(bool(check)))
extention_option_row = SettingsRowItem(self, "Line Extention", extention_option)
main_layout.addLayout(extention_option_row)
extension_option = QCheckBox(self)
extension_option.stateChanged.connect(self.set_extension_option)
extension_option_row = SettingsRowItem(self, " Line Extension", extension_option)
main_layout.addLayout(extension_option_row)

symbol_title_label = SettingsTitle(self, "Symbol")
main_layout.addWidget(symbol_title_label)
Expand Down Expand Up @@ -156,17 +156,20 @@ def set_curve_style(self, style: int) -> None:
def set_curve_width(self, width: int) -> None:
self.curve.lineWidth = width

@Slot(int)
@Slot(Qt.CheckState)
def set_extension_option(self, state: int | Qt.CheckState) -> None:
"""Set the line extension based on the checkbox state."""
enable = Qt.CheckState(state) == Qt.Checked

self.curve.show_extension_line = enable
self.curve.getViewBox().addItem(self.curve._extension_line)
self.curve.redrawCurve()

@Slot(object)
def set_symbol_shape(self, shape: str) -> None:
self.curve.symbol = shape

@Slot(object)
def set_symbol_size(self, size: int) -> None:
self.curve.symbolSize = size

@Slot(object)
def set_extension_option(self, enable: bool) -> None:
"""Set the line extension based on the checkbox state."""
self.curve.show_extension_line = enable
self.curve.getViewBox().addItem(self.curve._extension_line)
self.curve.redrawCurve()
31 changes: 23 additions & 8 deletions trace/widgets/plot_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def __init__(self, parent: QWidget, plot: PyDMArchiverTimePlot):
main_layout.addLayout(plot_title_row)

self.legend_checkbox = QCheckBox(self)
self.legend_checkbox.checkStateChanged.connect(lambda check: self.plot.setShowLegend(bool(check)))
self.legend_checkbox.stateChanged.connect(self.set_show_legend)
self.legend_checkbox.setChecked(True) # legend on by default
legend_row = SettingsRowItem(self, "Show Legend", self.legend_checkbox)
main_layout.addLayout(legend_row)
Expand Down Expand Up @@ -81,7 +81,7 @@ def __init__(self, parent: QWidget, plot: PyDMArchiverTimePlot):
main_layout.addLayout(end_dt_row)

self.crosshair_checkbox = QCheckBox(self)
self.crosshair_checkbox.checkStateChanged.connect(lambda check: self.plot.enableCrosshair(check, 100, 100))
self.crosshair_checkbox.stateChanged.connect(self.set_crosshair)
crosshair_row = SettingsRowItem(self, "Show Crosshair", self.crosshair_checkbox)
main_layout.addLayout(crosshair_row)

Expand All @@ -101,12 +101,12 @@ def __init__(self, parent: QWidget, plot: PyDMArchiverTimePlot):
main_layout.addLayout(axis_tick_font_size_row)

self.x_grid_checkbox = QCheckBox(self)
self.x_grid_checkbox.checkStateChanged.connect(self.show_x_grid)
self.x_grid_checkbox.stateChanged.connect(self.show_x_grid)
x_grid_row = SettingsRowItem(self, " X Axis Gridline", self.x_grid_checkbox)
main_layout.addLayout(x_grid_row)

self.y_grid_checkbox = QCheckBox(self)
self.y_grid_checkbox.checkStateChanged.connect(self.show_y_grid)
self.y_grid_checkbox.stateChanged.connect(self.show_y_grid)
y_grid_row = SettingsRowItem(self, " All Y Axis Gridlines", self.y_grid_checkbox)
main_layout.addLayout(y_grid_row)

Expand Down Expand Up @@ -145,6 +145,12 @@ def show(self):
self.move(global_pos)
super().show()

@Slot(int)
@Slot(Qt.CheckState)
def set_show_legend(self, state: int | Qt.CheckState) -> None:
checked = Qt.CheckState(state) == Qt.Checked
self.plot.setShowLegend(checked)

@Slot(int)
def set_axis_tick_font_size(self, size: int) -> None:
font = QFont()
Expand Down Expand Up @@ -185,6 +191,12 @@ def set_time_axis_range(self, raw_range: tuple[QDateTime, QDateTime] = (None, No
self.plot.plotItem.setXRange(*proc_range, padding=0)
self.plot.plotItem.vb.blockSignals(False)

@Slot(int)
@Slot(Qt.CheckState)
def set_crosshair(self, state: int | Qt.CheckState) -> None:
checked = Qt.CheckState(state) == Qt.Checked
self.plot.enableCrosshair(checked, 100, 100)

@Slot(object, object)
def set_axis_datetimes(self, _: ViewBox = None, time_range: tuple[float, float] = None) -> None:
"""Slot used to update the QDateTimeEdits on the Axis tab. This
Expand Down Expand Up @@ -213,14 +225,17 @@ def set_axis_datetimes(self, _: ViewBox = None, time_range: tuple[float, float]
qdt.blockSignals(False)

@Slot(int)
def show_x_grid(self, visible: int):
@Slot(Qt.CheckState)
def show_x_grid(self, state: int | Qt.CheckState) -> None:
"""Slot to show or hide the X-Axis gridlines."""
visible = Qt.CheckState(state) == Qt.Checked
opacity = self.gridline_opacity
self.set_plot_gridlines(bool(visible), opacity)
self.set_plot_gridlines(visible, opacity)

@Slot(int)
def show_y_grid(self, visible: int):
visible = bool(visible)
@Slot(Qt.CheckState)
def show_y_grid(self, state: int | Qt.CheckState) -> None:
visible = Qt.CheckState(state) == Qt.Checked
self.set_all_y_axis_gridlines.emit(visible)

@Slot(int)
Expand Down
Loading