fsleyes.displaycontext.display
¶
This module provides the Display
and DisplayOpts
classes,
which encapsulate overlay display settings.
-
class
fsleyes.displaycontext.display.
Display
(overlay, overlayList, displayCtx, parent=None, overlayType=None)¶ Bases:
__main__.MockClass
The
Display
class contains display settings which are common to all overlay types.A
Display
instance is also responsible for managing a singleDisplayOpts
instance, which contains overlay type specific display options. Whenever theoverlayType
property of aDisplay
instance changes, the oldDisplayOpts
instance (if any) is destroyed, and a new one, of the correct type, created.-
enabled
= <MagicMock name='mock.Boolean()' id='4122918732'>¶ Should this overlay be displayed at all?
-
alpha
= <MagicMock name='mock.Percentage()' id='4123118412'>¶ Opacity - 100% is fully opaque, and 0% is fully transparent.
-
brightness
= <MagicMock name='mock.Percentage()' id='4123118412'>¶ Brightness - 50% is normal brightness.
-
contrast
= <MagicMock name='mock.Percentage()' id='4123118412'>¶ Contrast - 50% is normal contrast.
-
__init__
(overlay, overlayList, displayCtx, parent=None, overlayType=None)¶ Create a
Display
for the specified overlay.Parameters: - overlay – The overlay object.
- overlayList – The
OverlayList
instance which contains all overlays. - displayCtx – A
DisplayContext
instance describing how the overlays are to be displayed. - parent – A parent
Display
instance - seeprops.syncable
. - overlayType – Initial overlay type - see the
overlayType
property.
-
name
= <MagicMock name='mock.String()' id='4123063564'>¶ The overlay name.
-
overlayType
= <MagicMock name='mock.Choice()' id='4123093036'>¶ This property defines the overlay type - how the data is to be displayed.
The options for this property are populated in the
__init__()
method, from thedisplaycontext.OVERLAY_TYPES
dictionary. ADisplayOpts
sub-class exists for every possible value that this property may take.
-
__del__
()¶ Prints a log message.
-
destroy
()¶ This method must be called when this
Display
instance is no longer needed.When a
Display
instance is destroyed, the correspondingDisplayOpts
instance is also destroyed.
-
getOverlay
= <MagicMock name='mock.deprecated()()' id='4123138092'>¶
-
overlay
¶ Returns the overlay associated with this
Display
instance.
-
opts
¶ Return the
DisplayOpts
instance associated with thisDisplay
, which contains overlay type specific display settings.If a
DisplayOpts
instance has not yet been created, or theoverlayType
property no longer matches the type of the existingDisplayOpts
instance, a newDisplayOpts
instance is created (and the old one destroyed if necessary).See the
__makeDisplayOpts()
method.
-
getDisplayOpts
= <MagicMock name='mock.deprecated()()' id='4123138092'>¶
-
_Display__findOptBaseType
(optType, optName)¶ Finds the class, in the hierarchy of the given
optType
(aDisplayOpts
sub-class) in which the givenoptName
is defined.This method is used by the
__saveOldDisplayOpts()
method, and is an annoying necessity caused by the way that theTypeDict
class works. ATypeDict
does not allow types to be used as keys - they must be strings containing the type names.Furthermore, in order for the property values of a common
DisplayOpts
base type to be shared across sub types (e.g. copying theNiftiOpts.transform
property betweenVolumeOpts
andLabelOpts
instances), we need to store the name of the common base type in the dictionary.
-
_Display__makeDisplayOpts
()¶ Creates a new
DisplayOpts
instance. The specificDisplayOpts
sub-class that is created is dictated by the current value of theoverlayType
property.The
displaycontext.DISPLAY_OPTS_MAP
dictionary defines the mapping between overlay types andoverlayType
values, andDisplayOpts
sub-class types.
-
_Display__overlayTypeChanged
(*a)¶ Called when the
overlayType
property changes. Makes sure that theDisplayOpts
instance is of the correct type.
-
_Display__restoreOldDisplayOpts
()¶ Restores any cached values for all of the properties on the current
DisplayOpts
instance.
-
_Display__saveOldDisplayOpts
()¶ Saves the value of every property on the current
DisplayOpts
instance, so they can be restored later if needed.
-
__module__
= 'fsleyes.displaycontext.display'¶
-
-
class
fsleyes.displaycontext.display.
DisplayOpts
(overlay, display, overlayList, displayCtx, **kwargs)¶ Bases:
__main__.MockClass
,fsleyes.actions.ActionProvider
The
DisplayOpts
class contains overlay type specific display settings.DisplayOpts
instances are managed byDisplay
instances.The
DisplayOpts
class is not meant to be created directly - it is a base class for type specific implementations (e.g. theVolumeOpts
class).The following attributes are available on all
DisplayOpts
instances:overlay
The overlay object display
The Display
instance that created thisDisplayOpts
instance.overlayType
The value of the Display.overlayType
property corresponding to the type of thisDisplayOpts
instance.overlayList
The OverlayList
instance, which contains all overlays.displayCtx
The DisplayContext
instance which is responsible for allDisplay
andDisplayOpts
instances.name
A unique name for this DisplayOpts
instance.-
bounds
= <MagicMock name='mock.Bounds()' id='4122626892'>¶ Specifies a bounding box in the display coordinate system which is big enough to contain the overlay described by this
DisplayOpts
instance.The values in this
bounds
property must be updated byDisplayOpts
subclasses whenever the spatial representation of their overlay changes.
-
__init__
(overlay, display, overlayList, displayCtx, **kwargs)¶ Create a
DisplayOpts
object.Parameters: - overlay – The overlay associated with this
DisplayOpts
instance. - display – The
Display
instance which owns thisDisplayOpts
instance. - overlayList – The
OverlayList
which contains all overlays. - displayCtx – A
DisplayContext
instance describing how the overlays are to be displayed.
- overlay – The overlay associated with this
-
__del__
()¶ Prints a log message.
-
destroy
()¶ This method must be called when this
DisplayOpts
instance is no longer needed.If a subclass overrides this method, the subclass implementation must call this method, after performing its own clean up.
-
classmethod
getVolumeProps
()¶ Intended to be overridden by sub-classes as needed. Returns a list of property names which control the currently displayed volume/timepoint for 4D overlays. The default implementation returns an empty list.
-
__module__
= 'fsleyes.displaycontext.display'¶
-
overlay
¶ Return the overlay associated with this
DisplayOpts
object.
-
overlayList
¶ Return the
OverlayList
that contains all overlays.
-
displayCtx
¶ Return the
DisplayContext
that is managing thisDisplayOpts
object.
-
overlayType
¶ Return the type of this
DisplayOpts
object (the value ofDisplay.overlayType
).
-
name
¶ Return the name of this
DisplayOpts
object.
-
referenceImage
¶ Return the reference image associated with this
DisplayOpts
instance.Some non-volumetric overlay types (e.g. the
Mesh
- seeMeshOpts
) may have a referenceNifti
instance associated with them, allowing the overlay to be localised in the coordinate space defined by theNifti
. TheDisplayOpts
sub-class which corresponds to such non-volumetric overlays should override this method to return that reference image.DisplayOpts
sub-classes which are associated with volumetric overlays (i.e.Nifti
instances) do not need to override this method - in this case, the overlay itself is considered to be its own reference image, and is returned by the base-class implementation of this method.Note
The reference
Nifti
instance returned by sub-class implementations of this method must be in theOverlayList
.
-
getReferenceImage
= <MagicMock name='mock.deprecated()()' id='4123138092'>¶
-
getLabels
()¶ Generates some orientation labels for the overlay associated with this
DisplayOpts
instance.If the overlay is not a
Nifti
instance, or does not have a reference image set, the labels will represent an unknown orientation.Returns a tuple containing:
- The
(xlo, ylo, zlo, xhi, yhi, zhi)
labels - The
(xorient, yorient, zorient)
orientations (seeImage.getOrientation()
)
- The
-