show and hide properly for maxTraces; +test (#1764)
This commit is contained in:
parent
cafe079910
commit
fa1be1e5bf
@ -1003,20 +1003,19 @@ class PlotItem(GraphicsWidget):
|
|||||||
return self.ctrl.clipToViewCheck.isChecked()
|
return self.ctrl.clipToViewCheck.isChecked()
|
||||||
|
|
||||||
def updateDecimation(self):
|
def updateDecimation(self):
|
||||||
if self.ctrl.maxTracesCheck.isChecked():
|
if not self.ctrl.maxTracesCheck.isChecked():
|
||||||
numCurves = self.ctrl.maxTracesSpin.value()
|
numCurves = len(self.curves)
|
||||||
else:
|
else:
|
||||||
numCurves = -1
|
numCurves = self.ctrl.maxTracesSpin.value()
|
||||||
|
|
||||||
curves = self.curves[:]
|
for i, curve in enumerate(self.curves):
|
||||||
split = len(curves) - numCurves
|
if i < numCurves:
|
||||||
for curve in curves[split:]:
|
curve.show()
|
||||||
if numCurves != -1:
|
elif self.ctrl.forgetTracesCheck.isChecked():
|
||||||
if self.ctrl.forgetTracesCheck.isChecked():
|
curve.clear()
|
||||||
curve.clear()
|
self.removeItem(curve)
|
||||||
self.removeItem(curve)
|
else:
|
||||||
else:
|
curve.hide()
|
||||||
curve.hide()
|
|
||||||
|
|
||||||
def updateAlpha(self, *args):
|
def updateAlpha(self, *args):
|
||||||
(alpha, auto) = self.alphaState()
|
(alpha, auto) = self.alphaState()
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
import numpy as np
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
import pyqtgraph as pg
|
import pyqtgraph as pg
|
||||||
|
|
||||||
app = pg.mkQApp()
|
app = pg.mkQApp()
|
||||||
@ -23,6 +25,21 @@ def test_PlotItem_shared_axis_items(orientation):
|
|||||||
pi2.setAxisItems({orientation: ax1})
|
pi2.setAxisItems({orientation: ax1})
|
||||||
|
|
||||||
|
|
||||||
|
def test_PlotItem_maxTraces():
|
||||||
|
item = pg.PlotItem()
|
||||||
|
|
||||||
|
curve1 = pg.PlotDataItem(np.random.normal(size=10))
|
||||||
|
item.addItem(curve1)
|
||||||
|
assert curve1.isVisible(), f"{curve1} should be visible"
|
||||||
|
|
||||||
|
item.ctrl.maxTracesCheck.setChecked(True)
|
||||||
|
item.ctrl.maxTracesSpin.setValue(0)
|
||||||
|
assert not curve1.isVisible(), f"{curve1} should not be visible"
|
||||||
|
|
||||||
|
item.ctrl.maxTracesCheck.setChecked(False)
|
||||||
|
assert curve1.isVisible(), f"{curve1} should be visible"
|
||||||
|
|
||||||
|
|
||||||
def test_plotitem_menu_initialize():
|
def test_plotitem_menu_initialize():
|
||||||
"""Test the menu initialization of the plotitem"""
|
"""Test the menu initialization of the plotitem"""
|
||||||
item = pg.PlotItem()
|
item = pg.PlotItem()
|
||||||
|
Loading…
Reference in New Issue
Block a user