ScatterPlotSpeedTest: add toggle for drawPixmapFragments

This commit is contained in:
KIU Shueng Chuan 2021-06-11 09:46:37 +08:00
parent 380ec2e0b2
commit ad3e3a6b8b

View File

@ -24,6 +24,7 @@ param = ptree.Parameter.create(name=translate('ScatterPlot', 'Parameters'), type
dict(name='count', title=translate('ScatterPlot', 'Count: '), type='int', limits=[1, None], value=500, step=100), dict(name='count', title=translate('ScatterPlot', 'Count: '), type='int', limits=[1, None], value=500, step=100),
dict(name='size', title=translate('ScatterPlot', 'Size: '), type='int', limits=[1, None], value=10), dict(name='size', title=translate('ScatterPlot', 'Size: '), type='int', limits=[1, None], value=10),
dict(name='randomize', title=translate('ScatterPlot', 'Randomize: '), type='bool', value=False), dict(name='randomize', title=translate('ScatterPlot', 'Randomize: '), type='bool', value=False),
dict(name='_USE_PXFRAGS', title='_USE_PXFRAGS: ', type='bool', value=pyqtgraph.graphicsItems.ScatterPlotItem._USE_PXFRAGS),
dict(name='_USE_QRECT', title='_USE_QRECT: ', type='bool', value=pyqtgraph.graphicsItems.ScatterPlotItem._USE_QRECT), dict(name='_USE_QRECT', title='_USE_QRECT: ', type='bool', value=pyqtgraph.graphicsItems.ScatterPlotItem._USE_QRECT),
dict(name='pxMode', title='pxMode: ', type='bool', value=True), dict(name='pxMode', title='pxMode: ', type='bool', value=True),
dict(name='useCache', title='useCache: ', type='bool', value=True), dict(name='useCache', title='useCache: ', type='bool', value=True),
@ -68,6 +69,7 @@ def mkDataAndItem():
def mkItem(): def mkItem():
global item global item
pyqtgraph.graphicsItems.ScatterPlotItem._USE_PXFRAGS = param['_USE_PXFRAGS']
pyqtgraph.graphicsItems.ScatterPlotItem._USE_QRECT = param['_USE_QRECT'] pyqtgraph.graphicsItems.ScatterPlotItem._USE_QRECT = param['_USE_QRECT']
item = pg.ScatterPlotItem(pxMode=param['pxMode'], **getData()) item = pg.ScatterPlotItem(pxMode=param['pxMode'], **getData())
item.opts['useCache'] = param['useCache'] item.opts['useCache'] = param['useCache']
@ -122,7 +124,7 @@ def update():
mkDataAndItem() mkDataAndItem()
for name in ['count', 'size']: for name in ['count', 'size']:
param.child(name).sigValueChanged.connect(mkDataAndItem) param.child(name).sigValueChanged.connect(mkDataAndItem)
for name in ['_USE_QRECT', 'useCache', 'pxMode', 'randomize']: for name in ['_USE_PXFRAGS', '_USE_QRECT', 'useCache', 'pxMode', 'randomize']:
param.child(name).sigValueChanged.connect(mkItem) param.child(name).sigValueChanged.connect(mkItem)
param.child('paused').sigValueChanged.connect(lambda _, v: timer.stop() if v else timer.start()) param.child('paused').sigValueChanged.connect(lambda _, v: timer.stop() if v else timer.start())
timer.timeout.connect(update) timer.timeout.connect(update)