hyperspy.drawing._widgets.rectangles module

class hyperspy.drawing._widgets.rectangles.RectangleWidget(axes_manager)

Bases: hyperspy.drawing._widgets.rectangles.SquareWidget, hyperspy.drawing.widget.ResizersMixin

RectangleWidget is a asymmetric, Rectangle-patch based widget, which can be dragged and resized by mouse/keys. For resizing by mouse, it adds a small Rectangle patch on the outer border of the main patch, to serve as resize handles. This feature can be enabled/disabled by the ‘resizers’ property, and the size/color of the handles are set by ‘resize_color’/’resize_pixel_size’.

For optimized changes of geometry, the class implements two methods ‘set_bounds’ and ‘set_ibounds’, to set the geomtry of the rectangle by value and index space coordinates, respectivly. It also adds the ‘width’ and ‘height’ properties for verbosity.

For keyboard resizing, ‘x’/’c’ and ‘y’/’u’ will increase/decrease the size of the rectangle along the first and the second axis, respectively.

Implements the internal method _validate_geometry to make sure the patch will always stay within bounds.

height
on_key_press(event)
set_bounds(*args, **kwargs)

Set bounds by values. Bounds can either be specified in order left, bottom, width, height; or by keywords:

  • ‘bounds’: tuple (left, top, width, height)

OR * ‘x’/’left’ * ‘y’/’top’ * ‘w’/’width’, alternatively ‘right’ (x+w) * ‘h’/’height’, alternatively ‘bottom’ (y+h)

If specifying with keywords, any unspecified dimensions will be kept constant (note: width/height will be kept, not right/bottom).

set_ibounds(*args, **kwargs)

Set bounds by indices. Bounds can either be specified in order left, bottom, width, height; or by keywords:

  • ‘bounds’: tuple (left, top, width, height)

OR * ‘x’/’left’ * ‘y’/’top’ * ‘w’/’width’, alternatively ‘right’ * ‘h’/’height’, alternatively ‘bottom’

If specifying with keywords, any unspecified dimensions will be kept constant (note: width/height will be kept, not right/bottom).

width
class hyperspy.drawing._widgets.rectangles.SquareWidget(axes_manager)

Bases: hyperspy.drawing.widget.Widget2DBase

SquareWidget is a symmetric, Rectangle-patch based widget, which can be dragged, and resized by keystrokes/code. As the widget is normally only meant to indicate position, the sizing is deemed purely visual, but there is nothing that forces this use. However, it should be noted that the outer bounds only correspond to pure indices for odd sizes.