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
d59bb108
Commit
d59bb108
authored
10 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
Zooming enabled. All working pretty nicely now.
parent
5a0d54d0
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/fslview/orthopanel.py
+86
-78
86 additions, 78 deletions
fsl/fslview/orthopanel.py
with
86 additions
and
78 deletions
fsl/fslview/orthopanel.py
+
86
−
78
View file @
d59bb108
...
@@ -37,6 +37,13 @@ class OrthoPanel(wx.Panel, props.HasProperties):
...
@@ -37,6 +37,13 @@ class OrthoPanel(wx.Panel, props.HasProperties):
maxval
=
20.0
,
maxval
=
20.0
,
default
=
1.0
,
default
=
1.0
,
clamped
=
True
)
clamped
=
True
)
def
_getAxisVal
(
self
,
axis
):
if
axis
==
0
:
return
self
.
xpos
elif
axis
==
1
:
return
self
.
ypos
elif
axis
==
2
:
return
self
.
zpos
def
__init__
(
self
,
parent
,
imageList
):
def
__init__
(
self
,
parent
,
imageList
):
"""
"""
...
@@ -69,12 +76,12 @@ class OrthoPanel(wx.Panel, props.HasProperties):
...
@@ -69,12 +76,12 @@ class OrthoPanel(wx.Panel, props.HasProperties):
self
.
Layout
()
self
.
Layout
()
self
.
xcanvas
.
Bind
(
wx
.
EVT_LEFT_DOWN
,
self
.
_
setCanvasPosition
)
self
.
xcanvas
.
Bind
(
wx
.
EVT_LEFT_DOWN
,
self
.
_
onMouseEvent
)
self
.
ycanvas
.
Bind
(
wx
.
EVT_LEFT_DOWN
,
self
.
_
setCanvasPosition
)
self
.
ycanvas
.
Bind
(
wx
.
EVT_LEFT_DOWN
,
self
.
_
onMouseEvent
)
self
.
zcanvas
.
Bind
(
wx
.
EVT_LEFT_DOWN
,
self
.
_
setCanvasPosition
)
self
.
zcanvas
.
Bind
(
wx
.
EVT_LEFT_DOWN
,
self
.
_
onMouseEvent
)
self
.
xcanvas
.
Bind
(
wx
.
EVT_MOTION
,
self
.
_
setCanvasPosition
)
self
.
xcanvas
.
Bind
(
wx
.
EVT_MOTION
,
self
.
_
onMouseEvent
)
self
.
ycanvas
.
Bind
(
wx
.
EVT_MOTION
,
self
.
_
setCanvasPosition
)
self
.
ycanvas
.
Bind
(
wx
.
EVT_MOTION
,
self
.
_
onMouseEvent
)
self
.
zcanvas
.
Bind
(
wx
.
EVT_MOTION
,
self
.
_
setCanvasPosition
)
self
.
zcanvas
.
Bind
(
wx
.
EVT_MOTION
,
self
.
_
onMouseEvent
)
xmin
=
imageList
.
minBounds
[
0
]
xmin
=
imageList
.
minBounds
[
0
]
xmax
=
imageList
.
maxBounds
[
0
]
xmax
=
imageList
.
maxBounds
[
0
]
...
@@ -90,10 +97,25 @@ class OrthoPanel(wx.Panel, props.HasProperties):
...
@@ -90,10 +97,25 @@ class OrthoPanel(wx.Panel, props.HasProperties):
self
.
imageList
.
addListener
(
lambda
il
:
self
.
_updateImageBounds
())
self
.
imageList
.
addListener
(
lambda
il
:
self
.
_updateImageBounds
())
self
.
_updateImageBounds
()
self
.
_updateImageBounds
()
self
.
_configPosListeners
()
self
.
_configShowListeners
()
self
.
_configShowListeners
()
self
.
_configZoomListeners
()
self
.
_configZoomListeners
()
def
_configPosListeners
(
self
):
def
moveX
(
ctx
,
value
,
valid
):
self
.
_setPosition
(
value
,
self
.
ypos
,
self
.
zpos
)
def
moveY
(
ctx
,
value
,
valid
):
self
.
_setPosition
(
self
.
xpos
,
value
,
self
.
zpos
)
def
moveZ
(
ctx
,
value
,
valid
):
self
.
_setPosition
(
self
.
xpos
,
self
.
ypos
,
value
)
self
.
addListener
(
'
xpos
'
,
self
.
name
,
moveX
)
self
.
addListener
(
'
ypos
'
,
self
.
name
,
moveY
)
self
.
addListener
(
'
zpos
'
,
self
.
name
,
moveZ
)
def
_configShowListeners
(
self
):
def
_configShowListeners
(
self
):
def
showCursor
(
ctx
,
value
,
valid
):
def
showCursor
(
ctx
,
value
,
valid
):
self
.
xcanvas
.
showCursor
=
value
self
.
xcanvas
.
showCursor
=
value
...
@@ -119,26 +141,32 @@ class OrthoPanel(wx.Panel, props.HasProperties):
...
@@ -119,26 +141,32 @@ class OrthoPanel(wx.Panel, props.HasProperties):
def
_configZoomListeners
(
self
):
def
_configZoomListeners
(
self
):
def
x
zoom
(
c
tx
,
value
,
val
id
):
def
zoom
(
c
anvas
,
xax
,
yax
,
val
ue
):
value
=
1.0
/
value
value
=
1.0
/
value
xlen
=
value
*
abs
(
self
.
imageList
.
maxBounds
[
1
]
-
xlen
=
value
*
abs
(
self
.
imageList
.
maxBounds
[
xax
]
-
self
.
imageList
.
minBounds
[
1
])
self
.
imageList
.
minBounds
[
xax
])
ylen
=
value
*
abs
(
self
.
imageList
.
maxBounds
[
2
]
-
ylen
=
value
*
abs
(
self
.
imageList
.
maxBounds
[
yax
]
-
self
.
imageList
.
minBounds
[
2
])
self
.
imageList
.
minBounds
[
yax
])
if
value
==
1
:
if
value
==
1
:
xcentre
=
self
.
imageList
.
minBounds
[
1
]
+
0.5
*
xlen
xcentre
=
self
.
imageList
.
minBounds
[
xax
]
+
0.5
*
xlen
ycentre
=
self
.
imageList
.
minBounds
[
2
]
+
0.5
*
ylen
ycentre
=
self
.
imageList
.
minBounds
[
yax
]
+
0.5
*
ylen
else
:
else
:
xcentre
=
self
.
ypos
xcentre
=
self
.
_getAxisVal
(
xax
)
ycentre
=
self
.
zpos
ycentre
=
self
.
_getAxisVal
(
yax
)
self
.
x
canvas
.
xmin
=
xcentre
-
0.5
*
xlen
canvas
.
xmin
=
xcentre
-
0.5
*
xlen
self
.
x
canvas
.
xmax
=
xcentre
+
0.5
*
xlen
canvas
.
xmax
=
xcentre
+
0.5
*
xlen
self
.
x
canvas
.
ymin
=
ycentre
-
0.5
*
ylen
canvas
.
ymin
=
ycentre
-
0.5
*
ylen
self
.
x
canvas
.
ymax
=
ycentre
+
0.5
*
ylen
canvas
.
ymax
=
ycentre
+
0.5
*
ylen
def
xzoom
(
ctx
,
value
,
valid
):
zoom
(
self
.
xcanvas
,
1
,
2
,
value
)
def
yzoom
(
ctx
,
value
,
valid
):
zoom
(
self
.
ycanvas
,
0
,
2
,
value
)
def
zzoom
(
ctx
,
value
,
valid
):
zoom
(
self
.
zcanvas
,
0
,
1
,
value
)
self
.
addListener
(
'
xCanvasZoom
'
,
self
.
name
,
xzoom
)
self
.
addListener
(
'
xCanvasZoom
'
,
self
.
name
,
xzoom
)
self
.
addListener
(
'
yCanvasZoom
'
,
self
.
name
,
yzoom
)
self
.
addListener
(
'
zCanvasZoom
'
,
self
.
name
,
zzoom
)
def
_updateImageBounds
(
self
):
def
_updateImageBounds
(
self
):
...
@@ -166,7 +194,7 @@ class OrthoPanel(wx.Panel, props.HasProperties):
...
@@ -166,7 +194,7 @@ class OrthoPanel(wx.Panel, props.HasProperties):
self
.
zpos
=
self
.
zpos
self
.
zpos
=
self
.
zpos
def
_shiftCanvas
(
self
,
canvas
,
xax
,
yax
,
newx
,
newy
):
def
_shiftCanvas
(
self
,
canvas
,
newx
,
newy
):
if
newx
>=
canvas
.
xmin
and
\
if
newx
>=
canvas
.
xmin
and
\
newx
<=
canvas
.
xmax
and
\
newx
<=
canvas
.
xmax
and
\
...
@@ -174,6 +202,9 @@ class OrthoPanel(wx.Panel, props.HasProperties):
...
@@ -174,6 +202,9 @@ class OrthoPanel(wx.Panel, props.HasProperties):
newy
<=
canvas
.
ymax
:
newy
<=
canvas
.
ymax
:
return
return
xax
=
canvas
.
xax
yax
=
canvas
.
yax
xshift
=
0
xshift
=
0
yshift
=
0
yshift
=
0
...
@@ -211,8 +242,38 @@ class OrthoPanel(wx.Panel, props.HasProperties):
...
@@ -211,8 +242,38 @@ class OrthoPanel(wx.Panel, props.HasProperties):
canvas
.
ymin
=
newymin
canvas
.
ymin
=
newymin
canvas
.
ymax
=
newymax
canvas
.
ymax
=
newymax
def
_setPosition
(
self
,
xpos
,
ypos
,
zpos
):
"""
Called on mouse movement and left clicks. The currently
displayed slices and cursor positions on each of the
canvases follow mouse clicks and drags, and an
EVT_LOCATION_EVENT is emitted when the cursor position
changes.
"""
self
.
xpos
=
xpos
self
.
ypos
=
ypos
self
.
zpos
=
zpos
self
.
xcanvas
.
xpos
=
ypos
self
.
xcanvas
.
ypos
=
zpos
self
.
xcanvas
.
zpos
=
xpos
self
.
ycanvas
.
xpos
=
xpos
self
.
ycanvas
.
ypos
=
zpos
self
.
ycanvas
.
zpos
=
ypos
def
_setCanvasPosition
(
self
,
ev
):
self
.
zcanvas
.
xpos
=
xpos
self
.
zcanvas
.
ypos
=
ypos
self
.
zcanvas
.
zpos
=
zpos
if
self
.
xCanvasZoom
!=
1
:
self
.
_shiftCanvas
(
self
.
xcanvas
,
ypos
,
zpos
)
if
self
.
yCanvasZoom
!=
1
:
self
.
_shiftCanvas
(
self
.
ycanvas
,
xpos
,
zpos
)
if
self
.
zCanvasZoom
!=
1
:
self
.
_shiftCanvas
(
self
.
zcanvas
,
xpos
,
ypos
)
def
_onMouseEvent
(
self
,
ev
):
"""
"""
Called on mouse movement and left clicks. The currently
Called on mouse movement and left clicks. The currently
displayed slices and cursor positions on each of the
displayed slices and cursor positions on each of the
...
@@ -233,63 +294,10 @@ class OrthoPanel(wx.Panel, props.HasProperties):
...
@@ -233,63 +294,10 @@ class OrthoPanel(wx.Panel, props.HasProperties):
xpos
=
source
.
canvasToWorldX
(
mx
)
xpos
=
source
.
canvasToWorldX
(
mx
)
ypos
=
source
.
canvasToWorldY
(
my
)
ypos
=
source
.
canvasToWorldY
(
my
)
if
source
==
self
.
xcanvas
:
if
source
==
self
.
xcanvas
:
self
.
_setPosition
(
self
.
xpos
,
xpos
,
ypos
)
self
.
ypos
=
xpos
elif
source
==
self
.
ycanvas
:
self
.
_setPosition
(
xpos
,
self
.
ypos
,
ypos
)
self
.
zpos
=
ypos
elif
source
==
self
.
zcanvas
:
self
.
_setPosition
(
xpos
,
ypos
,
self
.
zpos
)
self
.
xcanvas
.
xpos
=
xpos
self
.
xcanvas
.
ypos
=
ypos
self
.
ycanvas
.
ypos
=
ypos
self
.
ycanvas
.
zpos
=
xpos
self
.
zcanvas
.
ypos
=
xpos
self
.
zcanvas
.
zpos
=
ypos
if
self
.
yCanvasZoom
!=
1
:
self
.
_shiftCanvas
(
self
.
ycanvas
,
0
,
2
,
self
.
ycanvas
.
xpos
,
ypos
)
if
self
.
zCanvasZoom
!=
1
:
self
.
_shiftCanvas
(
self
.
zcanvas
,
0
,
1
,
self
.
zcanvas
.
xpos
,
xpos
)
elif
source
==
self
.
ycanvas
:
self
.
xpos
=
xpos
self
.
zpos
=
ypos
self
.
ycanvas
.
xpos
=
xpos
self
.
ycanvas
.
ypos
=
ypos
self
.
xcanvas
.
ypos
=
ypos
self
.
xcanvas
.
zpos
=
xpos
self
.
zcanvas
.
xpos
=
xpos
self
.
zcanvas
.
zpos
=
ypos
if
self
.
xCanvasZoom
!=
1
:
self
.
_shiftCanvas
(
self
.
xcanvas
,
1
,
2
,
self
.
xcanvas
.
xpos
,
ypos
)
if
self
.
zCanvasZoom
!=
1
:
self
.
_shiftCanvas
(
self
.
zcanvas
,
0
,
1
,
xpos
,
self
.
zcanvas
.
ypos
)
elif
source
==
self
.
zcanvas
:
self
.
xpos
=
xpos
self
.
ypos
=
ypos
self
.
zcanvas
.
xpos
=
xpos
self
.
zcanvas
.
ypos
=
ypos
self
.
xcanvas
.
xpos
=
ypos
self
.
xcanvas
.
zpos
=
xpos
self
.
ycanvas
.
xpos
=
xpos
self
.
ycanvas
.
zpos
=
ypos
if
self
.
xCanvasZoom
!=
1
:
self
.
_shiftCanvas
(
self
.
xcanvas
,
1
,
2
,
ypos
,
self
.
xcanvas
.
ypos
)
if
self
.
yCanvasZoom
!=
1
:
self
.
_shiftCanvas
(
self
.
ycanvas
,
0
,
2
,
xpos
,
self
.
ycanvas
.
ypos
)
class
OrthoFrame
(
wx
.
Frame
):
class
OrthoFrame
(
wx
.
Frame
):
"""
"""
...
...
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