Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
fslpy
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
Michiel Cottaar
fslpy
Commits
c129e70b
Commit
c129e70b
authored
9 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
Pan and zoom mode on time series plot
parent
ee993e1d
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/views/timeseriespanel.py
+96
-1
96 additions, 1 deletion
fsl/fslview/views/timeseriespanel.py
with
96 additions
and
1 deletion
fsl/fslview/views/timeseriespanel.py
+
96
−
1
View file @
c129e70b
...
...
@@ -94,6 +94,15 @@ class TimeSeriesPanel(plotpanel.PlotPanel):
self
,
parent
,
overlayList
,
displayCtx
,
actionz
=
actionz
)
figure
=
self
.
getFigure
()
canvas
=
self
.
getCanvas
()
self
.
__zoomMode
=
False
self
.
__mouseDown
=
None
self
.
__mouseDownLimits
=
None
canvas
.
mpl_connect
(
'
button_press_event
'
,
self
.
__onMouseDown
)
canvas
.
mpl_connect
(
'
button_release_event
'
,
self
.
__onMouseUp
)
canvas
.
mpl_connect
(
'
motion_notify_event
'
,
self
.
__onMouseMove
)
figure
.
subplots_adjust
(
top
=
1.0
,
bottom
=
0.0
,
left
=
0.0
,
right
=
1.0
)
...
...
@@ -185,7 +194,9 @@ class TimeSeriesPanel(plotpanel.PlotPanel):
def
__calcLimits
(
self
,
xlims
,
ylims
):
if
self
.
autoScale
:
if
(
self
.
autoScale
and
self
.
__mouseDown
is
None
)
or
\
(
self
.
xmin
==
self
.
xmax
)
or
\
(
self
.
ymin
==
self
.
ymax
):
xmin
=
min
([
lim
[
0
]
for
lim
in
xlims
])
xmax
=
max
([
lim
[
1
]
for
lim
in
xlims
])
ymin
=
min
([
lim
[
0
]
for
lim
in
ylims
])
...
...
@@ -346,3 +357,87 @@ class TimeSeriesPanel(plotpanel.PlotPanel):
return
((
np
.
nanmin
(
xdata
),
np
.
nanmax
(
xdata
)),
(
np
.
nanmin
(
ydata
),
np
.
nanmax
(
ydata
)))
def
__xform
(
self
,
axis
,
xdata
,
ydata
):
xlim
=
axis
.
get_xlim
()
ylim
=
axis
.
get_ylim
()
x
=
(
xdata
-
xlim
[
0
])
/
(
xlim
[
1
]
-
xlim
[
0
])
y
=
(
ydata
-
ylim
[
0
])
/
(
ylim
[
1
]
-
ylim
[
0
])
return
x
,
y
def
__onMouseDown
(
self
,
ev
):
axis
=
self
.
getAxis
()
if
ev
.
inaxes
!=
axis
:
return
if
ev
.
key
==
'
shift
'
:
self
.
__zoomMode
=
True
else
:
self
.
__zoomMode
=
False
self
.
__mouseDown
=
ev
.
xdata
,
ev
.
ydata
self
.
__mouseDownLimits
=
((
self
.
xmin
,
self
.
xmax
),
(
self
.
ymin
,
self
.
ymax
))
def
__onMouseUp
(
self
,
ev
):
self
.
__mouseDown
=
None
def
__onMouseMove
(
self
,
ev
):
axis
=
self
.
getAxis
()
if
self
.
__mouseDown
is
None
:
return
if
ev
.
inaxes
!=
axis
:
return
if
self
.
__zoomMode
:
newxlim
,
newylim
=
self
.
__zoomLimits
(
ev
)
else
:
newxlim
,
newylim
=
self
.
__panLimits
(
ev
)
for
prop
in
[
'
xmin
'
,
'
xmax
'
,
'
ymin
'
,
'
ymax
'
]:
self
.
disableListener
(
prop
,
self
.
_name
)
self
.
xmin
=
newxlim
[
0
]
self
.
xmax
=
newxlim
[
1
]
self
.
ymin
=
newylim
[
0
]
self
.
ymax
=
newylim
[
1
]
for
prop
in
[
'
xmin
'
,
'
xmax
'
,
'
ymin
'
,
'
ymax
'
]:
self
.
enableListener
(
prop
,
self
.
_name
)
self
.
_draw
()
def
__zoomLimits
(
self
,
ev
):
xlim
,
ylim
=
self
.
__mouseDownLimits
xlen
=
xlim
[
1
]
-
xlim
[
0
]
ylen
=
ylim
[
1
]
-
ylim
[
0
]
xmid
=
xlim
[
0
]
+
0.5
*
xlen
ymid
=
ylim
[
0
]
+
0.5
*
ylen
xdist
=
2
*
(
ev
.
xdata
-
self
.
__mouseDown
[
0
])
ydist
=
2
*
(
ev
.
ydata
-
self
.
__mouseDown
[
1
])
newxlen
=
xlen
*
xlen
/
(
xlen
+
xdist
)
newylen
=
ylen
*
ylen
/
(
ylen
+
ydist
)
newxlim
=
(
xmid
-
newxlen
*
0.5
,
xmid
+
newxlen
*
0.5
)
newylim
=
(
ymid
-
newylen
*
0.5
,
ymid
+
newylen
*
0.5
)
return
newxlim
,
newylim
def
__panLimits
(
self
,
mouseEv
):
xdist
=
self
.
__mouseDown
[
0
]
-
mouseEv
.
xdata
ydist
=
self
.
__mouseDown
[
1
]
-
mouseEv
.
ydata
return
((
self
.
xmin
+
xdist
,
self
.
xmax
+
xdist
),
(
self
.
ymin
+
ydist
,
self
.
ymax
+
ydist
))
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