4d846e2aad
- disabled opengl (performance issues in Qt 4.7) - numerous caching changes (disabled deviceCoordinateCache due to performance issues) - speed up loading large images in ImageView - bugfixes from Ingo Breßler - Transform rotation bugfix - Added debug module - Major performance enhancements for scatterplot, fixed point clicking issues ** API change for scatterplot click signals - Drawing on ImageItem is working well now - PlotItem downsampling no longer uses scipy.signal.resample (this was creating artifacts) - Fixed ViewBox behavior when aspect-locked
68 lines
2.2 KiB
Python
68 lines
2.2 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""
|
|
PlotWidget.py - Convenience class--GraphicsView widget displaying a single PlotItem
|
|
Copyright 2010 Luke Campagnola
|
|
Distributed under MIT/X11 license. See license.txt for more infomation.
|
|
"""
|
|
|
|
from GraphicsView import *
|
|
from PlotItem import *
|
|
import exceptions
|
|
|
|
class PlotWidget(GraphicsView):
|
|
|
|
#sigRangeChanged = QtCore.Signal(object, object) ## already defined in GraphicsView
|
|
|
|
"""Widget implementing a graphicsView with a single PlotItem inside."""
|
|
def __init__(self, parent=None, **kargs):
|
|
GraphicsView.__init__(self, parent)
|
|
self.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding)
|
|
self.enableMouse(False)
|
|
self.plotItem = PlotItem(**kargs)
|
|
self.setCentralItem(self.plotItem)
|
|
## Explicitly wrap methods from plotItem
|
|
for m in ['addItem', 'removeItem', 'autoRange', 'clear', 'setXRange', 'setYRange']:
|
|
setattr(self, m, getattr(self.plotItem, m))
|
|
#QtCore.QObject.connect(self.plotItem, QtCore.SIGNAL('viewChanged'), self.viewChanged)
|
|
self.plotItem.sigRangeChanged.connect(self.viewRangeChanged)
|
|
|
|
#def __dtor__(self):
|
|
##print "Called plotWidget sip destructor"
|
|
#self.quit()
|
|
|
|
|
|
#def quit(self):
|
|
|
|
def close(self):
|
|
self.plotItem.close()
|
|
self.plotItem = None
|
|
#self.scene().clear()
|
|
#self.mPlotItem.close()
|
|
self.setParent(None)
|
|
GraphicsView.close(self)
|
|
|
|
def __getattr__(self, attr): ## implicitly wrap methods from plotItem
|
|
if hasattr(self.plotItem, attr):
|
|
m = getattr(self.plotItem, attr)
|
|
if hasattr(m, '__call__'):
|
|
return m
|
|
raise exceptions.NameError(attr)
|
|
|
|
def viewRangeChanged(self, view, range):
|
|
#self.emit(QtCore.SIGNAL('viewChanged'), *args)
|
|
self.sigRangeChanged.emit(self, range)
|
|
|
|
def widgetGroupInterface(self):
|
|
return (None, PlotWidget.saveState, PlotWidget.restoreState)
|
|
|
|
def saveState(self):
|
|
return self.plotItem.saveState()
|
|
|
|
def restoreState(self, state):
|
|
return self.plotItem.restoreState(state)
|
|
|
|
def getPlotItem(self):
|
|
return self.plotItem
|
|
|
|
|
|
|