Exemplo n.º 1
0
def _genLightPosWidget(parent, opts):
    """Generates a widget for the :attr:`.Scene3DOpts.lightPos` property.
    """
    px, py, pz = props.makeListWidgets(parent,
                                       opts,
                                       'lightPos',
                                       slider=True,
                                       spin=True,
                                       showLimits=False,
                                       mousewheel=True)
    sizer = wx.BoxSizer(wx.VERTICAL)
    sizer.Add(px, flag=wx.EXPAND)
    sizer.Add(py, flag=wx.EXPAND)
    sizer.Add(pz, flag=wx.EXPAND)
    return sizer
Exemplo n.º 2
0
    def __init__(self, parent, overlayList, displayCtx, frame):

        fslpanel.FSLeyesPanel.__init__(self,
                                       parent,
                                       overlayList,
                                       displayCtx,
                                       frame,
                                       kbFocus=True)

        # Whenever the selected overlay changes,
        # a reference to it and its DisplayOpts
        # instance is stored, as property listeners
        # are registered on it (and need to be
        # de-registered later on).
        self.__registeredOverlay = None
        self.__registeredDisplay = None
        self.__registeredOpts    = None

        self.__column1 = wx.Panel(self)
        self.__column2 = wx.Panel(self)
        self.__info    = wxhtml.HtmlWindow(self)

        # HTMLWindow does not use
        # the parent font by default,
        # so we force it to at least
        # have the parent font size
        self.__info.SetStandardFonts(self.GetFont().GetPointSize())

        self.__worldLabel = wx.StaticText(
            self.__column1, label=strings.labels[self, 'worldLocation'])
        self.__volumeLabel = wx.StaticText(
            self.__column1, label=strings.labels[self, 'volume'])
        self.__voxelLabel = wx.StaticText(
            self.__column2, label=strings.labels[self, 'voxelLocation'])

        worldX, worldY, worldZ = props.makeListWidgets(
            self.__column1,
            self,
            'worldLocation',
            slider=False,
            spin=True,
            showLimits=False,
            mousewheel=True)

        voxelX, voxelY, voxelZ = props.makeListWidgets(
            self.__column2,
            self,
            'voxelLocation',
            slider=False,
            spin=True,
            spinWidth=7,
            showLimits=False,
            mousewheel=True)

        self.__worldX = worldX
        self.__worldY = worldY
        self.__worldZ = worldZ
        self.__voxelX = voxelX
        self.__voxelY = voxelY
        self.__voxelZ = voxelZ
        self.__volume = floatspin.FloatSpinCtrl(
            self.__column2,
            width=7,
            style=floatspin.FSC_MOUSEWHEEL | floatspin.FSC_INTEGER)

        self.__column1Sizer = wx.BoxSizer(wx.VERTICAL)
        self.__column2Sizer = wx.BoxSizer(wx.VERTICAL)
        self.__sizer        = wx.BoxSizer(wx.HORIZONTAL)

        self.__column1Sizer.Add(self.__worldLabel,  flag=wx.EXPAND)
        self.__column1Sizer.Add(self.__worldX,      flag=wx.EXPAND)
        self.__column1Sizer.Add(self.__worldY,      flag=wx.EXPAND)
        self.__column1Sizer.Add(self.__worldZ,      flag=wx.EXPAND)
        self.__column1Sizer.Add(self.__volumeLabel, flag=wx.ALIGN_RIGHT)

        self.__column2Sizer.Add(self.__voxelLabel, flag=wx.EXPAND)
        self.__column2Sizer.Add(self.__voxelX,     flag=wx.EXPAND)
        self.__column2Sizer.Add(self.__voxelY,     flag=wx.EXPAND)
        self.__column2Sizer.Add(self.__voxelZ,     flag=wx.EXPAND)
        self.__column2Sizer.Add(self.__volume,     flag=wx.EXPAND)

        self.__sizer.Add(self.__column1, flag=wx.EXPAND)
        self.__sizer.Add((5, -1))
        self.__sizer.Add(self.__column2, flag=wx.EXPAND)
        self.__sizer.Add((5, -1))
        self.__sizer.Add(self.__info,    flag=wx.EXPAND, proportion=1)

        self.__column1.SetSizer(self.__column1Sizer)
        self.__column2.SetSizer(self.__column2Sizer)
        self          .SetSizer(self.__sizer)

        self.overlayList.addListener('overlays',
                                     self.name,
                                     self.__selectedOverlayChanged)
        self.displayCtx .addListener('selectedOverlay',
                                     self.name,
                                     self.__selectedOverlayChanged)
        self.displayCtx .addListener('overlayOrder',
                                     self.name,
                                     self.__overlayOrderChanged)
        self.displayCtx .addListener('location',
                                     self.name,
                                     self.__displayLocationChanged)
        self.addListener(            'voxelLocation',
                                     self.name,
                                     self.__voxelLocationChanged)
        self.addListener(            'worldLocation',
                                     self.name,
                                     self.__worldLocationChanged)

        self.__selectedOverlayChanged()

        self.__worldLabel .SetMinSize(self.__calcWorldLabelMinSize())
        self.__voxelLabel .SetMinSize(self.__voxelLabel .GetBestSize())
        self.__volumeLabel.SetMinSize(self.__volumeLabel.GetBestSize())
        self.__column1    .SetMinSize(self.__column1    .GetBestSize())
        self.__column2    .SetMinSize(self.__column2    .GetBestSize())
        self.__info       .SetMinSize((100, 100))

        # Keyboard navigation - see FSLeyesPanel
        self.setNavOrder((self.__worldX,
                          self.__worldY,
                          self.__worldZ,
                          self.__voxelX,
                          self.__voxelY,
                          self.__voxelZ,
                          self.__volume))

        self.Layout()

        self.__minSize = self.__sizer.GetMinSize()
        self.SetMinSize(self.__minSize)
Exemplo n.º 3
0
    def generatePlotPanelWidgets(self, groupName):
        """Adds a collection of widgets to the given :class:`.WidgetList`,
        allowing the properties of the given :class:`.PlotPanel` instance
        to be changed.

        This method may be overridden by sub-classes to change/add to the
        list of properties that are added by default.

        :arg groupName: The :class:`.WidgetList` group name.

        :returns: A list of the widgets that were created, and should be
                  included in keyboard navigation (see
                  :meth:`.FSLeyesPanel.setNavOrder`).
        """

        widgetList = self.getWidgetList()
        plotPanel = self.__plotPanel
        allWidgets = []

        plotProps = [
            'smooth', 'legend', 'ticks', 'grid', 'gridColour', 'bgColour'
        ]

        for prop in plotProps:
            widget = props.makeWidget(widgetList, plotPanel, prop)
            allWidgets.append(widget)
            widgetList.AddWidget(widget,
                                 displayName=strings.properties[plotPanel,
                                                                prop],
                                 tooltip=fsltooltips.properties[plotPanel,
                                                                prop],
                                 groupName=groupName)

        limits = props.makeListWidgets(widgetList, plotPanel, 'limits')
        xlogscale = props.makeWidget(widgetList, plotPanel, 'xLogScale')
        ylogscale = props.makeWidget(widgetList, plotPanel, 'yLogScale')
        xinvert = props.makeWidget(widgetList, plotPanel, 'invertX')
        yinvert = props.makeWidget(widgetList, plotPanel, 'invertY')
        xscale = props.makeWidget(widgetList, plotPanel, 'xScale')
        yscale = props.makeWidget(widgetList, plotPanel, 'yScale')
        xoffset = props.makeWidget(widgetList, plotPanel, 'xOffset')
        yoffset = props.makeWidget(widgetList, plotPanel, 'yOffset')
        xautoscale = props.makeWidget(widgetList, plotPanel, 'xAutoScale')
        yautoscale = props.makeWidget(widgetList, plotPanel, 'yAutoScale')
        xlabel = props.makeWidget(widgetList, plotPanel, 'xlabel')
        ylabel = props.makeWidget(widgetList, plotPanel, 'ylabel')

        allWidgets.extend(limits)
        allWidgets.extend([
            xlogscale, ylogscale, xinvert, yinvert, xautoscale, yautoscale,
            xscale, yscale, xoffset, yoffset, xlabel, ylabel
        ])

        pairs = [('logscale', xlogscale, ylogscale),
                 ('invert', xinvert, yinvert),
                 ('autoscale', xautoscale, yautoscale),
                 ('scale', xscale, yscale), ('offset', xoffset, yoffset),
                 ('labels', xlabel, ylabel)]

        for key, xwidget, ywidget in pairs:

            sizer = wx.BoxSizer(wx.HORIZONTAL)

            sizer.Add(
                wx.StaticText(widgetList, label=strings.labels[self,
                                                               'xlabel']))
            sizer.Add(xwidget, flag=wx.EXPAND, proportion=1)
            sizer.Add(
                wx.StaticText(widgetList, label=strings.labels[self,
                                                               'ylabel']))
            sizer.Add(ywidget, flag=wx.EXPAND, proportion=1)

            widgetList.AddWidget(sizer,
                                 displayName=strings.labels[self, key],
                                 tooltip=fsltooltips.misc[self, key],
                                 groupName=groupName)

        # Store refs to the limit widgets
        # so they can be enabled/disabled
        # when xAutoScale/yAutoScale
        # changes.
        self.__xLimitWidgets = [limits[0], limits[1]]
        self.__yLimitWidgets = [limits[2], limits[3]]

        xlims = wx.BoxSizer(wx.HORIZONTAL)
        ylims = wx.BoxSizer(wx.HORIZONTAL)

        xlims.Add(limits[0], flag=wx.EXPAND, proportion=1)
        xlims.Add(limits[1], flag=wx.EXPAND, proportion=1)
        ylims.Add(limits[2], flag=wx.EXPAND, proportion=1)
        ylims.Add(limits[3], flag=wx.EXPAND, proportion=1)

        widgetList.AddWidget(xlims,
                             displayName=strings.labels[self, 'xlim'],
                             tooltip=fsltooltips.misc[self, 'xlim'],
                             groupName=groupName)
        widgetList.AddWidget(ylims,
                             displayName=strings.labels[self, 'ylim'],
                             tooltip=fsltooltips.misc[self, 'ylim'],
                             groupName=groupName)

        return allWidgets
