Updated ImageView and ViewBox documentation
This commit is contained in:
parent
7b862f4f87
commit
1729416914
@ -74,12 +74,11 @@ class ViewBox(GraphicsWidget):
|
|||||||
|
|
||||||
Features:
|
Features:
|
||||||
|
|
||||||
- Scaling contents by mouse or auto-scale when contents change
|
* Scaling contents by mouse or auto-scale when contents change
|
||||||
- View linking--multiple views display the same data ranges
|
* View linking--multiple views display the same data ranges
|
||||||
- Configurable by context menu
|
* Configurable by context menu
|
||||||
- Item coordinate mapping methods
|
* Item coordinate mapping methods
|
||||||
|
|
||||||
Not really compatible with GraphicsView having the same functionality.
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
sigYRangeChanged = QtCore.Signal(object, object)
|
sigYRangeChanged = QtCore.Signal(object, object)
|
||||||
@ -116,11 +115,15 @@ class ViewBox(GraphicsWidget):
|
|||||||
*enableMouse* (bool) Whether mouse can be used to scale/pan the view
|
*enableMouse* (bool) Whether mouse can be used to scale/pan the view
|
||||||
*invertY* (bool) See :func:`invertY <pyqtgraph.ViewBox.invertY>`
|
*invertY* (bool) See :func:`invertY <pyqtgraph.ViewBox.invertY>`
|
||||||
*invertX* (bool) See :func:`invertX <pyqtgraph.ViewBox.invertX>`
|
*invertX* (bool) See :func:`invertX <pyqtgraph.ViewBox.invertX>`
|
||||||
|
*enableMenu* (bool) Whether to display a context menu when
|
||||||
|
right-clicking on the ViewBox background.
|
||||||
|
*name* (str) Used to register this ViewBox so that it appears
|
||||||
|
in the "Link axis" dropdown inside other ViewBox
|
||||||
|
context menus. This allows the user to manually link
|
||||||
|
the axes of any other view to this one.
|
||||||
============== =============================================================
|
============== =============================================================
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
GraphicsWidget.__init__(self, parent)
|
GraphicsWidget.__init__(self, parent)
|
||||||
self.name = None
|
self.name = None
|
||||||
self.linksBlocked = False
|
self.linksBlocked = False
|
||||||
@ -220,7 +223,11 @@ class ViewBox(GraphicsWidget):
|
|||||||
def register(self, name):
|
def register(self, name):
|
||||||
"""
|
"""
|
||||||
Add this ViewBox to the registered list of views.
|
Add this ViewBox to the registered list of views.
|
||||||
*name* will appear in the drop-down lists for axis linking in all other views.
|
|
||||||
|
This allows users to manually link the axes of any other ViewBox to
|
||||||
|
this one. The specified *name* will appear in the drop-down lists for
|
||||||
|
axis linking in the context menus of all other views.
|
||||||
|
|
||||||
The same can be accomplished by initializing the ViewBox with the *name* attribute.
|
The same can be accomplished by initializing the ViewBox with the *name* attribute.
|
||||||
"""
|
"""
|
||||||
ViewBox.AllViews[self] = None
|
ViewBox.AllViews[self] = None
|
||||||
|
@ -12,8 +12,10 @@ Widget used for displaying 2D or 3D data. Features:
|
|||||||
- ROI plotting
|
- ROI plotting
|
||||||
- Image normalization through a variety of methods
|
- Image normalization through a variety of methods
|
||||||
"""
|
"""
|
||||||
from ..Qt import QtCore, QtGui, USE_PYSIDE
|
import sys
|
||||||
|
import numpy as np
|
||||||
|
|
||||||
|
from ..Qt import QtCore, QtGui, USE_PYSIDE
|
||||||
if USE_PYSIDE:
|
if USE_PYSIDE:
|
||||||
from .ImageViewTemplate_pyside import *
|
from .ImageViewTemplate_pyside import *
|
||||||
else:
|
else:
|
||||||
@ -24,13 +26,8 @@ from ..graphicsItems.ROI import *
|
|||||||
from ..graphicsItems.LinearRegionItem import *
|
from ..graphicsItems.LinearRegionItem import *
|
||||||
from ..graphicsItems.InfiniteLine import *
|
from ..graphicsItems.InfiniteLine import *
|
||||||
from ..graphicsItems.ViewBox import *
|
from ..graphicsItems.ViewBox import *
|
||||||
#from widgets import ROI
|
|
||||||
import sys
|
|
||||||
#from numpy import ndarray
|
|
||||||
from .. import ptime as ptime
|
from .. import ptime as ptime
|
||||||
import numpy as np
|
|
||||||
from .. import debug as debug
|
from .. import debug as debug
|
||||||
|
|
||||||
from ..SignalProxy import SignalProxy
|
from ..SignalProxy import SignalProxy
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -38,12 +35,6 @@ try:
|
|||||||
except ImportError:
|
except ImportError:
|
||||||
from numpy import nanmin, nanmax
|
from numpy import nanmin, nanmax
|
||||||
|
|
||||||
#try:
|
|
||||||
#from .. import metaarray as metaarray
|
|
||||||
#HAVE_METAARRAY = True
|
|
||||||
#except:
|
|
||||||
#HAVE_METAARRAY = False
|
|
||||||
|
|
||||||
|
|
||||||
class PlotROI(ROI):
|
class PlotROI(ROI):
|
||||||
def __init__(self, size):
|
def __init__(self, size):
|
||||||
@ -72,6 +63,16 @@ class ImageView(QtGui.QWidget):
|
|||||||
imv = pg.ImageView()
|
imv = pg.ImageView()
|
||||||
imv.show()
|
imv.show()
|
||||||
imv.setImage(data)
|
imv.setImage(data)
|
||||||
|
|
||||||
|
**Keyboard interaction**
|
||||||
|
|
||||||
|
* left/right arrows step forward/backward 1 frame when pressed,
|
||||||
|
seek at 20fps when held.
|
||||||
|
* up/down arrows seek at 100fps
|
||||||
|
* pgup/pgdn seek at 1000fps
|
||||||
|
* home/end seek immediately to the first/last frame
|
||||||
|
* space begins playing frames. If time values (in seconds) are given
|
||||||
|
for each frame, then playback is in realtime.
|
||||||
"""
|
"""
|
||||||
sigTimeChanged = QtCore.Signal(object, object)
|
sigTimeChanged = QtCore.Signal(object, object)
|
||||||
sigProcessingChanged = QtCore.Signal(object)
|
sigProcessingChanged = QtCore.Signal(object)
|
||||||
@ -79,8 +80,31 @@ class ImageView(QtGui.QWidget):
|
|||||||
def __init__(self, parent=None, name="ImageView", view=None, imageItem=None, *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
|
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
|
and a :class:`ViewBox <pyqtgraph.ViewBox>` to contain the ImageItem.
|
||||||
by specifying the *view* and/or *imageItem* arguments.
|
|
||||||
|
============= =========================================================
|
||||||
|
**Arguments**
|
||||||
|
parent (QWidget) Specifies the parent widget to which
|
||||||
|
this ImageView will belong. If None, then the ImageView
|
||||||
|
is created with no parent.
|
||||||
|
name (str) The name used to register both the internal ViewBox
|
||||||
|
and the PlotItem used to display ROI data. See the *name*
|
||||||
|
argument to :func:`ViewBox.__init__()
|
||||||
|
<pyqtgraph.ViewBox.__init__>`.
|
||||||
|
view (ViewBox or PlotItem) If specified, this will be used
|
||||||
|
as the display area that contains the displayed image.
|
||||||
|
Any :class:`ViewBox <pyqtgraph.ViewBox>`,
|
||||||
|
:class:`PlotItem <pyqtgraph.PlotItem>`, or other
|
||||||
|
compatible object is acceptable.
|
||||||
|
imageItem (ImageItem) If specified, this object will be used to
|
||||||
|
display the image. Must be an instance of ImageItem
|
||||||
|
or other compatible object.
|
||||||
|
============= =========================================================
|
||||||
|
|
||||||
|
Note: to display axis ticks inside the ImageView, instantiate it
|
||||||
|
with a PlotItem instance as its view::
|
||||||
|
|
||||||
|
pg.ImageView(view=pg.PlotItem())
|
||||||
"""
|
"""
|
||||||
QtGui.QWidget.__init__(self, parent, *args)
|
QtGui.QWidget.__init__(self, parent, *args)
|
||||||
self.levelMax = 4096
|
self.levelMax = 4096
|
||||||
@ -165,6 +189,7 @@ class ImageView(QtGui.QWidget):
|
|||||||
self.normRoi.sigRegionChangeFinished.connect(self.updateNorm)
|
self.normRoi.sigRegionChangeFinished.connect(self.updateNorm)
|
||||||
|
|
||||||
self.ui.roiPlot.registerPlot(self.name + '_ROI')
|
self.ui.roiPlot.registerPlot(self.name + '_ROI')
|
||||||
|
self.view.register(self.name)
|
||||||
|
|
||||||
self.noRepeatKeys = [QtCore.Qt.Key_Right, QtCore.Qt.Key_Left, QtCore.Qt.Key_Up, QtCore.Qt.Key_Down, QtCore.Qt.Key_PageUp, QtCore.Qt.Key_PageDown]
|
self.noRepeatKeys = [QtCore.Qt.Key_Right, QtCore.Qt.Key_Left, QtCore.Qt.Key_Up, QtCore.Qt.Key_Down, QtCore.Qt.Key_PageUp, QtCore.Qt.Key_PageDown]
|
||||||
|
|
||||||
@ -318,7 +343,7 @@ class ImageView(QtGui.QWidget):
|
|||||||
self.ui.histogram.setLevels(min, max)
|
self.ui.histogram.setLevels(min, max)
|
||||||
|
|
||||||
def autoRange(self):
|
def autoRange(self):
|
||||||
"""Auto scale and pan the view around the image."""
|
"""Auto scale and pan the view around the image such that the image fills the view."""
|
||||||
image = self.getProcessedImage()
|
image = self.getProcessedImage()
|
||||||
self.view.autoRange()
|
self.view.autoRange()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user