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
a0afa26b
Commit
a0afa26b
authored
9 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
Little tweaks to OverlayInfoPanel. A 'wait' dialog is displayed while
screenshot taken.
parent
165b890f
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
fsl/data/strings.py
+1
-1
1 addition, 1 deletion
fsl/data/strings.py
fsl/fslview/controls/overlayinfopanel.py
+16
-13
16 additions, 13 deletions
fsl/fslview/controls/overlayinfopanel.py
fsl/fslview/views/canvaspanel.py
+81
-71
81 additions, 71 deletions
fsl/fslview/views/canvaspanel.py
with
98 additions
and
85 deletions
fsl/data/strings.py
+
1
−
1
View file @
a0afa26b
...
...
@@ -672,7 +672,7 @@ nifti = TypeDict({
feat
=
TypeDict
({
'
analysisName
'
:
'
Analysis name
'
,
'
numPoints
'
:
'
Number of
time point
s
'
,
'
numPoints
'
:
'
Number of
volume
s
'
,
'
numEVs
'
:
'
Number of EVs
'
,
'
numContrasts
'
:
'
Number of contrasts
'
,
})
This diff is collapsed.
Click to expand it.
fsl/fslview/controls/overlayinfopanel.py
+
16
−
13
View file @
a0afa26b
...
...
@@ -10,8 +10,9 @@ import collections
import
wx
import
wx.html
as
wxhtml
import
fsl.data.strings
as
strings
import
fsl.fslview.panel
as
fslpanel
import
fsl.data.strings
as
strings
import
fsl.data.constants
as
constants
import
fsl.fslview.panel
as
fslpanel
class
OverlayInfo
(
object
):
...
...
@@ -138,6 +139,8 @@ class OverlayInfoPanel(fslpanel.FSLViewPanel):
hdr
=
img
.
get_header
()
voxUnits
,
timeUnits
=
hdr
.
get_xyzt_units
()
qformCode
=
int
(
hdr
[
'
qform_code
'
])
sformCode
=
int
(
hdr
[
'
sform_code
'
])
dimSect
=
strings
.
labels
[
self
,
overlay
,
'
dimensions
'
]
xformSect
=
strings
.
labels
[
self
,
overlay
,
'
transform
'
]
...
...
@@ -177,21 +180,21 @@ class OverlayInfoPanel(fslpanel.FSLViewPanel):
section
=
dimSect
)
info
.
addInfo
(
strings
.
nifti
[
'
qform_code
'
],
strings
.
anatomy
[
'
Image
'
,
'
space
'
,
int
(
hdr
[
'
qform
_c
ode
'
])
],
strings
.
anatomy
[
'
Image
'
,
'
space
'
,
qform
C
ode
],
section
=
xformSect
)
info
.
addInfo
(
strings
.
nifti
[
'
sform_code
'
],
strings
.
anatomy
[
'
Image
'
,
'
space
'
,
int
(
hdr
[
'
sform
_c
ode
'
])
],
strings
.
anatomy
[
'
Image
'
,
'
space
'
,
sform
C
ode
],
section
=
xformSect
)
# TODO matrix formatting (you'll need to use
#
HTML, or maybe get the formatOverlayInfo
#
method to support different types)
info
.
addInfo
(
strings
.
nifti
[
'
qform
'
],
self
.
__formatArray
(
img
.
get_qform
()),
section
=
xformSect
)
info
.
addInfo
(
strings
.
nifti
[
'
sform
'
],
self
.
__formatArray
(
img
.
get_sform
()),
section
=
xformSect
)
if
qformCode
!=
constants
.
NIFTI_XFORM_UNKNOWN
:
info
.
addInfo
(
strings
.
nifti
[
'
qform
'
],
self
.
__formatArray
(
img
.
get_qform
()),
section
=
xformSect
)
if
sformCode
!=
constants
.
NIFTI_XFORM_UNKNOWN
:
info
.
addInfo
(
strings
.
nifti
[
'
sform
'
],
self
.
__formatArray
(
img
.
get_sform
()),
section
=
xformSect
)
for
i
in
range
(
3
):
orient
=
overlay
.
getVoxelOrientation
(
i
)
...
...
This diff is collapsed.
Click to expand it.
fsl/fslview/views/canvaspanel.py
+
81
−
71
View file @
a0afa26b
...
...
@@ -398,77 +398,87 @@ def _screenshot(overlayList, displayCtx, canvasPanel):
dlg
.
Destroy
()
wx
.
Yield
()
# The typical way to get a screen grab of a wx
# Window is to use a wx.WindowDC, and a wx.MemoryDC,
# and to 'blit' a region from the window DC into
# the memory DC.
#
# This is precisely what we're doing here, but
# the process is complicated by the fact that,
# under OSX, the contents of wx.glcanvas.GLCanvas
# instances are not captured by WindowDCs.
#
# So I'm grabbing a screenshot of the canvas
# panel in the standard wxWidgets way, and then
# manually patching in bitmaps of each GLCanvas
# that is displayed in the canvas panel.
# Get all the wx GLCanvas instances
# which are displayed in the panel,
# including the colour bar canvas
glCanvases
=
canvasPanel
.
getGLCanvases
()
glCanvases
.
append
(
canvasPanel
.
getColourBarCanvas
())
# The canvas panel container is the
# direct parent of the colour bar
# canvas, and an ancestor of the
# other GL canvases
parent
=
canvasPanel
.
getCanvasContainer
()
width
,
height
=
parent
.
GetClientSize
().
Get
()
windowDC
=
wx
.
WindowDC
(
parent
)
memoryDC
=
wx
.
MemoryDC
()
bmp
=
wx
.
EmptyBitmap
(
width
,
height
)
# Copy the contents of the canvas container
# to the bitmap
memoryDC
.
SelectObject
(
bmp
)
memoryDC
.
Blit
(
0
,
0
,
width
,
height
,
windowDC
,
0
,
0
)
memoryDC
.
SelectObject
(
wx
.
NullBitmap
)
# Make a H*W*4 bitmap array
data
=
np
.
zeros
((
height
,
width
,
4
),
dtype
=
np
.
uint8
)
rgb
=
bmp
.
ConvertToImage
().
GetData
()
rgb
=
np
.
fromstring
(
rgb
,
dtype
=
np
.
uint8
)
data
[:,
:,
:
3
]
=
rgb
.
reshape
(
height
,
width
,
3
)
# Patch in bitmaps for every GL canvas
for
glCanvas
in
glCanvases
:
# If the colour bar is not displayed,
# the colour bar canvas will be None
if
glCanvas
is
None
:
continue
pos
=
relativePosition
(
glCanvas
,
parent
)
size
=
glCanvas
.
GetSize
().
Get
()
xstart
=
pos
[
0
]
ystart
=
pos
[
1
]
xend
=
xstart
+
size
[
0
]
yend
=
ystart
+
size
[
1
]
data
[
ystart
:
yend
,
xstart
:
xend
]
=
glCanvas
.
getBitmap
()
data
[:,
:,
3
]
=
255
mplimg
.
imsave
(
filename
,
data
)
def
doScreenshot
():
# The typical way to get a screen grab of a wx
# Window is to use a wx.WindowDC, and a wx.MemoryDC,
# and to 'blit' a region from the window DC into
# the memory DC.
#
# This is precisely what we're doing here, but
# the process is complicated by the fact that,
# under OSX, the contents of wx.glcanvas.GLCanvas
# instances are not captured by WindowDCs.
#
# So I'm grabbing a screenshot of the canvas
# panel in the standard wxWidgets way, and then
# manually patching in bitmaps of each GLCanvas
# that is displayed in the canvas panel.
# Get all the wx GLCanvas instances
# which are displayed in the panel,
# including the colour bar canvas
glCanvases
=
canvasPanel
.
getGLCanvases
()
glCanvases
.
append
(
canvasPanel
.
getColourBarCanvas
())
# The canvas panel container is the
# direct parent of the colour bar
# canvas, and an ancestor of the
# other GL canvases
parent
=
canvasPanel
.
getCanvasContainer
()
width
,
height
=
parent
.
GetClientSize
().
Get
()
windowDC
=
wx
.
WindowDC
(
parent
)
memoryDC
=
wx
.
MemoryDC
()
bmp
=
wx
.
EmptyBitmap
(
width
,
height
)
wx
.
Yield
()
# Copy the contents of the canvas container
# to the bitmap
memoryDC
.
SelectObject
(
bmp
)
memoryDC
.
Blit
(
0
,
0
,
width
,
height
,
windowDC
,
0
,
0
)
memoryDC
.
SelectObject
(
wx
.
NullBitmap
)
# Make a H*W*4 bitmap array
data
=
np
.
zeros
((
height
,
width
,
4
),
dtype
=
np
.
uint8
)
rgb
=
bmp
.
ConvertToImage
().
GetData
()
rgb
=
np
.
fromstring
(
rgb
,
dtype
=
np
.
uint8
)
data
[:,
:,
:
3
]
=
rgb
.
reshape
(
height
,
width
,
3
)
# Patch in bitmaps for every GL canvas
for
glCanvas
in
glCanvases
:
# If the colour bar is not displayed,
# the colour bar canvas will be None
if
glCanvas
is
None
:
continue
pos
=
relativePosition
(
glCanvas
,
parent
)
size
=
glCanvas
.
GetSize
().
Get
()
xstart
=
pos
[
0
]
ystart
=
pos
[
1
]
xend
=
xstart
+
size
[
0
]
yend
=
ystart
+
size
[
1
]
data
[
ystart
:
yend
,
xstart
:
xend
]
=
glCanvas
.
getBitmap
()
data
[:,
:,
3
]
=
255
mplimg
.
imsave
(
filename
,
data
)
fsldlg
.
ProcessingDialog
(
canvasPanel
.
GetTopLevelParent
(),
strings
.
messages
[
'
CanvasPanel.screenshot.pleaseWait
'
],
doScreenshot
).
Run
(
mainThread
=
True
)
fslsettings
.
write
(
'
canvasPanelScreenshotLastDir
'
,
op
.
dirname
(
filename
))
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