fsleyes.displaycontext.group

This module provides the OverlayGroup class, which allows the display properties of one or more overlays to be linked.

class fsleyes.displaycontext.group.OverlayGroup(displayCtx, overlayList)[source]

Bases: __main__.docbuilder.run.<locals>.MockClass

An OverlayGroup is a group of overlays for which the corresponding Display and DisplayOpts properties are synchronised.

The point of the OverlayGroup is to allow the user to define groups of overlays, so he/she can change display properties on the entire group, instead of having to change display properties on each overlay one by one.

Overlays can be added to an OverlayGroup with the addOverlay(), and removed with the removeOverlay().

When an OverlayGroup is created, it dynamically adds all of the properties which could possibly be linked between overlays to itself, using the props.HasProperties.addProperty() method. When the first overlay is added to the group, these group properties are set to the display properties of this overlay. Then, the display properties of overlays which are subsequently added to the group will be set to the group display properties.

Note

Currently, only a subset of display properties are linked between the overlays in a group. The properties which are linked are hard-coded in the _groupBindings dictionary.

A possible future FSLeyes enhancement will be to allow the user to specify which display properties within an OverlayGroup should be linked.

overlays = <MagicMock name='mock.List()' id='140604702366528'>

The list of overlays in this OverlayGroup.

Warning

Do not add/remove overlays directly to this list - use the addOverlay() and removeOverlay() methods instead.

_groupBindings = <MagicMock name='mock.utils.typedict.TypeDict()' id='140604702155312'>

This dictionary defines the properties which are bound across Display instances DisplayOpts sub-class instances, for overlays which are in the same group.

__init__(displayCtx, overlayList)[source]

Create an OverlayGroup.

Parameters
__copy__()[source]

Create a copy of this OverlayGroup.

A custom copy operator is needed due to the way that the props.HasProperties class works.

__str__()[source]

Returns a string representation of this OverlayGroup.

__repr__()[source]

Returns a string representation of this OverlayGroup.

__contains__(ovl)[source]

Returns True if ovl is in this OverlayGroup, False otherwise.

__len__()[source]

Returns the number of overlays in this OverlayGroup.

destroy()[source]

Must be called when this OverlayGroup is no longer needed. Removes all overlays from the group, and removes property listeners.

addOverlay(overlay)[source]

Add an overlay to this OverlayGroup.

If this is the first overlay to be added, the properties of this OverlayGroup are set to the overlay display properties. Otherwise, the overlay display properties are set to those of this OverlayGroup.

removeOverlay(overlay)[source]

Remove the given overlay from this OverlayGroup.

__bindDisplayOpts(target, unbind=False)

Binds or unbinds the properties of the given target to the properties of this OverlayGroup.

Parameters
  • target – A Display or DisplayOpts instance.

  • unbind – Set to True to bind the properties, False to unbind them.

__overlayListChanged(*a)

Called when overlays are added/removed to/from the OverlayList . Makes sure that the overlays list for this group does not contain any overlays that have been removed.

__annotations__ = {}
__module__ = 'fsleyes.displaycontext.group'
__overlayTypeChanged(value, valid, display, name)

This method is called when the Display.overlayType property for an overlay in the group changes.

It makes sure that the display properties of the new DisplayOpts instance are bound to the group properties.