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
a08cc784
Commit
a08cc784
authored
9 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
Fixed LightBoxPanel scrollbar layout - colour bar is now always flush
with canvas, and scrollbar no longer appears in screenshots.
parent
eded900f
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/fsleyes/views/canvaspanel.py
+111
-55
111 additions, 55 deletions
fsl/fsleyes/views/canvaspanel.py
fsl/fsleyes/views/lightboxpanel.py
+25
-6
25 additions, 6 deletions
fsl/fsleyes/views/lightboxpanel.py
fsl/fsleyes/views/orthopanel.py
+14
-13
14 additions, 13 deletions
fsl/fsleyes/views/orthopanel.py
with
150 additions
and
74 deletions
fsl/fsleyes/views/canvaspanel.py
+
111
−
55
View file @
a08cc784
...
...
@@ -36,8 +36,8 @@ import fsl.fsleyes.controls.clusterpanel as clusterpanel
import
fsl.fsleyes.controls.lookuptablepanel
as
lookuptablepanel
import
fsl.fsleyes.controls.shellpanel
as
shellpanel
import
colourbarpanel
import
viewpanel
import
colourbarpanel
import
viewpanel
log
=
logging
.
getLogger
(
__name__
)
...
...
@@ -64,10 +64,16 @@ class CanvasPanel(viewpanel.ViewPanel):
Sub-classes of the ``CanvasPanel`` must do the following:
1. Add their content to the panel that is accessible via the
:meth:`getC
anvas
Panel` method (see the note on
:meth:`getC
ontent
Panel` method (see the note on
:ref:`adding content <canvaspanel-adding-content>`).
2. Override the :meth:`getGLCanvases` method.
3. Call the :meth:`centrePanelLayout` method in their ``__init__``
method.
4. Override the :meth:`centrePanelLayout` method if any custom layout is
necessary.
**Actions**
...
...
@@ -104,14 +110,14 @@ class CanvasPanel(viewpanel.ViewPanel):
.. _canvaspanel-adding-content:
**Adding content**
To support colour bar functionality, the ``CanvasPanel`` uses a hierarchy
of ``wx.Panel`` instances, depicted in the following containment
hierarchy diagram:
To support colour bar and screenshot functionality, the ``CanvasPanel``
uses a hierarchy of ``wx.Panel`` instances, depicted in the following
containment hierarchy diagram:
.. graphviz::
...
...
@@ -127,23 +133,49 @@ class CanvasPanel(viewpanel.ViewPanel):
rankdir=
"
BT
"
;
1 [label=
"
CanvasPanel
"
];
2 [label=
"
Canvas container
"
];
3 [label=
"
ColourBarPanel
"
];
4 [label=
"
Centre panel
"
];
5 [label=
"
Content added by sub-classes
"
];
2 [label=
"
Centre panel
"
];
3 [label=
"
Advanced layout
"
];
4 [label=
"
Container panel
"
];
5 [label=
"
ColourBarPanel
"
];
6 [label=
"
Content panel
"
];
7 [label=
"
Content added by sub-classes
"
];
2 -> 1;
3 -> 2;
4 -> 2;
5 -> 4;
6 -> 4;
7 -> 6;
}
As depicted in the diagram, sub-classes need to add their content to the
*centre panel*. This panel is accessible via the :meth:`getCanvasPanel`
method. The *container panel* is what gets passed to the
*content panel*. This panel is accessible via the :meth:`getContentPanel`
method.
The *centre panel* is what gets passed to the
:meth:`.ViewPanel.setCentrePanel` method, and is accessible via the
:meth:`getCanvasContainer` method, if necessary.
:meth:`getCentrePanel` method, if necessary. The *container panel* is
also available, via the :meth:`getContainerPanel`. Everything in the
container panel will appear in screenshots (see the :meth:`screenshot`
method).
The :meth:`centrePanelLayout` method lays out the centre panel, using the
:meth:`layoutContainerPanel` method to lay out the colour bar and the
content panel. The ``centrePanelLayout`` method simply adds the canvas
container directly to the centre panel. Sub-classes which have more
advanced layout requirements (e.g. the :class:`.LightBoxPanel` needs a
scrollbar) may override the :meth:`centrePanelLayout` method to implement
their own layout. These sub-class implementations must:
1. Call the :meth:`layoutCanvasContainer` method.
2. Add the container panel (accessed via :meth:`getContainerPanel`)
to the centre panel (:meth:`getCentrePanel`)
3. Add any other custom content to the centre panel.
"""
...
...
@@ -274,10 +306,11 @@ class CanvasPanel(viewpanel.ViewPanel):
self
.
disableProperty
(
'
syncOverlayOrder
'
)
self
.
disableProperty
(
'
syncOverlayDisplay
'
)
self
.
__canvasContainer
=
wx
.
Panel
(
self
)
self
.
__canvasPanel
=
wx
.
Panel
(
self
.
__canvasContainer
)
self
.
__centrePanel
=
wx
.
Panel
(
self
)
self
.
__containerPanel
=
wx
.
Panel
(
self
.
__centrePanel
)
self
.
__contentPanel
=
wx
.
Panel
(
self
.
__containerPanel
)
self
.
setCentrePanel
(
self
.
__c
anvasContai
ne
r
)
self
.
setCentrePanel
(
self
.
__c
entrePa
ne
l
)
# Stores a reference to a wx.Timer
# when movie mode is enabled
...
...
@@ -291,17 +324,18 @@ class CanvasPanel(viewpanel.ViewPanel):
self
.
__movieRateChanged
)
# Canvas/colour bar layout is managed in
# the _layout/_toggleColourBar methods
self
.
__canvasSizer
=
None
self
.
__colourBar
=
None
# the layoutColourBarAndCanvas method
self
.
__colourBar
=
None
# Use a different listener name so that subclasses
# can register on the same properties with self._name
lName
=
'
CanvasPanel_{}
'
.
format
(
self
.
_name
)
self
.
__opts
.
addListener
(
'
colourBarLocation
'
,
lName
,
self
.
__layout
)
self
.
__opts
.
addListener
(
'
showColourBar
'
,
lName
,
self
.
__layout
)
self
.
__layout
()
self
.
__opts
.
addListener
(
'
colourBarLocation
'
,
lName
,
self
.
__colourBarPropsChanged
)
self
.
__opts
.
addListener
(
'
showColourBar
'
,
lName
,
self
.
__colourBarPropsChanged
)
def
destroy
(
self
):
...
...
@@ -337,20 +371,28 @@ class CanvasPanel(viewpanel.ViewPanel):
return
self
.
__opts
def
getCanvasPanel
(
self
):
def
getCentrePanel
(
self
):
"""
Returns the ``wx.Panel`` which is passed to
:meth:`.ViewPanel.setCentrePanel`. See the note on
:ref:`adding content <canvaspanel-adding-content>`.
"""
return
self
.
__centrePanel
def
getContentPanel
(
self
):
"""
Returns the ``wx.Panel`` to which sub-classes must add their content.
See the note on :ref:`adding content <canvaspanel-adding-content>`.
"""
return
self
.
__c
anvas
Panel
return
self
.
__c
ontent
Panel
def
getC
anvasC
ontainer
(
self
):
def
getContainer
Panel
(
self
):
"""
Returns the ``wx.Panel`` which contains the
:class:`.ColourBarPanel` if it is being displayed, and the c
anvas
:class:`.ColourBarPanel` if it is being displayed, and the c
ontent
panel. See the note on
:ref:`adding content <canvaspanel-adding-content>`.
"""
return
self
.
__c
anvasC
ontainer
return
self
.
__container
Panel
def
getGLCanvases
(
self
):
...
...
@@ -375,11 +417,27 @@ class CanvasPanel(viewpanel.ViewPanel):
return
None
def
__layout
(
self
,
*
a
):
"""
Called when any colour bar display properties are changed (see
:class:`.SceneOpts`). Lays out the container panel, which contains
the :class:`.ColourBarPanel` and all content added by the
``CanvasPanel`` sub-class implementation.
def
centrePanelLayout
(
self
):
"""
Lays out the centre panel. This method may be overridden by
sub-classes which need more advanced layout logic. See the note on
:ref:`adding content <canvaspanel-adding-content>`
"""
self
.
layoutContainerPanel
()
sizer
=
wx
.
BoxSizer
(
wx
.
HORIZONTAL
)
sizer
.
Add
(
self
.
__containerPanel
,
flag
=
wx
.
EXPAND
,
proportion
=
1
)
self
.
__centrePanel
.
SetSizer
(
sizer
)
self
.
PostSizeEvent
()
def
layoutContainerPanel
(
self
):
"""
Creates a ``wx.Sizer``, and uses it to lay out the colour bar panel
and canvas panel. The sizer object is returned.
This method is used by the default :meth:`centrePanelLayout` method,
and is available for custom sub-class implementations to use.
"""
if
not
self
.
__opts
.
showColourBar
:
...
...
@@ -391,19 +449,15 @@ class CanvasPanel(viewpanel.ViewPanel):
self
.
__colourBar
.
destroy
()
self
.
__colourBar
.
Destroy
()
self
.
__colourBar
=
None
self
.
__canvasSizer
=
wx
.
BoxSizer
(
wx
.
HORIZONTAL
)
self
.
__canvasSizer
.
Add
(
self
.
__canvasPanel
,
flag
=
wx
.
EXPAND
,
proportion
=
1
)
self
.
__canvasContainer
.
SetSizer
(
self
.
__canvasSizer
)
self
.
PostSizeEvent
()
sizer
=
wx
.
BoxSizer
(
wx
.
HORIZONTAL
)
sizer
.
Add
(
self
.
__contentPanel
,
flag
=
wx
.
EXPAND
,
proportion
=
1
)
self
.
__containerPanel
.
SetSizer
(
sizer
)
return
if
self
.
__colourBar
is
None
:
self
.
__colourBar
=
colourbarpanel
.
ColourBarPanel
(
self
.
__c
anvasC
ontainer
,
self
.
_overlayList
,
self
.
_displayCtx
)
self
.
__container
Panel
,
self
.
_overlayList
,
self
.
_displayCtx
)
self
.
__opts
.
bindProps
(
'
colourBarLabelSide
'
,
self
.
__colourBar
,
...
...
@@ -415,23 +469,18 @@ class CanvasPanel(viewpanel.ViewPanel):
self
.
__colourBar
.
orientation
=
'
vertical
'
if
self
.
__opts
.
colourBarLocation
in
(
'
top
'
,
'
bottom
'
):
s
elf
.
__canvasS
izer
=
wx
.
BoxSizer
(
wx
.
VERTICAL
)
sizer
=
wx
.
BoxSizer
(
wx
.
VERTICAL
)
else
:
self
.
__canvasSizer
=
wx
.
BoxSizer
(
wx
.
HORIZONTAL
)
self
.
__canvasContainer
.
SetSizer
(
self
.
__canvasSizer
)
sizer
=
wx
.
BoxSizer
(
wx
.
HORIZONTAL
)
if
self
.
__opts
.
colourBarLocation
in
(
'
top
'
,
'
left
'
):
self
.
__canvasSizer
.
Add
(
self
.
__colourBar
,
flag
=
wx
.
EXPAND
)
self
.
__canvasSizer
.
Add
(
self
.
__canvasPanel
,
flag
=
wx
.
EXPAND
,
proportion
=
1
)
sizer
.
Add
(
self
.
__colourBar
,
flag
=
wx
.
EXPAND
)
sizer
.
Add
(
self
.
__contentPanel
,
flag
=
wx
.
EXPAND
,
proportion
=
1
)
else
:
self
.
__canvasSizer
.
Add
(
self
.
__canvasPanel
,
flag
=
wx
.
EXPAND
,
proportion
=
1
)
self
.
__canvasSizer
.
Add
(
self
.
__colourBar
,
flag
=
wx
.
EXPAND
)
sizer
.
Add
(
self
.
__contentPanel
,
flag
=
wx
.
EXPAND
,
proportion
=
1
)
sizer
.
Add
(
self
.
__colourBar
,
flag
=
wx
.
EXPAND
)
# Force the canvas panel to resize itself
self
.
PostSizeEvent
()
self
.
__containerPanel
.
SetSizer
(
sizer
)
def
__movieModeChanged
(
self
,
*
a
):
...
...
@@ -455,6 +504,13 @@ class CanvasPanel(viewpanel.ViewPanel):
self
.
__movieTimer
=
wx
.
Timer
(
self
)
self
.
Bind
(
wx
.
EVT_TIMER
,
self
.
__movieUpdate
)
self
.
__movieTimer
.
Start
(
rate
)
def
__colourBarPropsChanged
(
self
,
*
a
):
"""
Called when any colour bar display properties are changed (see
:class:`.SceneOpts`). Calls :meth:`canvasPanelLayout`.
"""
self
.
centrePanelLayout
()
def
__movieRateChanged
(
self
,
*
a
):
...
...
@@ -653,7 +709,7 @@ def _screenshot(overlayList, displayCtx, canvasPanel):
# direct parent of the colour bar
# canvas, and an ancestor of the
# other GL canvases
parent
=
canvasPanel
.
getC
anvasC
ontainer
()
parent
=
canvasPanel
.
getContainer
Panel
()
width
,
height
=
parent
.
GetClientSize
().
Get
()
windowDC
=
wx
.
WindowDC
(
parent
)
memoryDC
=
wx
.
MemoryDC
()
...
...
This diff is collapsed.
Click to expand it.
fsl/fsleyes/views/lightboxpanel.py
+
25
−
6
View file @
a08cc784
...
...
@@ -86,11 +86,11 @@ class LightBoxPanel(canvaspanel.CanvasPanel):
actionz
)
self
.
__scrollbar
=
wx
.
ScrollBar
(
self
.
getC
anvas
Panel
(),
self
.
getC
entre
Panel
(),
style
=
wx
.
SB_VERTICAL
)
self
.
__lbCanvas
=
lightboxcanvas
.
WXGLLightBoxCanvas
(
self
.
getC
anvas
Panel
(),
self
.
getC
ontent
Panel
(),
overlayList
,
displayCtx
)
...
...
@@ -117,10 +117,9 @@ class LightBoxPanel(canvaspanel.CanvasPanel):
sceneOpts
.
bindProps
(
'
zrange
'
,
self
.
__lbCanvas
)
self
.
__canvasSizer
=
wx
.
BoxSizer
(
wx
.
HORIZONTAL
)
self
.
getC
anvas
Panel
().
SetSizer
(
self
.
__canvasSizer
)
self
.
getC
ontent
Panel
().
SetSizer
(
self
.
__canvasSizer
)
self
.
__canvasSizer
.
Add
(
self
.
__lbCanvas
,
flag
=
wx
.
EXPAND
,
proportion
=
1
)
self
.
__canvasSizer
.
Add
(
self
.
__scrollbar
,
flag
=
wx
.
EXPAND
)
self
.
__canvasSizer
.
Add
(
self
.
__lbCanvas
,
flag
=
wx
.
EXPAND
,
proportion
=
1
)
# When the display context location changes,
# make sure the location is shown on the canvas
...
...
@@ -162,8 +161,9 @@ class LightBoxPanel(canvaspanel.CanvasPanel):
self
.
__onLightBoxChange
()
self
.
__onZoom
()
self
.
__selectedOverlayChanged
()
self
.
Layout
()
self
.
centrePanel
Layout
()
self
.
initProfile
()
# The ViewPanel AuiManager seems to
...
...
@@ -204,6 +204,25 @@ class LightBoxPanel(canvaspanel.CanvasPanel):
"""
Returns a reference to the :class:`.LightBoxCanvas` instance.
"""
return
self
.
__lbCanvas
def
centrePanelLayout
(
self
):
"""
Overrides :meth:`.CanvasPanel.centrePanelLayout`. Adds the
scrollbar to the centre panel.
"""
self
.
layoutContainerPanel
()
centrePanel
=
self
.
getCentrePanel
()
containerPanel
=
self
.
getContainerPanel
()
sizer
=
wx
.
BoxSizer
(
wx
.
HORIZONTAL
)
centrePanel
.
SetSizer
(
sizer
)
sizer
.
Add
(
containerPanel
,
flag
=
wx
.
EXPAND
,
proportion
=
1
)
sizer
.
Add
(
self
.
__scrollbar
,
flag
=
wx
.
EXPAND
)
self
.
PostSizeEvent
()
def
__selectedOverlayChanged
(
self
,
*
a
):
"""
Called when the :attr:`.DisplayContext.selectedOverlay` changes.
...
...
This diff is collapsed.
Click to expand it.
fsl/fsleyes/views/orthopanel.py
+
14
−
13
View file @
a08cc784
...
...
@@ -148,19 +148,19 @@ class OrthoPanel(canvaspanel.CanvasPanel):
sceneOpts
,
actionz
)
c
anvas
Panel
=
self
.
getC
anvas
Panel
()
c
ontent
Panel
=
self
.
getC
ontent
Panel
()
# The canvases themselves - each one displays a
# slice along each of the three world axes
self
.
__xcanvas
=
slicecanvas
.
WXGLSliceCanvas
(
c
anvas
Panel
,
self
.
__xcanvas
=
slicecanvas
.
WXGLSliceCanvas
(
c
ontent
Panel
,
overlayList
,
displayCtx
,
zax
=
0
)
self
.
__ycanvas
=
slicecanvas
.
WXGLSliceCanvas
(
c
anvas
Panel
,
self
.
__ycanvas
=
slicecanvas
.
WXGLSliceCanvas
(
c
ontent
Panel
,
overlayList
,
displayCtx
,
zax
=
1
)
self
.
__zcanvas
=
slicecanvas
.
WXGLSliceCanvas
(
c
anvas
Panel
,
self
.
__zcanvas
=
slicecanvas
.
WXGLSliceCanvas
(
c
ontent
Panel
,
overlayList
,
displayCtx
,
zax
=
2
)
...
...
@@ -172,9 +172,9 @@ class OrthoPanel(canvaspanel.CanvasPanel):
self
.
__zLabels
=
{}
for
side
in
(
'
left
'
,
'
right
'
,
'
top
'
,
'
bottom
'
):
self
.
__xLabels
[
side
]
=
wx
.
StaticText
(
c
anvas
Panel
)
self
.
__yLabels
[
side
]
=
wx
.
StaticText
(
c
anvas
Panel
)
self
.
__zLabels
[
side
]
=
wx
.
StaticText
(
c
anvas
Panel
)
self
.
__xLabels
[
side
]
=
wx
.
StaticText
(
c
ontent
Panel
)
self
.
__yLabels
[
side
]
=
wx
.
StaticText
(
c
ontent
Panel
)
self
.
__zLabels
[
side
]
=
wx
.
StaticText
(
c
ontent
Panel
)
self
.
__xcanvas
.
bindProps
(
'
showCursor
'
,
sceneOpts
)
self
.
__ycanvas
.
bindProps
(
'
showCursor
'
,
sceneOpts
)
...
...
@@ -236,13 +236,14 @@ class OrthoPanel(canvaspanel.CanvasPanel):
# the slice canvases when the canvas
# panel is resized, so aspect ratio
# is maintained
c
anvas
Panel
.
Bind
(
wx
.
EVT_SIZE
,
self
.
__onResize
)
c
ontent
Panel
.
Bind
(
wx
.
EVT_SIZE
,
self
.
__onResize
)
# Initialise the panel
self
.
__refreshLayout
()
self
.
__bgColourChanged
()
self
.
__overlayListChanged
()
self
.
__locationChanged
()
self
.
centrePanelLayout
()
self
.
initProfile
()
# The ViewPanel AuiManager seems to
...
...
@@ -328,8 +329,8 @@ class OrthoPanel(canvaspanel.CanvasPanel):
bg
=
[
int
(
round
(
c
*
255
))
for
c
in
bg
]
fg
=
[
int
(
round
(
c
*
255
))
for
c
in
fg
]
self
.
getC
anvas
Panel
().
SetBackgroundColour
(
bg
)
self
.
getC
anvas
Panel
().
SetForegroundColour
(
fg
)
self
.
getC
ontent
Panel
().
SetBackgroundColour
(
bg
)
self
.
getC
ontent
Panel
().
SetForegroundColour
(
fg
)
self
.
__xcanvas
.
SetBackgroundColour
(
bg
)
self
.
__ycanvas
.
SetBackgroundColour
(
bg
)
...
...
@@ -539,7 +540,7 @@ class OrthoPanel(canvaspanel.CanvasPanel):
opts
=
self
.
getSceneOptions
()
layout
=
opts
.
layout
width
,
height
=
self
.
getC
anvas
Panel
().
GetClientSize
().
Get
()
width
,
height
=
self
.
getC
ontent
Panel
().
GetClientSize
().
Get
()
show
=
[
opts
.
showXCanvas
,
opts
.
showYCanvas
,
opts
.
showZCanvas
]
canvases
=
[
self
.
__xcanvas
,
self
.
__ycanvas
,
self
.
__zcanvas
]
...
...
@@ -765,7 +766,7 @@ class OrthoPanel(canvaspanel.CanvasPanel):
for
w
in
widgets
:
self
.
__canvasSizer
.
Add
(
w
,
flag
=
flag
)
self
.
getC
anvas
Panel
().
SetSizer
(
self
.
__canvasSizer
)
self
.
getC
ontent
Panel
().
SetSizer
(
self
.
__canvasSizer
)
# Calculate/ adjust the appropriate sizes
# for each canvas, such that they are scaled
...
...
@@ -775,7 +776,7 @@ class OrthoPanel(canvaspanel.CanvasPanel):
self
.
__calcCanvasSizes
()
self
.
Layout
()
self
.
getC
anvas
Panel
().
Layout
()
self
.
getC
ontent
Panel
().
Layout
()
self
.
Refresh
()
...
...
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