예제 #1
0
    def __makeLabelOptsTools(self, opts):
        """Creates and returns a collection of controls for editing properties
        of the given :class:`.LabelOpts` instance.
        """

        lutSpec = _TOOLBAR_PROPS[opts, 'lut']
        outlineSpec = _TOOLBAR_PROPS[opts, 'outline']
        widthSpec = _TOOLBAR_PROPS[opts, 'outlineWidth']

        # lut/outline width widgets
        # are on a single panel
        lutWidthPanel = wx.Panel(self)
        lutWidthSizer = wx.FlexGridSizer(2, 2, 0, 0)
        lutWidthPanel.SetSizer(lutWidthSizer)

        lutWidget = props.buildGUI(lutWidthPanel, opts, lutSpec)
        widthWidget = props.buildGUI(lutWidthPanel, opts, widthSpec)
        outlineWidget = props.buildGUI(self, opts, outlineSpec)

        lutLabel = wx.StaticText(lutWidthPanel)
        widthLabel = wx.StaticText(lutWidthPanel)

        lutLabel.SetLabel(strings.properties[opts, 'lut'])
        widthLabel.SetLabel(strings.properties[opts, 'outlineWidth'])

        lutWidthSizer.Add(lutLabel)
        lutWidthSizer.Add(lutWidget, flag=wx.EXPAND)
        lutWidthSizer.Add(widthLabel)
        lutWidthSizer.Add(widthWidget, flag=wx.EXPAND)

        tools = [lutWidthPanel, outlineWidget]
        nav = [lutWidget, widthWidget, outlineWidget]

        return tools, nav
예제 #2
0
    def __makeVolumeOptsTools(self, opts):
        """Creates and returns a collection of controls for editing properties
        of the given :class:`.VolumeOpts` instance.
        """
        rangeSpec = _TOOLBAR_PROPS[opts, 'displayRange']
        resetSpec = _TOOLBAR_PROPS[opts, 'resetDisplayRange']
        cmapSpec = _TOOLBAR_PROPS[opts, 'cmap']
        negCmapSpec = _TOOLBAR_PROPS[opts, 'negativeCmap']
        useNegCmapSpec = _TOOLBAR_PROPS[opts, 'useNegativeCmap']

        cmapPanel = wx.Panel(self)

        rangeWidget = props.buildGUI(self, opts, rangeSpec)
        resetWidget = props.buildGUI(self, opts, resetSpec)
        useNegCmapWidget = props.buildGUI(self, opts, useNegCmapSpec)
        cmapWidget = props.buildGUI(cmapPanel, opts, cmapSpec)
        negCmapWidget = props.buildGUI(cmapPanel, opts, negCmapSpec)

        cmapSizer = wx.BoxSizer(wx.VERTICAL)
        cmapPanel.SetSizer(cmapSizer)
        cmapSizer.Add(cmapWidget)
        cmapSizer.Add(negCmapWidget)

        tools = [resetWidget, rangeWidget, useNegCmapWidget, cmapPanel]
        nav = [
            resetWidget, rangeWidget, useNegCmapWidget, cmapWidget,
            negCmapWidget
        ]

        return tools, nav
예제 #3
0
def _NiftiOpts_VolumeWidget(
        target,
        parent,
        panel,
        overlayList,
        displayCtx,
        threedee):
    """Builds a panel which contains widgets for the
    :attr:`.NiftiOpts.volume` and :attr:`.NiftiOpts.volumeDim` properties.
    """

    volume    = getWidgetSpecs(target, threedee)['volume']
    volumeDim = getWidgetSpecs(target, threedee)['volumeDim']

    volume    = props.buildGUI(parent, target, volume)
    volumeDim = props.buildGUI(parent, target, volumeDim)

    dimLabel = wx.StaticText(parent,
                             label='Dim',
                             style=(wx.ALIGN_CENTRE_VERTICAL |
                                    wx.ALIGN_CENTRE_HORIZONTAL))

    sizer = wx.BoxSizer(wx.HORIZONTAL)

    sizer.Add(volume,    flag=wx.EXPAND, proportion=1)
    sizer.Add(dimLabel,  flag=wx.EXPAND)
    sizer.Add(volumeDim, flag=wx.EXPAND)

    return sizer, [volume, volumeDim]
예제 #4
0
    def __makeSHOptsTools(self, opts):
        """Creates and returns a collection of controls for editing properties
        of the given :class:`.SHOpts` instance.
        """
        sizeSpec = _TOOLBAR_PROPS[opts, 'size']
        radSpec = _TOOLBAR_PROPS[opts, 'radiusThreshold']

        panel = wx.Panel(self)
        sizer = wx.FlexGridSizer(2, 2, 0, 0)

        sizeWidget = props.buildGUI(panel, opts, sizeSpec)
        radWidget = props.buildGUI(panel, opts, radSpec)

        sizeLabel = wx.StaticText(panel)
        radLabel = wx.StaticText(panel)

        sizeLabel.SetLabel(strings.properties[opts, 'size'])
        radLabel.SetLabel(strings.properties[opts, 'radiusThreshold'])

        sizer.Add(sizeLabel)
        sizer.Add(sizeWidget)
        sizer.Add(radLabel)
        sizer.Add(radWidget)
        panel.SetSizer(sizer)

        tools, nav = self.__makeVectorOptsTools(opts)

        tools.extend([panel])
        nav.extend([sizeWidget, radWidget])

        return tools, nav
예제 #5
0
def _VolumeOpts_OverrideDataRangeWidget(
        target,
        parent,
        panel,
        overlayList,
        displayCtx,
        threedee):
    """Builds a panel which contains widgets for enabling and adjusting
    the :attr:`.VolumeOpts.overrideDataRange`.

    :returns: a ``wx.Sizer`` containing all of the widgets.
    """

    # Override data range widget
    enable   = getWidgetSpecs(target, threedee)['enableOverrideDataRange']
    ovrRange = getWidgetSpecs(target, threedee)['overrideDataRange']

    enable   = props.buildGUI(parent, target, enable)
    ovrRange = props.buildGUI(parent, target, ovrRange)

    sizer = wx.BoxSizer(wx.HORIZONTAL)

    sizer.Add(enable,   flag=wx.EXPAND)
    sizer.Add(ovrRange, flag=wx.EXPAND, proportion=1)

    return sizer, [enable, ovrRange]
예제 #6
0
    def __init__(self, parent, overlayList, displayCtx, frame, psPanel):
        """Create a ``PowerSpectrumToolBar``.

        :arg parent:      The :mod:`wx` parent object.
        :arg overlayList: The :class:`.OverlayList` instance.
        :arg displayCtx:  The :class:`.DisplayContext` instance.
        :arg frame:       The :class:`.FSLeyesFrame` instance.
        :arg psPanel:     The :class:`.PowerSpectrumPanel` instance.
        """

        plottoolbar.PlotToolBar.__init__(
            self, parent, overlayList, displayCtx, frame, psPanel)

        togControl = actions.ToggleActionButton(
            'togglePowerSpectrumControl',
            actionKwargs={'floatPane' : True},
            icon=[icons.findImageFile('spannerHighlight24'),
                  icons.findImageFile('spanner24')],
            tooltip=tooltips.actions[psPanel, 'togglePowerSpectrumControl'])

        togList = actions.ToggleActionButton(
            'togglePlotList',
            actionKwargs={'floatPane' : True},
            icon=[icons.findImageFile('listHighlight24'),
                  icons.findImageFile('list24')],
            tooltip=tooltips.actions[psPanel, 'togglePlotList'])

        togControl = props.buildGUI(self, psPanel, togControl)
        togList    = props.buildGUI(self, psPanel, togList)

        self.InsertTools([togControl, togList], 0)

        nav = [togControl, togList] + self.getCommonNavOrder()

        self.setNavOrder(nav)
