Skip to content
Snippets Groups Projects
Commit 16827f06 authored by Paul McCarthy's avatar Paul McCarthy
Browse files

posSync property on LightBoxPanel, which enables/disables

synchronisation between lightbox position and image list position
parent 22c56d6e
No related branches found
No related tags found
No related merge requests found
#!/usr/bin/env python #!/usr/bin/env python
# #
# lightboxpanel.py - # lightboxpanel.py - A panel which contains a LightBoxCanvas, for displaying
# multiple slices from a collection of images.
# #
# Author: Paul McCarthy <pauldmccarthy@gmail.com> # Author: Paul McCarthy <pauldmccarthy@gmail.com>
# #
"""This module defines the :class:`LightBoxPanel, a panel which contains a
:class:`~fsl.fslview.gl.LightBoxCanvas`, for displaying multiple slices from a
collection of images.
"""
import logging import logging
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
...@@ -14,11 +19,12 @@ import props ...@@ -14,11 +19,12 @@ import props
import fsl.fslview.gl.lightboxcanvas as lightboxcanvas import fsl.fslview.gl.lightboxcanvas as lightboxcanvas
class LightBoxPanel(wx.Panel, props.HasProperties): class LightBoxPanel(wx.Panel, props.HasProperties):
""" """Convenience Panel which contains a
Convenience Panel which contains a a LightBoxCanvas and a scrollbar, :class:`~fsl.fslview.gl.LightBoxCanvas` and a scrollbar, and sets up
and sets up mouse-scrolling behaviour. mouse-scrolling behaviour.
""" """
sliceSpacing = lightboxcanvas.LightBoxCanvas.sliceSpacing sliceSpacing = lightboxcanvas.LightBoxCanvas.sliceSpacing
"""See :attr:`fsl.fslview.gl.lightboxcanvas.LightBoxCanvas.sliceSpacing`. """See :attr:`fsl.fslview.gl.lightboxcanvas.LightBoxCanvas.sliceSpacing`.
""" """
...@@ -39,12 +45,33 @@ class LightBoxPanel(wx.Panel, props.HasProperties): ...@@ -39,12 +45,33 @@ class LightBoxPanel(wx.Panel, props.HasProperties):
"""See :attr:`fsl.fslview.gl.slicecanvas.SliceCanvas.zax`.""" """See :attr:`fsl.fslview.gl.slicecanvas.SliceCanvas.zax`."""
_labels = lightboxcanvas.LightBoxCanvas._labels posSync = props.Boolean(default=True)
"""See :attr:`fsl.fslview.gl.slicecanvas.SliceCanvas._labels`.""" """If False, the cursor position shown in the
:class:`fsl.fslview.gl.lightboxcanvas.LightBoxCanvas` instance, which
is contained in this :class:`LightBoxPanel` (the
:attr:`~fsl.fslview.gl.slicecanvas.SliceCanvas.pos` property) will not
be synchronised to the :class:`~fsl.data.fslimage.ImageList.location`
:attr:`~fsl.data.fslimage.ImageList.location` property.
"""
_labels = {
'zrange' : 'Slice range',
'posSync' : 'Synchronise position',
'sliceSpacing' : 'Slice spacing',
'ncols' : 'Number of columns',
'showCursor' : 'Show cursor',
'zax' : 'Z axis'}
"""Property labels to be used for GUI displays."""
_view = lightboxcanvas.LightBoxCanvas._view _view = props.VGroup(('showCursor',
"""See :attr:`fsl.fslview.gl.slicecanvas.SliceCanvas._view`.""" 'posSync',
'zrange',
'sliceSpacing',
'ncols',
'zax'))
"""Layout to be used for GUI displays."""
def __init__(self, parent, *args, **kwargs): def __init__(self, parent, *args, **kwargs):
...@@ -84,6 +111,7 @@ class LightBoxPanel(wx.Panel, props.HasProperties): ...@@ -84,6 +111,7 @@ class LightBoxPanel(wx.Panel, props.HasProperties):
self.Bind(wx.EVT_MOUSEWHEEL, self.onMouseScroll) self.Bind(wx.EVT_MOUSEWHEEL, self.onMouseScroll)
def move(*a): def move(*a):
if not self.posSync: return
xpos = self.imageList.location.getPos(self.canvas.xax) xpos = self.imageList.location.getPos(self.canvas.xax)
ypos = self.imageList.location.getPos(self.canvas.yax) ypos = self.imageList.location.getPos(self.canvas.yax)
zpos = self.imageList.location.getPos(self.canvas.zax) zpos = self.imageList.location.getPos(self.canvas.zax)
...@@ -121,7 +149,10 @@ class LightBoxPanel(wx.Panel, props.HasProperties): ...@@ -121,7 +149,10 @@ class LightBoxPanel(wx.Panel, props.HasProperties):
'({}, {} -> {: 5.2f}, {: 5.2f}, {: 5.2f})'.format( '({}, {} -> {: 5.2f}, {: 5.2f}, {: 5.2f})'.format(
self.canvas.name, mx, my, xpos, ypos, zpos)) self.canvas.name, mx, my, xpos, ypos, zpos))
self.imageList.location.xyz = xpos, ypos, zpos self.canvas.pos.xyz = (xpos, ypos, zpos)
if self.posSync:
self.imageList.location.xyz = xpos, ypos, zpos
def onMouseScroll(self, ev): def onMouseScroll(self, ev):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment