diff --git a/fsl/data/strings.py b/fsl/data/strings.py index f09013cb6deb6eb80d64d4a6110513745e0eb8f9..338b7aa17ad144e1a3fceb0a1de81e756f7acfd1 100644 --- a/fsl/data/strings.py +++ b/fsl/data/strings.py @@ -254,8 +254,8 @@ labels = TypeDict({ 'ClusterPanel.copemaxcoords' : 'COPE Max location', 'ClusterPanel.copemean' : 'COPE mean', - 'ClusterPanel.addZStats' : 'Add Z statistics', - 'ClusterPanel.addClusterMask' : 'Add cluster mask', + 'ClusterPanel.addZStats' : 'Add Z statistics', + 'ClusterPanel.addClustMask' : 'Add cluster mask', 'OverlayDisplayPanel.Display' : 'General display settings', diff --git a/fsl/fslview/controls/__init__.py b/fsl/fslview/controls/__init__.py index 5013b802918fbb463133851ef5919498697b8944..a9471fdad551b58a595041c24ae62fc14f19f333 100644 --- a/fsl/fslview/controls/__init__.py +++ b/fsl/fslview/controls/__init__.py @@ -8,7 +8,6 @@ from atlaspanel import AtlasPanel from overlaydisplaypanel import OverlayDisplayPanel from overlaylistpanel import OverlayListPanel -from overlayselectpanel import OverlaySelectPanel from locationpanel import LocationPanel from lookuptablepanel import LookupTablePanel from timeserieslistpanel import TimeSeriesListPanel diff --git a/fsl/fslview/controls/clusterpanel.py b/fsl/fslview/controls/clusterpanel.py index 938a2c9f35d7a4d78f4ff82baa231d5e7d38cae8..b8b65eec97766fcb29c6efb5308aecfe8d839600 100644 --- a/fsl/fslview/controls/clusterpanel.py +++ b/fsl/fslview/controls/clusterpanel.py @@ -29,15 +29,14 @@ class ClusterPanel(fslpanel.FSLViewPanel): style=(wx.ALIGN_CENTRE_HORIZONTAL | wx.ALIGN_CENTRE_VERTICAL)) - self.__overlayName = wx .StaticText( self) - self.__addZStats = wx.Button( self) - self.__addClusterMask = wx.Button( self) - self.__statSelect = wx .ComboBox( self, - style=wx.CB_READONLY) - self.__clusterList = widgetgrid.WidgetGrid(self) - - self.__addZStats .SetLabel(strings.labels[self, 'addZStats']) - self.__addClusterMask.SetLabel(strings.labels[self, 'addClusterMask']) + self.__overlayName = wx.StaticText(self) + self.__addZStats = wx.Button( self) + self.__addClustMask = wx.Button( self) + self.__statSelect = wx.ComboBox( self, style=wx.CB_READONLY) + self.__clusterList = widgetgrid.WidgetGrid(self) + + self.__addZStats .SetLabel(strings.labels[self, 'addZStats']) + self.__addClustMask.SetLabel(strings.labels[self, 'addClustMask']) self.__clusterList.ShowRowLabels(False) self.__clusterList.ShowColLabels(True) @@ -50,13 +49,13 @@ class ClusterPanel(fslpanel.FSLViewPanel): args = {'flag' : wx.EXPAND, 'proportion' : 1} - self.__topSizer.Add(self.__overlayName, **args) - self.__topSizer.Add(self.__statSelect, **args) - self.__topSizer.Add(self.__addZStats, **args) - self.__topSizer.Add(self.__addClusterMask, **args) + self.__topSizer.Add(self.__statSelect, flag=wx.EXPAND, proportion=1) + self.__topSizer.Add(self.__addZStats, flag=wx.EXPAND, proportion=1) + self.__topSizer.Add(self.__addClustMask, flag=wx.EXPAND, proportion=1) + self.__mainSizer.Add(self.__overlayName, flag=wx.EXPAND) self.__mainSizer.Add(self.__topSizer, flag=wx.EXPAND) - self.__mainSizer.Add(self.__clusterList, **args) + self.__mainSizer.Add(self.__clusterList, flag=wx.EXPAND, proportion=1) # Only one of the disabledText or # mainSizer are shown at any one time @@ -70,14 +69,38 @@ class ClusterPanel(fslpanel.FSLViewPanel): self._name, self.__selectedOverlayChanged) - self.__statSelect .Bind(wx.EVT_COMBOBOX, self.__statSelected) - self.__addZStats .Bind(wx.EVT_BUTTON, self.__addZStatsClick) - self.__addClusterMask.Bind(wx.EVT_BUTTON, self.__addClusterMaskClick) + self.__statSelect .Bind(wx.EVT_COMBOBOX, self.__statSelected) + self.__addZStats .Bind(wx.EVT_BUTTON, self.__addZStatsClick) + self.__addClustMask.Bind(wx.EVT_BUTTON, self.__addClustMaskClick) + + self.SetMinSize(self.__calcMinSize()) self.__selectedOverlay = None self.__selectedOverlayChanged() + def __calcMinSize(self): + """Figures out the minimum size that this ``ClusterPanel`` should + have. + + When the ``ClusterPanel`` is created, the COPE combo box is not + populated, so has no minimum size. Here, we figure out a good minimum + size for it. We can then calculate a good minimum size for the entire + panel. + """ + + dc = wx.ClientDC(self.__statSelect) + + dummyName = strings.labels[self, 'clustName'].format(1, 'WW') + + w, h = dc.GetTextExtent(dummyName) + + self.__statSelect .SetMinSize((w, h)) + self.__sizer.Layout() + + return self.__sizer.GetMinSize() + + def destroy(self): self._overlayList.removeListener('overlays', self._name) self._displayCtx .removeListener('selectedOverlay', self ._name) @@ -122,7 +145,7 @@ class ClusterPanel(fslpanel.FSLViewPanel): opts.clippingRange.x = -zthres, zthres - def __addClusterMaskClick(self, ev): + def __addClustMaskClick(self, ev): overlay = self.__selectedOverlay contrast = self.__statSelect.GetSelection() mask = overlay.getClusterMask(contrast) @@ -156,8 +179,8 @@ class ClusterPanel(fslpanel.FSLViewPanel): dss = [ovl.dataSource for ovl in self._overlayList] - self.__addZStats .Enable(zstat .dataSource not in dss) - self.__addClusterMask.Enable(clustMask.dataSource not in dss) + self.__addZStats .Enable(zstat .dataSource not in dss) + self.__addClustMask.Enable(clustMask.dataSource not in dss) def __selectedOverlayChanged(self, *a): diff --git a/fsl/fslview/controls/locationpanel.py b/fsl/fslview/controls/locationpanel.py index 5f505c6bb7ca6c8d65d17b541d9b880bdbdfaf0e..4a70f6efde9d4acc30e39cacf2c5de60384e3c78 100644 --- a/fsl/fslview/controls/locationpanel.py +++ b/fsl/fslview/controls/locationpanel.py @@ -48,18 +48,6 @@ class LocationPanel(fslpanel.FSLViewPanel): worldLocation = props.Point(ndims=3, real=True, labels=('X', 'Y', 'Z')) - - def _adjustFont(self, label, by, weight): - """ - Adjusts the font of the given wx.StaticText widget (or any other - widget which has a font) by the specified amount. Also sets the - font weight to the given weight. - """ - font = label.GetFont() - font.SetPointSize(font.GetPointSize() + by) - font.SetWeight(weight) - label.SetFont(font) - def __init__(self, parent, overlayList, displayCtx): """ @@ -153,10 +141,6 @@ class LocationPanel(fslpanel.FSLViewPanel): self.sizer.Add((5, -1)) self.sizer.Add(self.info, flag=wx.EXPAND, proportion=1) - self._adjustFont(self.voxelLabel, -2, wx.FONTWEIGHT_LIGHT) - self._adjustFont(self.worldLabel, -2, wx.FONTWEIGHT_LIGHT) - self._adjustFont(self.volumeLabel, -2, wx.FONTWEIGHT_LIGHT) - self.column1.SetSizer(self.column1Sizer) self.column2.SetSizer(self.column2Sizer) self .SetSizer(self.sizer) diff --git a/fsl/fslview/controls/lookuptablepanel.py b/fsl/fslview/controls/lookuptablepanel.py index 1b17e7f739f45724e987a3caa6265cdbfc9049f7..ce4da7873acd8622cd2d83347742f0d211c79e69 100644 --- a/fsl/fslview/controls/lookuptablepanel.py +++ b/fsl/fslview/controls/lookuptablepanel.py @@ -134,12 +134,6 @@ class LookupTablePanel(fslpanel.FSLViewPanel): self.__loadLutButton.SetLabel(strings.labels[ self, 'loadLut']) self.__saveLutButton.SetLabel(strings.labels[ self, 'saveLut']) - # Make the label name a bit smaller - font = self.__overlayNameLabel.GetFont() - font.SetPointSize(font.GetPointSize() - 2) - font.SetWeight(wx.FONTWEIGHT_LIGHT) - self.__overlayNameLabel.SetFont(font) - # Listen for listbox events self.__labelList.Bind(elistbox.EVT_ELB_ADD_EVENT, self.__onLabelAdd) diff --git a/fsl/fslview/controls/overlayselectpanel.py b/fsl/fslview/controls/overlayselectpanel.py deleted file mode 100644 index 257c0845dc1d9275ca223ae249525f1f06f34e37..0000000000000000000000000000000000000000 --- a/fsl/fslview/controls/overlayselectpanel.py +++ /dev/null @@ -1,186 +0,0 @@ -#!/usr/bin/env python -# -# overlayselectpanel.py - A little panel which allows the currently selected -# overlay to be changed. -# -# Author: Paul McCarthy <pauldmccarthy@gmail.com> -# -"""Defines the :class:`OverlaySelectPanel` which is a little panel that allows -the currently selected overlay to be changed. - -This panel is generally embedded within other control panels. -""" - -import logging - -import wx - -import fsl.fslview.panel as fslpanel - -log = logging.getLogger(__name__) - - -class OverlaySelectPanel(fslpanel.FSLViewPanel): - """A panel which displays the currently selected overlay, - and allows it to be changed. - """ - - def __init__(self, parent, overlayList, displayCtx, showName=True): - - fslpanel.FSLViewPanel.__init__(self, parent, overlayList, displayCtx) - - self.showName = showName - - # A button to select the previous image - self._prevButton = wx.Button(self, label=u'\u25C0', - style=wx.BU_EXACTFIT) - - # A button selecting the next image - self._nextButton = wx.Button(self, label=u'\u25B6', - style=wx.BU_EXACTFIT) - - self._sizer = wx.BoxSizer(wx.HORIZONTAL) - self.SetSizer(self._sizer) - - self._sizer.Add(self._prevButton, flag=wx.EXPAND) - self._sizer.Add(self._nextButton, flag=wx.EXPAND) - - # bind callbacks for next/prev buttons - self._nextButton.Bind(wx.EVT_BUTTON, self._onNextButton) - self._prevButton.Bind(wx.EVT_BUTTON, self._onPrevButton) - - # A label showing the name of the current overlay - if not showName: - self._overlayLabel = None - else: - self._overlayLabel = wx.StaticText(self, - style=wx.ALIGN_CENTRE | - wx.ST_ELLIPSIZE_MIDDLE) - - self._sizer.Insert(1, - self._overlayLabel, - flag=wx.EXPAND, - proportion=1) - - # Make the image name label font a bit smaller - font = self._overlayLabel.GetFont() - font.SetPointSize(font.GetPointSize() - 2) - font.SetWeight(wx.FONTWEIGHT_LIGHT) - self._overlayLabel.SetFont(font) - - self._overlayList.addListener( - 'overlays', - self._name, - self._overlayListChanged) - self._displayCtx.addListener( - 'selectedOverlay', - self._name, - self._selectedOverlayChanged) - - self._overlayListChanged() - - self.Layout() - self.SetMinSize(self._sizer.GetMinSize()) - - - def destroy(self): - - self._overlayList.removeListener('overlays', self._name) - self._displayCtx .removeListener('selectedOverlay', self._name) - - # the _overlayListChanged method registers - # a listener on the name of each overlay - for overlay in self._overlayList: - display = self._displayCtx.getDisplay(overlay) - display.removeListener('name', self._name) - - fslpanel.FSLViewPanel.destroy(self) - - - def _onPrevButton(self, ev): - """Called when the previous button is pushed. Selects the previous - overlay. - """ - allOverlays = self._displayCtx.getOrderedOverlays() - currOverlay = self._displayCtx.getSelectedOverlay() - currIdx = allOverlays.index(currOverlay) - - if currIdx == 0: - return - - self._displayCtx.selectOverlay(allOverlays[currIdx - 1]) - - - def _onNextButton(self, ev): - """Called when the previous button is pushed. Selects the next - overlay. - """ - allOverlays = self._displayCtx.getOrderedOverlays() - currOverlay = self._displayCtx.getSelectedOverlay() - currIdx = allOverlays.index(currOverlay) - - if currIdx == len(allOverlays) - 1: - return - - self._displayCtx.selectOverlay(allOverlays[currIdx + 1]) - - - def _overlayListChanged(self, *a): - """Called when the :class:`.OverlayList.overlays` list changes. - - Ensures that the currently selected overlay is displayed on the panel, - and that listeners are registered on the name property for each - overlay. - """ - - def nameChanged(value, valid, display, name): - - ovl = display.getOverlay() - idx = self._overlayList.index(ovl) - - # if the name of the currently selected overlay has changed, - # make sure that this panel updates to reflect the change - if idx == self._displayCtx.selectedOverlay: - self._selectedOverlayChanged() - - if self._overlayLabel is not None: - for overlay in self._overlayList: - display = self._displayCtx.getDisplay(overlay) - display.addListener('name', - self._name, - nameChanged, - overwrite=True) - - self._selectedOverlayChanged() - - - def _selectedOverlayChanged(self, *a): - """Called when the selected overlay is changed. Updates the overlay - name label. - """ - - allOverlays = self._displayCtx.getOrderedOverlays() - overlay = self._displayCtx.getSelectedOverlay() - novls = len(allOverlays) - - if novls > 0: idx = allOverlays.index(overlay) - else: idx = -1 - - self._prevButton.Enable(novls > 0 and idx > 0) - self._nextButton.Enable(novls > 0 and idx < novls - 1) - - if self._overlayLabel is None: - return - - if novls == 0: - self._overlayLabel.SetLabel('') - return - - display = self._displayCtx.getDisplay(overlay) - name = display.name - - if name is None: name = '' - self._overlayLabel.SetLabel('{}'.format(name)) - - self.Layout() - self.Refresh() diff --git a/fsl/fslview/frame.py b/fsl/fslview/frame.py index 9bf5b5cefcc103c8b6c3b930daefa078faa291cc..5347ab99a3342e4ff630a1e7081a7b75bea89dde 100644 --- a/fsl/fslview/frame.py +++ b/fsl/fslview/frame.py @@ -84,6 +84,13 @@ class FSLViewFrame(wx.Frame): """ wx.Frame.__init__(self, parent, title='FSLView') + + # Default application font - this is + # inherited by all child controls. + font = self.GetFont() + font.SetPointSize(10) + font.SetWeight(wx.FONTWEIGHT_LIGHT) + self.SetFont(font) self.__overlayList = overlayList self.__displayCtx = displayCtx