Skip to content
Merged
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
15 changes: 10 additions & 5 deletions trace/widgets/control_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,9 @@ 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)
widget = self.layout().itemAt(i).widget()
if isinstance(widget, CurveItem):
widget.active_toggle.setCheckState(state)

@Slot(int)
@Slot(Qt.CheckState)
Expand Down Expand Up @@ -724,9 +726,9 @@ def remove_curve_item(self, curve_item: "CurveItem", delete_curve: bool = False)
from the plot entirely. If False, it will just be unlinked
from this axis., by default False.
"""
self.plot.plotItem.unlinkDataFromAxis(curve_item.source)
curve_item.curve_deleted.disconnect()
self.layout().removeWidget(curve_item)
self.plot.plotItem.unlinkDataFromAxis(curve_item.source)

if delete_curve:
curve_item.close()
Expand All @@ -740,13 +742,16 @@ def add_curve_item(self, curve_item: "CurveItem") -> None:
curve_item : CurveItem
The CurveItem to be added to this axis.
"""
curve_item.source.y_axis_name = self.source.name
self.plot.plotItem.linkDataToAxis(curve_item.source, self.source.name)
# Need to link curve to axis before setting y_axis_name on curve
self.plot.plotItem.linkDataToAxis(curve_item.source, self.name)
curve_item.source.y_axis_name = self.name

curve_item.curve_deleted.connect(lambda curve: self.handle_curve_deleted(curve))
curve_item.active_toggle.setCheckState(self.active_toggle.checkState())

self.layout().removeWidget(curve_item) # in case we're reordering within an AxisItem
if self.layout().indexOf(curve_item) != -1:
self.layout().removeWidget(curve_item)

idx = self.layout().indexOf(self.placeholder)
self.layout().insertWidget(idx, curve_item)

Expand Down
Loading