예제 #1
0
    def __init__(self, parent, overlayList, displayCtx, frame, ortho):
        """Create an ``OrthoEditToolBar``.

        :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 ortho:       The :class:`.OrthoPanel` instance.
        """
        ctrlpanel.ControlToolBar.__init__(self,
                                          parent,
                                          overlayList,
                                          displayCtx,
                                          frame,
                                          height=24,
                                          kbFocus=True)

        self.__orthoPanel = ortho
        self.__dsWarning = dswarning.DisplaySpaceWarning(
            self, self.overlayList, self.displayCtx, self.frame,
            strings.messages[self, 'dsWarning'], 'not like overlay', 'overlay')

        ortho.addListener('profile', self.name, self.__profileChanged)

        self.__profileChanged()
예제 #2
0
    def __init__(self, parent, overlayList, displayCtx, frame, ortho):
        """Create an ``EditTransformPanel``.

        :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 ortho:       The :class:`.OrthoPanel` instance.
        """

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

        self.__ortho = ortho

        # A ref to the currently selected
        # (compatible) overlay is kept here.
        # The __extraXform attribute is used
        # to store a FLIRT transform if the
        # user has loaded one. This 'extra'
        # matrix is used in place of the
        # image voxToWorldMat (i.e. its sform);
        # the scale/offset/ rotate transform
        # defined by the widgets on this panel
        # is still applied.
        #
        # In the future, I might allow the
        # user to load/apply an arbitrary
        # (non-FLIRT) transform.
        self.__overlay = None
        self.__extraXform = None

        # When the selected overlay is changed, the
        # transform settings for the previously selected
        # overlay are cached in this dict, so they can be
        # restored if/when the overlay is re-selected.
        #
        # { overlay : (scales, offsets, rotations, extraXform) }
        self.__cachedXforms = {}

        scArgs = {
            'value': 0,
            'minValue': 0.001,
            'maxValue': 3,
            'style': fslider.SSP_NO_LIMITS
        }

        offArgs = {
            'value': 0,
            'minValue': -250,
            'maxValue': 250,
            'style': fslider.SSP_NO_LIMITS
        }

        rotArgs = {'value': 0, 'minValue': -180, 'maxValue': 180, 'style': 0}

        self.__overlayName = wx.StaticText(self)
        self.__dsWarning = dswarning.DisplaySpaceWarning(
            self, overlayList, displayCtx, frame,
            strings.labels[self, 'dsWarning'], 'overlay', 'world')

        self.__xscale = fslider.SliderSpinPanel(self, label='X', **scArgs)
        self.__yscale = fslider.SliderSpinPanel(self, label='Y', **scArgs)
        self.__zscale = fslider.SliderSpinPanel(self, label='Z', **scArgs)

        self.__xoffset = fslider.SliderSpinPanel(self, label='X', **offArgs)
        self.__yoffset = fslider.SliderSpinPanel(self, label='Y', **offArgs)
        self.__zoffset = fslider.SliderSpinPanel(self, label='Z', **offArgs)

        self.__xrotate = fslider.SliderSpinPanel(self, label='X', **rotArgs)
        self.__yrotate = fslider.SliderSpinPanel(self, label='Y', **rotArgs)
        self.__zrotate = fslider.SliderSpinPanel(self, label='Z', **rotArgs)

        self.__scaleLabel = wx.StaticText(self)
        self.__offsetLabel = wx.StaticText(self)
        self.__rotateLabel = wx.StaticText(self)

        self.__oldXformLabel = wx.StaticText(self)
        self.__oldXform = wx.StaticText(self)
        self.__newXformLabel = wx.StaticText(self)
        self.__newXform = wx.StaticText(self)

        self.__apply = wx.Button(self)
        self.__reset = wx.Button(self)
        self.__loadFlirt = wx.Button(self)
        self.__saveFlirt = wx.Button(self)
        self.__cancel = wx.Button(self)

        self.__overlayName.SetLabel(strings.labels[self, 'noOverlay'])
        self.__scaleLabel.SetLabel(strings.labels[self, 'scale'])
        self.__offsetLabel.SetLabel(strings.labels[self, 'offset'])
        self.__rotateLabel.SetLabel(strings.labels[self, 'rotate'])
        self.__apply.SetLabel(strings.labels[self, 'apply'])
        self.__reset.SetLabel(strings.labels[self, 'reset'])
        self.__loadFlirt.SetLabel(strings.labels[self, 'loadFlirt'])
        self.__saveFlirt.SetLabel(strings.labels[self, 'saveFlirt'])
        self.__cancel.SetLabel(strings.labels[self, 'cancel'])
        self.__oldXformLabel.SetLabel(strings.labels[self, 'oldXform'])
        self.__newXformLabel.SetLabel(strings.labels[self, 'newXform'])

        # Populate the xform labels with a
        # dummy xform, so an appropriate
        # minimum size will get calculated
        # below
        self.__formatXform(np.eye(4), self.__oldXform)
        self.__formatXform(np.eye(4), self.__newXform)

        self.__primarySizer = wx.BoxSizer(wx.VERTICAL)
        self.__secondarySizer = wx.BoxSizer(wx.HORIZONTAL)
        self.__controlSizer = wx.BoxSizer(wx.VERTICAL)
        self.__xformSizer = wx.BoxSizer(wx.VERTICAL)
        self.__buttonSizer = wx.BoxSizer(wx.HORIZONTAL)

        self.__primarySizer.Add((1, 10), flag=wx.EXPAND)
        self.__primarySizer.Add(self.__overlayName, flag=wx.CENTRE)
        self.__primarySizer.Add(self.__dsWarning, flag=wx.CENTRE)
        self.__primarySizer.Add((1, 10), flag=wx.EXPAND)
        self.__primarySizer.Add(self.__secondarySizer)
        self.__primarySizer.Add((1, 10), flag=wx.EXPAND)
        self.__primarySizer.Add(self.__buttonSizer, flag=wx.EXPAND)
        self.__primarySizer.Add((1, 10), flag=wx.EXPAND)

        self.__secondarySizer.Add((10, 1), flag=wx.EXPAND)
        self.__secondarySizer.Add(self.__controlSizer)
        self.__secondarySizer.Add((10, 1), flag=wx.EXPAND)
        self.__secondarySizer.Add(self.__xformSizer, flag=wx.EXPAND)
        self.__secondarySizer.Add((10, 1), flag=wx.EXPAND)

        self.__controlSizer.Add(self.__scaleLabel)
        self.__controlSizer.Add(self.__xscale)
        self.__controlSizer.Add(self.__yscale)
        self.__controlSizer.Add(self.__zscale)
        self.__controlSizer.Add(self.__offsetLabel)
        self.__controlSizer.Add(self.__xoffset)
        self.__controlSizer.Add(self.__yoffset)
        self.__controlSizer.Add(self.__zoffset)
        self.__controlSizer.Add(self.__rotateLabel)
        self.__controlSizer.Add(self.__xrotate)
        self.__controlSizer.Add(self.__yrotate)
        self.__controlSizer.Add(self.__zrotate)

        self.__xformSizer.Add((1, 1), flag=wx.EXPAND, proportion=1)
        self.__xformSizer.Add(self.__oldXformLabel)
        self.__xformSizer.Add(self.__oldXform)
        self.__xformSizer.Add((1, 1), flag=wx.EXPAND, proportion=1)
        self.__xformSizer.Add(self.__newXformLabel)
        self.__xformSizer.Add(self.__newXform)
        self.__xformSizer.Add((1, 1), flag=wx.EXPAND, proportion=1)

        self.__buttonSizer.Add((10, 1), flag=wx.EXPAND, proportion=1)
        self.__buttonSizer.Add(self.__apply, flag=wx.EXPAND)
        self.__buttonSizer.Add((10, 1), flag=wx.EXPAND)
        self.__buttonSizer.Add(self.__reset, flag=wx.EXPAND)
        self.__buttonSizer.Add((10, 1), flag=wx.EXPAND)
        self.__buttonSizer.Add(self.__loadFlirt, flag=wx.EXPAND)
        self.__buttonSizer.Add((10, 1), flag=wx.EXPAND)
        self.__buttonSizer.Add(self.__saveFlirt, flag=wx.EXPAND)
        self.__buttonSizer.Add((10, 1), flag=wx.EXPAND)
        self.__buttonSizer.Add(self.__cancel, flag=wx.EXPAND)
        self.__buttonSizer.Add((10, 1), flag=wx.EXPAND, proportion=1)

        self.SetSizer(self.__primarySizer)
        self.SetMinSize(self.__primarySizer.GetMinSize())

        self.__xscale.Bind(fslider.EVT_SSP_VALUE, self.__xformChanged)
        self.__yscale.Bind(fslider.EVT_SSP_VALUE, self.__xformChanged)
        self.__zscale.Bind(fslider.EVT_SSP_VALUE, self.__xformChanged)
        self.__xoffset.Bind(fslider.EVT_SSP_VALUE, self.__xformChanged)
        self.__yoffset.Bind(fslider.EVT_SSP_VALUE, self.__xformChanged)
        self.__zoffset.Bind(fslider.EVT_SSP_VALUE, self.__xformChanged)
        self.__xrotate.Bind(fslider.EVT_SSP_VALUE, self.__xformChanged)
        self.__yrotate.Bind(fslider.EVT_SSP_VALUE, self.__xformChanged)
        self.__zrotate.Bind(fslider.EVT_SSP_VALUE, self.__xformChanged)

        self.__apply.Bind(wx.EVT_BUTTON, self.__onApply)
        self.__reset.Bind(wx.EVT_BUTTON, self.__onReset)
        self.__loadFlirt.Bind(wx.EVT_BUTTON, self.__onLoadFlirt)
        self.__saveFlirt.Bind(wx.EVT_BUTTON, self.__onSaveFlirt)
        self.__cancel.Bind(wx.EVT_BUTTON, self.__onCancel)

        displayCtx.addListener('selectedOverlay', self.name,
                               self.__selectedOverlayChanged)
        overlayList.addListener('overlays', self.name,
                                self.__selectedOverlayChanged)

        self.__selectedOverlayChanged()
