Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
fslpy
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Analyze
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
FSL
fslpy
Commits
b765f82a
Commit
b765f82a
authored
9 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
SliceCanvas saves/restores overlay resolutions when it changes them (due
to resolutionLimit changes)
parent
f3efdecf
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
fsl/fsleyes/gl/slicecanvas.py
+86
-12
86 additions, 12 deletions
fsl/fsleyes/gl/slicecanvas.py
with
86 additions
and
12 deletions
fsl/fsleyes/gl/slicecanvas.py
+
86
−
12
View file @
b765f82a
...
...
@@ -182,6 +182,16 @@ class SliceCanvas(props.HasProperties):
self
.
_offscreenTextures
=
{}
self
.
_prerenderTextures
=
{}
# When the render mode is changed,
# overlay resolutions are potentially
# modified. When this happends, this
# is used to store the old overlay
# resolution, so it can be restored
# if the render mode is changed back.
# See the __resolutionLimitChanged
# method.
self
.
__overlayResolutions
=
{}
# The zax property is the image axis which maps to the
# 'depth' axis of this canvas. The _zAxisChanged method
# also fixes the values of 'xax' and 'yax'.
...
...
@@ -206,7 +216,7 @@ class SliceCanvas(props.HasProperties):
self
.
addListener
(
'
renderMode
'
,
self
.
name
,
self
.
_renderModeChange
)
self
.
addListener
(
'
resolutionLimit
'
,
self
.
name
,
self
.
_resolutionLimitChange
)
self
.
_
_
resolutionLimitChange
)
# When the overlay list changes, refresh the
# display, and update the display bounds
...
...
@@ -565,12 +575,17 @@ class SliceCanvas(props.HasProperties):
self
.
_renderModeChange
(
self
)
def
_resolutionLimitChange
(
self
,
*
a
):
def
_
_resolutionLimitChange
(
self
,
*
a
):
"""
Called when the :attr:`resolutionLimit` property changes.
Updates the minimum resolution of all overlays in the overlay list.
Updates the :attr:`.ImageOpts.resolution` of all :class:`.Image`
overlays in the overlay list. Whenever the resolution of an
overlay is changed, its old value is saved, so it can be restored
later on when possible.
"""
limit
=
self
.
resolutionLimit
for
ovl
in
self
.
overlayList
:
# No support for non-volumetric overlay
...
...
@@ -578,14 +593,63 @@ class SliceCanvas(props.HasProperties):
if
not
isinstance
(
ovl
,
fslimage
.
Image
):
continue
opts
=
self
.
displayCtx
.
getOpts
(
ovl
)
minres
=
min
(
ovl
.
pixdim
[:
3
])
if
self
.
resolutionLimit
>
minres
:
minres
=
self
.
resolutionLimit
if
opts
.
resolution
<
minres
:
opts
.
resolution
=
minres
opts
=
self
.
displayCtx
.
getOpts
(
ovl
)
currRes
=
opts
.
resolution
lastRes
=
self
.
__overlayResolutions
.
get
(
ovl
)
listening
=
opts
.
hasListener
(
'
resolution
'
,
self
.
name
)
if
listening
:
opts
.
disableListener
(
'
resolution
'
,
self
.
name
)
# The overlay resolution is below
# the limit - set it to the limit
if
currRes
<
limit
:
log
.
debug
(
'
Limiting overlay {} resolution to {}
'
.
format
(
ovl
,
limit
))
opts
.
resolution
=
limit
# Save the old resolution so we
# can restore it later if needed
if
ovl
not
in
self
.
__overlayResolutions
:
log
.
debug
(
'
Caching overlay {} resolution: {}
'
.
format
(
ovl
,
limit
))
self
.
__overlayResolutions
[
ovl
]
=
currRes
# We have previously modified the
# resolution of this overlay - restore
# it
elif
ovl
in
self
.
__overlayResolutions
:
# but only if the old resolution
# is within the new limits.
if
lastRes
>=
limit
:
log
.
debug
(
'
Restoring overlay {} resolution to {},
'
'
and clearing cache
'
.
format
(
ovl
,
lastRes
))
opts
.
resolution
=
lastRes
# We've restored the modified overlay
# resolution - clear it from the cache
self
.
__overlayResolutions
.
pop
(
ovl
)
else
:
log
.
debug
(
'
Limiting overlay {} resolution to {}
'
.
format
(
ovl
,
limit
))
opts
.
resolution
=
limit
if
listening
:
opts
.
enableListener
(
'
resolution
'
,
self
.
name
)
def
__overlayResolutionChanged
(
self
,
value
,
valid
,
opts
,
name
):
"""
Called when the :attr:`.ImageOpts.resolution` property for any
:class:`.Image` overlay changes. Clears the saved resolution for
the overlay if necessary (see :meth:`__resolutionLimitChange`).
"""
self
.
__overlayResolutions
.
pop
(
opts
.
overlay
,
None
)
def
_zAxisChanged
(
self
,
*
a
):
...
...
@@ -709,6 +773,16 @@ class SliceCanvas(props.HasProperties):
self
.
_refresh
,
overwrite
=
True
)
# Listen for resolution changes on Image
# overlays - see __overlayResolutionChanged,
# and __resolutionLimitChanged
if
isinstance
(
overlay
,
fslimage
.
Image
):
opts
=
display
.
getDisplayOpts
()
opts
.
addListener
(
'
resolution
'
,
self
.
name
,
self
.
__overlayResolutionChanged
,
overwrite
=
True
)
return
globj
...
...
@@ -743,7 +817,7 @@ class SliceCanvas(props.HasProperties):
self
.
__genGLObject
(
overlay
,
updateRenderTextures
=
False
)
self
.
_updateRenderTextures
()
self
.
_resolutionLimitChange
()
self
.
_
_
resolutionLimitChange
()
self
.
_refresh
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment