ui.mousemodes: Mouse modes

Classes to create mouse modes and assign mouse buttons and modifier keys to specific modes.

class AtomCenterOfRotationMode(session)

Bases: chimerax.core.ui.mousemodes.MouseMode

Clicking on an atom sets the center of rotation at that position.

class ClipMouseMode(session)

Bases: chimerax.core.ui.mousemodes.MouseMode

Move clip planes. Move front plane with no modifiers, back plane with alt, both planes with shift, and slab thickness with alt and shift. Move scene planes unless only near/far planes are enabled. If the planes do not exist create them.

class ClipRotateMouseMode(session)

Bases: chimerax.core.ui.mousemodes.MouseMode

Rotate clip planes.

class LabelMode(session)

Bases: chimerax.core.ui.mousemodes.MouseMode

Click an atom,ribbon,pseudobond or bond to label or unlabel it with default label.

class MouseBinding(button, modifiers, mode)

Bases: object

Associates a mouse button (‘left’, ‘middle’, ‘right’, ‘wheel’, ‘pause’) and set of modifier keys (‘alt’, ‘command’, ‘control’, ‘shift’) with a MouseMode.

exact_match(button, modifiers)

Does this binding exactly match the specified button and modifiers? An exact match requires the binding modifiers keys are exactly the same set as the specified modifier keys.

matches(button, modifiers)

Does this binding match the specified button and modifiers? A match requires all of the binding modifiers keys are among the specified modifiers (and possibly more).

class MouseEvent(event)

Bases: object

Provides an interface to mouse event coordinates and modifier keys so that mouse modes do not directly depend on details of the window toolkit.

alt_down()

Does the mouse event have the alt key down.

position()

Pair of integer x,y pixel coordinates relative to upper-left corner of graphics window.

shift_down()

Does the mouse event have the shift key down.

wheel_value()

Number of clicks the mouse wheel was turned, signed float. One click is typically 15 degrees of wheel rotation.

class MouseMode(session)

Bases: object

Classes derived from MouseMode implement specific mouse modes providing methods mouse_down(), mouse_up(), mouse_motion(), wheel(), pause() that are called when mouse events occur. Which mouse button and modifier keys are detected by a mode is controlled by a different MauseModes class.

enable()

Override if mode wants to know that it has been bound to a mouse button.

icon_file = None

Image file name for an icon for this mouse mode to show in the mouse mode GUI panel. The icon file of this name needs to be in the mouse_modes tool icons subdirectory, should be PNG, square, and at least 64 pixels square. It will be rescaled as needed. A none value means no icon will be shown in the gui interface.

last_mouse_position = None

Last mouse position during a mouse drag.

mouse_down(event)

Override this method to handle mouse down events. Derived methods can call this base class method to set mouse_down_position and last_mouse_position.

mouse_down_position = None

Pixel position (x,y) of mouse down, sometimes useful to detect on mouse up whether any mouse motion occured. Set to None after mouse up.

mouse_motion(event)

Return the mouse motion in pixels (dx,dy) since the last mouse event.

mouse_up(event)

Override this method to handle mouse down events. Derived methods can call this base class method to set mouse_down_position and last_mouse_position to None.

move_after_pause()

Override this method to take action when the mouse moves after a hover. This allows for instance undisplaying a popup help balloon window.

name = 'mode name'

Name of the mouse mode used with the mousemode command. Should be unique among all mouse modes.

pause(position)

Override this method to take action when the mouse hovers for a time given by the MouseModes pause interval (default 0.5 seconds).

pixel_size(center=None, min_scene_frac=1e-05)

Report the pixel size in scene units at the center of rotation. Clamp the value to be at least min_scene_fraction times the width of the displayed models.

wheel(event)

Override this method to handle mouse wheel events.

class MouseModes(session)

Bases: object

Keep the list of available mouse modes and also which mode is bound to each mouse button (left, middle, right), or mouse button and modifier key (alt, command, control shift). The mouse modes object for a session is session.ui.mouse_modes

add_mode(mode)