예제 #7
0
    def __makeVectorOptsTools(self, opts):
        """Creates and returns a collection of controls for editing properties
        of the given :class:`.VectorOpts` instance.
        """

        modSpec = _TOOLBAR_PROPS[opts, 'modulateImage']
        clipSpec = _TOOLBAR_PROPS[opts, 'clipImage']
        rangeSpec = _TOOLBAR_PROPS[opts, 'clippingRange']

        panel = wx.Panel(self)
        sizer = wx.GridBagSizer()
        panel.SetSizer(sizer)

        modWidget = props.buildGUI(panel, opts, modSpec)
        clipWidget = props.buildGUI(panel, opts, clipSpec)
        rangeWidget = props.buildGUI(panel, opts, rangeSpec)
        modLabel = wx.StaticText(panel)
        clipLabel = wx.StaticText(panel)

        modLabel.SetLabel(strings.properties[opts, 'modulateImage'])
        clipLabel.SetLabel(strings.properties[opts, 'clipImage'])

        sizer.Add(modLabel, pos=(0, 0), span=(1, 1), flag=wx.EXPAND)
        sizer.Add(modWidget, pos=(0, 1), span=(1, 1), flag=wx.EXPAND)
        sizer.Add(clipLabel, pos=(1, 0), span=(1, 1), flag=wx.EXPAND)
        sizer.Add(clipWidget, pos=(1, 1), span=(1, 1), flag=wx.EXPAND)
        sizer.Add(rangeWidget, pos=(0, 2), span=(2, 1), flag=wx.EXPAND)

        tools = [panel]
        nav = [modWidget, clipWidget, rangeWidget]

        return tools, nav
예제 #8
0
    def __init__(self, parent, overlayList, displayCtx, frame, histPanel):
        """Create a ``HistogramToolBar``.

        :arg parent:      The :mod:`wx` parent object.
        :arg overlayList: The :class:`.OverlayList` instance.
        :arg displayCtx:  The :class:`.DisplayContext` instance.
        :arg frame:       The :class:`.FSLeyesFrame` instance.
        :arg histPanel:   The :class:`.HistogramPanel` instance.
        """

        plottoolbar.PlotToolBar.__init__(self, parent, overlayList, displayCtx,
                                         frame, histPanel)

        togControl = actions.ToggleActionButton(
            'toggleHistogramControl',
            actionKwargs={'floatPane': True},
            icon=[
                icons.findImageFile('spannerHighlight24'),
                icons.findImageFile('spanner24')
            ],
            tooltip=tooltips.actions[histPanel, 'toggleHistogramControl'])

        togList = actions.ToggleActionButton(
            'togglePlotList',
            actionKwargs={'floatPane': True},
            icon=[
                icons.findImageFile('listHighlight24'),
                icons.findImageFile('list24')
            ],
            tooltip=tooltips.actions[histPanel, 'togglePlotList'])

        togOverlay = actions.ToggleActionButton(
            'toggleHistogramOverlay',
            icon=[
                icons.findImageFile('histogramOverlayHighlight24'),
                icons.findImageFile('histogramOverlay24')
            ])

        mode = props.Widget('histType',
                            labels=strings.choices[histPanel, 'histType'],
                            tooltip=tooltips.properties[histPanel, 'histType'])

        togControl = props.buildGUI(self, histPanel, togControl)
        togList = props.buildGUI(self, histPanel, togList)
        togOverlay = props.buildGUI(self, histPanel, togOverlay)
        mode = props.buildGUI(self, histPanel, mode)

        lblMode = self.MakeLabelledTool(
            mode, strings.properties[histPanel, 'histType'])

        self.InsertTools([togControl, togList], 0)
        self.AddTool(togOverlay)
        self.AddTool(lblMode)


        nav = [togControl, togList]    + \
              self.getCommonNavOrder() + \
              [togOverlay, mode]

        self.setNavOrder(nav)
예제 #9
0
    def __makeMaskOptsTools(self, opts):
        """Creates and returns a collection of controls for editing properties
        of the given :class:`.MaskOpts` instance.
        """
        thresSpec = _TOOLBAR_PROPS[opts, 'threshold']
        colourSpec = _TOOLBAR_PROPS[opts, 'colour']

        thresWidget = props.buildGUI(self, opts, thresSpec)
        colourWidget = props.buildGUI(self, opts, colourSpec)

        tools = [thresWidget, colourWidget]

        return tools, tools
예제 #10
0
    def __init__(self, parent, overlayList, displayCtx, frame, plotPanel):
        """Create a ``PlotToolBar``.

        :arg parent:      The :mod:`wx` parent object.
        :arg overlayList: The :class:`.OverlayList` instance.
        :arg displayCtx:  The :class:`.DisplayContext` instance.
        :arg frame:       The :class:`.FSLeyesFrame` instance.
        :arg plotPanel:   The :class:`.PlotPanel` instance.
        """

        ctrlpanel.ControlToolBar.__init__(self,
                                          parent,
                                          overlayList,
                                          displayCtx,
                                          frame,
                                          height=24,
                                          kbFocus=True)

        self.__plotPanel = plotPanel

        import_ = actions.ActionButton(
            'importDataSeries',
            icon=icons.findImageFile('importDataSeries24'),
            tooltip=tooltips.actions[plotPanel, 'importDataSeries'])
        export = actions.ActionButton(
            'exportDataSeries',
            icon=icons.findImageFile('exportDataSeries24'),
            tooltip=tooltips.actions[plotPanel, 'exportDataSeries'])
        add = actions.ActionButton('addDataSeries',
                                   icon=icons.findImageFile('add24'),
                                   tooltip=tooltips.actions[plotPanel,
                                                            'addDataSeries'])
        remove = actions.ActionButton(
            'removeDataSeries',
            icon=icons.findImageFile('remove24'),
            tooltip=tooltips.actions[plotPanel, 'removeDataSeries'])
        screenshot = actions.ActionButton(
            'screenshot',
            icon=icons.findImageFile('camera24'),
            tooltip=tooltips.actions[plotPanel, 'screenshot'])

        screenshot = props.buildGUI(self, plotPanel, screenshot)
        import_ = props.buildGUI(self, plotPanel, import_)
        export = props.buildGUI(self, plotPanel, export)
        add = props.buildGUI(self, plotPanel, add)
        remove = props.buildGUI(self, plotPanel, remove)

        self.__commonTools = [screenshot, import_, export, add, remove]
        self.__commonNav = [screenshot, import_, export, add, remove]

        self.SetTools([screenshot, import_, export, add, remove])
예제 #11
0
def _MeshOpts_vertexSetWidget(target, parent, panel, overlayList, displayCtx,
                              threedee):
    """Builds a panel which contains a widget for controlling the
    :attr:`.MeshOpts.vertexSet` property, and also has a button
    which opens a file dialog, allowing the user to select other
    data.
    """

    loadAction = loadvdata.LoadVertexDataAction(overlayList,
                                                displayCtx,
                                                vertices=True)
    loadButton = wx.Button(parent)
    loadButton.SetLabel(strings.labels[panel, 'loadVertices'])

    loadAction.bindToWidget(panel, wx.EVT_BUTTON, loadButton)

    sizer = wx.BoxSizer(wx.HORIZONTAL)

    vdata = getWidgetSpecs(target, threedee)['vertexSet']
    vdata = props.buildGUI(parent, target, vdata)

    sizer.Add(vdata, flag=wx.EXPAND, proportion=1)
    sizer.Add(loadButton, flag=wx.EXPAND)

    return sizer, [vdata]
예제 #12
0
    def __makeTensorOptsTools(self, opts):
        """Creates and returns a collection of controls for editing properties
        of the given :class:`.TensorOpts` instance.
        """
        lightingSpec = _TOOLBAR_PROPS[opts, 'lighting']
        lightingWidget = props.buildGUI(self, opts, lightingSpec)

        tools, nav = self.__makeVectorOptsTools(opts)

        return tools + [lightingWidget], nav + [lightingWidget]
