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
Package registry
Model registry
Operate
Environments
Terraform modules
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
Evan Edmond
fslpy
Commits
b12abd5c
Commit
b12abd5c
authored
9 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
LightBoxCanvas/Panel no longer resets sliceSpacing/zrange when selected
overlay, or bounds, change.
parent
67309857
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
fsl/fsleyes/gl/lightboxcanvas.py
+27
-30
27 additions, 30 deletions
fsl/fsleyes/gl/lightboxcanvas.py
fsl/fsleyes/views/lightboxpanel.py
+11
-5
11 additions, 5 deletions
fsl/fsleyes/views/lightboxpanel.py
with
38 additions
and
35 deletions
fsl/fsleyes/gl/lightboxcanvas.py
+
27
−
30
View file @
b12abd5c
...
...
@@ -109,14 +109,6 @@ class LightBoxCanvas(slicecanvas.SliceCanvas):
slicecanvas
.
SliceCanvas
.
__init__
(
self
,
overlayList
,
displayCtx
,
zax
)
# default to showing the entire slice range
zmin
,
zmax
=
displayCtx
.
bounds
.
getRange
(
self
.
zax
)
self
.
zrange
.
xmin
=
zmin
self
.
zrange
.
xmax
=
zmax
self
.
zrange
.
x
=
zmin
,
zmax
self
.
_slicePropsChanged
()
self
.
addListener
(
'
sliceSpacing
'
,
self
.
name
,
self
.
_slicePropsChanged
)
self
.
addListener
(
'
ncols
'
,
self
.
name
,
self
.
_slicePropsChanged
)
self
.
addListener
(
'
nrows
'
,
self
.
name
,
self
.
_slicePropsChanged
)
...
...
@@ -258,6 +250,17 @@ class LightBoxCanvas(slicecanvas.SliceCanvas):
self
.
_genSliceLocations
()
self
.
_zPosChanged
()
self
.
_updateDisplayBounds
()
if
log
.
getEffectiveLevel
()
==
logging
.
DEBUG
:
props
=
[(
'
nrows
'
,
self
.
nrows
),
(
'
ncols
'
,
self
.
ncols
),
(
'
sliceSpacing
'
,
self
.
sliceSpacing
),
(
'
zrange
'
,
self
.
zrange
)]
props
=
'
;
'
.
join
([
'
{}={}
'
.
format
(
k
,
v
)
for
k
,
v
in
props
])
log
.
debug
(
'
Lightbox properties changed: [{}]
'
.
format
(
props
))
self
.
_refresh
()
...
...
@@ -404,12 +407,11 @@ class LightBoxCanvas(slicecanvas.SliceCanvas):
def
_updateZAxisProperties
(
self
):
"""
Called by the :meth:`_overlayBoundsChanged` method.
"""
Called by the :meth:`_overlayListChanged` and
:meth:`_overlayBoundsChanged` methods.
The purpose of this method is to set the slice spacing and displayed Z
range to something sensible when the Z axis, or Z bounds are
changed (e.g. due to overlays being added/removed, or to overlay
transformation matrices being changed).
Updates the constraints (minimum/maximum values) of the
:attr:`sliceSpacing` and :attr:`zrange` properties.
"""
if
len
(
self
.
overlayList
)
==
0
:
...
...
@@ -418,11 +420,15 @@ class LightBoxCanvas(slicecanvas.SliceCanvas):
self
.
sliceSpacing
=
0
else
:
# Pick a sensible default for the
# Get the new Z range from the
# display context bounding box.
#
# And calculate the minimum possible
# slice spacing - the smallest pixdim
# across all overlays in the list
newZGap
=
sys
.
float_info
.
max
# across all overlays in the list.
newZRange
=
self
.
displayCtx
.
bounds
.
getRange
(
self
.
zax
)
newZGap
=
sys
.
float_info
.
max
for
overlay
in
self
.
overlayList
:
overlay
=
self
.
displayCtx
.
getReferenceImage
(
overlay
)
...
...
@@ -442,27 +448,18 @@ class LightBoxCanvas(slicecanvas.SliceCanvas):
if
zgap
<
newZGap
:
newZGap
=
zgap
newZRange
=
self
.
displayCtx
.
bounds
.
getRange
(
self
.
zax
)
# If there were no volumetric overlays
# in the overlay list, choose an arbitrary
# default slice spacing
if
newZGap
==
sys
.
float_info
.
max
:
newZGap
=
(
newZRange
[
1
]
-
newZRange
[
0
])
/
10.0
# Changing the zrange/sliceSpacing properties will, in most cases,
# trigger a call to _slicePropsChanged. But for overlays which have
# the same range across more than one dimension, the call might not
# happen. So we do a check and, if the dimension ranges are the
# same, manually call _slicePropsChanged. Bringing out the ugly
# side of event driven programming.
newZGap
=
(
newZRange
[
1
]
-
newZRange
[
0
])
/
50.0
# Update the zrange and slice
# spacing constraints
self
.
zrange
.
setLimits
(
0
,
*
newZRange
)
self
.
setConstraint
(
'
zrange
'
,
'
minDistance
'
,
newZGap
)
self
.
setConstraint
(
'
sliceSpacing
'
,
'
minval
'
,
newZGap
)
self
.
zrange
.
x
=
newZRange
self
.
sliceSpacing
=
newZGap
def
_overlayBoundsChanged
(
self
,
*
a
):
"""
Overrides :meth:`.SliceCanvas._overlayBoundsChanged`.
...
...
This diff is collapsed.
Click to expand it.
fsl/fsleyes/views/lightboxpanel.py
+
11
−
5
View file @
b12abd5c
...
...
@@ -261,7 +261,11 @@ class LightBoxPanel(canvaspanel.CanvasPanel):
self
.
_name
,
self
.
__transformChanged
)
self
.
__transformChanged
()
# If the current zrange is [0, 0] we'll
# assume that it needs to be initialised.
sceneOpts
=
self
.
getSceneOptions
()
if
sceneOpts
.
zrange
==
[
0.0
,
0.0
]:
sceneOpts
.
zrange
=
self
.
_displayCtx
.
bounds
.
getRange
(
sceneOpts
.
zax
)
def
__transformChanged
(
self
,
*
a
):
...
...
@@ -286,11 +290,13 @@ class LightBoxPanel(canvaspanel.CanvasPanel):
if
opts
.
transform
==
'
id
'
:
sceneOpts
.
sliceSpacing
=
1
sceneOpts
.
zrange
.
x
=
(
0
,
overlay
.
shape
[
sceneOpts
.
zax
]
-
1
)
else
:
elif
opts
.
transform
==
'
pixdim
'
:
sceneOpts
.
sliceSpacing
=
overlay
.
pixdim
[
sceneOpts
.
zax
]
sceneOpts
.
zrange
.
x
=
(
loBounds
[
sceneOpts
.
zax
],
hiBounds
[
sceneOpts
.
zax
])
else
:
sceneOpts
.
sliceSpacing
=
min
(
overlay
.
pixdim
[
sceneOpts
.
zax
])
sceneOpts
.
zrange
.
x
=
(
loBounds
[
sceneOpts
.
zax
],
hiBounds
[
sceneOpts
.
zax
])
self
.
__onResize
()
...
...
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