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)
    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)
Example #3
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)
Example #4
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)
Example #5
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)