Motor Map Widget#

The Motor Map Widget is a specialized tool for tracking and visualizing the positions of motors in real-time. This widget is crucial for applications requiring precise alignment and movement tracking during scans. It provides an intuitive way to monitor motor trajectories, ensuring accurate positioning throughout the scanning process.

Key Features:

  • Flexible Integration: The widget can be integrated into a BECDockArea, or used as an individual component in your application through BEC Designer.

  • Real-time Motor Position Visualization: Tracks motor positions in real-time and visually represents motor trajectories.

  • Customizable Visual Elements: The appearance of all widget components is fully customizable, including scatter size and background values.

  • Interactive Controls: Interactive controls for zooming, panning, and adjusting the visual properties of motor trajectories on the fly.

MotorMap

MotorMapWidget can be embedded in BECDockArea, or used as an individual component in your application through BEC Designer. However, the command-line API is the same for all cases.

Example 1 - Adding Motor Map Widget as a Dock in BECDockArea

Adding MotorMapWidget into a BECDockArea is similar to adding any other widget.

# Add new MotorMaps to the BECDockArea
dock_area = gui.new()
mm1 = dock_area.new().new(gui.available_widgets.MotorMap)
mm2 = dock_area.new().new(gui.available_widgets.MotorMap)

# Add signals to the MotorMaps
mm1.map(device_x='samx', device_y='samy')
mm2.map(device_x='aptrx', device_y='aptry')

Example 2 - Customizing Motor Map Display

The MotorMapWidget allows customization of its visual elements to better suit the needs of your application. Below is an example of how to adjust the scatter size, set background values, and limit the number of points displayed from the position buffer.

# Set scatter size
mm1.scatter_size = 10

# Set background value (between 0 and 100)
mm1.background_value = 0

# Limit the number of points displayed and saved in the position buffer
mm1.max_points = 500

Example 3 - Changing Motors and Resetting History

You can dynamically change the motors being tracked and reset the history of the motor trajectories during the session.

# Reset the history of motor movements
mm1.reset_history()

# Change the motors being tracked
mm1.map(device_x='aptrx', device_y='aptry')
class MotorMap(gui_id: str | None = None, config: dict | None = None, object_name: str | None = None, parent=None, **kwargs)[source]#

Bases: RPCBase

Motor map widget for plotting motor positions in 2D including a trace of the last points.

attach()[source]#

None

auto_range(value: bool = True)[source]#

On demand apply autorange to the plot item based on the visible curves.

Parameters:

value (bool) – If True, apply autorange to the visible curves.

property auto_range_x: bool#

Set auto range for the x-axis.

property auto_range_y: bool#

Set auto range for the y-axis.

property background_value: int#

Get the background value of the motor map.

property color: tuple#

Get the color of the motor trace.

Returns:

Color of the motor trace.

Return type:

tuple

detach()[source]#

Detach the widget from its parent dock widget (if widget is in the dock), making it a floating widget.

property device_x: str#

Name of the motor shown on the X axis.

property device_y: str#

Name of the motor shown on the Y axis.

property enable_fps_monitor: bool#

Enable the FPS monitor.

property enable_side_panel: bool#

Show Side Panel

property enable_toolbar: bool#

Show Toolbar.

get_data() dict[source]#

Get the data of the motor map.

Returns:

Data of the motor map.

Return type:

dict

property inner_axes: bool#

Show inner axes of the plot widget.

property legend_label_size: int#

The font size of the legend font.

property lock_aspect_ratio: bool#

Lock aspect ratio of the plot widget.

map(device_x: str, device_y: str, validate_bec: bool = True, suppress_errors=False) None[source]#

Set the x and y motor names.

Parameters:
  • device_x (str) – The name of the x motor.

  • device_y (str) – The name of the y motor.

  • validate_bec (bool, optional) – If True, validate the signal with BEC. Defaults to True.

  • suppress_errors (bool, optional) – If True, suppress errors during validation. Defaults to False. Used for properties setting. If the validation fails, the changes are not applied.

property max_points: int#

Get the maximum number of points to display.

property minimal_crosshair_precision: int#

Minimum decimal places for crosshair when dynamic precision is enabled.

property num_dim_points: int#

Get the number of dim points for the motor map.

property outer_axes: bool#

Show the outer axes of the plot widget.

property precision: int#

Set the decimal precision of the motor position.

remove()[source]#

Cleanup the BECConnector

reset_history()[source]#

Reset the history of the motor map.

property scatter_size: int#

Get the scatter size of the motor map plot.

screenshot(file_name: str | None = None)[source]#

Take a screenshot of the dock area and save it to a file.

set(**kwargs)[source]#

Set the properties of the plot widget.

Parameters:

**kwargs – Keyword arguments for the properties to be set.

Possible properties:
  • title: str

  • x_label: str

  • y_label: str

  • x_scale: Literal[“linear”, “log”]

  • y_scale: Literal[“linear”, “log”]

  • x_lim: tuple

  • y_lim: tuple

  • legend_label_size: int

property title: str#

Set title of the plot.

property x_grid: bool#

Show grid on the x-axis.

property x_label: str#

The set label for the x-axis.

property x_limits: QPointF#

Get the x limits of the plot.

property x_log: bool#

Set X-axis to log scale if True, linear if False.

property y_grid: bool#

Show grid on the y-axis.

property y_label: str#

The set label for the y-axis.

property y_limits: QPointF#

Get the y limits of the plot.

property y_log: bool#

Set Y-axis to log scale if True, linear if False.