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
331738b0
Commit
331738b0
authored
10 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
Grid lines option on light box canvas
parent
48f6e81e
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/fslview/gl/lightboxcanvas.py
+62
-14
62 additions, 14 deletions
fsl/fslview/gl/lightboxcanvas.py
fsl/fslview/views/lightboxpanel.py
+14
-7
14 additions, 7 deletions
fsl/fslview/views/lightboxpanel.py
with
76 additions
and
21 deletions
fsl/fslview/gl/lightboxcanvas.py
+
62
−
14
View file @
331738b0
...
@@ -60,25 +60,31 @@ class LightBoxCanvas(slicecanvas.SliceCanvas):
...
@@ -60,25 +60,31 @@ class LightBoxCanvas(slicecanvas.SliceCanvas):
coordinates, of the slices to be displayed.
coordinates, of the slices to be displayed.
"""
"""
showGridLines
=
props
.
Boolean
(
default
=
True
)
"""
If True, grid lines are drawn between the displayed slices.
"""
_labels
=
dict
(
_labels
=
dict
(
slicecanvas
.
SliceCanvas
.
_labels
.
items
()
+
slicecanvas
.
SliceCanvas
.
_labels
.
items
()
+
[(
'
sliceSpacing
'
,
'
Slice spacing
'
),
[(
'
sliceSpacing
'
,
'
Slice spacing
'
),
(
'
ncols
'
,
'
Number of columns
'
),
(
'
ncols
'
,
'
Number of columns
'
),
(
'
nrows
'
,
'
Number of rows
'
),
(
'
nrows
'
,
'
Number of rows
'
),
(
'
topRow
'
,
'
Top row
'
),
(
'
topRow
'
,
'
Top row
'
),
(
'
zrange
'
,
'
Slice range
'
)])
(
'
zrange
'
,
'
Slice range
'
),
(
'
showGridLines
'
,
'
Show grid lines
'
)])
"""
Labels for the properties which are intended to be user editable.
"""
"""
Labels for the properties which are intended to be user editable.
"""
_tooltips
=
dict
(
_tooltips
=
dict
(
slicecanvas
.
SliceCanvas
.
_tooltips
.
items
()
+
slicecanvas
.
SliceCanvas
.
_tooltips
.
items
()
+
[(
'
sliceSpacing
'
,
'
Distance (mm) between consecutive slices
'
),
[(
'
sliceSpacing
'
,
'
Distance (mm) between consecutive slices
'
),
(
'
ncols
'
,
'
Number of slices to display on one row
'
),
(
'
ncols
'
,
'
Number of slices to display on one row
'
),
(
'
nrows
'
,
'
Number of rows to display on the canvas
'
),
(
'
nrows
'
,
'
Number of rows to display on the canvas
'
),
(
'
topRow
'
,
'
Index number of top row (from
'
(
'
topRow
'
,
'
Index number of top row (from
'
'
0 to nrows-1) to display
'
),
'
0 to nrows-1) to display
'
),
(
'
zrange
'
,
'
Range (mm) along Z axis of slices to display
'
)])
(
'
zrange
'
,
'
Range (mm) along Z axis of slices to display
'
),
(
'
showGridLines
'
,
'
Show grid lines between slices
'
)])
"""
Tooltips to be used as help text.
"""
"""
Tooltips to be used as help text.
"""
_propHelp
=
_tooltips
_propHelp
=
_tooltips
...
@@ -181,6 +187,8 @@ class LightBoxCanvas(slicecanvas.SliceCanvas):
...
@@ -181,6 +187,8 @@ class LightBoxCanvas(slicecanvas.SliceCanvas):
self
.
addListener
(
'
ncols
'
,
self
.
name
,
self
.
_slicePropsChanged
)
self
.
addListener
(
'
ncols
'
,
self
.
name
,
self
.
_slicePropsChanged
)
self
.
addListener
(
'
nrows
'
,
self
.
name
,
self
.
_slicePropsChanged
)
self
.
addListener
(
'
nrows
'
,
self
.
name
,
self
.
_slicePropsChanged
)
self
.
addListener
(
'
zrange
'
,
self
.
name
,
self
.
_slicePropsChanged
)
self
.
addListener
(
'
zrange
'
,
self
.
name
,
self
.
_slicePropsChanged
)
self
.
addListener
(
'
showGridLines
'
,
self
.
name
,
lambda
*
a
:
self
.
_refresh
())
# Called when the top row changes -
# Called when the top row changes -
# adjusts display range and refreshes
# adjusts display range and refreshes
...
@@ -441,6 +449,46 @@ class LightBoxCanvas(slicecanvas.SliceCanvas):
...
@@ -441,6 +449,46 @@ class LightBoxCanvas(slicecanvas.SliceCanvas):
return
translate
return
translate
def
_drawGridLines
(
self
):
"""
Draws grid lines between all the displayed slices.
"""
xlen
=
self
.
imageList
.
bounds
.
getLen
(
self
.
xax
)
ylen
=
self
.
imageList
.
bounds
.
getLen
(
self
.
yax
)
xmin
=
self
.
imageList
.
bounds
.
getLo
(
self
.
xax
)
ymin
=
self
.
imageList
.
bounds
.
getLo
(
self
.
yax
)
rowLines
=
np
.
zeros
(((
self
.
nrows
-
1
)
*
2
,
3
),
dtype
=
np
.
float32
)
colLines
=
np
.
zeros
(((
self
.
ncols
-
1
)
*
2
,
3
),
dtype
=
np
.
float32
)
topRow
=
self
.
_totalRows
-
self
.
topRow
btmRow
=
topRow
-
self
.
nrows
rowLines
[:,
self
.
yax
]
=
np
.
arange
(
ymin
+
(
btmRow
+
1
)
*
ylen
,
ymin
+
topRow
*
ylen
,
ylen
).
repeat
(
2
)
rowLines
[:,
self
.
xax
]
=
np
.
tile
(
np
.
array
([
xmin
,
xmin
+
self
.
ncols
*
xlen
]),
self
.
nrows
-
1
)
colLines
[:,
self
.
xax
]
=
np
.
arange
(
xmin
+
xlen
,
xmin
+
xlen
*
self
.
ncols
,
xlen
).
repeat
(
2
)
colLines
[:,
self
.
yax
]
=
np
.
tile
(
np
.
array
([
ymin
+
btmRow
*
ylen
,
ymin
+
topRow
*
ylen
]),
self
.
ncols
-
1
)
gl
.
glLineWidth
(
1
)
gl
.
glBegin
(
gl
.
GL_LINES
)
gl
.
glColor3f
(
1
,
1
,
1
)
for
vertex
in
rowLines
:
gl
.
glVertex3f
(
*
vertex
)
for
vertex
in
colLines
:
gl
.
glVertex3f
(
*
vertex
)
gl
.
glEnd
()
def
_drawCursor
(
self
):
def
_drawCursor
(
self
):
"""
Draws a cursor at the current canvas position (the
"""
Draws a cursor at the current canvas position (the
:attr:`~fsl.fslview.gl.SliceCanvas.pos` property).
:attr:`~fsl.fslview.gl.SliceCanvas.pos` property).
...
@@ -453,7 +501,7 @@ class LightBoxCanvas(slicecanvas.SliceCanvas):
...
@@ -453,7 +501,7 @@ class LightBoxCanvas(slicecanvas.SliceCanvas):
xmin
=
self
.
imageList
.
bounds
.
getLo
(
self
.
xax
)
xmin
=
self
.
imageList
.
bounds
.
getLo
(
self
.
xax
)
ymin
=
self
.
imageList
.
bounds
.
getLo
(
self
.
yax
)
ymin
=
self
.
imageList
.
bounds
.
getLo
(
self
.
yax
)
row
=
self
.
_totalRows
-
int
(
np
.
floor
(
sliceno
/
self
.
ncols
))
-
1
row
=
self
.
_totalRows
-
int
(
np
.
floor
(
sliceno
/
self
.
ncols
))
-
1
col
=
int
(
np
.
floor
(
sliceno
%
self
.
ncols
))
col
=
int
(
np
.
floor
(
sliceno
%
self
.
ncols
))
xpos
,
ypos
=
self
.
worldToCanvas
(
*
self
.
pos
.
xyz
)
xpos
,
ypos
=
self
.
worldToCanvas
(
*
self
.
pos
.
xyz
)
...
@@ -520,7 +568,7 @@ class LightBoxCanvas(slicecanvas.SliceCanvas):
...
@@ -520,7 +568,7 @@ class LightBoxCanvas(slicecanvas.SliceCanvas):
globj
.
draw
(
self
.
_sliceLocs
[
i
][
zi
],
globj
.
draw
(
self
.
_sliceLocs
[
i
][
zi
],
self
.
_transforms
[
i
][
zi
])
self
.
_transforms
[
i
][
zi
])
if
self
.
showCursor
:
if
self
.
showCursor
:
self
.
_drawCursor
()
self
.
_draw
Cursor
()
if
self
.
showGridLines
:
self
.
_draw
GridLines
()
self
.
_postDraw
()
self
.
_postDraw
()
This diff is collapsed.
Click to expand it.
fsl/fslview/views/lightboxpanel.py
+
14
−
7
View file @
331738b0
...
@@ -52,12 +52,18 @@ class LightBoxPanel(canvaspanel.CanvasPanel):
...
@@ -52,12 +52,18 @@ class LightBoxPanel(canvaspanel.CanvasPanel):
"""
See :attr:`fsl.fslview.gl.slicecanvas.SliceCanvas.zax`.
"""
"""
See :attr:`fsl.fslview.gl.slicecanvas.SliceCanvas.zax`.
"""
showGridLines
=
lightboxcanvas
.
LightBoxCanvas
.
showGridLines
"""
See :attr:`fsl.fslview.gl.lightboxcanvas.LightBoxCanvas.showGridLines`.
"""
_labels
=
dict
(
lightboxcanvas
.
LightBoxCanvas
.
_labels
.
items
()
+
_labels
=
dict
(
lightboxcanvas
.
LightBoxCanvas
.
_labels
.
items
()
+
canvaspanel
.
CanvasPanel
.
_labels
.
items
())
canvaspanel
.
CanvasPanel
.
_labels
.
items
())
"""
Property labels to be used for GUI displays.
"""
"""
Property labels to be used for GUI displays.
"""
_view
=
props
.
VGroup
((
'
showCursor
'
,
_view
=
props
.
VGroup
((
'
showCursor
'
,
'
showGridLines
'
,
'
posSync
'
,
'
posSync
'
,
'
zrange
'
,
'
zrange
'
,
'
sliceSpacing
'
,
'
sliceSpacing
'
,
...
@@ -87,13 +93,14 @@ class LightBoxPanel(canvaspanel.CanvasPanel):
...
@@ -87,13 +93,14 @@ class LightBoxPanel(canvaspanel.CanvasPanel):
imageList
)
imageList
)
# My properties are the canvas properties
# My properties are the canvas properties
self
.
bindProps
(
'
sliceSpacing
'
,
self
.
_lbCanvas
)
self
.
bindProps
(
'
sliceSpacing
'
,
self
.
_lbCanvas
)
self
.
bindProps
(
'
ncols
'
,
self
.
_lbCanvas
)
self
.
bindProps
(
'
ncols
'
,
self
.
_lbCanvas
)
self
.
bindProps
(
'
nrows
'
,
self
.
_lbCanvas
)
self
.
bindProps
(
'
nrows
'
,
self
.
_lbCanvas
)
self
.
bindProps
(
'
topRow
'
,
self
.
_lbCanvas
)
self
.
bindProps
(
'
topRow
'
,
self
.
_lbCanvas
)
self
.
bindProps
(
'
zrange
'
,
self
.
_lbCanvas
)
self
.
bindProps
(
'
zrange
'
,
self
.
_lbCanvas
)
self
.
bindProps
(
'
showCursor
'
,
self
.
_lbCanvas
)
self
.
bindProps
(
'
showCursor
'
,
self
.
_lbCanvas
)
self
.
bindProps
(
'
zax
'
,
self
.
_lbCanvas
)
self
.
bindProps
(
'
showGridLines
'
,
self
.
_lbCanvas
)
self
.
bindProps
(
'
zax
'
,
self
.
_lbCanvas
)
self
.
_canvasSizer
=
wx
.
BoxSizer
(
wx
.
HORIZONTAL
)
self
.
_canvasSizer
=
wx
.
BoxSizer
(
wx
.
HORIZONTAL
)
self
.
getCanvasPanel
().
SetSizer
(
self
.
_canvasSizer
)
self
.
getCanvasPanel
().
SetSizer
(
self
.
_canvasSizer
)
...
...
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