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
fd6677c0
Commit
fd6677c0
authored
9 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
Cosmetic name change in Profile - Profiles are available on all
ViewPanels, not just CanvasPanels.
parent
fafa4200
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
fsl/fslview/profiles/__init__.py
+31
-31
31 additions, 31 deletions
fsl/fslview/profiles/__init__.py
with
31 additions
and
31 deletions
fsl/fslview/profiles/__init__.py
+
31
−
31
View file @
fd6677c0
...
...
@@ -5,19 +5,19 @@
# Author: Paul McCarthy <pauldmccarthy@gmail.com>
#
"""
The :mod:`profiles` module contains logic for mouse/keyboard interaction
with :class:`.
Canvas
Panel` panels.
with :class:`.
View
Panel` panels.
This logic is encapsulated in two classes:
- The :class:`Profile` class is intended to be subclassed. A :class:`Profile`
instance contains the mouse/keyboard event handlers for a particular type
of ``
Canvas
Panel`` to allow the user to interact with the
canvas
in a
of ``
View
Panel`` to allow the user to interact with the
view
in a
particular way. For example, the :class:`.OrthoViewProfile` class allows
the user to navigate through the display space in an :class:`.OrthoPanel`
canvas, wherease the :class:`.OrthoEditProfile` class contains interaction
logic for selecting and editing image voxels in an ``OrthoPanel``.
- The :class:`ProfileManager` class is used by ``
Canvas
Panel`` instances to
- The :class:`ProfileManager` class is used by ``
View
Panel`` instances to
create and change the ``Profile`` instance currently in use.
"""
...
...
@@ -34,7 +34,7 @@ import fsl.fslview.actions as actions
class
Profile
(
actions
.
ActionProvider
):
"""
A :class:`Profile` class implements keyboard/mouse interaction behaviour
for a :class:`.
Canvas
Panel` instance.
for a :class:`.
View
Panel` instance.
Subclasses should specify at least one
'
mode
'
of operation, which defines
...
...
@@ -103,14 +103,14 @@ class Profile(actions.ActionProvider):
def
__init__
(
self
,
canvas
Panel
,
view
Panel
,
overlayList
,
displayCtx
,
modes
=
None
,
actionz
=
None
):
"""
Create a :class:`Profile` instance.
:arg
canvas
Panel: The :class:`.
Canvas
Panel` instance for which this
:arg
view
Panel:
The :class:`.
View
Panel` instance for which this
:class:`Profile` instance defines mouse/keyboard
interaction behaviour.
...
...
@@ -132,12 +132,12 @@ class Profile(actions.ActionProvider):
for
name
,
func
in
actionz
.
items
():
def
wrap
(
f
=
func
):
f
()
canvas
Panel
.
Refresh
()
view
Panel
.
Refresh
()
actionz
[
name
]
=
wrap
actions
.
ActionProvider
.
__init__
(
self
,
overlayList
,
displayCtx
,
actionz
)
self
.
_
canvasPanel
=
canvas
Panel
self
.
_
viewPanel
=
view
Panel
self
.
_overlayList
=
overlayList
self
.
_displayCtx
=
displayCtx
self
.
_name
=
'
{}_{}
'
.
format
(
self
.
__class__
.
__name__
,
id
(
self
))
...
...
@@ -265,7 +265,7 @@ class Profile(actions.ActionProvider):
t
.
Bind
(
wx
.
EVT_MOTION
,
None
)
t
.
Bind
(
wx
.
EVT_MOUSEWHEEL
,
None
)
t
.
Bind
(
wx
.
EVT_CHAR
,
None
)
self
.
_
canvas
Panel
.
Refresh
()
self
.
_
view
Panel
.
Refresh
()
def
__getTempMode
(
self
,
ev
):
...
...
@@ -392,7 +392,7 @@ class Profile(actions.ActionProvider):
wheel
,
canvas
.
name
))
handler
(
ev
,
canvas
,
wheel
,
mouseLoc
,
canvasLoc
)
self
.
_
canvas
Panel
.
Refresh
()
self
.
_
view
Panel
.
Refresh
()
def
__onMouseDown
(
self
,
ev
):
...
...
@@ -419,7 +419,7 @@ class Profile(actions.ActionProvider):
mouseLoc
,
canvasLoc
,
canvas
.
name
))
handler
(
ev
,
canvas
,
mouseLoc
,
canvasLoc
)
self
.
_
canvas
Panel
.
Refresh
()
self
.
_
view
Panel
.
Refresh
()
self
.
__lastMousePos
=
mouseLoc
self
.
__lastCanvasPos
=
canvasLoc
...
...
@@ -446,7 +446,7 @@ class Profile(actions.ActionProvider):
mouseLoc
,
canvasLoc
,
canvas
.
name
))
handler
(
ev
,
canvas
,
mouseLoc
,
canvasLoc
)
self
.
_
canvas
Panel
.
Refresh
()
self
.
_
view
Panel
.
Refresh
()
self
.
__mouseDownPos
=
None
self
.
__canvasDownPos
=
None
...
...
@@ -474,7 +474,7 @@ class Profile(actions.ActionProvider):
mouseLoc
,
canvasLoc
,
canvas
.
name
))
handler
(
ev
,
canvas
,
mouseLoc
,
canvasLoc
)
self
.
_
canvas
Panel
.
Refresh
()
self
.
_
view
Panel
.
Refresh
()
self
.
__lastMousePos
=
mouseLoc
self
.
__lastCanvasPos
=
canvasLoc
...
...
@@ -499,7 +499,7 @@ class Profile(actions.ActionProvider):
mouseLoc
,
canvasLoc
,
canvas
.
name
))
handler
(
ev
,
canvas
,
mouseLoc
,
canvasLoc
)
self
.
_
canvas
Panel
.
Refresh
()
self
.
_
view
Panel
.
Refresh
()
self
.
__lastMousePos
=
mouseLoc
self
.
__lastCanvasPos
=
canvasLoc
...
...
@@ -521,24 +521,24 @@ class Profile(actions.ActionProvider):
log
.
debug
(
'
Keyboard event ({}) on canvas {}
'
.
format
(
key
,
canvas
.
name
))
handler
(
ev
,
canvas
,
key
)
self
.
_
canvas
Panel
.
Refresh
()
self
.
_
view
Panel
.
Refresh
()
class
ProfileManager
(
object
):
"""
Manages creation/registration/de-regsistration of :class:`Profile`
instances for a :class:`.
Canvas
Panel` instance.
instances for a :class:`.
View
Panel` instance.
A :class:`ProfileManager` instance is created and used by every
:class:`.
Canvas
Panel` instance. The :mod:`.profilemap` defines the
:class:`.
View
Panel` instance. The :mod:`.profilemap` defines the
:class:`Profile` types which should be used for specific
:class:`.
Canvas
Panel` types.
:class:`.
View
Panel` types.
"""
def
__init__
(
self
,
canvas
Panel
,
overlayList
,
displayCtx
):
def
__init__
(
self
,
view
Panel
,
overlayList
,
displayCtx
):
"""
Create a :class:`ProfileManager`.
:arg
canvas
Panel: The :class:`.
Canvas
Panel` instance which this
:arg
view
Panel:
The :class:`.
View
Panel` instance which this
:class:`ProfileManager` is to manage.
:arg overlayList: The :class:`.OverlayList` instance containing the
...
...
@@ -550,23 +550,23 @@ class ProfileManager(object):
"""
import
profilemap
self
.
_
canvas
Panel
=
canvas
Panel
self
.
_
canvas
Cls
=
canvas
Panel
.
__class__
self
.
_
view
Panel
=
view
Panel
self
.
_
view
Cls
=
view
Panel
.
__class__
self
.
_overlayList
=
overlayList
self
.
_displayCtx
=
displayCtx
self
.
_currentProfile
=
None
profileProp
=
canvas
Panel
.
getProp
(
'
profile
'
)
profilez
=
profilemap
.
profiles
.
get
(
canvas
Panel
.
__class__
,
[])
profileProp
=
view
Panel
.
getProp
(
'
profile
'
)
profilez
=
profilemap
.
profiles
.
get
(
view
Panel
.
__class__
,
[])
for
profile
in
profilez
:
profileProp
.
addChoice
(
profile
,
strings
.
profiles
[
canvas
Panel
,
profile
],
canvas
Panel
)
strings
.
profiles
[
view
Panel
,
profile
],
view
Panel
)
if
len
(
profilez
)
>
0
:
canvas
Panel
.
profile
=
profilez
[
0
]
view
Panel
.
profile
=
profilez
[
0
]
def
getCurrentProfile
(
self
):
...
...
@@ -581,7 +581,7 @@ class ProfileManager(object):
import
profilemap
profileCls
=
profilemap
.
profileHandlers
[
self
.
_
canvas
Cls
,
profile
]
profileCls
=
profilemap
.
profileHandlers
[
self
.
_
view
Cls
,
profile
]
# the current profile is the requested profile
if
(
self
.
_currentProfile
is
not
None
)
and
\
...
...
@@ -591,15 +591,15 @@ class ProfileManager(object):
if
self
.
_currentProfile
is
not
None
:
log
.
debug
(
'
Deregistering {} profile from {}
'
.
format
(
self
.
_currentProfile
.
__class__
.
__name__
,
self
.
_
canvas
Cls
.
__name__
))
self
.
_
view
Cls
.
__name__
))
self
.
_currentProfile
.
deregister
()
self
.
_currentProfile
=
profileCls
(
self
.
_
canvas
Panel
,
self
.
_currentProfile
=
profileCls
(
self
.
_
view
Panel
,
self
.
_overlayList
,
self
.
_displayCtx
)
log
.
debug
(
'
Registering {} profile with {}
'
.
format
(
self
.
_currentProfile
.
__class__
.
__name__
,
self
.
_
canvas
Cls
.
__name__
))
self
.
_
view
Cls
.
__name__
))
self
.
_currentProfile
.
register
()
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