Exemplo n.º 4
0
    def generateCustomDataSeriesWidgets(self, ts, groupName):
        """Overrides :meth:`.PlotControlPanel.generateCustomDataSeriesWidgets`.

        If the given :class:`.TimeSeries` is a :class:`.FEATTimeSeries`
        instance, this method adds some widgets for controlling the
        FEAT-related settings of the instance.
        """

        overlay = ts.overlay
        widgetList = self.getWidgetList()
        allWidgets = []

        if not (isinstance(overlay, fslfeatimage.FEATImage) and isinstance(
                ts, timeseries.FEATTimeSeries) and overlay.hasStats()):
            return allWidgets

        full = props.makeWidget(widgetList, ts, 'plotFullModelFit')
        res = props.makeWidget(widgetList, ts, 'plotResiduals')
        evs = props.makeListWidgets(widgetList, ts, 'plotEVs')
        pes = props.makeListWidgets(widgetList, ts, 'plotPEFits')
        copes = props.makeListWidgets(widgetList, ts, 'plotCOPEFits')
        partial = props.makeWidget(widgetList, ts, 'plotPartial')
        data = props.makeWidget(widgetList, ts, 'plotData')

        allWidgets.append(full)
        allWidgets.append(res)
        allWidgets.extend(evs)
        allWidgets.extend(pes)
        allWidgets.extend(copes)
        allWidgets.append(partial)
        allWidgets.append(data)

        widgetList.AddWidget(data,
                             displayName=strings.properties[ts, 'plotData'],
                             tooltip=fsltooltips.properties[ts, 'plotData'],
                             groupName=groupName)
        widgetList.AddWidget(
            full,
            displayName=strings.properties[ts, 'plotFullModelFit'],
            tooltip=fsltooltips.properties[ts, 'plotFullModelFit'],
            groupName=groupName)

        widgetList.AddWidget(res,
                             displayName=strings.properties[ts,
                                                            'plotResiduals'],
                             tooltip=fsltooltips.properties[ts,
                                                            'plotResiduals'],
                             groupName=groupName)

        widgetList.AddWidget(partial,
                             displayName=strings.properties[ts, 'plotPartial'],
                             tooltip=fsltooltips.properties[ts, 'plotPartial'],
                             groupName=groupName)

        widgetList.AddSpace(groupName=groupName)

        for i, ev in enumerate(evs):

            evName = overlay.evNames()[i]
            widgetList.AddWidget(
                ev,
                displayName=strings.properties[ts, 'plotEVs'].format(
                    i + 1, evName),
                tooltip=fsltooltips.properties[ts, 'plotEVs'],
                groupName=groupName)

        widgetList.AddSpace(groupName=groupName)

        for i, pe in enumerate(pes):
            evName = overlay.evNames()[i]
            widgetList.AddWidget(
                pe,
                displayName=strings.properties[ts, 'plotPEFits'].format(
                    i + 1, evName),
                tooltip=fsltooltips.properties[ts, 'plotPEFits'],
                groupName=groupName)

        widgetList.AddSpace(groupName=groupName)

        copeNames = overlay.contrastNames()
        for i, (cope, name) in enumerate(zip(copes, copeNames)):
            widgetList.AddWidget(
                cope,
                displayName=strings.properties[ts, 'plotCOPEFits'].format(
                    i + 1, name),
                tooltip=fsltooltips.properties[ts, 'plotCOPEFits'],
                groupName=groupName)

        return allWidgets
    def __generateFeatWidgets(self, ts, groupName):
        """Called by :meth:`generateCustomDataSeriesWidgets`. Generates
        widgets for :class:`.FEATTimeSeries` options, and adds them
        to the widget list.
        """

        overlay = ts.overlay
        widgetList = self.getWidgetList()
        allWidgets = []

        full = props.makeWidget(widgetList, ts, 'plotFullModelFit')
        res = props.makeWidget(widgetList, ts, 'plotResiduals')
        evs = props.makeListWidgets(widgetList, ts, 'plotEVs')
        pes = props.makeListWidgets(widgetList, ts, 'plotPEFits')
        copes = props.makeListWidgets(widgetList, ts, 'plotCOPEFits')
        partial = props.makeWidget(widgetList, ts, 'plotPartial')
        data = props.makeWidget(widgetList, ts, 'plotData')

        allWidgets.append(full)
        allWidgets.append(res)
        allWidgets.extend(evs)
        allWidgets.extend(pes)
        allWidgets.extend(copes)
        allWidgets.append(partial)
        allWidgets.append(data)

        widgetList.AddWidget(data,
                             displayName=strings.properties[ts, 'plotData'],
                             tooltip=fsltooltips.properties[ts, 'plotData'],
                             groupName=groupName)
        widgetList.AddWidget(
            full,
            displayName=strings.properties[ts, 'plotFullModelFit'],
            tooltip=fsltooltips.properties[ts, 'plotFullModelFit'],
            groupName=groupName)

        widgetList.AddWidget(res,
                             displayName=strings.properties[ts,
                                                            'plotResiduals'],
                             tooltip=fsltooltips.properties[ts,
                                                            'plotResiduals'],
                             groupName=groupName)

        widgetList.AddWidget(partial,
                             displayName=strings.properties[ts, 'plotPartial'],
                             tooltip=fsltooltips.properties[ts, 'plotPartial'],
                             groupName=groupName)

        widgetList.AddSpace(groupName=groupName)

        for i, ev in enumerate(evs):

            evName = overlay.evNames()[i]
            widgetList.AddWidget(
                ev,
                displayName=strings.properties[ts, 'plotEVs'].format(
                    i + 1, evName),
                tooltip=fsltooltips.properties[ts, 'plotEVs'],
                groupName=groupName)

        widgetList.AddSpace(groupName=groupName)

        for i, pe in enumerate(pes):
            evName = overlay.evNames()[i]
            widgetList.AddWidget(
                pe,
                displayName=strings.properties[ts, 'plotPEFits'].format(
                    i + 1, evName),
                tooltip=fsltooltips.properties[ts, 'plotPEFits'],
                groupName=groupName)

        widgetList.AddSpace(groupName=groupName)

        copeNames = overlay.contrastNames()
        for i, (cope, name) in enumerate(zip(copes, copeNames)):
            widgetList.AddWidget(
                cope,
                displayName=strings.properties[ts, 'plotCOPEFits'].format(
                    i + 1, name),
                tooltip=fsltooltips.properties[ts, 'plotCOPEFits'],
                groupName=groupName)

        return allWidgets