Removed some debugging code, moved examples
This commit is contained in:
parent
3d84aefbc4
commit
11897061d1
@ -234,11 +234,11 @@ class GraphicsView(QtGui.QGraphicsView):
|
||||
|
||||
def mousePressEvent(self, ev):
|
||||
QtGui.QGraphicsView.mousePressEvent(self, ev)
|
||||
print "Press over:"
|
||||
for i in self.items(ev.pos()):
|
||||
print i.zValue(), int(i.acceptedMouseButtons()), i, i.scenePos()
|
||||
print "Event accepted:", ev.isAccepted()
|
||||
print "Grabber:", self.scene().mouseGrabberItem()
|
||||
#print "Press over:"
|
||||
#for i in self.items(ev.pos()):
|
||||
#print i.zValue(), int(i.acceptedMouseButtons()), i, i.scenePos()
|
||||
#print "Event accepted:", ev.isAccepted()
|
||||
#print "Grabber:", self.scene().mouseGrabberItem()
|
||||
if not self.mouseEnabled:
|
||||
return
|
||||
self.lastMousePos = Point(ev.pos())
|
||||
|
@ -13,7 +13,7 @@ try:
|
||||
from metaarray import *
|
||||
HAVE_METAARRAY = True
|
||||
except:
|
||||
raise
|
||||
#raise
|
||||
HAVE_METAARRAY = False
|
||||
|
||||
|
||||
|
49
examples/test_ImageItem.py
Normal file
49
examples/test_ImageItem.py
Normal file
@ -0,0 +1,49 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
## Add path to library (just for examples; you do not need this)
|
||||
import sys, os
|
||||
sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..'))
|
||||
|
||||
from pyqtgraph.GraphicsView import *
|
||||
from pyqtgraph.graphicsItems import *
|
||||
from numpy import random
|
||||
from PyQt4 import QtCore, QtGui
|
||||
from scipy.ndimage import *
|
||||
|
||||
app = QtGui.QApplication([])
|
||||
|
||||
## Create window with GraphicsView widget
|
||||
win = QtGui.QMainWindow()
|
||||
view = GraphicsView()
|
||||
win.setCentralWidget(view)
|
||||
win.show()
|
||||
|
||||
## Allow mouse scale/pan
|
||||
view.enableMouse()
|
||||
|
||||
## ..But lock the aspect ratio
|
||||
view.setAspectLocked(True)
|
||||
|
||||
## Create image item
|
||||
img = ImageItem()
|
||||
view.scene().addItem(img)
|
||||
|
||||
## Set initial view bounds
|
||||
view.setRange(QtCore.QRectF(0, 0, 200, 200))
|
||||
|
||||
def updateData():
|
||||
global img
|
||||
## Create random image
|
||||
data = random.random((200, 200))
|
||||
|
||||
## Display the data
|
||||
img.updateImage(data)
|
||||
|
||||
|
||||
# update image data every 20ms (or so)
|
||||
t = QtCore.QTimer()
|
||||
QtCore.QObject.connect(t, QtCore.SIGNAL('timeout()'), updateData)
|
||||
t.start(20)
|
||||
|
||||
|
||||
|
||||
app.exec_()
|
@ -1,21 +1,30 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
## Add path to library (just for examples; you do not need this)
|
||||
import sys, os
|
||||
sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..'))
|
||||
|
||||
from ImageView import *
|
||||
from pyqtgraph.ImageView import *
|
||||
from numpy import random
|
||||
from PyQt4 import QtCore, QtGui
|
||||
from scipy.ndimage import *
|
||||
|
||||
app = QtGui.QApplication([])
|
||||
|
||||
## Create window with ImageView widget
|
||||
win = QtGui.QMainWindow()
|
||||
imv = ImageView()
|
||||
win.setCentralWidget(imv)
|
||||
win.show()
|
||||
|
||||
## Create random 3D data set
|
||||
img = gaussian_filter(random.random((200, 200)), (5, 5)) * 5
|
||||
data = random.random((100, 200, 200))
|
||||
data += img
|
||||
|
||||
for i in range(data.shape[0]):
|
||||
data[i] += exp(-(2.*i)/data.shape[0])
|
||||
data += 10
|
||||
imv.setImage(data)
|
||||
|
||||
## Display the data
|
||||
imv.setImage(data)
|
||||
|
||||
app.exec_()
|
@ -1,12 +1,19 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
## Add path to library (just for examples; you do not need this)
|
||||
import sys, os
|
||||
sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..'))
|
||||
|
||||
from scipy import random
|
||||
from numpy import linspace
|
||||
from PyQt4 import QtGui, QtCore
|
||||
from MultiPlotWidget import *
|
||||
from metaarray import *
|
||||
|
||||
from pyqtgraph.MultiPlotWidget import *
|
||||
try:
|
||||
from metaarray import *
|
||||
except:
|
||||
print "MultiPlot is only used with MetaArray for now (and you do not have the metaarray module)"
|
||||
exit()
|
||||
|
||||
app = QtGui.QApplication([])
|
||||
mw = QtGui.QMainWindow()
|
||||
pw = MultiPlotWidget()
|
||||
@ -15,3 +22,5 @@ mw.show()
|
||||
|
||||
ma = MetaArray(random.random((3, 1000)), info=[{'name': 'Signal', 'cols': [{'name': 'Col1'}, {'name': 'Col2'}, {'name': 'Col3'}]}, {'name': 'Time', 'vals': linspace(0., 1., 1000)}])
|
||||
pw.plot(ma)
|
||||
|
||||
app.exec_()
|
@ -1,10 +1,13 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
## Add path to library (just for examples; you do not need this)
|
||||
import sys, os
|
||||
sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..'))
|
||||
|
||||
from scipy import random
|
||||
from PyQt4 import QtGui, QtCore
|
||||
from PlotWidget import *
|
||||
from graphicsItems import *
|
||||
from pyqtgraph.PlotWidget import *
|
||||
from pyqtgraph.graphicsItems import *
|
||||
|
||||
|
||||
app = QtGui.QApplication([])
|
||||
@ -77,4 +80,4 @@ for i in range(0, 5):
|
||||
yd, xd = rand(10000)
|
||||
pw2.plot(yd*(j+1), xd, params={'iter': i, 'val': j})
|
||||
|
||||
#app.exec_()
|
||||
app.exec_()
|
@ -1,13 +1,17 @@
|
||||
#!/usr/bin/python -i
|
||||
# -*- coding: utf-8 -*-
|
||||
## Add path to library (just for examples; you do not need this)
|
||||
import sys, os
|
||||
sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..'))
|
||||
|
||||
from scipy import zeros
|
||||
from graphicsWindows import *
|
||||
from graphicsItems import *
|
||||
from widgets import *
|
||||
from PlotWidget import *
|
||||
from pyqtgraph.graphicsWindows import *
|
||||
from pyqtgraph.graphicsItems import *
|
||||
from pyqtgraph.widgets import *
|
||||
from pyqtgraph.PlotWidget import *
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
qapp = QtGui.QApplication([])
|
||||
app = QtGui.QApplication([])
|
||||
|
||||
#i = PlotWindow(array([0,1,2,1,2]), parent=None, title='')
|
||||
|
||||
@ -85,4 +89,5 @@ mlroi.connect(QtCore.SIGNAL('regionChanged'), lambda: updateImg(mlroi))
|
||||
|
||||
v.setRange(QtCore.QRect(-2, -2, 220, 220))
|
||||
|
||||
w.show()
|
||||
w.show()
|
||||
app.exec_()
|
@ -1,11 +1,13 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
## Add path to library (just for examples; you do not need this)
|
||||
import sys, os
|
||||
sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..'))
|
||||
|
||||
from scipy import random
|
||||
from PyQt4 import QtGui, QtCore
|
||||
from GraphicsView import *
|
||||
from graphicsItems import *
|
||||
|
||||
from pyqtgraph.GraphicsView import *
|
||||
from pyqtgraph.graphicsItems import *
|
||||
|
||||
app = QtGui.QApplication([])
|
||||
mw = QtGui.QMainWindow()
|
||||
@ -19,7 +21,6 @@ mw.resize(800, 600)
|
||||
|
||||
gv = GraphicsView(cw)
|
||||
gv.enableMouse(False)
|
||||
#w1 = QtGui.QGraphicsWidget()
|
||||
l = QtGui.QGraphicsGridLayout()
|
||||
l.setHorizontalSpacing(0)
|
||||
l.setVerticalSpacing(0)
|
||||
@ -27,46 +28,23 @@ l.setVerticalSpacing(0)
|
||||
|
||||
vb = ViewBox()
|
||||
p1 = PlotCurveItem()
|
||||
#gv.scene().addItem(vb)
|
||||
vb.addItem(p1)
|
||||
vl.addWidget(gv)
|
||||
rect = QtGui.QGraphicsRectItem(QtCore.QRectF(0, 0, 1, 1))
|
||||
rect.setPen(QtGui.QPen(QtGui.QColor(100, 200, 100)))
|
||||
vb.addItem(rect)
|
||||
|
||||
l.addItem(vb, 0, 2)
|
||||
l.addItem(vb, 0, 1)
|
||||
gv.centralWidget.setLayout(l)
|
||||
|
||||
|
||||
xScale = ScaleItem(orientation='bottom', linkView=vb)
|
||||
l.addItem(xScale, 1, 2)
|
||||
l.addItem(xScale, 1, 1)
|
||||
yScale = ScaleItem(orientation='left', linkView=vb)
|
||||
l.addItem(yScale, 0, 1)
|
||||
l.addItem(yScale, 0, 0)
|
||||
|
||||
xLabel = LabelItem(u"<span style='color: #ff0000; font-weight: bold'>X</span> <i>Axis</i> <span style='font-size: 6pt'>(μV)</span>", html=True, color='CCC')
|
||||
l.setRowFixedHeight(2, 20)
|
||||
l.setRowFixedHeight(1, 40)
|
||||
l.addItem(xLabel, 2, 2)
|
||||
yLabel = LabelItem("Y Axis", color=QtGui.QColor(200, 200, 200))
|
||||
yLabel.setAngle(90)
|
||||
l.setColumnFixedWidth(0, 20)
|
||||
l.setColumnFixedWidth(1, 60)
|
||||
l.addItem(yLabel, 0, 0)
|
||||
|
||||
|
||||
#grid = GridItem(gv)
|
||||
#vb.addItem(grid)
|
||||
|
||||
#gv.scene().addItem(w1)
|
||||
#w1.setGeometry(0, 0, 1, 1)
|
||||
|
||||
|
||||
#c1 = Qwt.QwtPlotCurve()
|
||||
#c1.setData(range(len(data)), data)
|
||||
#c1.attach(p1)
|
||||
#c2 = PlotCurve()
|
||||
#c2.setData([1,2,3,4,5,6,7,8], [1,2,10,4,3,2,4,1])
|
||||
#c2.attach(p2)
|
||||
xScale.setLabel(text=u"<span style='color: #ff0000; font-weight: bold'>X</span> <i>Axis</i>", units="s")
|
||||
yScale.setLabel('Y Axis', units='V')
|
||||
|
||||
def rand(n):
|
||||
data = random.random(n)
|
||||
@ -74,23 +52,14 @@ def rand(n):
|
||||
data[int(n*0.18)] += 2
|
||||
data[int(n*0.1):int(n*0.13)] *= 5
|
||||
data[int(n*0.18)] *= 20
|
||||
#c1.setData(range(len(data)), data)
|
||||
return data, arange(n, n+len(data)) / float(n)
|
||||
|
||||
|
||||
def updateData():
|
||||
yd, xd = rand(10000)
|
||||
p1.updateData(yd, x=xd)
|
||||
|
||||
#vb.setRange(p1.boundingRect())
|
||||
#p1.plot(yd, x=xd, clear=True)
|
||||
|
||||
yd, xd = rand(10000)
|
||||
#p2.plot(yd * 1000, x=xd)
|
||||
#for i in [1,2]:
|
||||
#for j in range(3):
|
||||
#yd, xd = rand(1000)
|
||||
#p3.plot(yd * 100000 * i, x=xd, params={'repetitions': j, 'scale': i})
|
||||
updateData()
|
||||
vb.autoRange()
|
||||
|
||||
@ -98,3 +67,4 @@ t = QtCore.QTimer()
|
||||
QtCore.QObject.connect(t, QtCore.SIGNAL('timeout()'), updateData)
|
||||
t.start(50)
|
||||
|
||||
app.exec_()
|
@ -631,14 +631,14 @@ class Handle(QtGui.QGraphicsItem):
|
||||
return self.bounds
|
||||
|
||||
def mousePressEvent(self, ev):
|
||||
print "handle press"
|
||||
#print "handle press"
|
||||
if ev.button() != QtCore.Qt.LeftButton:
|
||||
ev.ignore()
|
||||
return
|
||||
self.cursorOffset = self.scenePos() - ev.scenePos()
|
||||
for r in self.roi:
|
||||
r[0].pointPressEvent(r[1], ev)
|
||||
print " accepted."
|
||||
#print " accepted."
|
||||
ev.accept()
|
||||
|
||||
def mouseReleaseEvent(self, ev):
|
||||
|
Loading…
Reference in New Issue
Block a user