예제 #3
0
    def __init__(self, parent, overlayList, displayCtx, frame, ortho):
        """Create a ``CropImagePanel``.

        :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 ortho:       The :class:`.OrthoPanel` instance.
        """
        ctrlpanel.ControlPanel.__init__(
            self, parent, overlayList, displayCtx, frame)

        profile = ortho.getCurrentProfile()

        self.__ortho   = ortho
        self.__profile = profile
        self.__overlay = None

        self.__cropBoxWidget = props.makeWidget(
            self,
            profile,
            'cropBox',
            showLimits=False,
            labels=['xmin', 'xmax', 'ymin', 'ymax', 'zmin', 'zmax'])

        self.__volumeWidget = rslider.RangeSliderSpinPanel(
            self,
            minValue=0,
            maxValue=1,
            minDistance=1,
            lowLabel='tmin',
            highLabel='tmax',
            style=rslider.RSSP_INTEGER)

        self.__dsWarning = dswarning.DisplaySpaceWarning(
            self,
            overlayList,
            displayCtx,
            frame,
            strings.messages[self, 'dsWarning'],
            'not like overlay',
            'overlay')

        self.__cropLabel       = wx.StaticText(self)
        self.__sizeLabel       = wx.StaticText(self)
        self.__cropButton      = wx.Button(    self, id=wx.ID_OK)
        self.__robustFovButton = wx.Button(    self)
        self.__loadButton      = wx.Button(    self)
        self.__saveButton      = wx.Button(    self)
        self.__cancelButton    = wx.Button(    self, id=wx.ID_CANCEL)

        self.__cropButton     .SetLabel(strings.labels[self, 'crop'])
        self.__robustFovButton.SetLabel(strings.labels[self, 'robustFov'])
        self.__loadButton     .SetLabel(strings.labels[self, 'load'])
        self.__saveButton     .SetLabel(strings.labels[self, 'save'])
        self.__cancelButton   .SetLabel(strings.labels[self, 'cancel'])

        self.__sizer    = wx.BoxSizer(wx.VERTICAL)
        self.__btnSizer = wx.BoxSizer(wx.HORIZONTAL)

        self.__sizer.Add((1, 10))
        self.__sizer.Add(self.__cropLabel,     flag=wx.CENTRE)
        self.__sizer.Add((1, 10))
        self.__sizer.Add(self.__dsWarning,     flag=wx.CENTRE)
        self.__sizer.Add((1, 10), proportion=1)
        self.__sizer.Add(self.__cropBoxWidget, flag=wx.EXPAND)
        self.__sizer.Add(self.__volumeWidget,  flag=wx.EXPAND)
        self.__sizer.Add((1, 10))
        self.__sizer.Add(self.__sizeLabel,     flag=wx.CENTRE, proportion=1)
        self.__sizer.Add((1, 10))
        self.__sizer.Add(self.__btnSizer,      flag=wx.CENTRE)
        self.__sizer.Add((1, 10))

        self.__btnSizer.Add((10, 1),                flag=wx.EXPAND,
                            proportion=1)
        self.__btnSizer.Add(self.__cropButton,      flag=wx.EXPAND)
        self.__btnSizer.Add((10, 1),                flag=wx.EXPAND)
        self.__btnSizer.Add(self.__robustFovButton, flag=wx.EXPAND)
        self.__btnSizer.Add((10, 1),                flag=wx.EXPAND)
        self.__btnSizer.Add(self.__loadButton,      flag=wx.EXPAND)
        self.__btnSizer.Add((10, 1),                flag=wx.EXPAND)
        self.__btnSizer.Add(self.__saveButton,      flag=wx.EXPAND)
        self.__btnSizer.Add((10, 1),                flag=wx.EXPAND)
        self.__btnSizer.Add(self.__cancelButton,    flag=wx.EXPAND)
        self.__btnSizer.Add((10, 1),                flag=wx.EXPAND,
                            proportion=1)

        self.SetSizer(self.__sizer)
        self.SetMinSize(self.__sizer.GetMinSize())
        self.__cropButton.SetDefault()

        self.__cropButton  .Bind(wx.EVT_BUTTON,          self.__onCrop)
        self.__loadButton  .Bind(wx.EVT_BUTTON,          self.__onLoad)
        self.__saveButton  .Bind(wx.EVT_BUTTON,          self.__onSave)
        self.__cancelButton.Bind(wx.EVT_BUTTON,          self.__onCancel)
        self.__volumeWidget.Bind(rslider.EVT_RANGE,      self.__onVolume)
        self.__volumeWidget.Bind(rslider.EVT_LOW_RANGE,  self.__onVolume)
        self.__volumeWidget.Bind(rslider.EVT_HIGH_RANGE, self.__onVolume)

        profile.robustfov.bindToWidget(self,
                                       wx.EVT_BUTTON,
                                       self.__robustFovButton)

        displayCtx .addListener('selectedOverlay',
                                self.name,
                                self.__selectedOverlayChanged)
        overlayList.addListener('overlays',
                                self.name,
                                self.__selectedOverlayChanged)
        profile    .addListener('cropBox',
                                self.name,
                                self.__cropBoxChanged)

        self.__selectedOverlayChanged()
        self.__cropBoxChanged()