예제 #13
0
    def __makeMeshOptsTools(self, opts):
        """Creates and returns a collection of controls for editing properties
        of the given :class:`.MeshOpts` instance.
        """
        colourSpec = _TOOLBAR_PROPS[opts, 'colour']
        outlineSpec = _TOOLBAR_PROPS[opts, 'outline']
        widthSpec = _TOOLBAR_PROPS[opts, 'outlineWidth']

        colourWidget = props.buildGUI(self, opts, colourSpec)
        outlineWidget = props.buildGUI(self, opts, outlineSpec)
        widthWidget = props.buildGUI(self, opts, widthSpec)

        lblWidthWidget = self.MakeLabelledTool(
            widthWidget, strings.properties[opts, 'outlineWidth'])

        tools = [colourWidget, outlineWidget, lblWidthWidget]
        nav = [colourWidget, outlineWidget, widthWidget]

        return tools, nav
예제 #14
0
def _MeshOpts_LutWidget(target, parent, panel, overlayList, displayCtx,
                        threedee):
    """Builds a panel which contains the provided :attr:`.MeshOpts.lut`
    widget, and also a widget for :attr:`.MeshOpts.useLut`.
    """

    # enable lut widget
    lut = getWidgetSpecs(target, threedee)['lut']
    enable = getWidgetSpecs(target, threedee)['useLut']

    lut = props.buildGUI(parent, target, lut)
    enable = props.buildGUI(parent, target, enable)

    sizer = wx.BoxSizer(wx.HORIZONTAL)

    sizer.Add(enable, flag=wx.EXPAND)
    sizer.Add(lut, flag=wx.EXPAND, proportion=1)

    return sizer, [enable, lut]
예제 #15
0
    def __makeGiftiOptsTools(self, opts):
        """Creates and returns a collection of controls for editing properties
        of the given :class:`.GiftiOpts` instance.
        """
        tools, nav = self.__makeMeshOptsTools(opts)

        vertWidget = _TOOLBAR_PROPS[opts, 'vertexSet']
        vdataWidget = _TOOLBAR_PROPS[opts, 'vertexData']

        panel = wx.Panel(self)
        sizer = wx.BoxSizer(wx.VERTICAL)
        vertWidget = props.buildGUI(panel, opts, vertWidget)
        vdataWidget = props.buildGUI(panel, opts, vdataWidget)

        sizer.Add(vertWidget, flag=wx.EXPAND)
        sizer.Add(vdataWidget, flag=wx.EXPAND)
        panel.SetSizer(sizer)

        tools += [panel]
        nav += [vertWidget, vdataWidget]

        return tools, nav
예제 #16
0
    def __makeLineVectorOptsTools(self, opts):
        """Creates and returns a collection of controls for editing properties
        of the given :class:`.LineVectorOpts` instance.
        """
        widthSpec = _TOOLBAR_PROPS[opts, 'lineWidth']

        widget = props.buildGUI(self, opts, widthSpec)
        lblWidget = self.MakeLabelledTool(
            widget, strings.properties[opts, 'lineWidth'])

        tools, nav = self.__makeVectorOptsTools(opts)

        return tools + [lblWidget], nav + [widget]
예제 #17
0
def _ColourMapOpts_ColourMapWidget(target, parent, panel, overlayList,
                                   displayCtx, threedee):
    """Builds a panel which contains widgets for controlling the
    :attr:`.ColourMapOpts.cmap`, :attr:`.ColourMapOpts.negativeCmap`, and
    :attr:`.ColourMapOpts.useNegativeCmap`.

    :returns: A ``wx.Sizer`` containing all of the widgets, and a list
              containing the extra widgets that were added.
    """

    # Button to load a new
    # colour map from file
    loadAction = loadcmap.LoadColourMapAction(overlayList, displayCtx)

    loadButton = wx.Button(parent)
    loadButton.SetLabel(strings.labels[panel, 'loadCmap'])

    loadAction.bindToWidget(panel, wx.EVT_BUTTON, loadButton)

    cmap = getWidgetSpecs(target, threedee)['cmap']
    negCmap = getWidgetSpecs(target, threedee)['negativeCmap']
    useNegCmap = getWidgetSpecs(target, threedee)['useNegativeCmap']

    cmap = props.buildGUI(parent, target, cmap)
    negCmap = props.buildGUI(parent, target, negCmap)
    useNegCmap = props.buildGUI(parent, target, useNegCmap)

    useNegCmap.SetLabel(strings.properties[target, 'useNegativeCmap'])

    sizer = wx.FlexGridSizer(2, 2, 0, 0)
    sizer.AddGrowableCol(0)

    sizer.Add(cmap, flag=wx.EXPAND)
    sizer.Add(loadButton, flag=wx.EXPAND)
    sizer.Add(negCmap, flag=wx.EXPAND)
    sizer.Add(useNegCmap, flag=wx.EXPAND)

    return sizer, [cmap, negCmap, useNegCmap]
예제 #18
0
    def __makeComplexOptsTools(self, opts):
        """Creates and returns a collection of controls for editing properties
        of the given :class:`.ComplexOpts` instance.
        """
        rangeSpec = _TOOLBAR_PROPS[opts, 'displayRange']
        resetSpec = _TOOLBAR_PROPS[opts, 'resetDisplayRange']
        cmapSpec = _TOOLBAR_PROPS[opts, 'cmap']
        compSpec = _TOOLBAR_PROPS[opts, 'component']
        ccpanel = wx.Panel(self)

        rangeWidget = props.buildGUI(self, opts, rangeSpec)
        resetWidget = props.buildGUI(self, opts, resetSpec)
        cmapWidget = props.buildGUI(ccpanel, opts, cmapSpec)
        compWidget = props.buildGUI(ccpanel, opts, compSpec)

        ccsizer = wx.BoxSizer(wx.VERTICAL)
        ccpanel.SetSizer(ccsizer)
        ccsizer.Add(cmapWidget, flag=wx.EXPAND)
        ccsizer.Add(compWidget, flag=wx.EXPAND)

        tools = [resetWidget, rangeWidget, ccpanel]
        nav = [resetWidget, rangeWidget, cmapWidget, compWidget]

        return tools, nav
예제 #19
0
    def __profileChanged(self, *a):
        """Called when the :attr:`.ViewPanel.profile` property of the
        :class:`.OrthoPanel` changes. Shows/hides edit controls accordingly.
        """

        self.ClearTools(destroy=True, postevent=False)

        ortho      = self.__ortho
        profile    = ortho.profile
        profileObj = ortho.getCurrentProfile()

        if profile != 'edit':
            return

        tools = []
        nav   = []

        for spec in _TOOLBAR_SPECS:

            if spec == 'div':
                tools.append(fsltoolbar.ToolBarDivider(self,
                                                       height=24,
                                                       orient=wx.HORIZONTAL))
                continue

            if spec.key == 'toggleEditPanel': target = ortho
            else:                             target = profileObj

            widget    = props.buildGUI(self, target, spec)
            navWidget = widget

            if spec.label is not None:
                widget = self.MakeLabelledTool(widget, spec.label)

            tools.append(widget)
            nav  .append(navWidget)

        self.SetTools(tools)
        self.setNavOrder(nav)
