2012-04-30 22:20:27 +00:00
|
|
|
#!/usr/bin/python
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
## Add path to library (just for examples; you do not need this)
|
|
|
|
import sys, os
|
|
|
|
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', '..'))
|
|
|
|
|
|
|
|
|
2012-09-09 23:07:36 +00:00
|
|
|
from pyqtgraph.Qt import QtGui, QtCore, USE_PYSIDE
|
2012-04-30 22:20:27 +00:00
|
|
|
import numpy as np
|
|
|
|
import pyqtgraph as pg
|
|
|
|
from pyqtgraph.ptime import time
|
|
|
|
#QtGui.QApplication.setGraphicsSystem('raster')
|
|
|
|
app = QtGui.QApplication([])
|
|
|
|
#mw = QtGui.QMainWindow()
|
|
|
|
#mw.resize(800,800)
|
2012-09-09 23:07:36 +00:00
|
|
|
if USE_PYSIDE:
|
|
|
|
from ScatterPlotSpeedTestTemplate_pyside import Ui_Form
|
|
|
|
else:
|
|
|
|
from ScatterPlotSpeedTestTemplate_pyqt import Ui_Form
|
2012-04-30 22:20:27 +00:00
|
|
|
|
2012-05-11 03:37:07 +00:00
|
|
|
win = QtGui.QWidget()
|
|
|
|
ui = Ui_Form()
|
|
|
|
ui.setupUi(win)
|
|
|
|
win.show()
|
2012-04-30 22:20:27 +00:00
|
|
|
|
2012-05-11 03:37:07 +00:00
|
|
|
p = ui.plot
|
2012-04-30 22:20:27 +00:00
|
|
|
|
2012-05-11 03:37:07 +00:00
|
|
|
data = np.random.normal(size=(50,500), scale=100)
|
2012-04-30 22:20:27 +00:00
|
|
|
ptr = 0
|
|
|
|
lastTime = time()
|
|
|
|
fps = None
|
|
|
|
def update():
|
|
|
|
global curve, data, ptr, p, lastTime, fps
|
|
|
|
p.clear()
|
2012-05-11 03:37:07 +00:00
|
|
|
curve = pg.ScatterPlotItem(x=data[ptr%10], y=data[(ptr+1)%10], pen='w', brush='b', size=10, pxMode=ui.pixelModeCheck.isChecked())
|
2012-04-30 22:20:27 +00:00
|
|
|
p.addItem(curve)
|
|
|
|
ptr += 1
|
|
|
|
now = time()
|
|
|
|
dt = now - lastTime
|
|
|
|
lastTime = now
|
|
|
|
if fps is None:
|
|
|
|
fps = 1.0/dt
|
|
|
|
else:
|
|
|
|
s = np.clip(dt*3., 0, 1)
|
|
|
|
fps = fps * (1-s) + (1.0/dt) * s
|
|
|
|
p.setTitle('%0.2f fps' % fps)
|
|
|
|
app.processEvents() ## force complete redraw for every plot
|
|
|
|
timer = QtCore.QTimer()
|
|
|
|
timer.timeout.connect(update)
|
|
|
|
timer.start(0)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## Start Qt event loop unless running in interactive mode.
|
|
|
|
if sys.flags.interactive != 1:
|
|
|
|
app.exec_()
|