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
08142e75
Commit
08142e75
authored
11 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
Working on a little image list widget. Sorta functional, but still buggy
parent
7cfa6c1a
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
fsl/data/fslimage.py
+2
-1
2 additions, 1 deletion
fsl/data/fslimage.py
fsl/utils/imageview.py
+166
-7
166 additions, 7 deletions
fsl/utils/imageview.py
with
168 additions
and
8 deletions
fsl/data/fslimage.py
+
2
−
1
View file @
08142e75
...
...
@@ -161,8 +161,9 @@ class ImageList(object):
def
pop
(
self
,
index
=-
1
):
self
.
_images
.
pop
(
index
)
popped
=
self
.
_images
.
pop
(
index
)
self
.
notify
()
return
popped
def
insert
(
self
,
index
,
image
):
...
...
This diff is collapsed.
Click to expand it.
fsl/utils/imageview.py
+
166
−
7
View file @
08142e75
...
...
@@ -2,7 +2,7 @@
#
# imgshow.py - A wx/OpenGL widget for displaying and interacting with a
# collection of 3D images. Displays three canvases, each of which shows
# a slice of the images along each dimension.
#
# Author: Paul McCarthy <pauldmccarthy@gmail.com>
#
...
...
@@ -28,6 +28,170 @@ import fsl.utils.slicecanvas as slicecanvas
LocationEvent
,
EVT_LOCATION_EVENT
=
wxevent
.
NewEvent
()
class
EditableListBox
(
wx
.
Panel
):
"""
wx.gizmos.EditableListBox is rubbish.
"""
ListSelectEvent
,
EVT_ELB_SELECT_EVENT
=
wxevent
.
NewEvent
()
ListAddEvent
,
EVT_ELB_ADD_EVENT
=
wxevent
.
NewEvent
()
ListRemoveEvent
,
EVT_ELB_REMOVE_EVENT
=
wxevent
.
NewEvent
()
ListMoveEvent
,
EVT_ELB_MOVE_EVENT
=
wxevent
.
NewEvent
()
def
__init__
(
self
,
parent
,
choices
,
clientData
):
wx
.
Panel
.
__init__
(
self
,
parent
)
self
.
listBox
=
wx
.
ListBox
(
self
,
style
=
wx
.
LB_SINGLE
|
wx
.
LB_NEEDED_SB
)
for
choice
,
data
in
zip
(
choices
,
clientData
):
self
.
listBox
.
Append
(
choice
,
data
)
self
.
listBox
.
Bind
(
wx
.
EVT_LISTBOX
,
self
.
itemSelected
)
self
.
buttonPanel
=
wx
.
Panel
(
self
)
self
.
upButton
=
wx
.
Button
(
self
.
buttonPanel
,
label
=
u
'
\u25B2
'
)
self
.
downButton
=
wx
.
Button
(
self
.
buttonPanel
,
label
=
u
'
\u25BC
'
)
self
.
addButton
=
wx
.
Button
(
self
.
buttonPanel
,
label
=
'
+
'
)
self
.
removeButton
=
wx
.
Button
(
self
.
buttonPanel
,
label
=
'
-
'
)
self
.
upButton
.
Bind
(
wx
.
EVT_BUTTON
,
self
.
moveItemUp
)
self
.
downButton
.
Bind
(
wx
.
EVT_BUTTON
,
self
.
moveItemDown
)
self
.
addButton
.
Bind
(
wx
.
EVT_BUTTON
,
self
.
addItem
)
self
.
removeButton
.
Bind
(
wx
.
EVT_BUTTON
,
self
.
removeItem
)
self
.
buttonPanelSizer
=
wx
.
BoxSizer
(
wx
.
VERTICAL
)
self
.
buttonPanel
.
SetSizer
(
self
.
buttonPanelSizer
)
self
.
buttonPanelSizer
.
Add
(
self
.
upButton
)
self
.
buttonPanelSizer
.
Add
(
self
.
downButton
)
self
.
buttonPanelSizer
.
Add
(
self
.
addButton
)
self
.
buttonPanelSizer
.
Add
(
self
.
removeButton
)
self
.
sizer
=
wx
.
BoxSizer
(
wx
.
HORIZONTAL
)
self
.
SetSizer
(
self
.
sizer
)
self
.
sizer
.
Add
(
self
.
buttonPanel
,
flag
=
wx
.
EXPAND
)
self
.
sizer
.
Add
(
self
.
listBox
,
flag
=
wx
.
EXPAND
,
proportion
=
1
)
self
.
Layout
()
def
itemSelected
(
self
,
ev
):
idx
=
ev
.
GetSelection
()
choice
=
self
.
listBox
.
GetString
(
idx
)
data
=
self
.
listBox
.
GetClientData
(
idx
)
print
'
selected {}
'
.
format
(
idx
)
ev
=
EditableListBox
.
ListSelectEvent
(
idx
=
idx
,
choice
=
choice
,
data
=
data
)
wx
.
PostEvent
(
self
,
ev
)
def
moveItem
(
self
,
oldIdx
,
newIdx
):
# nothing is selected
if
oldIdx
==
wx
.
NOT_FOUND
:
return
choice
=
self
.
listBox
.
GetString
(
oldIdx
)
data
=
self
.
listBox
.
GetClientData
(
oldIdx
)
choices
=
self
.
listBox
.
GetItems
()
if
oldIdx
<
0
or
oldIdx
>=
len
(
choices
):
return
if
newIdx
<
0
or
newIdx
>=
len
(
choices
):
return
self
.
listBox
.
Delete
(
oldIdx
)
self
.
listBox
.
Insert
(
choice
,
newIdx
,
data
)
self
.
listBox
.
SetSelection
(
newIdx
)
ev
=
EditableListBox
.
ListMoveEvent
(
oldIdx
=
oldIdx
,
newIdx
=
newIdx
,
choice
=
choice
,
data
=
data
)
wx
.
PostEvent
(
self
,
ev
)
def
moveItemDown
(
self
,
ev
):
oldIdx
=
self
.
listBox
.
GetSelection
()
newIdx
=
oldIdx
+
1
self
.
moveItem
(
oldIdx
,
newIdx
)
def
moveItemUp
(
self
,
ev
):
oldIdx
=
self
.
listBox
.
GetSelection
()
newIdx
=
oldIdx
-
1
self
.
moveItem
(
oldIdx
,
newIdx
)
def
addItem
(
self
,
ev
):
pass
def
removeItem
(
self
,
ev
):
pass
class
DisplayControl
(
wx
.
Panel
):
def
__init__
(
self
,
parent
,
imageList
):
wx
.
Panel
.
__init__
(
self
,
parent
)
self
.
imageList
=
imageList
imageNames
=
[
img
.
name
for
img
in
imageList
]
self
.
listBox
=
EditableListBox
(
self
,
imageNames
,
imageList
)
self
.
listBox
.
Bind
(
EditableListBox
.
EVT_ELB_SELECT_EVENT
,
self
.
imageSelected
)
self
.
listBox
.
Bind
(
EditableListBox
.
EVT_ELB_MOVE_EVENT
,
self
.
imageMoved
)
self
.
editPanels
=
[]
for
image
in
imageList
:
displayProps
=
props
.
buildGUI
(
self
,
image
.
display
)
self
.
editPanels
.
append
(
displayProps
)
self
.
sizer
=
wx
.
BoxSizer
(
wx
.
HORIZONTAL
)
self
.
SetSizer
(
self
.
sizer
)
self
.
sizer
.
Add
(
self
.
listBox
,
flag
=
wx
.
EXPAND
,
proportion
=
1
)
for
i
,
editPanel
in
enumerate
(
self
.
editPanels
):
self
.
sizer
.
Add
(
editPanel
,
flag
=
wx
.
EXPAND
,
proportion
=
2
)
editPanel
.
Show
(
i
==
0
)
self
.
Layout
()
def
imageMoved
(
self
,
ev
):
oldIdx
=
ev
.
oldIdx
newIdx
=
ev
.
newIdx
image
=
self
.
imageList
.
pop
(
oldIdx
)
self
.
imageList
.
insert
(
newIdx
,
image
)
self
.
Refresh
()
def
imageSelected
(
self
,
ev
):
"""
"""
print
'
imageSelected
'
for
i
,
editPanel
in
enumerate
(
self
.
editPanels
):
editPanel
.
Show
(
i
==
ev
.
idx
)
self
.
Layout
()
class
ImageView
(
wx
.
Panel
):
def
__init__
(
self
,
parent
,
imageList
,
*
args
,
**
kwargs
):
...
...
@@ -59,12 +223,7 @@ class ImageView(wx.Panel):
self
.
zcanvas
=
slicecanvas
.
SliceCanvas
(
self
.
canvasPanel
,
imageList
,
zax
=
2
,
context
=
self
.
xcanvas
.
context
)
self
.
controlPanel
=
wx
.
Notebook
(
self
)
for
image
in
imageList
:
displayProps
=
props
.
buildGUI
(
self
.
controlPanel
,
image
.
display
)
self
.
controlPanel
.
AddPage
(
displayProps
,
image
.
name
)
self
.
controlPanel
=
DisplayControl
(
self
,
imageList
)
self
.
mainSizer
=
wx
.
BoxSizer
(
wx
.
VERTICAL
)
self
.
canvasSizer
=
wx
.
BoxSizer
(
wx
.
HORIZONTAL
)
...
...
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