ImageView can now be initialized with custom view and image objects
This commit is contained in:
parent
e4e3a636f3
commit
b88f0a22a2
@ -73,6 +73,7 @@ class PlotItem(GraphicsWidget):
|
||||
:func:`enableAutoRange <pyqtgraph.ViewBox.enableAutoRange>`,
|
||||
:func:`disableAutoRange <pyqtgraph.ViewBox.disableAutoRange>`,
|
||||
:func:`setAspectLocked <pyqtgraph.ViewBox.setAspectLocked>`,
|
||||
:func:`invertY <pyqtgraph.ViewBox.invertY>`,
|
||||
:func:`register <pyqtgraph.ViewBox.register>`,
|
||||
:func:`unregister <pyqtgraph.ViewBox.unregister>`
|
||||
|
||||
@ -188,7 +189,7 @@ class PlotItem(GraphicsWidget):
|
||||
for m in [
|
||||
'setXRange', 'setYRange', 'setXLink', 'setYLink', 'setAutoPan', 'setAutoVisible',
|
||||
'setRange', 'autoRange', 'viewRect', 'viewRange', 'setMouseEnabled',
|
||||
'enableAutoRange', 'disableAutoRange', 'setAspectLocked',
|
||||
'enableAutoRange', 'disableAutoRange', 'setAspectLocked', 'invertY',
|
||||
'register', 'unregister']: ## NOTE: If you update this list, please update the class docstring as well.
|
||||
setattr(self, m, getattr(self.vb, m))
|
||||
|
||||
|
@ -67,7 +67,12 @@ class ImageView(QtGui.QWidget):
|
||||
sigTimeChanged = QtCore.Signal(object, object)
|
||||
sigProcessingChanged = QtCore.Signal(object)
|
||||
|
||||
def __init__(self, parent=None, name="ImageView", *args):
|
||||
def __init__(self, parent=None, name="ImageView", view=None, imageItem=None, *args):
|
||||
"""
|
||||
By default, this class creates an :class:`ImageItem <pyqtgraph.ImageItem>` to display image data
|
||||
and a :class:`ViewBox <pyqtgraph.ViewBox>` to contain the ImageItem. Custom items may be given instead
|
||||
by specifying the *view* and/or *imageItem* arguments.
|
||||
"""
|
||||
QtGui.QWidget.__init__(self, parent, *args)
|
||||
self.levelMax = 4096
|
||||
self.levelMin = 0
|
||||
@ -89,7 +94,10 @@ class ImageView(QtGui.QWidget):
|
||||
#self.ui.graphicsView.setAspectLocked(True)
|
||||
#self.ui.graphicsView.invertY()
|
||||
#self.ui.graphicsView.enableMouse()
|
||||
self.view = ViewBox()
|
||||
if view is None:
|
||||
self.view = ViewBox()
|
||||
else:
|
||||
self.view = view
|
||||
self.ui.graphicsView.setCentralItem(self.view)
|
||||
self.view.setAspectLocked(True)
|
||||
self.view.invertY()
|
||||
@ -101,7 +109,10 @@ class ImageView(QtGui.QWidget):
|
||||
#self.ui.gradientWidget.setTickColor(self.ticks[1], QtGui.QColor(255,255,255))
|
||||
#self.ui.gradientWidget.setOrientation('right')
|
||||
|
||||
self.imageItem = ImageItem()
|
||||
if imageItem is None:
|
||||
self.imageItem = ImageItem()
|
||||
else:
|
||||
self.imageItem = imageItem
|
||||
self.view.addItem(self.imageItem)
|
||||
self.currentIndex = 0
|
||||
|
||||
@ -668,4 +679,10 @@ class ImageView(QtGui.QWidget):
|
||||
#return self.levelMin + (self.levelMax-self.levelMin) * self.ui.gradientWidget.tickValue(self.ticks[0])
|
||||
##return self.levelMin + ((self.levelMax-self.levelMin) / self.ui.blackSlider.maximum()) * self.ui.blackSlider.value()
|
||||
|
||||
|
||||
def getView(self):
|
||||
"""Return the ViewBox (or other compatible object) which displays the ImageItem"""
|
||||
return self.view
|
||||
|
||||
def getImageItem(self):
|
||||
"""Return the ImageItem for this ImageView."""
|
||||
return self.imageItem
|
Loading…
Reference in New Issue
Block a user