fsleyes.controls.locationpanel
¶
This module provides the LocationPanel
class, a FSLeyes control
panel which shows information about the current display location.
-
class
fsleyes.controls.locationpanel.
LocationPanel
(parent, overlayList, displayCtx, frame, showHistory=False)[source]¶ Bases:
fsleyes.controls.controlpanel.ControlPanel
The
LocationPanel
is a panel which contains controls allowing the user to view and modify theDisplayContext.location
property.A
LocationPanel
is intended to be contained within aCanvasPanel
, and looks something like this:By default, the
LocationPanel
contains a notebook with two pages:The
LocationInfoPanel
contains information about the currently displayed location, and controls allowing the user to change the location.The
LocationHistoryPanel
contains a list of previously visited locations, and allows the user to revisit those locations.
The history panel is optional - if the
showHistory
parameter to__init__
isFalse
then only the information panel will be shown.-
__init__
(parent, overlayList, displayCtx, frame, showHistory=False)[source]¶ Creat a
LocationPanel
.- Parameters
parent – The
wx
parent object, assumed to be aCanvasPanel
.overlayList – The
OverlayList
instance.displayCtx – The
DisplayContext
instance.frame – The
FSLeyesFrame
instance.showHistory – Defaults to
False
. IfTrue
, create and display aLocationHistoryPanel
.
-
__module__
= 'fsleyes.controls.locationpanel'¶
-
class
fsleyes.controls.locationpanel.
LocationInfoPanel
(parent, overlayList, displayCtx, frame)[source]¶ Bases:
fsleyes.panel.FSLeyesPanel
The
LocationInfoPanel
is a panel which is embedded in theLocationPanel
, and which contains controls allowing the user to view and modify theDisplayContext.location
property.The
LocationInfoPanel
contains two main sections:A collection of controls which show the current
DisplayContext.location
A
wx.html.HtmlWindow
which displays information about the currentDisplayContext.location
for all overlays in theOverlayList
.
NIFTI overlays
The
LocationInfoPanel
is primarily designed to work withImage
overlays. If theDisplayContext.selectedOverlay
is anImage
, or has an associated reference image (seeDisplayOpts.referenceImage()
), theLocationInfoPanel
will display the currentDisplayContext.location
in both the the voxel coordinates and world coordinates of theImage
instance.Other overlays
If the
DisplayContext.selectedOverlay
is not anImage
, or does not have an associated reference image, theLocationInfoPanel
will display the currentDisplayContext.location
as-is (i.e. in the display coordinate system); furthermore, the voxel location controls will be disabled.Location updates
The
DISPLAYOPTS_BOUNDS
andDISPLAYOPTS_INFO
dictionaries contain lists of property names that theLocationInfoPanel
listens on for changes, so it knows when the location widgets, and information about the currenty location, need to be refreshed. For example, when the :attr`.NiftiOpts.volume` property of aNifti
overlay changes, the volume index, and potentially the overlay information, needs to be updated.-
voxelLocation
= <MagicMock name='mock.Point()' id='281473494796800'>¶ If the currently selected overlay is a
Image
instance , this property tracks the currentDisplayContext.location
in voxel coordinates.
-
worldLocation
= <MagicMock name='mock.Point()' id='281473494796800'>¶ For
Image
overlays, this property tracks the currentDisplayContext.location
in the image world coordinates. For other overlay types, this property tracks the current location in display coordinates.
-
__init__
(parent, overlayList, displayCtx, frame)[source]¶ Create a
_FSLeyesPanel
.- Parameters
overlayList – A
OverlayList
instance.displayCtx – A
DisplayContext
instance.frame – The
FSLeyesFrame
that created this_FSLeyesPanel
. May beNone
.kbFocus – If
True
, a keyboard event handler is configured to interceptTab
andShift+Tab
keyboard events, to shift focus between a set of child widgets. The child widgets to be included in the navigation can be specified with thesetNavOrder()
method.
-
destroy
()[source]¶ Must be called when this
LocationInfoPanel
is no longer needed. Removes property listeners and callsFSLeyesPanel.destroy()
.
-
GetMinSize
()[source]¶ Returns the minimum size for this
LocationInfoPanel
.Under Linux/GTK, the
wx.agw.lib.aui
layout manager seems to arbitrarily adjust the minimum sizes of some panels. Therefore, The minimum size of theLocationInfoPanel
is calculated in__init__()
, and is fixed.
-
_LocationInfoPanel__boundsOptsChanged
(*a)¶ Called when a
DisplayOpts
property associated with the currently selected overlay, and listed in theDISPLAYOPTS_BOUNDS
dictionary, changes. Refreshes theLocationInfoPanel
interface accordingly.
-
_LocationInfoPanel__calcWorldLabelMinSize
()¶ Calculates the minimum size that the world label (the label which shows the coordinate space of the currently selected overlay) needs. Called by the
__init__()
method.The world label displays different things depending on the currently selected overlay. But we want it to be a fixed size. So this method calculates the size of all possible values that the world label will display, and returns the maximum size. This is then used as the minimum size for the world label.
-
_LocationInfoPanel__deregisterOverlay
()¶ De-registers property listeners with the
Display
andDisplayOpts
instances associated with the previously registered overlay.
-
_LocationInfoPanel__displayLocationChanged
(*a)¶ Called when the
DisplayContext.location
changes. Propagates the change on to thevoxelLocation
andworldLocation
properties.Note
Because the
DisplayContext.location
,voxelLocation
andworldLocation
properties are all linked through property listeners (seeprops.HasProperties.addListener()
), we need to be a bit careful to avoid circular updates. Therefore, each of the__displayLocationChanged()
,__worldLocationChanged()
and__voxelLocationChanged()
methods use the__prePropagate()
,__propagate()
, and__postPropagate()
methods to propagate changes between the three location properties.
-
_LocationInfoPanel__genDisplaySpaceWarning
()¶ Generate a warning if images with different orientations and/or fields-of-view are loaded.
-
_LocationInfoPanel__genImageInfo
(ovl, opts)¶ Generate an info line for the given
Image
overlay.
-
_LocationInfoPanel__genMeshInfo
(ovl, opts)¶ Generate an info line for the given
Mesh
overlay.
-
_LocationInfoPanel__infoOptsChanged
(*a)¶ Called when a
DisplayOpts
property associated with the currently selected overlay, and listed in theDISPLAYOPTS_INFO
dictionary, changes. Refreshes theLocationInfoPanel
interface accordingly.
-
_LocationInfoPanel__overlayOrderChanged
(*a)¶ Called when the
DisplayContext.overlayOrder
changes, Refreshes the information panel.
-
_LocationInfoPanel__postPropagate
()¶ Called by the
__displayLocationChanged()
,__worldLocationChanged()
and__voxelLocationChanged()
methods.Re-enables the property listeners that were disabled by the
__postPropagate()
method.
-
_LocationInfoPanel__prePropagate
()¶ Called by the
__displayLocationChanged()
,__worldLocationChanged()
and__voxelLocationChanged()
methods.Disables notification of all location property listeners, so circular updates do not occur.
-
_LocationInfoPanel__propagate
(source, target)¶ Called by the
__displayLocationChanged()
,__worldLocationChanged()
and__voxelLocationChanged()
methods. Copies the coordinates from thesource
location to thetarget
location. Valid values for thesource
andtarget
are:display
The
DisplayContext.location
property.voxel
The
voxelLocation
property.world
The
worldLocation
property.
-
_LocationInfoPanel__registerOverlay
()¶ Registers property listeners with the
Display
andDisplayOpts
instances associated with the currently selected overlay.
-
_LocationInfoPanel__selectedOverlayChanged
(*a)¶ Called when the
DisplayContext.selectedOverlay
orOverlayList
is changed. Registered with the new overlay, and refreshes theLocationInfoPanel
interface accordingly.
-
_LocationInfoPanel__updateLocationInfo
()¶ Called whenever the
DisplayContext.location
changes. Updates the HTML panel which displays information about all overlays in theOverlayList
.
-
_LocationInfoPanel__updateWidgets
()¶ Called by the
__selectedOverlayChanged()
and__displayOptsChanged()
methods. Enables/disables the voxel/world location and volume controls depending on the currently selected overlay (or reference image).
-
_LocationInfoPanel__vertexDataChanged
(*a)¶ Called when the selected overlay is a
Mesh
, and itsMeshOpts.vertexData
property changes. Updates the volume widget.
-
_LocationInfoPanel__volumeDimChanged
(*a)¶ Called when the selected overlay is a
Nifti
, and itsNiftiOpts.volumeDim
property changes. Updates the volume widget.
-
_LocationInfoPanel__voxelLocationChanged
(*a)¶ Called when the
voxelLocation
changes. Propagates the change on to theworldLocation
andDisplayContext.location
properties.
-
_LocationInfoPanel__worldLocationChanged
(*a)¶ Called when the
worldLocation
changes. Propagates the change on to thevoxelLocation
andDisplayContext.location
properties.
-
__module__
= 'fsleyes.controls.locationpanel'¶
-
fsleyes.controls.locationpanel.
DISPLAYOPTS_BOUNDS
= <MagicMock name='mock.utils.typedict.TypeDict()' id='281473492539520'>¶ Different
DisplayOpts
types have different properties which affect the current overlay bounds. Therefore, when the current overlay changes (as dictated by theDisplayContext.selectedOverlay
property),the__registerOverlay()
method registers property listeners on the properties specified in this dictionary.
-
fsleyes.controls.locationpanel.
DISPLAYOPTS_INFO
= <MagicMock name='mock.utils.typedict.TypeDict()' id='281473492539520'>¶ Different
DisplayOpts
types have different properties which affect the current overlay location information. Therefore, when the current overlay changes the__registerOverlay()
method registers property listeners on the properties specified in this dictionary.
-
class
fsleyes.controls.locationpanel.
LocationHistoryPanel
(parent, overlayList, displayCtx, frame, canvasPanel, limit=500)[source]¶ Bases:
fsleyes.panel.FSLeyesPanel
The
LocationHistoryPanel
is a panel which is embedded in theLocationPanel
, and which contains a list of locations previously visited by the user.-
__init__
(parent, overlayList, displayCtx, frame, canvasPanel, limit=500)[source]¶ Create a
LocationHistoryPanel
.- Parameters
parent – The
wx
parent object.overlayList – The
OverlayList
instance.displayCtx – The
DisplayContext
instance.frame – The
FSLeyesFrame
instance.canvasPanel – The
CanvasPanel
which owns thisLocationHistoryPanel
.limit – Maximum number of locations to save before dropping old locations.
-
getHistory
()[source]¶ Returns a list containing the currently displayed location history. Each entry in the list is a tuple containing the coordinates, and any comment that the user has addded.
-
_LocationHistoryPanel__addLocation
(worldLoc, comment=None)¶ Add a location to the location history.
- Parameters
worldLoc – Location in world coordinates
comment – Comment about the location
-
_LocationHistoryPanel__deregisterProfile
()¶ De-registers listeners that have previously been registered with a
Profile
object.
-
_LocationHistoryPanel__onClear
(ev)¶ Called when the clear button is pushed. Clears the current history.
-
_LocationHistoryPanel__onListSelect
(ev)¶ Called when a location is selected from the location history list.
Sets the
DisplayContext.worldLocation
accordingly.
-
_LocationHistoryPanel__onLoad
(ev)¶ Called when the load button is pushed. Prompts the user to select a file, then loads a history from that file.
-
_LocationHistoryPanel__onMouseUp
(ev, canvas, mouseLoc, canvasLoc)¶ Called on mouse up events. Adds the mouse location (in the world coordinate system) to the location history list.
-
_LocationHistoryPanel__onSave
(ev)¶ Called when the save button is pushed. Prompts the user to select a file name, then saves the current history to that file.
-
_LocationHistoryPanel__profileChanged
(*a)¶ Called when the
CanvasPanel.profile
changes. Re-registers mouse event listeners with the newProfile
object.
-
_LocationHistoryPanel__registerProfile
(profile)¶ Registers a mouse event listener with the given
profile
.
-
__module__
= 'fsleyes.controls.locationpanel'¶
-
-
fsleyes.controls.locationpanel.
loadLocationHistory
(filename)[source]¶ Loads a location history from the given
filename
. A location history file contains one location on each line, where the X, Y, and Z coordinates are separated by a space character. All remaining characters on the line are treated as the location comment. For example:1.27 4.23 1.63 this is a comment 5.25 2.66 1.23
Returns a list containing the location history, in the same format as that returned by
LocationHistoryPanel.getHistory()
.
-
fsleyes.controls.locationpanel.
saveLocationHistory
(history, filename)[source]¶ Saves the given location
history
to the givenfilename
. SeeloadLocationHistory()
andLocationHistoryPanel.getHistory()
.