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
d863a2a1
Commit
d863a2a1
authored
10 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
Bounding box calculation is performed on window resize, rather than on every draw.
parent
d79fab4e
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/slicecanvas.py
+44
-14
44 additions, 14 deletions
fsl/fslview/slicecanvas.py
with
44 additions
and
14 deletions
fsl/fslview/slicecanvas.py
+
44
−
14
View file @
d863a2a1
...
...
@@ -435,6 +435,21 @@ class SliceCanvas(wxgl.GLCanvas):
self
.
_ypos
=
ypos
@property
def
canvasXpos
(
self
):
pass
@canvasXpos.setter
def
canvasXpos
(
self
):
pass
@property
def
canvasYpos
(
self
):
pass
@canvasYpos.setter
def
canvasYpos
(
self
):
pass
def
__init__
(
self
,
parent
,
imageList
,
zax
=
0
,
context
=
None
):
"""
...
...
@@ -492,6 +507,16 @@ class SliceCanvas(wxgl.GLCanvas):
self
.
_ypos
=
self
.
ymin
+
abs
(
self
.
ymax
-
self
.
ymin
)
/
2.0
self
.
_zpos
=
self
.
zmin
+
abs
(
self
.
zmax
-
self
.
zmin
)
/
2.0
# When drawn, the slice does not necessarily take
# up the entire canvas size, as its aspect ratio
# is maintained. The _canvasBBox attribute is used
# to store the [x, y, width, height] bounding box
# within which the slice is actually drawn. It is
# updated by the _calculateCanvasBBox method
# whenever the canvas is resized
self
.
_canvasBBox
=
[
0
,
0
,
0
,
0
]
self
.
Bind
(
wx
.
EVT_SIZE
,
self
.
_calculateCanvasBBox
)
# This flag is set by the _initGLData method
# when it has finished initialising the OpenGL
# shaders
...
...
@@ -638,14 +663,19 @@ class SliceCanvas(wxgl.GLCanvas):
self
.
glReady
=
True
def
calculateCanvas
Size
(
self
,
width
,
height
):
def
_
calculateCanvas
BBox
(
self
,
ev
):
"""
Calculates the best size to draw the slice, maintaining its
aspect ratio, within the given (maximum) width and height.
"""
size
=
self
.
GetClientSize
()
if
(
size
.
width
==
0
)
or
(
size
.
height
==
0
):
return
width
=
float
(
width
)
height
=
float
(
height
)
width
=
float
(
size
.
width
)
height
=
float
(
size
.
height
)
realWidth
=
float
(
self
.
xmax
-
self
.
xmin
)
realHeight
=
float
(
self
.
ymax
-
self
.
ymin
)
...
...
@@ -660,6 +690,15 @@ class SliceCanvas(wxgl.GLCanvas):
width
=
int
(
np
.
floor
(
width
))
height
=
int
(
np
.
floor
(
height
))
# center the slice within
# the available space
x
=
0
y
=
0
if
width
!=
size
.
width
:
x
=
(
size
.
width
-
width
)
/
2
if
height
!=
size
.
height
:
y
=
(
size
.
height
-
height
)
/
2
self
.
_canvasBBox
=
[
x
,
y
,
width
,
height
]
return
width
,
height
...
...
@@ -671,19 +710,10 @@ class SliceCanvas(wxgl.GLCanvas):
so does not need to be called manually.
"""
size
=
self
.
GetClientSize
()
width
,
height
=
self
.
calculateCanvasSize
(
size
.
width
,
size
.
height
)
# center the slice within
# the available space
widthOff
=
0
heightOff
=
0
if
width
!=
size
.
width
:
widthOff
=
(
size
.
width
-
width
)
/
2
if
height
!=
size
.
height
:
heightOff
=
(
size
.
height
-
height
)
/
2
x
,
y
,
width
,
height
=
self
.
_canvasBBox
# set up 2D orthographic drawing
gl
.
glViewport
(
widthOff
,
heightOff
,
width
,
height
)
gl
.
glViewport
(
x
,
y
,
width
,
height
)
gl
.
glMatrixMode
(
gl
.
GL_PROJECTION
)
gl
.
glLoadIdentity
()
gl
.
glOrtho
(
self
.
xmin
,
self
.
xmax
,
...
...
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