fsleyes.profiles.orthoviewprofile

This module provides the OrthoViewProfile class, an interaction Profile for OrthoPanel views.

class fsleyes.profiles.orthoviewprofile.OrthoViewProfile(viewPanel, overlayList, displayCtx, extraModes=None)

Bases: fsleyes.profiles.Profile

The OrthoViewProfile class is a Profile for the OrthoPanel class. It defines mouse/keyboard handlers which allow the user to navigate through the OrthoPanel display of the overlays in the OverlayList.

OrthoViewProfile defines the following modes (see the Profile class documentation):

nav

The user can change the currently displayed location. This is accomplished by updating the DisplayContext.location property on left mouse drags.

slice

The user can change the current slice shown on a single canvas.

zoom

The user can zoom in/out of a canvas with the mouse wheel, and draw a rectangle on a canvas in which to zoom. This is accomplished by updating the SliceCanvasOpts.zoom property on mouse wheel changes, and displaying a Rect annotation on left mouse drags.

pan

The user can pan around a canvas (if the canvas is zoomed in). This is accomplished by calling the SliceCanvas.panDisplayBy() on left mouse drags.

bricon

The user can drag the mouse along a canvas to change the brightness/contrast of the currently selected overlay.

pick

If the currently selected overlay is a Mesh, the user can select the mesh vertex which is nearest to the mouse click.

The OrthoViewProfile class also defines a few actions:

resetDisplay

Resets the display bounds for all canvases.

centreCursor

Sets the DisplayContext.location to the centre of the DisplayContext.bounds.

__init__(viewPanel, overlayList, displayCtx, extraModes=None)

Creates an OrthoViewProfile, which can be registered with the given viewPanel.

Note

The OrthoEditProfile is a sub-class of the OrthoViewProfile. It uses the extraModes argument to set up its edit-related modes.

Parameters
  • viewPanel – An OrthoPanel instance.

  • overlayList – The OverlayList instance.

  • displayCtx – The DisplayContext instance.

  • extraModes – Extra modes to pass through to the Profile constructor.

destroy()

Must be called when this OrthoViewProfile is no longer needed. Removes some property listeners, and calls Profile.destroy().

getEventTargets()

Overrides Profile.getEventTargets().

Returns the three SliceCanvas instances displayed in the OrthoPanel instance that is using this OrthoViewProfile.

resetDisplay()

Resets the display bounds for all canvases. Also resets the SceneOpts.zoom, OrthoOpts.xzoom, OrthoOpts.yzoom, and OrthoOpts.zzoom properties to 100%.

See the SliceCanvas.resetDisplay() method.

centreCursor()

Sets the DisplayContext.location to the centre of the DisplayContext.bounds.

centreCursorWorld()

Sets the DisplayContext.location to world location (0, 0, 0), where the ‘world’ is in terms of the currently selected ovelray.

_navModeLeftMouseDrag(ev, canvas, mousePos, canvasPos)

Handles left mouse drags in nav mode.

Left mouse drags in nav mode update the DisplayContext.location to follow the mouse location.

_navModeChar(ev, canvas, key)

Handles key presses in nav mode.

Arrow key presses in nav mode update the DisplayContext.location. Arrow keys map to the horizontal/vertical axes, and -/+ keys map to the depth axis of the canvas which was the target of the event.

_sliceModeMouseWheel(ev, canvas, wheel, mousePos=None, canvasPos=None)

Handles mouse wheel movement in slice mode.

Mouse wheel movement on a canvas changes the depth location displayed on that canvas.

_sliceModeChar(ev, canvas, key)

Handles character events in slice mode.

Up/down and Page-up/Page-down keys will increase/decrease the depth location on the current canvas.

_zoomModeMouseWheel(ev, canvas, wheel, mousePos=None, canvasPos=None)

Handles mouse wheel events in zoom mode.

Mouse wheel motion in zoom mode increases/decreases the zoom level of the target canvas.

_zoomModeChar(ev, canvas, key)

Handles key presses in zoom mode.

The +/- keys in zoom mode increase/decrease the zoom level of the target canvas.

_zoomModeRightMouseDrag(ev, canvas, mousePos, canvasPos)

Handles right mouse drags in zoom mode.

Right mouse drags in zoom mode draw a rectangle on the target canvas.

When the user releases the mouse (see _zoomModeLeftMouseUp()), the canvas will be zoomed in to the drawn rectangle.

_zoomModeRightMouseUp(ev, canvas, mousePos, canvasPos)

Handles right mouse up events in zoom mode.

When the right mouse is released in zoom mode, the target canvas is zoomed in to the rectangle region that was drawn by the user.

_panModeLeftMouseDrag(ev, canvas, mousePos, canvasPos)

Handles left mouse drags in pan mode.

Left mouse drags in pan mode move the target canvas display about to follow the mouse.

If the target canvas is not zoomed in, this has no effect.

_panModeChar(ev, canvas, key)

Handles key presses in pan mode.

The arrow keys in pan mode move the target canvas display around (unless the canvas is not zoomed in).

_briconModeLeftMouseDown(ev, canvas, mousePos, canvasPos)

Handles left mouse down events in bricon mode. Stores the current Display.brightness/Display.contrast for the currently selected overlay.

_briconModeLeftMouseUp(ev, canvas, mousePos, canvasPos)

Handles left mouse up events in bricon mode.

_briconModeLeftMouseDrag(ev, canvas, mousePos, canvasPos)

Handles left mouse drags in bricon mode.

The brightness and contrast of the currently selected overlay are adjusted according to the location of the mouse, relative to the canvas.

_pickModeLeftMouseDrag(ev, canvas, mousePos, canvasPos)

Handles left mouse drag events in pick mode. If the currently selected overlay is a Mesh, identifies the mesh vertex which is nearest to the mouse click, and updates the DisplayContext.location. Otherwise, returns False.

_OrthoViewProfile__offsetLocation(x, y, z)

Used by some nav mode handlers. Returns a sequence of three values, one per display space axis, which specify the amount by which the DisplayContext.location should be changed, according to the directions specified by the x, y, and z arguments.

If the currently selected overlay is an Nifti instance, the distance that a navigation operation should shift the display will differ depending on the value of the NiftiOpts.transform property. For example, if transform is id, the display should be moved by one unit (which corresponds to one voxel). But if the transform is pixdim, the display should be moved by one pixdim (e.g. 2, for a “math:2mm^3 image).

Each of the x, y and z arguments are interpreted as being positive, zero, or negative. A positive/negative value indicates that the display location should be increased/decreased along the corresponding axis, and zero indicates that the location should stay the same along an axis.

_OrthoViewProfile__selectedOverlayChanged(*a)

Called when the OverlayList or DisplayContext.selectedOverlay changes. Enables/disables the action methods based on the newly selected overlay.

__module__ = 'fsleyes.profiles.orthoviewprofile'