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
94954ac3
Commit
94954ac3
authored
10 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
Mouse cursor location is correctly translated between screen and world coordinates
parent
d863a2a1
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/fslview/orthopanel.py
+2
-2
2 additions, 2 deletions
fsl/fslview/orthopanel.py
fsl/fslview/slicecanvas.py
+42
-16
42 additions, 16 deletions
fsl/fslview/slicecanvas.py
with
44 additions
and
18 deletions
fsl/fslview/orthopanel.py
+
2
−
2
View file @
94954ac3
...
@@ -119,8 +119,8 @@ class OrthoPanel(wx.Panel, props.HasProperties):
...
@@ -119,8 +119,8 @@ class OrthoPanel(wx.Panel, props.HasProperties):
y
=
self
.
ycanvas
.
zpos
y
=
self
.
ycanvas
.
zpos
z
=
self
.
zcanvas
.
zpos
z
=
self
.
zcanvas
.
zpos
mx
=
mx
*
(
source
.
xmax
-
source
.
xmin
)
/
float
(
w
)
+
source
.
xmin
mx
=
source
.
canvasToWorldX
(
mx
)
my
=
my
*
(
source
.
ymax
-
source
.
ymin
)
/
float
(
h
)
+
source
.
ymin
my
=
source
.
canvasToWorldY
(
my
)
if
source
==
self
.
xcanvas
:
y
,
z
=
mx
,
my
if
source
==
self
.
xcanvas
:
y
,
z
=
mx
,
my
elif
source
==
self
.
ycanvas
:
x
,
z
=
mx
,
my
elif
source
==
self
.
ycanvas
:
x
,
z
=
mx
,
my
...
...
This diff is collapsed.
Click to expand it.
fsl/fslview/slicecanvas.py
+
42
−
16
View file @
94954ac3
...
@@ -435,22 +435,43 @@ class SliceCanvas(wxgl.GLCanvas):
...
@@ -435,22 +435,43 @@ class SliceCanvas(wxgl.GLCanvas):
self
.
_ypos
=
ypos
self
.
_ypos
=
ypos
@property
def
canvasXpos
(
self
):
pass
@canvasXpos.setter
def
canvasToWorldX
(
self
,
xpos
):
def
canvasXpos
(
self
):
"""
pass
Given a pixel x coordinate on this canvas, translates it
into the real world coordinates of the displayed slice.
"""
@property
realWidth
=
float
(
self
.
xmax
-
self
.
xmin
)
def
canvasYpos
(
self
):
sliceStart
=
float
(
self
.
_canvasBBox
[
0
])
pass
sliceWidth
=
float
(
self
.
_canvasBBox
[
2
])
# Translate the xpos from the canvas to
# the slice bounding box, then translate
# the xpos from the slice bounding box
# to real world coordinates
xpos
=
xpos
-
sliceStart
xpos
=
self
.
xmin
+
(
xpos
/
sliceWidth
)
*
realWidth
return
xpos
def
canvasToWorldY
(
self
,
ypos
):
"""
Given a pixel y coordinate on this canvas, translates it
into the real world coordinates of the displayed slice.
"""
realHeight
=
float
(
self
.
ymax
-
self
.
ymin
)
sliceStart
=
float
(
self
.
_canvasBBox
[
1
])
sliceHeight
=
float
(
self
.
_canvasBBox
[
3
])
ypos
=
ypos
-
sliceStart
ypos
=
self
.
ymin
+
(
ypos
/
sliceHeight
)
*
realHeight
@canvasYpos.setter
return
ypos
def
canvasYpos
(
self
):
pass
def
__init__
(
self
,
parent
,
imageList
,
zax
=
0
,
context
=
None
):
def
__init__
(
self
,
parent
,
imageList
,
zax
=
0
,
context
=
None
):
"""
"""
Creates a canvas object. The OpenGL data buffers are set up the
Creates a canvas object. The OpenGL data buffers are set up the
...
@@ -699,7 +720,7 @@ class SliceCanvas(wxgl.GLCanvas):
...
@@ -699,7 +720,7 @@ class SliceCanvas(wxgl.GLCanvas):
if
height
!=
size
.
height
:
y
=
(
size
.
height
-
height
)
/
2
if
height
!=
size
.
height
:
y
=
(
size
.
height
-
height
)
/
2
self
.
_canvasBBox
=
[
x
,
y
,
width
,
height
]
self
.
_canvasBBox
=
[
x
,
y
,
width
,
height
]
return
width
,
height
return
width
,
height
...
@@ -879,12 +900,17 @@ class SliceCanvas(wxgl.GLCanvas):
...
@@ -879,12 +900,17 @@ class SliceCanvas(wxgl.GLCanvas):
xverts
=
np
.
zeros
((
2
,
3
))
xverts
=
np
.
zeros
((
2
,
3
))
yverts
=
np
.
zeros
((
2
,
3
))
yverts
=
np
.
zeros
((
2
,
3
))
xverts
[:,
self
.
xax
]
=
self
.
xpos
# add a little padding to the lines if they are
# on the boundary, so they don't get cropped
if
self
.
xpos
==
self
.
xmin
:
xverts
[:,
self
.
xax
]
=
self
.
xpos
+
0.5
else
:
xverts
[:,
self
.
xax
]
=
self
.
xpos
if
self
.
ypos
==
self
.
ymin
:
yverts
[:,
self
.
yax
]
=
self
.
ypos
+
0.5
else
:
yverts
[:,
self
.
yax
]
=
self
.
ypos
xverts
[:,
self
.
yax
]
=
[
self
.
ymin
,
self
.
ymax
]
xverts
[:,
self
.
yax
]
=
[
self
.
ymin
,
self
.
ymax
]
xverts
[:,
self
.
zax
]
=
self
.
zpos
+
1
xverts
[:,
self
.
zax
]
=
self
.
zpos
+
1
yverts
[:,
self
.
xax
]
=
[
self
.
xmin
,
self
.
xmax
]
yverts
[:,
self
.
xax
]
=
[
self
.
xmin
,
self
.
xmax
]
yverts
[:,
self
.
yax
]
=
self
.
ypos
yverts
[:,
self
.
zax
]
=
self
.
zpos
+
1
yverts
[:,
self
.
zax
]
=
self
.
zpos
+
1
gl
.
glBegin
(
gl
.
GL_LINES
)
gl
.
glBegin
(
gl
.
GL_LINES
)
gl
.
glColor3f
(
0
,
1
,
0
)
gl
.
glColor3f
(
0
,
1
,
0
)
...
...
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