예제 #20
0
def _ColourMapOpts_ColourMapWidget(target, parent, panel, overlayList,
                                   displayCtx, threedee):
    """Builds a panel which contains widgets for controlling the
    :attr:`.ColourMapOpts.cmap`, :attr:`.ColourMapOpts.negativeCmap`, and
    :attr:`.ColourMapOpts.useNegativeCmap`.

    :returns: A ``wx.Sizer`` containing all of the widgets, and a list
              containing the extra widgets that were added.
    """

    # Button to load a new
    # colour map from file
    loadAction = loadcmap.LoadColourMapAction(overlayList, displayCtx)

    loadButton = wx.Button(parent)
    loadButton.SetLabel(strings.labels[panel, 'loadCmap'])

    loadAction.bindToWidget(panel, wx.EVT_BUTTON, loadButton)

    cmap = getWidgetSpecs(target, threedee)['cmap']
    negCmap = getWidgetSpecs(target, threedee)['negativeCmap']
    useNegCmap = getWidgetSpecs(target, threedee)['useNegativeCmap']

    cbpanel = imagepanel.ImagePanel(parent)
    cbpanel.SetMinSize((-1, 30))
    colourbar = cbar.ColourBar(overlayList, displayCtx)

    colourbar.bgColour = (0, 0, 0, 0)
    colourbar.showLabel = False
    colourbar.showTicks = False

    def cbarUpdate(*a):
        w, h = cbpanel.GetSize().Get()

        if w < 20 or h < 20:
            return

        bmp = colourbar.colourBar(w, h)

        if bmp is None:
            return

        if fwidgets.wxversion() == fwidgets.WX_PHOENIX:
            bmp = wx.Bitmap.FromBufferRGBA(w, h, bmp.transpose(1, 0, 2))
        else:
            bmp = wx.BitmapFromBufferRGBA(w, h, bmp.transpose(1, 0, 2))

        cbpanel.SetImage(bmp.ConvertToImage())

    lname = 'ColourBarWidget_{}'.format(colourbar)

    def onDestroy(ev):
        colourbar.deregister(lname)
        colourbar.destroy()

    colourbar.register(lname, cbarUpdate)
    cbpanel.Bind(wx.EVT_SIZE, cbarUpdate)
    cbpanel.Bind(wx.EVT_WINDOW_DESTROY, onDestroy)

    cbarUpdate()

    cmap = props.buildGUI(parent, target, cmap)
    negCmap = props.buildGUI(parent, target, negCmap)
    useNegCmap = props.buildGUI(parent, target, useNegCmap)

    useNegCmap.SetLabel(strings.properties[target, 'useNegativeCmap'])

    sizer = wx.GridBagSizer()
    sizer.AddGrowableCol(0)

    sizer.Add(cbpanel, (0, 0), (1, 2), flag=wx.EXPAND)
    sizer.Add(cmap, (1, 0), (1, 1), flag=wx.EXPAND)
    sizer.Add(loadButton, (1, 1), (1, 1), flag=wx.EXPAND)
    sizer.Add(negCmap, (2, 0), (1, 1), flag=wx.EXPAND)
    sizer.Add(useNegCmap, (2, 1), (1, 1), flag=wx.EXPAND)

    return sizer, [cmap, negCmap, useNegCmap]
예제 #21
0
    def generateCustomDataSeriesWidgets(self, hs, groupName):
        """Overrides :meth:`.PlotControlPanel.generateCustomDataSeriesWidgets`.
        Adds some widgets to control properties of the
        :class:`.HistogramSeries`.
        """

        isimage = isinstance(hs, hseries.ImageHistogramSeries)
        widgetList = self.getWidgetList()

        autoBin = props.Widget('autoBin')
        nbins = props.Widget('nbins',
                             enabledWhen=lambda i: not i.autoBin,
                             showLimits=False)
        autoBin = props.buildGUI(widgetList, hs, autoBin)
        nbins = props.buildGUI(widgetList, hs, nbins)

        dataRange = props.makeWidget(
            widgetList,
            hs,
            'dataRange',
            labels=[
                strings.choices['HistogramPanel.dataRange.min'],
                strings.choices['HistogramPanel.dataRange.max']
            ],
            showLimits=False)

        ignoreZeros = props.makeWidget(widgetList, hs, 'ignoreZeros')
        includeOutliers = props.makeWidget(widgetList, hs, 'includeOutliers')

        if isimage:
            showOverlay = props.makeWidget(widgetList, hs, 'showOverlay')

        widgetList.AddWidget(ignoreZeros,
                             groupName=groupName,
                             displayName=strings.properties[hs, 'ignoreZeros'],
                             tooltip=fsltooltips.properties[hs, 'ignoreZeros'])

        if isimage:
            widgetList.AddWidget(showOverlay,
                                 groupName=groupName,
                                 displayName=strings.properties[hs,
                                                                'showOverlay'],
                                 tooltip=fsltooltips.properties[hs,
                                                                'showOverlay'])

        widgetList.AddWidget(includeOutliers,
                             groupName=groupName,
                             displayName=strings.properties[hs,
                                                            'includeOutliers'],
                             tooltip=fsltooltips.properties[hs,
                                                            'includeOutliers'])
        widgetList.AddWidget(autoBin,
                             groupName=groupName,
                             displayName=strings.properties[hs, 'autoBin'],
                             tooltip=fsltooltips.properties[hs, 'autoBin'])
        widgetList.AddWidget(nbins,
                             groupName=groupName,
                             displayName=strings.properties[hs, 'nbins'],
                             tooltip=fsltooltips.properties[hs, 'nbins'])
        widgetList.AddWidget(dataRange,
                             groupName=groupName,
                             displayName=strings.properties[hs, 'dataRange'],
                             tooltip=fsltooltips.properties[hs, 'dataRange'])

        if isimage:
            return [
                ignoreZeros, showOverlay, includeOutliers, autoBin, nbins,
                dataRange
            ]
        else:
            return [ignoreZeros, includeOutliers, autoBin, nbins, dataRange]
예제 #22
0
    def __makeTools(self, *a):
        """Called by :meth:`__init__`, and whenever the
        :attr:`.ViewPanel.profile` property changes.

        Re-creates all tools shown on this ``OrthoToolBar``.
        """

        ortho = self.orthoPanel
        orthoOpts = ortho.sceneOpts
        profile = ortho.getCurrentProfile()

        coronalIcon = 'coronalSlice24'
        coronalHighlightIcon = 'coronalSliceHighlight24'

        icons = {
            'screenshot':
            fslicons.findImageFile('camera24'),
            'resetDisplay':
            fslicons.findImageFile('resetZoom24'),
            'showCursorAndLabels': [
                fslicons.findImageFile('addHighlight24'),
                fslicons.findImageFile('add24')
            ],
            'movieMode': [
                fslicons.findImageFile('movieHighlight24'),
                fslicons.findImageFile('movie24')
            ],
            'showXCanvas': [
                fslicons.findImageFile('sagittalSliceHighlight24'),
                fslicons.findImageFile('sagittalSlice24')
            ],
            'showYCanvas': [
                fslicons.findImageFile(coronalHighlightIcon),
                fslicons.findImageFile(coronalIcon)
            ],
            'showZCanvas': [
                fslicons.findImageFile('axialSliceHighlight24'),
                fslicons.findImageFile('axialSlice24')
            ],
            'toggleCanvasSettingsPanel': [
                fslicons.findImageFile('spannerHighlight24'),
                fslicons.findImageFile('spanner24')
            ],
            'layout': {
                'horizontal': [
                    fslicons.findImageFile('horizontalLayoutHighlight24'),
                    fslicons.findImageFile('horizontalLayout24')
                ],
                'vertical': [
                    fslicons.findImageFile('verticalLayoutHighlight24'),
                    fslicons.findImageFile('verticalLayout24')
                ],
                'grid': [
                    fslicons.findImageFile('gridLayoutHighlight24'),
                    fslicons.findImageFile('gridLayout24')
                ]
            }
        }

        tooltips = {
            'screenshot':
            fsltooltips.actions[ortho, 'screenshot'],
            'resetDisplay':
            fsltooltips.actions[profile, 'resetDisplay'],
            'movieMode':
            fsltooltips.properties[ortho, 'movieMode'],
            'showCursorAndLabels':
            fsltooltips.properties[self, 'showCursorAndLabels'],
            'zoom':
            fsltooltips.properties[orthoOpts, 'zoom'],
            'layout':
            fsltooltips.properties[orthoOpts, 'layout'],
            'showXCanvas':
            fsltooltips.properties[orthoOpts, 'showXCanvas'],
            'showYCanvas':
            fsltooltips.properties[orthoOpts, 'showYCanvas'],
            'showZCanvas':
            fsltooltips.properties[orthoOpts, 'showZCanvas'],
            'toggleCanvasSettingsPanel':
            fsltooltips.actions[ortho, 'toggleCanvasSettingsPanel'],
        }

        targets = {
            'screenshot': ortho,
            'movieMode': ortho,
            'showCursorAndLabels': self,
            'resetDisplay': profile,
            'zoom': orthoOpts,
            'layout': orthoOpts,
            'showXCanvas': orthoOpts,
            'showYCanvas': orthoOpts,
            'showZCanvas': orthoOpts,
            'toggleCanvasSettingsPanel': ortho
        }

        toolSpecs = [
            actions.ToggleActionButton(
                'toggleCanvasSettingsPanel',
                actionKwargs={'floatPane': True},
                icon=icons['toggleCanvasSettingsPanel'],
                tooltip=tooltips['toggleCanvasSettingsPanel']),
            actions.ActionButton('screenshot',
                                 icon=icons['screenshot'],
                                 tooltip=tooltips['screenshot']),
            'div',
            props.Widget('showXCanvas',
                         icon=icons['showXCanvas'],
                         tooltip=tooltips['showXCanvas']),
            props.Widget('showYCanvas',
                         icon=icons['showYCanvas'],
                         tooltip=tooltips['showYCanvas']),
            props.Widget('showZCanvas',
                         icon=icons['showZCanvas'],
                         tooltip=tooltips['showZCanvas']),
            'div',
            props.Widget('layout',
                         icons=icons['layout'],
                         tooltip=tooltips['layout']),
            'div',
            props.Widget('movieMode',
                         icon=icons['movieMode'],
                         tooltip=tooltips['movieMode']),
            props.Widget('showCursorAndLabels',
                         icon=icons['showCursorAndLabels'],
                         tooltip=tooltips['showCursorAndLabels']),
            actions.ActionButton('resetDisplay',
                                 icon=icons['resetDisplay'],
                                 tooltip=tooltips['resetDisplay']),
            props.Widget('zoom',
                         spin=True,
                         slider=True,
                         showLimits=False,
                         spinWidth=5,
                         tooltip=tooltips['zoom']),
        ]

        tools = []
        nav = []

        for spec in toolSpecs:

            if spec == 'div':
                tools.append(
                    fsltoolbar.ToolBarDivider(self,
                                              height=24,
                                              orient=wx.VERTICAL))
                continue

            widget = props.buildGUI(self, targets[spec.key], spec)
            navWidget = widget

            if spec.key in ('zoom', ):
                widget = self.MakeLabelledTool(
                    widget, strings.properties[targets[spec.key], spec.key])

            tools.append(widget)
            nav.append(navWidget)

        self.SetTools(tools, destroy=True)
        self.setNavOrder(nav)
예제 #23
0
    def __makeTools(self):
        """Called by :meth:`__init__`. Creates the toolbar widgets. """

        panel = self.panel
        opts = panel.sceneOpts
        profile = panel.getCurrentProfile()

        icons = {
            'screenshot':
            fslicons.findImageFile('camera24'),
            'resetDisplay':
            fslicons.findImageFile('resetZoom24'),
            'showCursorAndLegend': [
                fslicons.findImageFile('addHighlight24'),
                fslicons.findImageFile('add24')
            ],
            'movieMode': [
                fslicons.findImageFile('movieHighlight24'),
                fslicons.findImageFile('movie24')
            ],
            'toggleCanvasSettingsPanel': [
                fslicons.findImageFile('spannerHighlight24'),
                fslicons.findImageFile('spanner24')
            ],
        }

        tooltips = {
            'screenshot':
            fsltooltips.actions[panel, 'screenshot'],
            'resetDisplay':
            fsltooltips.actions[profile, 'resetDisplay'],
            'movieMode':
            fsltooltips.properties[panel, 'movieMode'],
            'showCursorAndLegend':
            fsltooltips.properties[self, 'showCursorAndLegend'],
            'zoom':
            fsltooltips.properties[opts, 'zoom'],
            'toggleCanvasSettingsPanel':
            fsltooltips.actions[panel, 'toggleCanvasSettingsPanel'],
        }

        targets = {
            'screenshot': panel,
            'resetDisplay': profile,
            'movieMode': panel,
            'showCursorAndLegend': self,
            'zoom': opts,
            'toggleCanvasSettingsPanel': panel,
        }

        toolSpecs = [
            actions.ToggleActionButton(
                'toggleCanvasSettingsPanel',
                actionKwargs={'floatPane': True},
                icon=icons['toggleCanvasSettingsPanel'],
                tooltip=tooltips['toggleCanvasSettingsPanel']),
            actions.ActionButton('screenshot',
                                 icon=icons['screenshot'],
                                 tooltip=tooltips['screenshot']),
            'div',
            props.Widget('movieMode',
                         icon=icons['movieMode'],
                         tooltip=tooltips['movieMode']),
            props.Widget('showCursorAndLegend',
                         icon=icons['showCursorAndLegend'],
                         tooltip=tooltips['showCursorAndLegend']),
            actions.ActionButton('resetDisplay',
                                 icon=icons['resetDisplay'],
                                 tooltip=tooltips['resetDisplay']),
            props.Widget('zoom',
                         spin=True,
                         slider=True,
                         showLimits=False,
                         spinWidth=5,
                         tooltip=tooltips['zoom']),
        ]

        tools = []
        nav = []

        for spec in toolSpecs:

            if spec == 'div':
                tools.append(
                    fsltoolbar.ToolBarDivider(self,
                                              height=24,
                                              orient=wx.VERTICAL))
                continue

            widget = props.buildGUI(self, targets[spec.key], spec)
            navWidget = widget

            if spec.key in ('zoom', ):
                widget = self.MakeLabelledTool(
                    widget, strings.properties[targets[spec.key], spec.key])

            tools.append(widget)
            nav.append(navWidget)

        self.SetTools(tools, destroy=True)
        self.setNavOrder(nav)
예제 #24
0
    def __profileChanged(self, *a):
        """Called when the :attr:`.ViewPanel.profile` property of the
        :class:`.OrthoPanel` changes. Shows/hides edit controls accordingly.
        """

        self.ClearTools(destroy=True, postevent=False)

        ortho = self.__orthoPanel
        profile = ortho.profile
        profileObj = ortho.getCurrentProfile()

        if profile != 'edit':
            self.__dsWarning.Show(False)
            return

        allTools = []
        allWidgets = []

        for specGroup in _TOOLBAR_SPECS:

            if specGroup == 'div':
                allTools.append(
                    fsltoolbar.ToolBarDivider(self,
                                              height=24,
                                              orient=wx.VERTICAL))
                continue

            groupWidgets = []
            isGroup = isinstance(specGroup, list)

            if isGroup:
                parent = wx.Panel(self)

            else:
                parent = self
                specGroup = [specGroup]

            for spec in specGroup:

                widget = props.buildGUI(parent, profileObj, spec)

                if not isGroup and spec.label is not None:
                    widget = self.MakeLabelledTool(widget, spec.label)

                allWidgets.append(widget)
                groupWidgets.append(widget)

            # Assuming here that all
            # widgets have labels
            if isGroup:

                sizer = wx.FlexGridSizer(2, 2, 0, 0)
                parent.SetSizer(sizer)

                labels = [s.label for s in specGroup]
                labels = [wx.StaticText(parent, label=l) for l in labels]

                for w, l in zip(groupWidgets, labels):
                    sizer.Add(l,
                              flag=wx.ALIGN_CENTRE_VERTICAL | wx.ALIGN_RIGHT)
                    sizer.Add(w,
                              flag=wx.ALIGN_CENTRE_VERTICAL | wx.ALIGN_RIGHT)

                allTools.append(parent)

            else:
                allTools.append(groupWidgets[0])

        self.SetTools([self.__dsWarning] + allTools)
        self.setNavOrder(allWidgets)
예제 #25
0
    def generateCustomDataSeriesWidgets(self, hs, groupName):
        """Overrides :meth:`.PlotControlPanel.generateCustomDataSeriesWidgets`.
        Adds some widgets to control properties of the
        :class:`.HistogramSeries`.
        """

        isimage = isinstance(hs, hseries.ImageHistogramSeries)
        widgetList = self.getWidgetList()
        allWidgets = []

        autoBin = props.Widget('autoBin')
        nbins = props.Widget('nbins',
                             enabledWhen=lambda i: not i.autoBin,
                             showLimits=False)
        autoBin = props.buildGUI(widgetList, hs, autoBin)
        nbins = props.buildGUI(widgetList, hs, nbins)

        dataRange = props.makeWidget(
            widgetList,
            hs,
            'dataRange',
            labels=[
                strings.choices['HistogramPanel.dataRange.min'],
                strings.choices['HistogramPanel.dataRange.max']
            ],
            showLimits=False)

        ignoreZeros = props.makeWidget(widgetList, hs, 'ignoreZeros')
        includeOutliers = props.makeWidget(widgetList, hs, 'includeOutliers')

        widgetList.AddWidget(ignoreZeros,
                             groupName=groupName,
                             displayName=strings.properties[hs, 'ignoreZeros'],
                             tooltip=fsltooltips.properties[hs, 'ignoreZeros'])
        allWidgets.append(ignoreZeros)

        if isimage:
            showOverlay = props.makeWidget(widgetList, hs, 'showOverlay')
            widgetList.AddWidget(showOverlay,
                                 groupName=groupName,
                                 displayName=strings.properties[hs,
                                                                'showOverlay'],
                                 tooltip=fsltooltips.properties[hs,
                                                                'showOverlay'])
            allWidgets.append(showOverlay)

        widgetList.AddWidget(includeOutliers,
                             groupName=groupName,
                             displayName=strings.properties[hs,
                                                            'includeOutliers'],
                             tooltip=fsltooltips.properties[hs,
                                                            'includeOutliers'])
        widgetList.AddWidget(autoBin,
                             groupName=groupName,
                             displayName=strings.properties[hs, 'autoBin'],
                             tooltip=fsltooltips.properties[hs, 'autoBin'])
        widgetList.AddWidget(nbins,
                             groupName=groupName,
                             displayName=strings.properties[hs, 'nbins'],
                             tooltip=fsltooltips.properties[hs, 'nbins'])
        widgetList.AddWidget(dataRange,
                             groupName=groupName,
                             displayName=strings.properties[hs, 'dataRange'],
                             tooltip=fsltooltips.properties[hs, 'dataRange'])
        allWidgets.append(includeOutliers)
        allWidgets.append(autoBin)
        allWidgets.append(nbins)
        allWidgets.append(dataRange)

        if isinstance(hs, hseries.ComplexHistogramSeries):
            for propName in [
                    'plotReal', 'plotImaginary', 'plotMagnitude', 'plotPhase'
            ]:
                widget = props.makeWidget(widgetList, hs, propName)
                widgetList.AddWidget(widget,
                                     groupName=groupName,
                                     displayName=strings.properties[hs,
                                                                    propName],
                                     tooltip=fsltooltips.properties[hs,
                                                                    propName])
                allWidgets.append(widget)

        return allWidgets
예제 #26
0
    def __makeTools(self):
        """Generates all of the tools and adds them to the :class:`.WidgetList`
        (see :class:`.FSLeyesSettingsPanel`),
        """

        ortho = self.__ortho
        widgets = self.getWidgetList()
        profile = ortho.getCurrentProfile()

        if ortho.profile != 'edit':
            return

        generalProps = [
            props.Widget('mode',
                         labels=strings.choices[profile, 'mode'],
                         fixChoices=['nav', 'sel', 'desel', 'selint']),
            props.Widget('drawMode'),
            props.Widget('selectionIs3D'),
            props.Widget('selectionSize',
                         slider=False,
                         spin=True,
                         showLimits=False),
            props.Widget('fillValue', slider=False, spin=True),
            props.Widget('eraseValue', slider=False, spin=True),

            # 'showSelectionOutline',
            props.Widget('selectionCursorColour'),
            props.Widget('selectionOverlayColour'),
            props.Widget('locationFollowsMouse',
                         dependencies=['drawMode'],
                         enabledWhen=lambda p, m: not m),
            props.Widget('showSelection',
                         dependencies=['drawMode'],
                         enabledWhen=lambda p, m: not m)
        ]

        selintProps = [
            props.Widget('localFill',
                         dependencies=['mode'],
                         enabledWhen=lambda p, m: m == 'selint'),
            props.Widget('limitToRadius',
                         dependencies=['mode'],
                         enabledWhen=lambda p, m: m == 'selint'),
            props.Widget('intensityThresLimit',
                         spin=True,
                         slider=False,
                         showLimits=False,
                         dependencies=['mode'],
                         enabledWhen=lambda p, m: m == 'selint'),
            props.Widget('intensityThres',
                         spin=True,
                         slider=True,
                         showLimits=False,
                         dependencies=['mode'],
                         enabledWhen=lambda p, m: m == 'selint'),
            props.Widget('searchRadius',
                         spin=True,
                         slider=True,
                         showLimits=False,
                         dependencies=['mode', 'limitToRadius'],
                         enabledWhen=lambda p, m, r: m == 'selint' and r),
        ]

        widgets.AddGroup('general', strings.labels[self, 'general'])
        widgets.AddGroup('selint', strings.labels[self, 'selint'])

        allWidgets = []

        for spec in generalProps:

            widget = props.buildGUI(widgets, profile, spec)
            allWidgets.append(widget)
            widgets.AddWidget(widget,
                              displayName=strings.properties[profile,
                                                             spec.key],
                              tooltip=fsltooltips.properties[profile,
                                                             spec.key],
                              groupName='general')

        for spec in selintProps:

            widget = props.buildGUI(widgets, profile, spec)
            allWidgets.append(widget)
            widgets.AddWidget(widget,
                              displayName=strings.properties[profile,
                                                             spec.key],
                              tooltip=fsltooltips.properties[profile,
                                                             spec.key],
                              groupName='selint')

        self.setNavOrder(allWidgets)
        widgets.Expand('general')
        widgets.Expand('selint')
예제 #27
0
    def __updateWidgets(self, target, groupName):
        """Called by the :meth:`__selectedOverlayChanged` and
        :meth:`__ovlTypeChanged` methods. Re-creates the controls on this
        ``OverlayDisplayPanel`` for the specified group.

        :arg target:    A :class:`.Display` or :class:`.DisplayOpts` instance,
                        which contains the properties that controls are to be
                        created for.

        :arg groupName: Either ``'display'`` or ``'opts'``/``'3d'``,
                        corresponding to :class:`.Display` or
                        :class:`.DisplayOpts` properties.

        :returns:       A list containing all of the new widgets that
                        were created.
        """

        widgetList = self.getWidgetList()

        widgetList.ClearGroup(groupName)

        if groupName == '3d':
            dispProps = odwidgets.get3DPropertyList(target)
            dispSpecs = odwidgets.get3DWidgetSpecs(target)
        else:
            dispProps = odwidgets.getPropertyList(target, self.__threedee)
            dispSpecs = odwidgets.getWidgetSpecs(target, self.__threedee)

        allLabels = []
        allTooltips = []
        allWidgets = []
        allContainers = []

        for p in dispProps:

            spec = dispSpecs[p]

            specs = [spec]
            labels = [strings.properties.get((target, p), None)]
            tooltips = [fsltooltips.properties.get((target, p), None)]

            if callable(spec):

                # Will either return a contsiner
                # widget/sizer and a list of widgets
                # for setting the navigation order,
                # or will return a list of specs
                # (with an irrelevant second parameter)
                container, widgets = spec(target, widgetList, self,
                                          self.overlayList, self.displayCtx,
                                          self.__threedee)

                if isinstance(container, collections.Sequence):
                    specs = container
                    keys = [s.key for s in specs]
                    labels = [
                        strings.properties.get((target, k), None) for k in keys
                    ]
                    tooltips = [
                        fsltooltips.properties.get((target, k), None)
                        for k in keys
                    ]

                else:
                    allContainers.append(container)
                    allWidgets.extend(widgets)
                    specs = []

            for s in specs:
                widget = props.buildGUI(widgetList, target, s)

                allWidgets.append(widget)
                allContainers.append(widget)

            allLabels.extend(labels)
            allTooltips.extend(tooltips)

        for widget, label, tooltip in zip(allContainers, allLabels,
                                          allTooltips):
            if label is None:
                label = ''
            widgetList.AddWidget(widget,
                                 label,
                                 tooltip=tooltip,
                                 groupName=groupName)

        return allWidgets
예제 #28
0
    def __makeTools(self):

        displayCtx = self.displayCtx
        canvasPanel = self.__canvasPanel
        widgets = self.getWidgetList()

        canvasPanelProps = collections.OrderedDict(
            (('syncOverlayOrder', props.Widget('syncOverlayOrder')),
             ('syncLocation', props.Widget('syncLocation')),
             ('syncOverlayDisplay', props.Widget('syncOverlayDisplay')),
             ('syncOverlayVolume', props.Widget('syncOverlayVolume')),
             ('movieMode',
              props.Widget('movieMode')), ('movieSyncRefresh',
                                           props.Widget('movieSyncRefresh')),
             ('movieAxis',
              props.Widget('movieAxis',
                           labels=strings.choices[canvasPanel, 'movieAxis'])),
             ('movieRate',
              props.Widget('movieRate', spin=False, showLimits=False))))

        sceneOptsProps = collections.OrderedDict(
            (('showCursor',
              props.Widget('showCursor')), ('bgColour',
                                            props.Widget('bgColour')),
             ('fgColour',
              props.Widget('fgColour')), ('cursorColour',
                                          props.Widget('cursorColour')),
             ('performance',
              props.Widget('performance',
                           spin=False,
                           showLimits=False,
                           labels=strings.choices['SceneOpts.performance'])),
             ('highDpi',
              props.Widget('highDpi')), ('showColourBar',
                                         props.Widget('showColourBar')),
             ('colourBarLabelSide',
              props.Widget(
                  'colourBarLabelSide',
                  labels=strings.choices['SceneOpts.colourBarLabelSide'],
                  enabledWhen=lambda o: o.showColourBar)),
             ('colourBarLocation',
              props.Widget(
                  'colourBarLocation',
                  labels=strings.choices['SceneOpts.colourBarLocation'],
                  enabledWhen=lambda o: o.showColourBar)),
             ('colourBarSize',
              props.Widget('colourBarSize',
                           showLimits=False,
                           slider=True,
                           spin=True)), ('labelSize',
                                         props.Widget('labelSize',
                                                      spin=True,
                                                      showLimits=False))))

        # The highDpi setting is
        # only relevant on macOS
        if platform.system != 'Darwin':
            sceneOptsProps.pop('highDpi')

        def _displaySpaceOptionName(opt):

            if isinstance(opt, fslimage.Nifti):
                return opt.name
            else:
                return strings.choices['DisplayContext.displaySpace'][opt]

        displayCtxProps = collections.OrderedDict(
            (('displaySpace',
              props.Widget('displaySpace',
                           labels=_displaySpaceOptionName,
                           dependencies=[(canvasPanel, 'profile')],
                           enabledWhen=lambda i, p: p == 'view')),
             ('radioOrientation', props.Widget('radioOrientation'))))

        orthoOptsProps = collections.OrderedDict(
            (('layout',
              props.Widget('layout',
                           labels=strings.choices['OrthoOpts.layout'])),
             ('zoom', props.Widget('zoom', showLimits=False)),
             ('showLabels', props.Widget('showLabels')),
             ('cursorGap',
              props.Widget('cursorGap')), ('showXCanvas',
                                           props.Widget('showXCanvas')),
             ('showYCanvas',
              props.Widget('showYCanvas')), ('showZCanvas',
                                             props.Widget('showZCanvas'))))

        lightBoxOptsProps = collections.OrderedDict(
            (('zax',
              props.Widget('zax', labels=strings.choices['CanvasOpts.zax'])),
             ('zoom', props.Widget('zoom', showLimits=False, spin=False)),
             ('sliceSpacing', props.Widget('sliceSpacing', showLimits=False)),
             ('zrange', props.Widget('zrange', showLimits=False)),
             ('highlightSlice', props.Widget('highlightSlice')),
             ('showGridLines', props.Widget('showGridLines'))))

        scene3dOptsProps = collections.OrderedDict((
            ('zoom', props.Widget('zoom', showLimits=False)),
            ('showLegend', props.Widget('showLegend')),
            ('light', props.Widget('light')),
            ('occlusion', props.Widget('occlusion')),
        ))

        import fsleyes.views.orthopanel as orthopanel
        import fsleyes.views.lightboxpanel as lightboxpanel
        import fsleyes.views.scene3dpanel as scene3dpanel

        if isinstance(canvasPanel, orthopanel.OrthoPanel):
            panelGroup = 'ortho'
            panelProps = orthoOptsProps

        elif isinstance(canvasPanel, lightboxpanel.LightBoxPanel):
            panelGroup = 'lightbox'
            panelProps = lightBoxOptsProps
        elif isinstance(canvasPanel, scene3dpanel.Scene3DPanel):
            panelGroup = '3d'
            panelProps = scene3dOptsProps

            # We hide some options in 3D
            sceneOptsProps.pop('performance')
            displayCtxProps.pop('displaySpace')
            displayCtxProps.pop('radioOrientation')

        widgets.AddGroup('scene', strings.labels[self, 'scene'])
        widgets.AddGroup(panelGroup, strings.labels[self, panelGroup])

        allWidgets = []

        for dispProp in canvasPanelProps.values():

            widget = props.buildGUI(widgets,
                                    canvasPanel,
                                    dispProp,
                                    showUnlink=False)

            allWidgets.append(widget)
            widgets.AddWidget(widget,
                              displayName=strings.properties[canvasPanel,
                                                             dispProp.key],
                              tooltip=fsltooltips.properties[canvasPanel,
                                                             dispProp.key],
                              groupName='scene')

        opts = canvasPanel.sceneOpts

        for dispProp in sceneOptsProps.values():

            widget = props.buildGUI(widgets, opts, dispProp, showUnlink=False)

            allWidgets.append(widget)
            widgets.AddWidget(widget,
                              displayName=strings.properties[opts,
                                                             dispProp.key],
                              tooltip=fsltooltips.properties[opts,
                                                             dispProp.key],
                              groupName='scene')

        for dispProp in displayCtxProps.values():
            widget = props.buildGUI(widgets,
                                    displayCtx,
                                    dispProp,
                                    showUnlink=False)

            allWidgets.append(widget)
            widgets.AddWidget(widget,
                              displayName=strings.properties[displayCtx,
                                                             dispProp.key],
                              tooltip=fsltooltips.properties[displayCtx,
                                                             dispProp.key],
                              groupName='scene')

        for dispProp in panelProps.values():

            widget = props.buildGUI(widgets, opts, dispProp, showUnlink=False)

            allWidgets.append(widget)
            widgets.AddWidget(widget,
                              displayName=strings.properties[opts,
                                                             dispProp.key],
                              tooltip=fsltooltips.properties[opts,
                                                             dispProp.key],
                              groupName=panelGroup)

        self.setNavOrder(allWidgets)

        widgets.Expand('scene')
        widgets.Expand(panelGroup)
