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

Edit profile only works for images with a 'volume' type. Little bugfixes

in editor/selection so they work with 4D images.
parent 4615d134
No related branches found
No related tags found
No related merge requests found
......@@ -140,7 +140,13 @@ class Editor(props.HasProperties):
if len(self._undoneStack) == 0:
self.canRedo = False
image = change.image
image = change.image
display = self._displayCtx.getDisplayProperties(image)
volume = None
if image.is4DImage():
volume = display.volume
if self._displayCtx.getSelectedImage() != image:
self._displayCtx.selectImage(image)
......@@ -151,7 +157,7 @@ class Editor(props.HasProperties):
return
if isinstance(change, ValueChange):
change.image.applyChange(change.selection, change.newVals)
change.image.applyChange(change.selection, change.newVals, volume)
elif isinstance(change, SelectionChange):
self._selection.disableListener('selection', self._name)
......
......@@ -29,7 +29,7 @@ class Selection(props.HasProperties):
self._image = image
self._lastSelection = None
self._currentSelection = None
self.selection = np.zeros(image.shape, dtype=np.bool)
self.selection = np.zeros(image.shape[:3], dtype=np.bool)
def _filterVoxels(self, xyzs):
......
......@@ -133,7 +133,9 @@ class OrthoEditProfile(orthoviewprofile.OrthoViewProfile):
self._selAnnotation = None
self._tempAnnotation = None
if image is None:
# Edit mode is only supported on images with
# the 'volume' type for the time being
if image is None or image.imageType != 'volume':
return
selection.addListener('selection', self._name, self._selectionChanged)
......@@ -350,8 +352,9 @@ class OrthoEditProfile(orthoviewprofile.OrthoViewProfile):
image = self._displayCtx.getSelectedImage()
display = self._displayCtx.getDisplayProperties(image)
opts = display.displayOpts
step = display.displayRange.xlen / 50.0
step = opts.displayRange.xlen / 50.0
if wheel > 0: self.intensityThres += step
elif wheel < 0: self.intensityThres -= step
......
......@@ -296,8 +296,16 @@ class CanvasPanel(fslpanel.FSLViewPanel):
self.addListener('colourBarLocation', lName, self.__layout)
self.addListener('profile', lName, self.__profileChanged)
imageList .addListener('images',
lName,
self.__selectedImageChanged)
displayCtx.addListener('selectedImage',
lName,
self.__selectedImageChanged)
self._init()
self.__profileChanged()
self.__selectedImageChanged()
self.__layout()
......@@ -306,6 +314,41 @@ class CanvasPanel(fslpanel.FSLViewPanel):
'provided by subclasses')
def __selectedImageChanged(self, *a):
"""Called when the image list or selected image changed.
This method is slightly hard-coded and hacky. For the time being, edit
profiles are only going to be supported for ``volume`` image
types. This method checks the type of the selected image, and disables
the ``edit`` profile option (if it is an option), so the user can
only choose an ``edit`` profile on ``volume`` image types.
"""
image = self._displayCtx.getSelectedImage()
if image is None:
return
profileProp = self.getProp('profile')
# edit profile is not an option -
# nothing to be done
if 'edit' not in profileProp.getChoices(self):
return
if image.imageType != 'volume':
# change profile if needed,
if self.profile == 'edit':
self.profile = 'view'
# and disable edit profile
profileProp.disableChoice('edit', self)
# make sure edit is enabled for volume images
else:
profileProp.enableChoice('edit', self)
def __profileChanged(self, *a):
import fsl.fslview.layouts as layouts
......
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