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.
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.
———————– —————————————————-
When handles move, they must ask the ROI if the move is acceptable. By default, this always returns True. Subclasses may wish override.
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.
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.
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.
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.
Returns the position of a handle in ROI coordinates
Remove a handle from this ROI. Argument may be either a Handle instance or the integer index of the handle.
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.
Return the state of the widget in a format suitable for storing to disk. (Points are converted to tuple)
Resize the ROI by scaling relative to center. See setPos() for an explanation of the update and finish arguments.
Set the angle of rotation (in degrees) for this ROI. See setPos() for an explanation of the update and finish arguments.
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.
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.
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.
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.
Also accepts update and finish arguments (see setPos() for a description of these).