示例#1
0
    def refresh(self, *args):

        choices = []

        for data in self._data:

            if len(self._data) > 1:
                if data.label is None or data.label == '':
                    choices.append(ChoiceSeparator('Untitled Data'))
                else:
                    choices.append(ChoiceSeparator(data.label))

            if self.visible:
                all_component_ids = data.visible_components
            else:
                all_component_ids = data.components

            component_ids = []
            for cid in all_component_ids:
                comp = data.get_component(cid)
                if ((comp.numeric and self.numeric) or
                        (comp.categorical and self.categorical) or
                        (cid in data.pixel_component_ids and self.pixel_coord) or
                        (cid in data.world_component_ids and self.world_coord)):
                    component_ids.append(cid)

            choices.extend(component_ids)

        self.choices = choices
示例#2
0
    def refresh(self, *args):

        choices = []

        if self._none:
            choices.append(None)

        for data in self._data:

            derived_components = [
                cid for cid in data.derived_components if cid.parent is data
            ]

            if len(self._data) > 1:
                if data.label is None or data.label == '':
                    choices.append(ChoiceSeparator('Untitled Data'))
                else:
                    choices.append(ChoiceSeparator(data.label))

            cids = [ChoiceSeparator('Main components')]
            for cid in data.primary_components:
                if cid not in data.coordinate_components:
                    comp = data.get_component(cid)
                    if ((comp.numeric and self.numeric)
                            or (comp.categorical and self.categorical)):
                        cids.append(cid)
            if len(cids) > 1:
                if self.pixel_coord or self.world_coord or (
                        self.derived and len(derived_components) > 0):
                    choices += cids
                else:
                    choices += cids[1:]

            if self.numeric and self.derived:
                cids = [ChoiceSeparator('Derived components')]
                for cid in derived_components:
                    cids.append(cid)
                if len(cids) > 1:
                    choices += cids

            if self.pixel_coord or self.world_coord:
                cids = [ChoiceSeparator('Coordinate components')]
                if self.pixel_coord:
                    cids += data.pixel_component_ids
                if self.world_coord:
                    cids += data.world_component_ids
                if len(cids) > 1:
                    choices += cids

        self.choices = choices