Skip to content

Commit 4af4aa2

Browse files
authored
Merge pull request #237 from zhujun98/fix_master_slave_mode_bug
Fix master-slave reset bug
2 parents 2eabc24 + 875b676 commit 4af4aa2

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

extra_foam/gui/windows/correlation_w.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,18 @@ def refresh(self):
6666
self._resolution = 0
6767

6868
self._plot.setData(item.x, y)
69-
if y_slave is not None and len(y_slave) > 0:
69+
# The following code looks awkward but it is by far
70+
# the best solution. The user could choose to deactivate
71+
# the master-slave mode and keep the slave data there.
72+
# In this case, a legend is still required. Therefore,
73+
# we cannot toggle the legend by the signal from the
74+
# master-slave checkbox in the GUI.
75+
if y_slave is not None:
7076
self._plot_slave.setData(item.x_slave, y_slave)
71-
self.showLegend()
77+
if len(y_slave) > 0:
78+
self.showLegend()
79+
else:
80+
self.hideLegend()
7281
else:
7382
self.hideLegend()
7483
else:
@@ -84,11 +93,14 @@ def refresh(self):
8493
self._resolution = resolution
8594

8695
self._plot.setData(item.x, y.avg, y_min=y.min, y_max=y.max)
87-
if y_slave is not None and len(y_slave.avg) > 0:
96+
if y_slave is not None:
8897
self._plot_slave.setData(
8998
item.x_slave, y_slave.avg,
9099
y_min=y_slave.min, y_max=y_slave.max)
91-
self.showLegend()
100+
if len(y_slave.avg) > 0:
101+
self.showLegend()
102+
else:
103+
self.hideLegend()
92104
else:
93105
self.hideLegend()
94106

0 commit comments

Comments
 (0)