Skip to main content

roi_from_draw

Function roi_from_draw 

Source
pub fn roi_from_draw(kind: RoiDrawKind, params: &DrawParams) -> Option<Roi>
Expand description

Build the Roi from a finished draw’s DrawParams, the setFirstShapePoints equivalent per ROI class (items/roi.py, items/_arc_roi.py, items/_band_roi.py). Returns None for a (kind, params) pair that roi_draw_mode can never produce together (e.g. an HLine/VLine/FreeHand params for any ROI kind), so an unexpected pairing is dropped rather than mis-built.

Geometry per kind (each silx default cited inline):

  • Rect <- Rectangle{x,y,w,h} (silx _setBound, items/roi.py:558).
  • Line <- Line endpoints (silx setEndPoints, items/roi.py:254).
  • Polygon <- Polygon vertices (silx setPoints, items/roi.py:1236).
  • Point/Cross <- Point (silx setPosition(points[0]), items/roi.py:89/:176).
  • Circle <- Line: center = start, radius = |end - start| (silx CircleROI._setRay, items/roi.py:782).
  • Ellipse <- Ellipse{center, semi_axes}: radii = semi_axes (the silx SelectEllipse interaction; see roi_draw_mode).
  • HRange <- Line: y = (min, max) of the two endpoint Ys (the band over a Y range; silx HorizontalRangeROI.setFirstShapePoints is the X analogue, items/roi.py:1420).
  • VRange <- Line: x = (min, max) of the two endpoint Xs (silx HorizontalRangeROI.setFirstShapePoints, items/roi.py:1420).
  • Arc <- Line: the faithful silx default arc from the 2 diameter points (silx ArcROI.setFirstShapePoints + _createGeometryFromControlPoints, items/_arc_roi.py:363/:622); see arc_from_two_points.
  • Band <- Line: begin = start, end = end, width = 0.1 * |end - begin| (silx BandGeometry.create default width, items/_band_roi.py:64-66).