예제 #29
0
    def __init__(self, parent, overlayList, displayCtx, frame, lb):
        """Create a ``LightBoxToolBar``.

        :arg parent:      The :mod:`wx` parent object.
        :arg overlayList: The :class:`.OverlayList` instance.
        :arg displayCtx:  The :class:`.DisplayContext` instance.
        :arg frame:       The :class:`.FSLeyesFrame` instance.
        :arg lb:          The :class:`.LightBoxPanel` instance.
        """

        fsltoolbar.FSLeyesToolBar.__init__(self,
                                           parent,
                                           overlayList,
                                           displayCtx,
                                           frame,
                                           height=24,
                                           kbFocus=True)

        self.lightBoxPanel = lb

        lbOpts = lb.sceneOpts

        if BUM_MODE: coronalIcon = 'coronalBumSlice24'
        else: coronalIcon = 'coronalSlice24'
        if BUM_MODE: coronalHighlightIcon = 'coronalBumSliceHighlight24'
        else: coronalHighlightIcon = 'coronalSliceHighlight24'

        icons = {
            'screenshot':
            fslicons.findImageFile('camera24'),
            'movieMode': [
                fslicons.findImageFile('movieHighlight24'),
                fslicons.findImageFile('movie24')
            ],
            'toggleCanvasSettingsPanel': [
                fslicons.findImageFile('spannerHighlight24'),
                fslicons.findImageFile('spanner24')
            ],
            'zax': {
                0: [
                    fslicons.findImageFile('sagittalSliceHighlight24'),
                    fslicons.findImageFile('sagittalSlice24')
                ],
                1: [
                    fslicons.findImageFile(coronalHighlightIcon),
                    fslicons.findImageFile(coronalIcon)
                ],
                2: [
                    fslicons.findImageFile('axialSliceHighlight24'),
                    fslicons.findImageFile('axialSlice24')
                ],
            }
        }

        tooltips = {
            'screenshot':
            fsltooltips.actions[lb, 'screenshot'],
            'movieMode':
            fsltooltips.properties[lb, 'movieMode'],
            'zax':
            fsltooltips.properties[lbOpts, 'zax'],
            'sliceSpacing':
            fsltooltips.properties[lbOpts, 'sliceSpacing'],
            'zrange':
            fsltooltips.properties[lbOpts, 'zrange'],
            'zoom':
            fsltooltips.properties[lbOpts, 'zoom'],
            'toggleCanvasSettingsPanel':
            fsltooltips.actions[lb, 'toggleCanvasSettingsPanel'],
        }

        specs = {
            'toggleCanvasSettingsPanel':
            actions.ToggleActionButton(
                'toggleCanvasSettingsPanel',
                actionKwargs={'floatPane': True},
                icon=icons['toggleCanvasSettingsPanel'],
                tooltip=tooltips['toggleCanvasSettingsPanel']),
            'screenshot':
            actions.ActionButton('screenshot',
                                 icon=icons['screenshot'],
                                 tooltip=tooltips['screenshot']),
            'movieMode':
            props.Widget('movieMode',
                         icon=icons['movieMode'],
                         tooltip=tooltips['movieMode']),
            'zax':
            props.Widget('zax', icons=icons['zax'], tooltip=tooltips['zax']),
            'sliceSpacing':
            props.Widget('sliceSpacing',
                         spin=False,
                         showLimits=False,
                         tooltip=tooltips['sliceSpacing']),
            'zrange':
            props.Widget('zrange',
                         spin=False,
                         showLimits=False,
                         tooltip=tooltips['zrange'],
                         labels=[
                             strings.choices[lbOpts, 'zrange', 'min'],
                             strings.choices[lbOpts, 'zrange', 'max']
                         ]),
            'zoom':
            props.Widget('zoom',
                         spin=False,
                         showLimits=False,
                         tooltip=tooltips['zoom']),
        }

        # Slice spacing and zoom go on a single panel
        panel = wx.Panel(self)
        sizer = wx.FlexGridSizer(2, 2, 0, 0)
        panel.SetSizer(sizer)

        more = props.buildGUI(self, lb, specs['toggleCanvasSettingsPanel'])
        screenshot = props.buildGUI(self, lb, specs['screenshot'])
        movieMode = props.buildGUI(self, lb, specs['movieMode'])
        zax = props.buildGUI(self, lbOpts, specs['zax'])
        zrange = props.buildGUI(self, lbOpts, specs['zrange'])
        zoom = props.buildGUI(panel, lbOpts, specs['zoom'])
        spacing = props.buildGUI(panel, lbOpts, specs['sliceSpacing'])
        zoomLabel = wx.StaticText(panel)
        spacingLabel = wx.StaticText(panel)

        zoomLabel.SetLabel(strings.properties[lbOpts, 'zoom'])
        spacingLabel.SetLabel(strings.properties[lbOpts, 'sliceSpacing'])

        sizer.Add(zoomLabel)
        sizer.Add(zoom, flag=wx.EXPAND)
        sizer.Add(spacingLabel)
        sizer.Add(spacing, flag=wx.EXPAND)

        tools = [
            more, screenshot,
            fsltoolbar.ToolBarDivider(self, height=24,
                                      orient=wx.VERTICAL), zax,
            fsltoolbar.ToolBarDivider(self, height=24, orient=wx.VERTICAL),
            movieMode, zrange, panel
        ]
        nav = [more, screenshot, zax, movieMode, zrange, zoom, spacing]

        self.SetTools(tools)
        self.setNavOrder(nav)
예제 #30
0
    def __makeDisplayTools(self, display):
        """Creates and returns a collection of controls for editing properties
        of the given :class:`.Display` instance.
        """

        viewPanel = self.__viewPanel

        # Display settings
        nameSpec = _TOOLBAR_PROPS[display, 'name']
        typeSpec = _TOOLBAR_PROPS[display, 'overlayType']
        alphaSpec = _TOOLBAR_PROPS[display, 'alpha']
        briSpec = _TOOLBAR_PROPS[display, 'brightness']
        conSpec = _TOOLBAR_PROPS[display, 'contrast']

        # Buttons which toggle overlay
        # info and display panel
        panelSpec = actions.ToggleActionButton(
            'toggleDisplayPanel',
            actionKwargs={'floatPane': True},
            icon=[
                icons.findImageFile('gearHighlight24'),
                icons.findImageFile('gear24')
            ],
            tooltip=fsltooltips.actions[viewPanel, 'toggleDisplayPanel'])

        infoSpec = actions.ToggleActionButton(
            'toggleOverlayInfo',
            actionKwargs={'floatPane': True},
            icon=[
                icons.findImageFile('informationHighlight24'),
                icons.findImageFile('information24')
            ],
            tooltip=fsltooltips.actions[viewPanel, 'toggleOverlayInfo'])

        # Name/overlay type and brightness/contrast
        # are respectively placed together
        nameTypePanel = wx.Panel(self)
        briconPanel = wx.Panel(self)
        nameTypeSizer = wx.BoxSizer(wx.VERTICAL)
        briconSizer = wx.FlexGridSizer(2, 2, 0, 0)

        briconSizer.AddGrowableCol(1)

        nameTypePanel.SetSizer(nameTypeSizer)
        briconPanel.SetSizer(briconSizer)

        panelWidget = props.buildGUI(self, viewPanel, panelSpec)
        infoWidget = props.buildGUI(self, viewPanel, infoSpec)
        nameWidget = props.buildGUI(nameTypePanel, display, nameSpec)
        typeWidget = props.buildGUI(nameTypePanel, display, typeSpec)
        briWidget = props.buildGUI(briconPanel, display, briSpec)
        conWidget = props.buildGUI(briconPanel, display, conSpec)
        alphaWidget = props.buildGUI(self, display, alphaSpec)

        briLabel = wx.StaticText(briconPanel)
        conLabel = wx.StaticText(briconPanel)

        briLabel.SetLabel(strings.properties[display, 'brightness'])
        conLabel.SetLabel(strings.properties[display, 'contrast'])

        # name/type panel
        nameTypeSizer.Add(nameWidget, flag=wx.EXPAND)
        nameTypeSizer.Add(typeWidget, flag=wx.EXPAND)

        # opacity is given a label
        alphaPanel = self.MakeLabelledTool(
            alphaWidget, strings.properties[display, 'alpha'])

        # bricon panel
        briconSizer.Add(briLabel)
        briconSizer.Add(briWidget)
        briconSizer.Add(conLabel)
        briconSizer.Add(conWidget)

        tools = [
            panelWidget, infoWidget, nameTypePanel, alphaPanel, briconPanel
        ]
        nav = [
            panelWidget, infoWidget, nameWidget, typeWidget, alphaWidget,
            briWidget, conWidget
        ]

        return tools, nav