ROI — pyqtgraph 0.9.8 documentation

### Navigation

- index
- modules |
- next |
- previous |
- pyqtgraph 0.9.8 documentation »
- API Reference »
- Pyqtgraph’s Graphics Items »

# ROI

class `pyqtgraph.` `ROI`(pos, size=Point(1.000000, 1.000000), angle=0.0, invertible=False, maxBounds=None, snapSize=1.0, scaleSnap=False, translateSnap=False, rotateSnap=False, parent=None, pen=None, movable=True, removable=False)

  Generic region-of-interest widget. Can be used for implementing many types of selection box with rotate/translate/scale handles.

  Signals ———————– —————————————————- sigRegionChangeFinished Emitted when the user stops dragging the ROI (or

  > one of its handles) or if the ROI is changed programatically.

  sigRegionChangeStarted Emitted when the user starts dragging the ROI (or
    one of its handles).
  sigRegionChanged Emitted any time the position of the ROI changes,
    including while it is being dragged by the user.

  sigHoverEvent Emitted when the mouse hovers over the ROI. sigClicked Emitted when the user clicks on the ROI.

  > Note that clicking is disabled by default to prevent stealing clicks from objects behind the ROI. To enable clicking, call roi.setAcceptedMouseButtons(QtCore.Qt.LeftButton). See QtGui.QGraphicsItem documentation for more details.

  sigRemoveRequested Emitted when the user selects ‘remove’ from the
    ROI’s context menu (if available).

  ———————– —————————————————-

  `__init__`(pos, size=Point(1.000000, 1.000000), angle=0.0, invertible=False, maxBounds=None, snapSize=1.0, scaleSnap=False, translateSnap=False, rotateSnap=False, parent=None, pen=None, movable=True, removable=False)
  `checkPointMove`(handle, pos, modifiers)

    When handles move, they must ask the ROI if the move is acceptable. By default, this always returns True. Subclasses may wish override.

  `getAffineSliceParams`(data, img, axes=(0, 1))

    Returns the parameters needed to use `affineSlice` to extract a subset of data using this ROI and img to specify the subset.

    See `getArrayRegion` for more information.

  `getArrayRegion`(data, img, axes=(0, 1), returnMappedCoords=False, **kwds)

    Use the position and orientation of this ROI relative to an imageItem to pull a slice from an array.

    This method uses `affineSlice` to generate the slice from data and uses `getAffineSliceParams` to determine the parameters to pass to `affineSlice`.

    If returnMappedCoords is True, then the method returns a tuple (result, coords) such that coords is the set of coordinates used to interpolate values from the original data, mapped into the parent coordinate system of the image. This is useful, when slicing data from images that have been transformed, for determining the location of each value in the sliced data.

    All extra keyword arguments are passed to `affineSlice`.

  `getArraySlice`(data, img, axes=(0, 1), returnSlice=True)

    Return a tuple of slice objects that can be used to slice the region from data covered by this ROI. Also returns the transform which maps the ROI into data coordinates.

    If returnSlice is set to False, the function returns a pair of tuples with the values that would have been used to generate the slice objects. ((ax0Start, ax0Stop), (ax1Start, ax1Stop))

    If the slice can not be computed (usually because the scene/transforms are not properly constructed yet), then the method returns None.

  `getGlobalTransform`(relativeTo=None)

    Return global transformation (rotation angle+translation) required to move from relative state to current state. If relative state isn’t specified, then we use the state of the ROI when mouse is pressed.

  `getLocalHandlePositions`(index=None)

    Returns the position of a handle in ROI coordinates

  `removeHandle`(handle)

    Remove a handle from this ROI. Argument may be either a Handle instance or the integer index of the handle.

  `replaceHandle`(oldHandle, newHandle)

    Replace one handle in the ROI for another. This is useful when connecting multiple ROIs together. oldHandle may be a Handle instance or the index of a handle.

  `saveState`()

    Return the state of the widget in a format suitable for storing to disk. (Points are converted to tuple)

  `scale`(s, center=[0, 0], update=True, finish=True)

    Resize the ROI by scaling relative to center. See setPos() for an explanation of the update and finish arguments.

  `setAngle`(angle, update=True, finish=True)

    Set the angle of rotation (in degrees) for this ROI. See setPos() for an explanation of the update and finish arguments.

  `setPos`(pos, update=True, finish=True)

    Set the position of the ROI (in the parent’s coordinate system). By default, this will cause both sigRegionChanged and sigRegionChangeFinished to be emitted.

    If finish is False, then sigRegionChangeFinished will not be emitted. You can then use stateChangeFinished() to cause the signal to be emitted after a series of state changes.

    If update is False, the state change will be remembered but not processed and no signals will be emitted. You can then use stateChanged() to complete the state change. This allows multiple change functions to be called sequentially while minimizing processing overhead and repeated signals. Setting update=False also forces finish=False.

  `setSize`(size, update=True, finish=True)

    Set the size of the ROI. May be specified as a QPoint, Point, or list of two values. See setPos() for an explanation of the update and finish arguments.

  `stateChanged`(finish=True)

    Process changes to the state of the ROI. If there are any changes, then the positions of handles are updated accordingly and sigRegionChanged is emitted. If finish is True, then sigRegionChangeFinished will also be emitted.

  `translate`(*args, **kargs)

    Move the ROI to a new position. Accepts either (x, y, snap) or ([x,y], snap) as arguments If the ROI is bounded and the move would exceed boundaries, then the ROI is moved to the nearest acceptable position instead.

    snap can be:
      None (default): use self.translateSnap and self.snapSize to determine whether/how to snap False: do not snap Point(w,h) snap to rectangular grid with spacing (w,h) True: snap using self.snapSize (and ignoring self.translateSnap)

    Also accepts update and finish arguments (see setPos() for a description of these).

### Navigation

- index
- modules |
- next |
- previous |
- pyqtgraph 0.9.8 documentation »
- API Reference »
- Pyqtgraph’s Graphics Items »