Add a MouseMode instance to the list of available modes.

bind_mouse_mode(button, modifiers, mode)

Button is “left”, “middle”, “right”, “wheel”, or “pause”. Modifiers is a list 0 or more of ‘alt’, ‘command’, ‘control’, ‘shift’. Mode is a MouseMode instance.

bind_standard_mouse_modes(buttons=('left', 'middle', 'right', 'wheel', 'pause'))

Bind the standard mouse modes: left = rotate, ctrl-left = select, middle = translate, right = zoom, wheel = zoom, pause = identify object.

bindings

List of MouseBinding instances.

mode(button='left', modifiers=[])

Return the MouseMode associated with a specified button and modifiers, or None if no mode is bound.

modes

List of MouseMode instances.

mouse_pause_tracking()

Called periodically to check for mouse pause and invoke pause mode. Typically this will be called by the redraw loop and is used to determine when a mouse pause occurs.

remove_binding(button, modifiers)

Unbind the mouse button and modifier key combination. No mode will be associated with this button and modifier.

remove_mode(mode)

Remove a MouseMode instance from the list of available modes.

class NullMouseMode(session)

Bases: chimerax.core.ui.mousemodes.MouseMode

Used to assign no mode to a mouse button.

class ObjectIdMouseMode(session)

Bases: chimerax.core.ui.mousemodes.MouseMode

Mouse mode to that shows the name of an object in a popup window when the mouse is hovered over the object for 0.5 seconds.

class RotateAndSelectMouseMode(session)

Bases: chimerax.core.ui.mousemodes.RotateMouseMode

Mouse mode to rotate objects like RotateMouseMode. Also clicking without dragging selects objects. This mode allows click with no modifier keys to perform selection, while click and drag produces rotation.

class RotateMouseMode(session)

Bases: chimerax.core.ui.mousemodes.MouseMode

Mouse mode to rotate objects (actually the camera is moved) by dragging. Mouse drags initiated near the periphery of the window cause a screen z rotation, while other mouse drags use rotation axes lying in the plane of the screen and perpendicular to the direction of the drag.

class RotateSelectedMouseMode(session)

Bases: chimerax.core.ui.mousemodes.RotateMouseMode

Mouse mode to rotate objects like RotateMouseMode but only selected models are rotated. Selected models are actually moved in scene coordinates instead of moving the camera. If nothing is selected, then the camera is moved as if all models are rotated.

class SelectAddMouseMode(session)

Bases: chimerax.core.ui.mousemodes.SelectMouseMode

Mouse mode to add objects to selection by clicking on them.

class SelectMouseMode(session)

Bases: chimerax.core.ui.mousemodes.MouseMode

Mouse mode to select objects by clicking on them.

class SelectSubtractMouseMode(session)

Bases: chimerax.core.ui.mousemodes.SelectMouseMode

Mouse mode to subtract objects from selection by clicking on them.

class SelectToggleMouseMode(session)

Bases: chimerax.core.ui.mousemodes.SelectMouseMode

Mouse mode to toggle selected objects by clicking on them.

class TranslateMouseMode(session)

Bases: chimerax.core.ui.mousemodes.MouseMode

Mouse mode to move objects in x and y (actually the camera is moved) by dragging.

class TranslateSelectedMouseMode(session)

Bases: chimerax.core.ui.mousemodes.TranslateMouseMode

Mouse mode to move objects in x and y like TranslateMouseMode but only selected models are moved. Selected models are actually moved in scene coordinates instead of moving the camera. If nothing is selected, then the camera is moved as if all models are shifted.

class ZoomMouseMode(session)

Bases: chimerax.core.ui.mousemodes.MouseMode

Mouse mode to move objects in z, actually the camera is moved and the objects remain at their same scene coordinates.

mod_key_info(key_function)

Qt swaps control/meta on Mac, so centralize that knowledge here. The possible “key_functions” are: alt, control, command, and shift

Returns the Qt modifier bit (e.g. Qt.AltModifier) and name of the actual key

standard_mouse_mode_classes()

List of core MouseMode classes.