RoiModeBase

class glue.viewers.common.qt.mouse_mode.RoiModeBase(viewer, **kwargs)[source]

Bases: glue.viewers.common.qt.mouse_mode.MouseMode

Base class for defining ROIs. ROIs accessible via the roi() method

See RoiMode and ClickRoiMode subclasses for interaction details

An roi_callback function can be provided. When ROIs are finalized (i.e. fully defined), this function will be called with the RoiMode object as the argument. Clients can use RoiMode.roi() to retrieve the new ROI, and take the appropriate action. By default, roi_callback will default to calling an apply_roi method on the data viewer.

Parameters:

roi_callback : func

Function that will be called when the ROI is finished being defined.

Attributes Summary

action_text
enabled A property that callback functions can be added to.
icon
persistent
shortcut
status_tip
tool_id
tool_tip

Methods Summary

activate()
clear()
close(*args)
deactivate() Fired when the toolbar button is deactivated
key(event) Handles key press events.
menu_actions() List of QtWidgets.QActions to be attached to this tool as a context menu.
move(event) Handles mouse move events.
press(event) Handles mouse presses.
release(event) Handles mouse release events.
roi() The ROI defined by this mouse mode

Attributes Documentation

action_text = None
enabled

A property that callback functions can be added to.

When a callback property changes value, each callback function is called with information about the state change. Otherwise, callback properties behave just like normal instance variables.

CallbackProperties must be defined at the class level. Use the helper function add_callback() to attach a callback to a specific instance of a class with CallbackProperties

Parameters:

default

The initial value for the property

docstring : str

The docstring for the property

getter, setter : func

Custom getter and setter functions (advanced)

icon = None
persistent = False
shortcut = None
status_tip = None
tool_id = None
tool_tip = None

Methods Documentation

activate()[source]
clear()[source]
close(*args)[source]
deactivate()

Fired when the toolbar button is deactivated

key(event)

Handles key press events.

Calls key_callback method.

Parameters:

event : KeyEvent

The event that was triggered

menu_actions()

List of QtWidgets.QActions to be attached to this tool as a context menu.

move(event)

Handles mouse move events.

Logs mouse position and calls move_callback method.

Parameters:

event : MouseEvent

The event that was triggered

press(event)

Handles mouse presses.

Logs mouse position and calls press_callback method.

Parameters:

event : MouseEvent

The event that was triggered

release(event)

Handles mouse release events.

Logs mouse position and calls release_callback method.

Parameters:

event : MouseEvent

The event that was triggered

roi()[source]

The ROI defined by this mouse mode

Returns:roi : Roi